/home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/cuda_error.hh Source File

Ratpac-two: /home/docs/checkouts/readthedocs.org/user_builds/ratpac/checkouts/latest/src/util/include/RAT/cuda_error.hh Source File
Ratpac-two
cuda_error.hh
1 #ifndef __CUDA_ERROR__
2 #define __CUDA_ERROR__
3 #include <stdio.h>
4 #include <stdlib.h>
5 
6 namespace RAT {
7 
8 class CUDAException {
9  // no content
10 };
11 
12 } // namespace RAT
13 
14 #define CUDA_SAFE_CALL(call) \
15  do { \
16  cudaError err = call; \
17  if (cudaSuccess != err) { \
18  fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n", __FILE__, __LINE__, cudaGetErrorString(err)); \
19  throw RAT::CUDAException(); \
20  } \
21  } while (0)
22 
23 #define CUT_CHECK_ERROR(errorMessage) \
24  do { \
25  cudaError_t err = cudaGetLastError(); \
26  if (cudaSuccess != err) { \
27  fprintf(stderr, "Cuda error: %s in file '%s' in line %i : %s.\n", errorMessage, __FILE__, __LINE__, \
28  cudaGetErrorString(err)); \
29  throw RAT::CUDAException(); \
30  } \
31  } while (0)
32 
33 #define CU_SAFE_CALL(call) \
34  do { \
35  CUresult err = call; \
36  if (CUDA_SUCCESS != err) { \
37  fprintf(stderr, "Cuda driver error %x in file '%s' in line %i.\n", err, __FILE__, __LINE__); \
38  throw RAT::CUDAException(); \
39  } \
40  } while (0)
41 
42 #endif
Definition: cuda_error.hh:8
Definition: CCCrossSecMessenger.hh:29