TDLS 0.4.0
Tiny Device-callable Linear Solvers
Loading...
Searching...
No Matches
macros.hpp
Go to the documentation of this file.
1#ifndef TDLS_CORE_MACROS_HPP
2#define TDLS_CORE_MACROS_HPP
3
4
5
26
27#include <cstddef>
28
29#include <tdls/core/target.hpp>
30
31
32
43
44#ifndef TDLS_HOST_DEVICE
45#if defined(TDLS_DETAIL_LANG_HIP)
46#define TDLS_HOST_DEVICE __attribute__((host)) __attribute__((device))
47#elif defined(TDLS_DETAIL_FRONTEND_CUDA)
48#define TDLS_HOST_DEVICE __host__ __device__
49#else
50#define TDLS_HOST_DEVICE
51#endif
52#endif
53
54
55
68
69#ifndef TDLS_FORCE_INLINE_GPU
70#if defined(TDLS_DETAIL_LANG_HIP)
71#define TDLS_FORCE_INLINE_GPU inline __attribute__((always_inline))
72#elif defined(TDLS_DETAIL_FRONTEND_CUDA)
73#define TDLS_FORCE_INLINE_GPU __forceinline__
74#elif defined(TDLS_DETAIL_LANG_SYCL_DEVICE)
75#define TDLS_FORCE_INLINE_GPU inline __attribute__((always_inline))
76#else
77#define TDLS_FORCE_INLINE_GPU inline
78#endif
79#endif
80
81
82
92
93#ifndef TDLS_FORCE_INLINE_ALL
94#if defined(TDLS_DETAIL_LANG_HIP) || defined(TDLS_DETAIL_FRONTEND_CUDA)
95#define TDLS_FORCE_INLINE_ALL TDLS_FORCE_INLINE_GPU
96#elif defined(TDLS_DETAIL_COMPILER_MSVC)
97#define TDLS_FORCE_INLINE_ALL __forceinline
98#elif defined(TDLS_DETAIL_COMPILER_GNU_ATTRIBUTES)
99#define TDLS_FORCE_INLINE_ALL inline __attribute__((always_inline))
100#else
101#define TDLS_FORCE_INLINE_ALL inline
102#endif
103#endif
104
105
106
116
117#ifndef TDLS_NO_INLINE_GPU
118#if defined(TDLS_DETAIL_LANG_HIP)
119#define TDLS_NO_INLINE_GPU __attribute__((noinline))
120#elif defined(TDLS_DETAIL_FRONTEND_CUDA)
121#define TDLS_NO_INLINE_GPU __noinline__
122#elif defined(TDLS_DETAIL_LANG_SYCL_DEVICE)
123#define TDLS_NO_INLINE_GPU __attribute__((noinline))
124#else
125#define TDLS_NO_INLINE_GPU inline
126#endif
127#endif
128
129
130
137
138#ifndef TDLS_NO_INLINE
139#if defined(TDLS_DETAIL_FRONTEND_CUDA)
140#define TDLS_NO_INLINE __noinline__
141#elif defined(TDLS_DETAIL_COMPILER_MSVC)
142#define TDLS_NO_INLINE __declspec(noinline)
143#elif defined(TDLS_DETAIL_COMPILER_GNU_ATTRIBUTES)
144#define TDLS_NO_INLINE __attribute__((noinline))
145#else
146#define TDLS_NO_INLINE
147#endif
148#endif
149
150
151
167
168#ifndef TDLS_RESTRICT
169#if defined(TDLS_DETAIL_COMPILER_MSVC)
170#define TDLS_RESTRICT __restrict
171#elif defined(TDLS_DETAIL_CODEGEN_NVCXX)
172#define TDLS_RESTRICT
173#else
174#define TDLS_RESTRICT __restrict__
175#endif
176#endif
177
178
179
200
201#ifndef TDLS_STRIDED
202#if defined(TDLS_DETAIL_CODEGEN_NVCXX)
203#define TDLS_STRIDED(i, s) \
204 (static_cast<std::size_t>(static_cast<std::ptrdiff_t>(i)) * static_cast<unsigned>(s))
205#else
206#define TDLS_STRIDED(i, s) \
207 (static_cast<std::size_t>(static_cast<unsigned>(i)) * static_cast<unsigned>(s))
208#endif
209#endif
210
211
212
222
223#ifndef TDLS_STRIDED_WIDE
224#if defined(TDLS_DETAIL_CODEGEN_NVCXX)
225#define TDLS_STRIDED_WIDE(i, s) (static_cast<std::size_t>(static_cast<std::ptrdiff_t>(i)) * (s))
226#else
227#define TDLS_STRIDED_WIDE(i, s) (static_cast<std::size_t>(static_cast<unsigned>(i)) * (s))
228#endif
229#endif
230
231
232
242
243#ifndef TDLS_UNROLL_FORCE
244#if defined(TDLS_DETAIL_FRONTEND_CUDA) || defined(TDLS_DETAIL_LANG_HIP) || \
245 defined(TDLS_DETAIL_COMPILER_NVCXX) || defined(TDLS_DETAIL_COMPILER_CLANG)
246#define TDLS_UNROLL_FORCE _Pragma("unroll")
247#elif defined(TDLS_DETAIL_COMPILER_GCC)
248#define TDLS_UNROLL_FORCE _Pragma("GCC unroll 64")
249#else
250#define TDLS_UNROLL_FORCE
251#endif
252#endif
253
254
255
268
269#ifndef TDLS_EXEC_CHECK_DISABLE
270#if defined(TDLS_DETAIL_FRONTEND_CUDA) && !defined(TDLS_DETAIL_COMPILER_CLANG) && \
271 !defined(TDLS_DETAIL_COMPILER_NVCXX)
272#define TDLS_EXEC_CHECK_DISABLE _Pragma("nv_exec_check_disable")
273#else
274#define TDLS_EXEC_CHECK_DISABLE
275#endif
276#endif
277
278
279
280#endif // TDLS_CORE_MACROS_HPP
Detection of the compiler, of the language and of the side of the compilation pass: the one place whe...