isce3 0.25.0
Loading...
Searching...
No Matches
Common.h
1#pragma once
2
3/*
4 * Try to hide CUDA-specific declarations from the host compiler by
5 * recognizing device-only specifiers and disabling them with attributes
6 */
7
8// Clang supports the enable_if attribute, so we
9// can hard-code false and provide an error message.
10#if defined(__clang__)
11#define ATTRIB_DISABLE(msg) __attribute(( enable_if(0, msg) ))
12// Otherwise, fall back to the error attribute.
13// GCC uses this attribute to abort compilation with an error message.
14// Compilers without support should nonetheless display a warning.
15#else
16#define ATTRIB_DISABLE(msg) __attribute(( error(msg) ))
17#endif
18
19#ifdef __CUDACC__
20#define CUDA_HOST __host__
21#define CUDA_HOSTDEV __host__ __device__
22#define CUDA_DEV __device__
23#define CUDA_GLOBAL __global__
24#else
25// Pass valid host functions through
26#define CUDA_HOST
27#define CUDA_HOSTDEV
28// Prevent linking to device-only functions
29#define CUDA_DEV ATTRIB_DISABLE( \
30 "cannot call a __device__ function directly from CPU code")
31#define CUDA_GLOBAL ATTRIB_DISABLE( \
32 "calling a __global__ function (i.e. kernel) " \
33 "is not supported by non-CUDA compilers")
34#endif
35
36// Suppress nvcc warnings about calling a __host__ function
37// from a __host__ __device__ function
38#ifdef __NVCC__
39#define NVCC_HD_WARNING_DISABLE _Pragma("hd_warning_disable")
40#else
41#define NVCC_HD_WARNING_DISABLE
42#endif
43
44// Convert s into a string literal (s is not macro-expanded first)
45#define STRINGIFY(s) #s
46
47// Hint to the compiler that the subsequent loop should be unrolled (if
48// supported by the compiler). The unroll count can be optionally specified.
49#if defined(__clang__) || defined(__NVCC__)
50#define PRAGMA_UNROLL _Pragma("unroll")
51#define PRAGMA_UNROLL_COUNT(count) _Pragma(STRINGIFY(unroll count))
52#else
53#define PRAGMA_UNROLL
54#define PRAGMA_UNROLL_COUNT(count)
55#endif

Generated for ISCE3.0 by doxygen 1.13.2.