Skip to content

Instantly share code, notes, and snippets.

@tonyyang-svail
Last active April 11, 2018 22:05
Show Gist options
  • Save tonyyang-svail/67b6cb354dee3fb6eb53da29610760b8 to your computer and use it in GitHub Desktop.
Save tonyyang-svail/67b6cb354dee3fb6eb53da29610760b8 to your computer and use it in GitHub Desktop.
// https://stackoverflow.com/questions/14038589/what-is-the-canonical-way-to-check-for-errors-using-the-cuda-runtime-api
#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(cudaGetDeviceCount(&dc));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment