VecCore
0.8.1
C++ Library for Portable SIMD Vectorization
Loading...
Searching...
No Matches
Assert.h
Go to the documentation of this file.
1
#ifndef VECCORE_ASSERT_H
2
#define VECCORE_ASSERT_H
3
4
#if !defined(__NVCC__)
5
#include <cassert>
6
#else
7
8
// NVCC sometimes cannot process plain assert() from <cassert>, so
9
// we need to provide our own implementation that works around the bug
10
// by avoiding the __PRETTY_FUNCTION__ macro where it causes problems.
11
// A bug for this has been filed by Philippe Canal at the link below:
12
// https://developer.nvidia.com/nvbugs/cuda/edit/1729798
13
14
#ifdef assert
15
#undef assert
16
#endif
17
18
#ifdef NDEBUG
19
#define assert(x)
20
#else
21
22
#include <cstdio>
23
24
#ifndef __CUDA_ARCH__
25
#define assert(x) \
26
do { \
27
if (!(x)) { \
28
fprintf(stderr, "%s:%d: Assertion failed: '%s'\n"
, __FILE__, __LINE__, #x); \
29
abort(); \
30
} \
31
} while (0)
32
#else
33
#define assert(x) \
34
do { \
35
if (!(x)) { \
36
printf("%s:%d:\n%s: Assertion failed: '%s'\n"
, __FILE__, __LINE__, __PRETTY_FUNCTION__, #x); \
37
__syncthreads(); \
38
asm("trap;"); \
39
} \
40
} while (0)
41
#endif
// ifndef __CUDA_ARCH__
42
43
#endif
// ifdef NDEBUG
44
45
#endif
// if !defined(__NVCC__)
46
47
#endif
VecCore
Assert.h
Generated by
1.9.6