trunk,cudamatrix: bugfix, we should use GPU memory caching via CuDevice for CuArray too...

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@3309 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
This commit is contained in:
Karel Vesely 2013-12-13 16:36:46 +00:00
Родитель 48984495c4
Коммит 29e2e8e207
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -50,7 +50,11 @@ void CuArray<T>::Resize(MatrixIndexT dim, MatrixResizeType resize_type) {
#if HAVE_CUDA == 1 #if HAVE_CUDA == 1
if (CuDevice::Instantiate().Enabled()) { if (CuDevice::Instantiate().Enabled()) {
CU_SAFE_CALL(cudaMalloc((void**)&data_, dim*sizeof(T))); Timer tim;
this->data_ = static_cast<T*>(CuDevice::Instantiate().Malloc(dim * sizeof(T)));
this->dim_ = dim;
if (resize_type == kSetZero) this->SetZero();
CuDevice::Instantiate().AccuProfile("CuArray::Resize", tim.Elapsed());
} else } else
#endif #endif
{ {
@ -75,7 +79,7 @@ void CuArray<T>::Destroy() {
#if HAVE_CUDA == 1 #if HAVE_CUDA == 1
if (CuDevice::Instantiate().Enabled()) { if (CuDevice::Instantiate().Enabled()) {
if (data_ != NULL) { if (data_ != NULL) {
CU_SAFE_CALL(cudaFree(data_)); CuDevice::Instantiate().Free(this->data_);
} }
} else } else
#endif #endif