CoreNEURON
utils_cuda.h
Go to the documentation of this file.
1 /*
2 # =============================================================================
3 # Copyright (c) 2016 - 2021 Blue Brain Project/EPFL
4 #
5 # See top-level LICENSE file for details.
6 # =============================================================================.
7 */
8 
9 #pragma once
10 
11 #include <stdio.h>
12 #include <cuda_runtime_api.h>
13 
14 // From Random123 lib
15 #define CHECKLAST(MSG) \
16  do { \
17  cudaError_t e = cudaGetLastError(); \
18  if (e != cudaSuccess) { \
19  fprintf(stderr, \
20  "%s:%d: CUDA Error: %s: %s\n", \
21  __FILE__, \
22  __LINE__, \
23  (MSG), \
24  cudaGetErrorString(e)); \
25  exit(1); \
26  } \
27  } while (0)
28 #define CHECKCALL(RET) \
29  do { \
30  cudaError_t e = (RET); \
31  if (e != cudaSuccess) { \
32  fprintf(stderr, "%s:%d: CUDA Error: %s\n", __FILE__, __LINE__, cudaGetErrorString(e)); \
33  exit(1); \
34  } \
35  } while (0)