Created
October 7, 2018 18:02
-
-
Save alifahrri/bdd76b0e3729b1bb56d8672c13725292 to your computer and use it in GitHub Desktop.
Error check for cuda code
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
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } | |
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true) | |
{ | |
if (code != cudaSuccess) | |
{ | |
fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line); | |
if (abort) exit(code); | |
} | |
} | |
gpuErrchk( cudaMalloc(&a_d, size*sizeof(int)) ); | |
kernel<<<1,1>>>(a); | |
gpuErrchk( cudaPeekAtLastError() ); | |
gpuErrchk( cudaDeviceSynchronize() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment