Created
August 19, 2015 16:41
-
-
Save Trass3r/022a3dc263ccdfb4f700 to your computer and use it in GitHub Desktop.
CUDA simple memory wrapper class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
struct CUDAMem | |
{ | |
T* ptr; | |
CUDAMem() | |
: ptr(0) | |
{ | |
cudaError_t err = cudaMallocArray(&ptr, sizeof(T)); | |
if (err != cudaSuccess) | |
fprintf(stderr, "%s(%i): CUDA error : %s : (%d) %s.\n", | |
__FILE__, __LINE__, errorMessage, (int)err, cudaGetErrorString(err)); | |
} | |
~CUDAMem() | |
{ | |
cudaFreeArray(ptr); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment