Debian Codegraph @

packages/kokkos/tpls/mdspan/include/experimental/__p0009_bits/config.hpp

raw
1 //@HEADER
2 // ************************************************************************
3 //
4 // Kokkos v. 4.0
5 // Copyright (2022) National Technology & Engineering
6 // Solutions of Sandia, LLC (NTESS).
7 //
8 // Under the terms of Contract DE-NA0003525 with NTESS,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions.
12 // See https://kokkos.org/LICENSE for license information.
13 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
14 //
15 //@HEADER
16 #pragma once
17
18 #ifndef __has_include
19 # define __has_include(x) 0
20 #endif
21
22 #if __has_include(<version>)
23 # include <version>
24 #else
25 # include <type_traits>
26 # include <utility>
27 #endif
28
29 #ifdef _MSVC_LANG
30 #define _MDSPAN_CPLUSPLUS _MSVC_LANG
31 #else
32 #define _MDSPAN_CPLUSPLUS __cplusplus
33 #endif
34
35 #define MDSPAN_CXX_STD_14 201402L
36 #define MDSPAN_CXX_STD_17 201703L
37 #define MDSPAN_CXX_STD_20 202002L
38 // Note GCC has not updated this in version 13
39 #ifdef __clang__
40 #define MDSPAN_CXX_STD_23 202302L
41 #else
42 #define MDSPAN_CXX_STD_23 202100L
43 #endif
44
45 #define MDSPAN_HAS_CXX_14 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14)
46 #define MDSPAN_HAS_CXX_17 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_17)
47 #define MDSPAN_HAS_CXX_20 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_20)
48 #define MDSPAN_HAS_CXX_23 (_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_23)
49
50 static_assert(_MDSPAN_CPLUSPLUS >= MDSPAN_CXX_STD_14, "mdspan requires C++14 or later.");
51
52 #ifndef _MDSPAN_COMPILER_CLANG
53 # if defined(__clang__)
54 # define _MDSPAN_COMPILER_CLANG __clang__
55 # endif
56 #endif
57
58 #if !defined(_MDSPAN_COMPILER_MSVC) && !defined(_MDSPAN_COMPILER_MSVC_CLANG)
59 # if defined(_MSC_VER)
60 # if !defined(_MDSPAN_COMPILER_CLANG)
61 # define _MDSPAN_COMPILER_MSVC _MSC_VER
62 # else
63 # define _MDSPAN_COMPILER_MSVC_CLANG _MSC_VER
64 # endif
65 # endif
66 #endif
67
68 #ifndef _MDSPAN_COMPILER_INTEL
69 # ifdef __INTEL_COMPILER
70 # define _MDSPAN_COMPILER_INTEL __INTEL_COMPILER
71 # endif
72 #endif
73
74 #ifndef _MDSPAN_COMPILER_APPLECLANG
75 # ifdef __apple_build_version__
76 # define _MDSPAN_COMPILER_APPLECLANG __apple_build_version__
77 # endif
78 #endif
79
80 #ifndef _MDSPAN_HAS_CUDA
81 # if defined(__CUDACC__)
82 # define _MDSPAN_HAS_CUDA __CUDACC__
83 # endif
84 #endif
85
86 #ifndef _MDSPAN_HAS_HIP
87 # if defined(__HIPCC__)
88 # define _MDSPAN_HAS_HIP __HIPCC__
89 # endif
90 #endif
91
92 #ifndef _MDSPAN_HAS_SYCL
93 # if defined(SYCL_LANGUAGE_VERSION)
94 # define _MDSPAN_HAS_SYCL SYCL_LANGUAGE_VERSION
95 # endif
96 #endif
97
98 #ifndef __has_cpp_attribute
99 # define __has_cpp_attribute(x) 0
100 #endif
101
102 #ifndef _MDSPAN_PRESERVE_STANDARD_LAYOUT
103 // Preserve standard layout by default, but we're not removing the old version
104 // that turns this off until we're sure this doesn't have an unreasonable cost
105 // to the compiler or optimizer.
106 # define _MDSPAN_PRESERVE_STANDARD_LAYOUT 1
107 #endif
108
109 #if !defined(_MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS)
110 # if ((__has_cpp_attribute(no_unique_address) >= 201803L) && \
111 (!defined(__NVCC__) || MDSPAN_HAS_CXX_20) && \
112 (!defined(_MDSPAN_COMPILER_MSVC) || MDSPAN_HAS_CXX_20))
113 # define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1
114 # define _MDSPAN_NO_UNIQUE_ADDRESS [[no_unique_address]]
115 # else
116 # define _MDSPAN_NO_UNIQUE_ADDRESS
117 # endif
118 #endif
119
120 // NVCC older than 11.6 chokes on the no-unique-address-emulation
121 // so just pretend to use it (to avoid the full blown EBO workaround
122 // which NVCC also doesn't like ...), and leave the macro empty
123 #ifndef _MDSPAN_NO_UNIQUE_ADDRESS
124 # if defined(__NVCC__)
125 # define _MDSPAN_USE_ATTRIBUTE_NO_UNIQUE_ADDRESS 1
126 # define _MDSPAN_USE_FAKE_ATTRIBUTE_NO_UNIQUE_ADDRESS
127 # endif
128 # define _MDSPAN_NO_UNIQUE_ADDRESS
129 #endif
130
131 // AMDs HIP compiler seems to have issues with concepts
132 // it pretends concepts exist, but doesn't ship <concept>
133 #ifndef __HIPCC__
134 #ifndef _MDSPAN_USE_CONCEPTS
135 # if defined(__cpp_concepts) && __cpp_concepts >= 201507L
136 # define _MDSPAN_USE_CONCEPTS 1
137 # endif
138 #endif
139 #endif
140
141 #ifndef _MDSPAN_USE_FOLD_EXPRESSIONS
142 # if (defined(__cpp_fold_expressions) && __cpp_fold_expressions >= 201603L) \
143 || (!defined(__cpp_fold_expressions) && MDSPAN_HAS_CXX_17)
144 # define _MDSPAN_USE_FOLD_EXPRESSIONS 1
145 # endif
146 #endif
147
148 #ifndef _MDSPAN_USE_INLINE_VARIABLES
149 # if defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L \
150 || (!defined(__cpp_inline_variables) && MDSPAN_HAS_CXX_17)
151 # define _MDSPAN_USE_INLINE_VARIABLES 1
152 # endif
153 #endif
154
155 #ifndef _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS
156 # if (!(defined(__cpp_lib_type_trait_variable_templates) && __cpp_lib_type_trait_variable_templates >= 201510L) \
157 || !MDSPAN_HAS_CXX_17)
158 # if !(defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_17)
159 # define _MDSPAN_NEEDS_TRAIT_VARIABLE_TEMPLATE_BACKPORTS 1
160 # endif
161 # endif
162 #endif
163
164 #ifndef _MDSPAN_USE_VARIABLE_TEMPLATES
165 # if (defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 && MDSPAN_HAS_CXX_17) \
166 || (!defined(__cpp_variable_templates) && MDSPAN_HAS_CXX_17)
167 # define _MDSPAN_USE_VARIABLE_TEMPLATES 1
168 # endif
169 #endif // _MDSPAN_USE_VARIABLE_TEMPLATES
170
171 #ifndef _MDSPAN_USE_CONSTEXPR_14
172 # if (defined(__cpp_constexpr) && __cpp_constexpr >= 201304) \
173 || (!defined(__cpp_constexpr) && MDSPAN_HAS_CXX_14) \
174 && (!(defined(__INTEL_COMPILER) && __INTEL_COMPILER <= 1700))
175 # define _MDSPAN_USE_CONSTEXPR_14 1
176 # endif
177 #endif
178
179 #ifndef _MDSPAN_USE_INTEGER_SEQUENCE
180 # if defined(_MDSPAN_COMPILER_MSVC)
181 # if (defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304)
182 # define _MDSPAN_USE_INTEGER_SEQUENCE 1
183 # endif
184 # endif
185 #endif
186 #ifndef _MDSPAN_USE_INTEGER_SEQUENCE
187 # if (defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304) \
188 || (!defined(__cpp_lib_integer_sequence) && MDSPAN_HAS_CXX_14) \
189 /* as far as I can tell, libc++ seems to think this is a C++11 feature... */ \
190 || (defined(__GLIBCXX__) && __GLIBCXX__ > 20150422 && __GNUC__ < 5 && !defined(__INTEL_CXX11_MODE__))
191 // several compilers lie about integer_sequence working properly unless the C++14 standard is used
192 # define _MDSPAN_USE_INTEGER_SEQUENCE 1
193 # elif defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_14
194 // appleclang seems to be missing the __cpp_lib_... macros, but doesn't seem to lie about C++14 making
195 // integer_sequence work
196 # define _MDSPAN_USE_INTEGER_SEQUENCE 1
197 # endif
198 #endif
199
200 #ifndef _MDSPAN_USE_RETURN_TYPE_DEDUCTION
201 # if (defined(__cpp_return_type_deduction) && __cpp_return_type_deduction >= 201304) \
202 || (!defined(__cpp_return_type_deduction) && MDSPAN_HAS_CXX_14)
203 # define _MDSPAN_USE_RETURN_TYPE_DEDUCTION 1
204 # endif
205 #endif
206
207 #ifndef _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
208 # if (!defined(__NVCC__) || (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__ * 10 >= 1170)) && \
209 ((defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201703) || \
210 (!defined(__cpp_deduction_guides) && MDSPAN_HAS_CXX_17))
211 # define _MDSPAN_USE_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1
212 # endif
213 #endif
214
215 #ifndef _MDSPAN_USE_STANDARD_TRAIT_ALIASES
216 # if (defined(__cpp_lib_transformation_trait_aliases) && __cpp_lib_transformation_trait_aliases >= 201304) \
217 || (!defined(__cpp_lib_transformation_trait_aliases) && MDSPAN_HAS_CXX_14)
218 # define _MDSPAN_USE_STANDARD_TRAIT_ALIASES 1
219 # elif defined(_MDSPAN_COMPILER_APPLECLANG) && MDSPAN_HAS_CXX_14
220 // appleclang seems to be missing the __cpp_lib_... macros, but doesn't seem to lie about C++14
221 # define _MDSPAN_USE_STANDARD_TRAIT_ALIASES 1
222 # endif
223 #endif
224
225 #ifndef _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND
226 # ifdef __GNUC__
227 # if __GNUC__ < 9
228 # define _MDSPAN_DEFAULTED_CONSTRUCTORS_INHERITANCE_WORKAROUND 1
229 # endif
230 # endif
231 #endif
232
233 #ifndef MDSPAN_CONDITIONAL_EXPLICIT
234 # if MDSPAN_HAS_CXX_20
235 # define MDSPAN_CONDITIONAL_EXPLICIT(COND) explicit(COND)
236 # else
237 # define MDSPAN_CONDITIONAL_EXPLICIT(COND)
238 # endif
239 #endif
240
241 #ifndef MDSPAN_USE_BRACKET_OPERATOR
242 # if defined(__cpp_multidimensional_subscript)
243 // The following if/else is necessary to workaround a clang issue
244 // relative to using a parameter pack inside a bracket operator in C++2b/C++23 mode
245 # if defined(_MDSPAN_COMPILER_CLANG) && ((__clang_major__ == 15) || (__clang_major__ == 16))
246 # define MDSPAN_USE_BRACKET_OPERATOR 0
247 # else
248 # define MDSPAN_USE_BRACKET_OPERATOR 1
249 # endif
250 # else
251 # define MDSPAN_USE_BRACKET_OPERATOR 0
252 # endif
253 #endif
254
255 #ifndef MDSPAN_USE_PAREN_OPERATOR
256 # if !MDSPAN_USE_BRACKET_OPERATOR
257 # define MDSPAN_USE_PAREN_OPERATOR 1
258 # else
259 # define MDSPAN_USE_PAREN_OPERATOR 0
260 # endif
261 #endif
262
263 #if MDSPAN_USE_BRACKET_OPERATOR
264 # define __MDSPAN_OP(mds,...) mds[__VA_ARGS__]
265 // Corentins demo compiler for subscript chokes on empty [] call,
266 // though I believe the proposal supports it?
267 #ifdef MDSPAN_NO_EMPTY_BRACKET_OPERATOR
268 # define __MDSPAN_OP0(mds) mds.accessor().access(mds.data_handle(),0)
269 #else
270 # define __MDSPAN_OP0(mds) mds[]
271 #endif
272 # define __MDSPAN_OP1(mds, a) mds[a]
273 # define __MDSPAN_OP2(mds, a, b) mds[a,b]
274 # define __MDSPAN_OP3(mds, a, b, c) mds[a,b,c]
275 # define __MDSPAN_OP4(mds, a, b, c, d) mds[a,b,c,d]
276 # define __MDSPAN_OP5(mds, a, b, c, d, e) mds[a,b,c,d,e]
277 # define __MDSPAN_OP6(mds, a, b, c, d, e, f) mds[a,b,c,d,e,f]
278 #else
279 # define __MDSPAN_OP(mds,...) mds(__VA_ARGS__)
280 # define __MDSPAN_OP0(mds) mds()
281 # define __MDSPAN_OP1(mds, a) mds(a)
282 # define __MDSPAN_OP2(mds, a, b) mds(a,b)
283 # define __MDSPAN_OP3(mds, a, b, c) mds(a,b,c)
284 # define __MDSPAN_OP4(mds, a, b, c, d) mds(a,b,c,d)
285 # define __MDSPAN_OP5(mds, a, b, c, d, e) mds(a,b,c,d,e)
286 # define __MDSPAN_OP6(mds, a, b, c, d, e, f) mds(a,b,c,d,e,f)
287 #endif