Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:51

0001 #ifndef VECCORE_ASSERT_H
0002 #define VECCORE_ASSERT_H
0003 
0004 #if !defined(__NVCC__)
0005 #include <cassert>
0006 #else
0007 
0008 // NVCC sometimes cannot process plain assert() from <cassert>, so
0009 // we need to provide our own implementation that works around the bug
0010 // by avoiding the __PRETTY_FUNCTION__ macro where it causes problems.
0011 // A bug for this has been filed by Philippe Canal at the link below:
0012 // https://developer.nvidia.com/nvbugs/cuda/edit/1729798
0013 
0014 #ifdef assert
0015 #undef assert
0016 #endif
0017 
0018 #ifdef NDEBUG
0019 #define assert(x)
0020 #else
0021 
0022 #include <cstdio>
0023 
0024 #ifndef __CUDA_ARCH__
0025 #define assert(x)                                                                 \
0026   do {                                                                            \
0027     if (!(x)) {                                                                   \
0028       fprintf(stderr, "%s:%d: Assertion failed: '%s'\n", __FILE__, __LINE__, #x); \
0029       abort();                                                                    \
0030     }                                                                             \
0031   } while (0)
0032 #else
0033 #define assert(x)                                                                                  \
0034   do {                                                                                             \
0035     if (!(x)) {                                                                                    \
0036       printf("%s:%d:\n%s: Assertion failed: '%s'\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #x); \
0037       __syncthreads();                                                                             \
0038       asm("trap;");                                                                                \
0039     }                                                                                              \
0040   } while (0)
0041 #endif // ifndef __CUDA_ARCH__
0042 
0043 #endif // ifdef NDEBUG
0044 
0045 #endif // if !defined(__NVCC__)
0046 
0047 #endif