-
Notifications
You must be signed in to change notification settings - Fork 179
/
Copy path__config
386 lines (327 loc) · 14.7 KB
/
__config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCUDACXX_CONFIG
#define _LIBCUDACXX_CONFIG
#include <cuda/__cccl_config> // IWYU pragma: export
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
# pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
#include <cuda/std/__internal/cpp_dialect.h>
#include <cuda/std/__internal/features.h>
#include <cuda/std/__internal/namespaces.h>
#ifdef __cplusplus
// __config may be included in `extern "C"` contexts, switch back to include <nv/target>
extern "C++" {
# include <nv/target>
}
# define _LIBCUDACXX_VERSION 10000
# ifndef __has_extension
# define __has_extension(__x) 0
# endif
# ifdef __LITTLE_ENDIAN__
# if __LITTLE_ENDIAN__
# define _LIBCUDACXX_LITTLE_ENDIAN
# endif // __LITTLE_ENDIAN__
# endif // __LITTLE_ENDIAN__
# ifdef __BIG_ENDIAN__
# if __BIG_ENDIAN__
# define _LIBCUDACXX_BIG_ENDIAN
# endif // __BIG_ENDIAN__
# endif // __BIG_ENDIAN__
# ifdef __BYTE_ORDER__
# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define _LIBCUDACXX_LITTLE_ENDIAN
# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define _LIBCUDACXX_BIG_ENDIAN
# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# endif // __BYTE_ORDER__
# if defined(_WIN32)
# define _LIBCUDACXX_LITTLE_ENDIAN
# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
# define _LIBCUDACXX_HAS_BITSCAN64
# endif
// Some CRT APIs are unavailable to store apps
# if defined(WINAPI_FAMILY)
# include <winapifamily.h>
# if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) \
&& (!defined(WINAPI_PARTITION_SYSTEM) || !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM))
# define _LIBCUDACXX_WINDOWS_STORE_APP
# endif
# endif
# endif // defined(_WIN32)
# ifndef _LIBCUDACXX_LITTLE_ENDIAN
# if _CCCL_COMPILER(NVRTC)
# define _LIBCUDACXX_LITTLE_ENDIAN
# endif
# endif // _LIBCUDACXX_LITTLE_ENDIAN
# if !defined(_LIBCUDACXX_LITTLE_ENDIAN) && !defined(_LIBCUDACXX_BIG_ENDIAN)
# include <endian.h>
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define _LIBCUDACXX_LITTLE_ENDIAN
# elif __BYTE_ORDER == __BIG_ENDIAN
# define _LIBCUDACXX_BIG_ENDIAN
# else // __BYTE_ORDER == __BIG_ENDIAN
# error unable to determine endian
# endif
# endif // !defined(_LIBCUDACXX_LITTLE_ENDIAN) && !defined(_LIBCUDACXX_BIG_ENDIAN)
# if _CCCL_HAS_ATTRIBUTE(__no_sanitize__) && !_CCCL_COMPILER(GCC)
# define _LIBCUDACXX_NO_CFI __attribute__((__no_sanitize__("cfi")))
# else
# define _LIBCUDACXX_NO_CFI
# endif
# if _CCCL_COMPILER(NVRTC)
# define __alignof(x) alignof(x)
# endif // _CCCL_COMPILER(NVRTC)
# if _CCCL_COMPILER(MSVC)
# define __alignof__ __alignof
# endif
# define _LIBCUDACXX_ALIGNOF(_Tp) alignof(_Tp)
# define _LIBCUDACXX_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
# if _CCCL_COMPILER(MSVC)
# define _CCCL_ALIGNAS_TYPE(x) alignas(x)
# define _CCCL_ALIGNAS(x) __declspec(align(x))
# elif _CCCL_HAS_FEATURE(cxx_alignas)
# define _CCCL_ALIGNAS_TYPE(x) alignas(x)
# define _CCCL_ALIGNAS(x) alignas(x)
# else
# define _CCCL_ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCUDACXX_ALIGNOF(x))))
# define _CCCL_ALIGNAS(x) __attribute__((__aligned__(x)))
# endif // !_CCCL_COMPILER(MSVC) && !_CCCL_HAS_FEATURE(cxx_alignas)
// This is wrapped in __CUDA_ARCH__ to prevent error: "ignoring '#pragma unroll'
// [-Werror=unknown-pragmas]"
# if defined(__CUDA_ARCH__)
# define _LIBCUDACXX_PRAGMA_UNROLL(_N) _CCCL_PRAGMA(unroll _N)
# else // ^^^ __CUDA_ARCH__ ^^^ / vvv !__CUDA_ARCH__ vvv
# define _LIBCUDACXX_PRAGMA_UNROLL(_N)
# endif // !__CUDA_ARCH__
# if _CCCL_HAS_CUDA_COMPILER
# define _LIBCUDACXX_ATOMIC_ALWAYS_LOCK_FREE(size, ptr) (size <= 8)
# elif _CCCL_COMPILER(CLANG) || _CCCL_COMPILER(GCC)
# define _LIBCUDACXX_ATOMIC_ALWAYS_LOCK_FREE(...) __atomic_always_lock_free(__VA_ARGS__)
# endif // _CCCL_CUDA_COMPILER
# if _CCCL_COMPILER(CLANG)
// Allow for build-time disabling of unsigned integer sanitization
# if !defined(_LIBCUDACXX_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK) && _CCCL_HAS_ATTRIBUTE(no_sanitize)
# define _LIBCUDACXX_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK \
__attribute__((__no_sanitize__("unsigned-integer-overflow")))
# endif
# endif // _CCCL_COMPILER(CLANG)
# ifdef _LIBCUDACXX_HAS_NO_UNICODE_CHARS
using char16_t = unsigned short;
using char32_t = unsigned int;
# endif // _LIBCUDACXX_HAS_NO_UNICODE_CHARS
# ifdef _LIBCUDACXX_DEBUG
# if _LIBCUDACXX_DEBUG == 0
# define _LIBCUDACXX_DEBUG_LEVEL 1
# elif _LIBCUDACXX_DEBUG == 1
# define _LIBCUDACXX_DEBUG_LEVEL 2
# else
# error Supported values for _LIBCUDACXX_DEBUG are 0 and 1
# endif
# if !defined(_LIBCUDACXX_BUILDING_LIBRARY)
# define _LIBCUDACXX_EXTERN_TEMPLATE(...)
# endif
# endif
# ifdef _LIBCUDACXX_DISABLE_EXTERN_TEMPLATE
# define _LIBCUDACXX_EXTERN_TEMPLATE(...)
# endif
# ifndef _LIBCUDACXX_EXTERN_TEMPLATE
# define _LIBCUDACXX_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
# endif
// Deprecation macros.
//
// Deprecations warnings are always enabled, except when users explicitly opt-out
// by defining _LIBCUDACXX_DISABLE_DEPRECATION_WARNINGS.
// NVCC 11.1 and 11.2 are broken with the deprecated attribute, so disable it
# if !defined(_LIBCUDACXX_DISABLE_DEPRECATION_WARNINGS) && _CCCL_CUDACC_AT_LEAST(11, 3)
# if _CCCL_HAS_ATTRIBUTE(deprecated)
# define _LIBCUDACXX_DEPRECATED __attribute__((deprecated))
# elif _CCCL_STD_VER > 2011
# define _LIBCUDACXX_DEPRECATED [[deprecated]]
# else
# define _LIBCUDACXX_DEPRECATED
# endif
# else
# define _LIBCUDACXX_DEPRECATED
# endif
# define _LIBCUDACXX_DEPRECATED_IN_CXX11 _LIBCUDACXX_DEPRECATED
# if _CCCL_STD_VER >= 2014
# define _LIBCUDACXX_DEPRECATED_IN_CXX14 _LIBCUDACXX_DEPRECATED
# else
# define _LIBCUDACXX_DEPRECATED_IN_CXX14
# endif
# if _CCCL_STD_VER >= 2017
# define _LIBCUDACXX_DEPRECATED_IN_CXX17 _LIBCUDACXX_DEPRECATED
# else
# define _LIBCUDACXX_DEPRECATED_IN_CXX17
# endif
# if _CCCL_STD_VER >= 2020
# define _LIBCUDACXX_DEPRECATED_IN_CXX20 _LIBCUDACXX_DEPRECATED
# else
# define _LIBCUDACXX_DEPRECATED_IN_CXX20
# endif
// Thread API
# ifndef _LIBCUDACXX_HAS_THREAD_API_EXTERNAL
# if _CCCL_COMPILER(NVRTC) || defined(__EMSCRIPTEN__)
# define _LIBCUDACXX_HAS_THREAD_API_EXTERNAL
# endif
# endif // _LIBCUDACXX_HAS_THREAD_API_EXTERNAL
# ifndef _LIBCUDACXX_HAS_THREAD_API_CUDA
# if (defined(__CUDA_ARCH__) || defined(__EMSCRIPTEN__))
# define _LIBCUDACXX_HAS_THREAD_API_CUDA
# endif // __cuda_std__
# endif // _LIBCUDACXX_HAS_THREAD_API_CUDA
# ifndef _LIBCUDACXX_HAS_THREAD_API_WIN32
# if _CCCL_COMPILER(MSVC) && !defined(_LIBCUDACXX_HAS_THREAD_API_CUDA)
# define _LIBCUDACXX_HAS_THREAD_API_WIN32
# endif
# endif // _LIBCUDACXX_HAS_THREAD_API_WIN32
# if !defined(_LIBCUDACXX_HAS_NO_THREADS) && !defined(_LIBCUDACXX_HAS_THREAD_API_PTHREAD) \
&& !defined(_LIBCUDACXX_HAS_THREAD_API_WIN32) && !defined(_LIBCUDACXX_HAS_THREAD_API_EXTERNAL)
# if defined(__linux__) || defined(__GNU__) || defined(__APPLE__) \
|| (defined(__MINGW32__) && _CCCL_HAS_INCLUDE(<pthread.h>))
# define _LIBCUDACXX_HAS_THREAD_API_PTHREAD
# elif defined(_WIN32)
# define _LIBCUDACXX_HAS_THREAD_API_WIN32
# else
# define _LIBCUDACXX_UNSUPPORTED_THREAD_API
# endif // _LIBCUDACXX_HAS_THREAD_API
# endif // _LIBCUDACXX_HAS_NO_THREADS
# if defined(_LIBCUDACXX_HAS_NO_THREADS) && defined(_LIBCUDACXX_HAS_THREAD_API_PTHREAD)
# error _LIBCUDACXX_HAS_THREAD_API_PTHREAD may only be defined when \
_LIBCUDACXX_HAS_NO_THREADS is not defined.
# endif
# if defined(_LIBCUDACXX_HAS_NO_THREADS) && defined(_LIBCUDACXX_HAS_THREAD_API_EXTERNAL)
# error _LIBCUDACXX_HAS_THREAD_API_EXTERNAL may not be defined when \
_LIBCUDACXX_HAS_NO_THREADS is defined.
# endif
# if defined(__STDCPP_THREADS__) && defined(_LIBCUDACXX_HAS_NO_THREADS)
# error _LIBCUDACXX_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set.
# endif
# if !defined(_LIBCUDACXX_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__)
# define __STDCPP_THREADS__ 1
# endif
// TODO: Support C11 Atomics?
// #if _CCCL_HAS_FEATURE(cxx_atomic) || __has_extension(c_atomic) || _CCCL_HAS_KEYWORD(_Atomic)
// # define _LIBCUDACXX_HAS_C_ATOMIC_IMP
# if _CCCL_COMPILER(CLANG)
# define _LIBCUDACXX_HAS_GCC_ATOMIC_IMP
# elif _CCCL_COMPILER(GCC)
# define _LIBCUDACXX_HAS_GCC_ATOMIC_IMP
# elif _CCCL_COMPILER(NVHPC)
# define _LIBCUDACXX_HAS_GCC_ATOMIC_IMP
# elif _CCCL_COMPILER(MSVC)
# define _LIBCUDACXX_HAS_MSVC_ATOMIC_IMPL
# endif
// Enable bypassing automatic storage checks in atomics when using CTK 12.2 and below and if NDEBUG is defined.
# if _CCCL_CUDACC_BELOW(12, 2) && !defined(NDEBUG)
# define _LIBCUDACXX_ATOMIC_UNSAFE_AUTOMATIC_STORAGE
# endif // _CCCL_CUDACC_BELOW(12, 2)
// CUDA Atomics supersede host atomics in order to insert the host/device dispatch layer
# if _CCCL_CUDA_COMPILER(NVCC) || _CCCL_COMPILER(NVRTC) || _CCCL_COMPILER(NVHPC) || _CCCL_CUDACC
# define _LIBCUDACXX_HAS_CUDA_ATOMIC_IMPL
# endif
# if (!defined(_LIBCUDACXX_HAS_C_ATOMIC_IMP) && !defined(_LIBCUDACXX_HAS_GCC_ATOMIC_IMP) \
&& !defined(_LIBCUDACXX_HAS_EXTERNAL_ATOMIC_IMP)) \
|| defined(_LIBCUDACXX_HAS_NO_THREADS)
# define _LIBCUDACXX_HAS_NO_ATOMIC_HEADER
# else
# ifdef __cuda_std__
# undef _LIBCUDACXX_ATOMIC_FLAG_TYPE
# define _LIBCUDACXX_ATOMIC_FLAG_TYPE int
# endif
# ifndef _LIBCUDACXX_ATOMIC_FLAG_TYPE
# define _LIBCUDACXX_ATOMIC_FLAG_TYPE bool
# endif
# endif
# ifndef _LIBCUDACXX_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
# define _LIBCUDACXX_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
# endif
# if _CCCL_HAS_ATTRIBUTE(require_constant_initialization)
# define _LIBCUDACXX_SAFE_STATIC __attribute__((__require_constant_initialization__))
# else
# define _LIBCUDACXX_SAFE_STATIC
# endif
# if _CCCL_HAS_ATTRIBUTE(diagnose_if) && !defined(_LIBCUDACXX_DISABLE_ADDITIONAL_DIAGNOSTICS)
# define _LIBCUDACXX_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning")))
# define _LIBCUDACXX_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error")))
# else
# define _LIBCUDACXX_DIAGNOSE_WARNING(...)
# define _LIBCUDACXX_DIAGNOSE_ERROR(...)
# endif
# if _CCCL_HAS_ATTRIBUTE(__preferred_name__)
# define _LIBCUDACXX_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
# else
# define _LIBCUDACXX_PREFERRED_NAME(x)
# endif
# if defined(_LIBCUDACXX_ENABLE_CXX17_REMOVED_FEATURES)
# define _LIBCUDACXX_ENABLE_CXX17_REMOVED_AUTO_PTR
# define _LIBCUDACXX_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
# define _LIBCUDACXX_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
# define _LIBCUDACXX_ENABLE_CXX17_REMOVED_BINDERS
# endif // _LIBCUDACXX_ENABLE_CXX17_REMOVED_FEATURES
# define _LIBCUDACXX_UNUSED_VAR(x) ((void) (x))
# ifndef _LIBCUDACXX_SYS_CLOCK_DURATION
# define _LIBCUDACXX_SYS_CLOCK_DURATION nanoseconds
# endif // _LIBCUDACXX_SYS_CLOCK_DURATION
// There are a handful of public standard library types that are intended to
// support CTAD but don't need any explicit deduction guides to do so. This
// macro is used to mark them as such, which suppresses the
// '-Wctad-maybe-unsupported' compiler warning when CTAD is used in user code
// with these classes.
# if (!_CCCL_COMPILER(GCC) || _CCCL_COMPILER(GCC, >, 6)) && _CCCL_STD_VER >= 2017
# define _LIBCUDACXX_CTAD_SUPPORTED_FOR_TYPE(_ClassName) \
template <class... _Tag> \
_ClassName(typename _Tag::__allow_ctad...)->_ClassName<_Tag...>
# else
# define _LIBCUDACXX_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
# endif
// Older nvcc do not handle the constraint of `construct_at` in earlier std modes
// So to preserve our performance optimization we default to the unconstrained
// `__construct_at` and only in C++20 use `construct_at`
# if _CCCL_STD_VER > 2017
# define _LIBCUDACXX_CONSTRUCT_AT(_LOCATION, ...) \
_CUDA_VSTD::construct_at(_CUDA_VSTD::addressof(_LOCATION), __VA_ARGS__)
# else
# define _LIBCUDACXX_CONSTRUCT_AT(_LOCATION, ...) \
_CUDA_VSTD::__construct_at(_CUDA_VSTD::addressof(_LOCATION), __VA_ARGS__)
# endif
// We can only expose constexpr allocations if the compiler supports it
# if defined(__cpp_constexpr_dynamic_alloc) && defined(__cpp_lib_constexpr_dynamic_alloc) && _CCCL_STD_VER >= 2020 \
&& !_CCCL_COMPILER(NVRTC)
# define _CCCL_HAS_CONSTEXPR_ALLOCATION
# define _CCCL_CONSTEXPR_CXX20_ALLOCATION constexpr
# else // ^^^ __cpp_constexpr_dynamic_alloc ^^^ / vvv !__cpp_constexpr_dynamic_alloc vvv
# define _CCCL_CONSTEXPR_CXX20_ALLOCATION
# endif
// NVRTC has a bug that prevented the use of delegated constructors, as it did not accept execution space annotations.
// This creates a whole lot of boilerplate that we can avoid through a macro (see nvbug3961621)
# if (_CCCL_CUDACC_BELOW(12, 6) && _CCCL_COMPILER(NVRTC)) || (_CCCL_CUDACC_BELOW(11, 3) && _CCCL_COMPILER(CLANG))
# define _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__class, __baseclass, ...) \
using __base = __baseclass<__VA_ARGS__>; \
_CCCL_TEMPLATE(class... _Args) \
_CCCL_REQUIRES(_CCCL_TRAIT(is_constructible, __base, _Args...)) \
_LIBCUDACXX_HIDE_FROM_ABI constexpr __class(_Args&&... __args) noexcept( \
_CCCL_TRAIT(is_nothrow_constructible, __base, _Args...)) \
: __base(_CUDA_VSTD::forward<_Args>(__args)...) \
{} \
_CCCL_HIDE_FROM_ABI constexpr __class() noexcept = default;
# else // ^^^ workaround ^^^ / vvv no workaround vvv
# define _LIBCUDACXX_DELEGATE_CONSTRUCTORS(__class, __baseclass, ...) \
using __base = __baseclass<__VA_ARGS__>; \
using __base::__base; \
_CCCL_HIDE_FROM_ABI constexpr __class() noexcept = default;
# endif // !(_CCCL_CUDACC_BELOW(12,5) && _CCCL_COMPILER(NVRTC)) && !(_CCCL_CUDACC_BELOW(11,3) && _CCCL_COMPILER(CLANG))
#endif // __cplusplus
#endif // _LIBCUDACXX_CONFIG