YAKL
YAKL_defines.h
Go to the documentation of this file.
1 
7 #pragma once
8 // Included by YAKL.h
9 
10 #ifdef YAKL_B4B
11  #define YAKL_MANAGED_MEMORY
12 #endif
13 
14 #ifdef YAKL_DEBUG
15  #ifndef YAKL_AUTO_FENCE
16  #define YAKL_AUTO_FENCE
17  #endif
18 #endif
19 
20 #ifdef YAKL_AUTO_PROFILE
21  #ifndef YAKL_PROFILE
22  #define YAKL_PROFILE
23  #endif
24 #endif
25 
26 #ifdef YAKL_VERBOSE_FILE
27  #ifndef YAKL_VERBOSE
28  #define YAKL_VERBOSE
29  #endif
30 #endif
31 
32 #if defined(YAKL_AUTO_PROFILE) || defined(YAKL_VERBOSE)
33  #define YAKL_AUTO_LABEL() (std::string(basename(__FILE__)) + std::string(":") + std::to_string(__LINE__)).c_str()
34 #else
35 
38  #define YAKL_AUTO_LABEL() ""
39 #endif
40 
41 
42 #ifdef YAKL_ARCH_CUDA
43 
44 
45  #define YAKL_LAMBDA [=] __host__ __device__
46  #define YAKL_DEVICE_LAMBDA [=] __device__
47  #define YAKL_CLASS_LAMBDA [=, *this] __host__ __device__
48  #define YAKL_INLINE __host__ __device__ __forceinline__
49  #define YAKL_DEVICE_INLINE __forceinline__ __device__
50  #define YAKL_SCOPE(a,b) auto &a = b
51  #ifndef YAKL_SINGLE_MEMORY_SPACE
52  #define YAKL_SEPARATE_MEMORY_SPACE
53  #endif
54  #if defined(__NVCOMPILER_CUDA__)
55  #define YAKL_EXECUTE_ON_HOST_ONLY(...) NV_IF_TARGET(NV_IS_HOST, __VA_ARGS__)
56  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...) NV_IF_TARGET(NV_IS_DEVICE, __VA_ARGS__)
57  #else
58  #ifdef __CUDA_ARCH__
59  #define YAKL_EXECUTE_ON_HOST_ONLY(...)
60  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...) __VA_ARGS__
61  #else
62  #define YAKL_EXECUTE_ON_HOST_ONLY(...) __VA_ARGS__
63  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...)
64  #endif
65  #endif
66 
67 
68 #elif defined(YAKL_ARCH_HIP)
69 
70 
71  #define YAKL_LAMBDA [=] __host__ __device__
72  #define YAKL_DEVICE_LAMBDA [=] __device__
73  #define YAKL_CLASS_LAMBDA [=, *this] __host__ __device__
74  #define YAKL_INLINE __host__ __device__ __forceinline__
75  #define YAKL_DEVICE_INLINE __forceinline__ __device__
76  #define YAKL_SCOPE(a,b) auto &a = std::ref(b).get()
77  #ifndef YAKL_SINGLE_MEMORY_SPACE
78  #define YAKL_SEPARATE_MEMORY_SPACE
79  #endif
80  #ifdef __HIP_DEVICE_COMPILE__
81  #define YAKL_EXECUTE_ON_HOST_ONLY(...)
82  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...) __VA_ARGS__
83  #else
84  #define YAKL_EXECUTE_ON_HOST_ONLY(...) __VA_ARGS__
85  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...)
86  #endif
87 
88 
89 #elif defined(YAKL_ARCH_SYCL)
90 
91 
92  #define YAKL_LAMBDA [=]
93  #define YAKL_DEVICE_LAMBDA [=]
94  #define YAKL_CLASS_LAMBDA [=, *this]
95  #define YAKL_INLINE __inline__ __attribute__((always_inline))
96  #define YAKL_DEVICE_INLINE __inline__ __attribute__((always_inline))
97  #define YAKL_SCOPE(a,b) auto &a = std::ref(b).get()
98  #ifndef YAKL_SINGLE_MEMORY_SPACE
99  #define YAKL_SEPARATE_MEMORY_SPACE
100  #endif
101  #ifdef __SYCL_DEVICE_ONLY__
102  #define YAKL_EXECUTE_ON_HOST_ONLY(...)
103  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...) __VA_ARGS__
104  #define CL_CONSTANT __attribute__((opencl_constant))
105  #else
106  #define YAKL_EXECUTE_ON_HOST_ONLY(...) __VA_ARGS__
107  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...)
108  #define CL_CONSTANT
109  #endif
110 
111 
112 #elif defined(YAKL_ARCH_OPENMP)
113 
114 
115  #define YAKL_LAMBDA [=]
116  #define YAKL_DEVICE_LAMBDA [=]
117  #define YAKL_CLASS_LAMBDA [=, *this]
118  #define YAKL_INLINE inline
119  #define YAKL_DEVICE_INLINE inline
120  #define YAKL_SCOPE(a,b) auto &a = b
121  #define YAKL_EXECUTE_ON_HOST_ONLY(...) __VA_ARGS__
122  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...) __VA_ARGS__
123 
124 #else
125 
128  #define YAKL_LAMBDA [=]
129 
132  #define YAKL_DEVICE_LAMBDA [=]
133 
136  #define YAKL_CLASS_LAMBDA [=, *this]
137 
140  #define YAKL_INLINE inline
141 
144  #define YAKL_DEVICE_INLINE inline
145 
148  #define YAKL_SCOPE(a,b) auto &a = b
149 
153  #define YAKL_EXECUTE_ON_HOST_ONLY(...) __VA_ARGS__
154 
158  #define YAKL_EXECUTE_ON_DEVICE_ONLY(...) __VA_ARGS__
159 
160 #endif
161