@@ -202,9 +202,8 @@ private:
202
202
* Allocate `size` number of `T` data on the device.
203
203
* @param size number of data elements to allocate
204
204
* @param zero sets allocated data to `0`
205
- * @return
206
205
*/
207
- bool allocateOnDevice (size_t size, bool zero = false );
206
+ void allocateOnDevice (size_t size, bool zero = false );
208
207
209
208
/* *
210
209
* Create column-major `std::vector` from a row-major one.
@@ -837,23 +836,24 @@ void DTensor<T>::applyLeftGivensRotation(size_t i, size_t j, const T *c, const T
837
836
}
838
837
839
838
template <typename T>
840
- inline bool DTensor<T>::allocateOnDevice(size_t size, bool zero) {
841
- if (size <= 0 ) return false ;
839
+ inline void DTensor<T>::allocateOnDevice(size_t size, bool zero) {
840
+ cudaError_t cudaStatus;
841
+ if (size <= 0 ) return ;
842
842
destroy ();
843
843
m_doDestroyData = true ;
844
844
size_t buffer_size = size * sizeof (T);
845
- bool cudaStatus = cudaMalloc (&m_d_data, buffer_size);
846
- if (cudaStatus != cudaSuccess) return false ;
845
+ gpuErrChk (cudaMalloc (&m_d_data, buffer_size));
847
846
if (zero) gpuErrChk (cudaMemset (m_d_data, 0 , buffer_size)); // set to zero all elements
848
847
849
848
if (numMats () > 1 ) {
850
849
m_doDestroyPtrMatrices = true ;
851
850
cudaStatus = cudaMalloc (&m_d_ptrMatrices, numMats () * sizeof (T *));
851
+ if (cudaStatus != cudaSuccess) {
852
+ gpuErrChk (cudaFree (m_d_data));
853
+ }
852
854
} else {
853
855
m_doDestroyPtrMatrices = false ;
854
856
}
855
-
856
- return (cudaStatus != cudaSuccess);
857
857
}
858
858
859
859
template <typename T>
0 commit comments