Skip to content

Instantly share code, notes, and snippets.

@luoyetx
Created September 2, 2016 13:07
Show Gist options
  • Save luoyetx/9a9d3ef7939bc9077915a95ba94ded78 to your computer and use it in GitHub Desktop.
Save luoyetx/9a9d3ef7939bc9077915a95ba94ded78 to your computer and use it in GitHub Desktop.
#ifdef DEBUG
#define cudaCheckError(ans) { cudaAssert((ans), __FILE__, __LINE__); }
inline void cudaAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
if (code != cudaSuccess)
{
fprintf(stderr, "CUDA Error: %s at %s:%d\n",
cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
}
#else
#define cudaCheckError(ans) ans
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment