LSLab
lslab.h
Go to the documentation of this file.
1 
4 #include <cstdio>
5 
6 #pragma once
7 
8 #if defined(__NVCC__) || (defined(__clang__) && defined(__CUDA__))
9 
10 #define LSLAB_HOST __host__
11 
12 #define LSLAB_HOST_DEVICE __host__ __device__ __forceinline__
13 
14 #define LSLAB_DEVICE __device__ __forceinline__
15 
16 #else
17 
18 #define LSLAB_HOST inline
19 
20 #define LSLAB_DEVICE inline
21 
22 #define LSLAB_HOST_DEVICE inline
23 
24 #endif
25 
26 #ifndef __CUDACC_RTC__
27 
28 #define gpuErrchk(ans) \
29  { lslab::gpuAssert_slab((ans), __FILE__, __LINE__); }
30 namespace lslab {
31 
33 LSLAB_HOST void gpuAssert_slab(cudaError_t code, const char *file, int line,
34  bool abort = true) {
35  if (code != cudaSuccess) {
36  fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file,
37  line);
38  if (abort)
39  exit(code);
40  }
41 }
42 
43 }
44 
45 #endif
LSLAB_HOST void gpuAssert_slab(cudaError_t code, const char *file, int line, bool abort=true)
Assertion function to assert cuda is sucessful.
Definition: lslab.h:33