forked from weft/warp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_cuda.h
23 lines (21 loc) · 892 Bytes
/
check_cuda.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef CHECK_CUDA_H
#define CHECK_CUDA_H
/**
* \brief CUDA error check wrapper, host only
* \details this inline function prints detailed information about the return code of host-side
* CUDA functions and where they occur in the code
* @param[in] code - CUDA error code output from some host-side CUDA function call
* @param[in] file - file where erroring fuction is, written inline by preprocessor
* @param[in] line - line of file where erroring fuction is, written inline by preprocessor
* @param[in] abort - flag to exit on error, default is true
*/
__host__ inline void check_cuda(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);
}
}
#define check_cuda(ans) { check_cuda((ans), __FILE__, __LINE__); }
#endif