Branch data Line data Source code
1 : : // This file is part of Eigen, a lightweight C++ template library
2 : : // for linear algebra.
3 : : //
4 : : // Copyright (C) 2008-2015 Gael Guennebaud <gael.guennebaud@inria.fr>
5 : : // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
6 : : //
7 : : // This Source Code Form is subject to the terms of the Mozilla
8 : : // Public License v. 2.0. If a copy of the MPL was not distributed
9 : : // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 : :
11 : : #ifndef EIGEN_MACROS_H
12 : : #define EIGEN_MACROS_H
13 : :
14 : : //------------------------------------------------------------------------------------------
15 : : // Eigen version and basic defaults
16 : : //------------------------------------------------------------------------------------------
17 : :
18 : : #define EIGEN_WORLD_VERSION 3
19 : : #define EIGEN_MAJOR_VERSION 4
20 : : #define EIGEN_MINOR_VERSION 0
21 : :
22 : : #define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
23 : : (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
24 : : EIGEN_MINOR_VERSION>=z))))
25 : :
26 : : #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
27 : : #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::RowMajor
28 : : #else
29 : : #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION Eigen::ColMajor
30 : : #endif
31 : :
32 : : #ifndef EIGEN_DEFAULT_DENSE_INDEX_TYPE
33 : : #define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
34 : : #endif
35 : :
36 : : // Upperbound on the C++ version to use.
37 : : // Expected values are 03, 11, 14, 17, etc.
38 : : // By default, let's use an arbitrarily large C++ version.
39 : : #ifndef EIGEN_MAX_CPP_VER
40 : : #define EIGEN_MAX_CPP_VER 99
41 : : #endif
42 : :
43 : : /** Allows to disable some optimizations which might affect the accuracy of the result.
44 : : * Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
45 : : * They currently include:
46 : : * - single precision ArrayBase::sin() and ArrayBase::cos() for SSE and AVX vectorization.
47 : : */
48 : : #ifndef EIGEN_FAST_MATH
49 : : #define EIGEN_FAST_MATH 1
50 : : #endif
51 : :
52 : : #ifndef EIGEN_STACK_ALLOCATION_LIMIT
53 : : // 131072 == 128 KB
54 : : #define EIGEN_STACK_ALLOCATION_LIMIT 131072
55 : : #endif
56 : :
57 : : //------------------------------------------------------------------------------------------
58 : : // Compiler identification, EIGEN_COMP_*
59 : : //------------------------------------------------------------------------------------------
60 : :
61 : : /// \internal EIGEN_COMP_GNUC set to 1 for all compilers compatible with GCC
62 : : #ifdef __GNUC__
63 : : #define EIGEN_COMP_GNUC (__GNUC__*10+__GNUC_MINOR__)
64 : : #else
65 : : #define EIGEN_COMP_GNUC 0
66 : : #endif
67 : :
68 : : /// \internal EIGEN_COMP_CLANG set to major+minor version (e.g., 307 for clang 3.7) if the compiler is clang
69 : : #if defined(__clang__)
70 : : #define EIGEN_COMP_CLANG (__clang_major__*100+__clang_minor__)
71 : : #else
72 : : #define EIGEN_COMP_CLANG 0
73 : : #endif
74 : :
75 : : /// \internal EIGEN_COMP_CASTXML set to 1 if being preprocessed by CastXML
76 : : #if defined(__castxml__)
77 : : #define EIGEN_COMP_CASTXML 1
78 : : #else
79 : : #define EIGEN_COMP_CASTXML 0
80 : : #endif
81 : :
82 : : /// \internal EIGEN_COMP_LLVM set to 1 if the compiler backend is llvm
83 : : #if defined(__llvm__)
84 : : #define EIGEN_COMP_LLVM 1
85 : : #else
86 : : #define EIGEN_COMP_LLVM 0
87 : : #endif
88 : :
89 : : /// \internal EIGEN_COMP_ICC set to __INTEL_COMPILER if the compiler is Intel compiler, 0 otherwise
90 : : #if defined(__INTEL_COMPILER)
91 : : #define EIGEN_COMP_ICC __INTEL_COMPILER
92 : : #else
93 : : #define EIGEN_COMP_ICC 0
94 : : #endif
95 : :
96 : : /// \internal EIGEN_COMP_MINGW set to 1 if the compiler is mingw
97 : : #if defined(__MINGW32__)
98 : : #define EIGEN_COMP_MINGW 1
99 : : #else
100 : : #define EIGEN_COMP_MINGW 0
101 : : #endif
102 : :
103 : : /// \internal EIGEN_COMP_SUNCC set to 1 if the compiler is Solaris Studio
104 : : #if defined(__SUNPRO_CC)
105 : : #define EIGEN_COMP_SUNCC 1
106 : : #else
107 : : #define EIGEN_COMP_SUNCC 0
108 : : #endif
109 : :
110 : : /// \internal EIGEN_COMP_MSVC set to _MSC_VER if the compiler is Microsoft Visual C++, 0 otherwise.
111 : : #if defined(_MSC_VER)
112 : : #define EIGEN_COMP_MSVC _MSC_VER
113 : : #else
114 : : #define EIGEN_COMP_MSVC 0
115 : : #endif
116 : :
117 : : #if defined(__NVCC__)
118 : : #if defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 9)
119 : : #define EIGEN_COMP_NVCC ((__CUDACC_VER_MAJOR__ * 10000) + (__CUDACC_VER_MINOR__ * 100))
120 : : #elif defined(__CUDACC_VER__)
121 : : #define EIGEN_COMP_NVCC __CUDACC_VER__
122 : : #else
123 : : #error "NVCC did not define compiler version."
124 : : #endif
125 : : #else
126 : : #define EIGEN_COMP_NVCC 0
127 : : #endif
128 : :
129 : : // For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC:
130 : : // name ver MSC_VER
131 : : // 2008 9 1500
132 : : // 2010 10 1600
133 : : // 2012 11 1700
134 : : // 2013 12 1800
135 : : // 2015 14 1900
136 : : // "15" 15 1900
137 : : // 2017-14.1 15.0 1910
138 : : // 2017-14.11 15.3 1911
139 : : // 2017-14.12 15.5 1912
140 : : // 2017-14.13 15.6 1913
141 : : // 2017-14.14 15.7 1914
142 : :
143 : : /// \internal EIGEN_COMP_MSVC_LANG set to _MSVC_LANG if the compiler is Microsoft Visual C++, 0 otherwise.
144 : : #if defined(_MSVC_LANG)
145 : : #define EIGEN_COMP_MSVC_LANG _MSVC_LANG
146 : : #else
147 : : #define EIGEN_COMP_MSVC_LANG 0
148 : : #endif
149 : :
150 : : // For the record, here is a table summarizing the possible values for EIGEN_COMP_MSVC_LANG:
151 : : // MSVC option Standard MSVC_LANG
152 : : // /std:c++14 (default as of VS 2019) C++14 201402L
153 : : // /std:c++17 C++17 201703L
154 : : // /std:c++latest >C++17 >201703L
155 : :
156 : : /// \internal EIGEN_COMP_MSVC_STRICT set to 1 if the compiler is really Microsoft Visual C++ and not ,e.g., ICC or clang-cl
157 : : #if EIGEN_COMP_MSVC && !(EIGEN_COMP_ICC || EIGEN_COMP_LLVM || EIGEN_COMP_CLANG)
158 : : #define EIGEN_COMP_MSVC_STRICT _MSC_VER
159 : : #else
160 : : #define EIGEN_COMP_MSVC_STRICT 0
161 : : #endif
162 : :
163 : : /// \internal EIGEN_COMP_IBM set to xlc version if the compiler is IBM XL C++
164 : : // XLC version
165 : : // 3.1 0x0301
166 : : // 4.5 0x0405
167 : : // 5.0 0x0500
168 : : // 12.1 0x0C01
169 : : #if defined(__IBMCPP__) || defined(__xlc__) || defined(__ibmxl__)
170 : : #define EIGEN_COMP_IBM __xlC__
171 : : #else
172 : : #define EIGEN_COMP_IBM 0
173 : : #endif
174 : :
175 : : /// \internal EIGEN_COMP_PGI set to PGI version if the compiler is Portland Group Compiler
176 : : #if defined(__PGI)
177 : : #define EIGEN_COMP_PGI (__PGIC__*100+__PGIC_MINOR__)
178 : : #else
179 : : #define EIGEN_COMP_PGI 0
180 : : #endif
181 : :
182 : : /// \internal EIGEN_COMP_ARM set to 1 if the compiler is ARM Compiler
183 : : #if defined(__CC_ARM) || defined(__ARMCC_VERSION)
184 : : #define EIGEN_COMP_ARM 1
185 : : #else
186 : : #define EIGEN_COMP_ARM 0
187 : : #endif
188 : :
189 : : /// \internal EIGEN_COMP_EMSCRIPTEN set to 1 if the compiler is Emscripten Compiler
190 : : #if defined(__EMSCRIPTEN__)
191 : : #define EIGEN_COMP_EMSCRIPTEN 1
192 : : #else
193 : : #define EIGEN_COMP_EMSCRIPTEN 0
194 : : #endif
195 : :
196 : :
197 : : /// \internal EIGEN_GNUC_STRICT set to 1 if the compiler is really GCC and not a compatible compiler (e.g., ICC, clang, mingw, etc.)
198 : : #if EIGEN_COMP_GNUC && !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || EIGEN_COMP_IBM || EIGEN_COMP_ARM || EIGEN_COMP_EMSCRIPTEN)
199 : : #define EIGEN_COMP_GNUC_STRICT 1
200 : : #else
201 : : #define EIGEN_COMP_GNUC_STRICT 0
202 : : #endif
203 : :
204 : :
205 : : #if EIGEN_COMP_GNUC
206 : : #define EIGEN_GNUC_AT_LEAST(x,y) ((__GNUC__==x && __GNUC_MINOR__>=y) || __GNUC__>x)
207 : : #define EIGEN_GNUC_AT_MOST(x,y) ((__GNUC__==x && __GNUC_MINOR__<=y) || __GNUC__<x)
208 : : #define EIGEN_GNUC_AT(x,y) ( __GNUC__==x && __GNUC_MINOR__==y )
209 : : #else
210 : : #define EIGEN_GNUC_AT_LEAST(x,y) 0
211 : : #define EIGEN_GNUC_AT_MOST(x,y) 0
212 : : #define EIGEN_GNUC_AT(x,y) 0
213 : : #endif
214 : :
215 : : // FIXME: could probably be removed as we do not support gcc 3.x anymore
216 : : #if EIGEN_COMP_GNUC && (__GNUC__ <= 3)
217 : : #define EIGEN_GCC3_OR_OLDER 1
218 : : #else
219 : : #define EIGEN_GCC3_OR_OLDER 0
220 : : #endif
221 : :
222 : :
223 : :
224 : : //------------------------------------------------------------------------------------------
225 : : // Architecture identification, EIGEN_ARCH_*
226 : : //------------------------------------------------------------------------------------------
227 : :
228 : :
229 : : #if defined(__x86_64__) || (defined(_M_X64) && !defined(_M_ARM64EC)) || defined(__amd64)
230 : : #define EIGEN_ARCH_x86_64 1
231 : : #else
232 : : #define EIGEN_ARCH_x86_64 0
233 : : #endif
234 : :
235 : : #if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || defined(__i386)
236 : : #define EIGEN_ARCH_i386 1
237 : : #else
238 : : #define EIGEN_ARCH_i386 0
239 : : #endif
240 : :
241 : : #if EIGEN_ARCH_x86_64 || EIGEN_ARCH_i386
242 : : #define EIGEN_ARCH_i386_OR_x86_64 1
243 : : #else
244 : : #define EIGEN_ARCH_i386_OR_x86_64 0
245 : : #endif
246 : :
247 : : /// \internal EIGEN_ARCH_ARM set to 1 if the architecture is ARM
248 : : #if defined(__arm__)
249 : : #define EIGEN_ARCH_ARM 1
250 : : #else
251 : : #define EIGEN_ARCH_ARM 0
252 : : #endif
253 : :
254 : : /// \internal EIGEN_ARCH_ARM64 set to 1 if the architecture is ARM64
255 : : #if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
256 : : #define EIGEN_ARCH_ARM64 1
257 : : #else
258 : : #define EIGEN_ARCH_ARM64 0
259 : : #endif
260 : :
261 : : /// \internal EIGEN_ARCH_ARM_OR_ARM64 set to 1 if the architecture is ARM or ARM64
262 : : #if EIGEN_ARCH_ARM || EIGEN_ARCH_ARM64
263 : : #define EIGEN_ARCH_ARM_OR_ARM64 1
264 : : #else
265 : : #define EIGEN_ARCH_ARM_OR_ARM64 0
266 : : #endif
267 : :
268 : : /// \internal EIGEN_ARCH_ARMV8 set to 1 if the architecture is armv8 or greater.
269 : : #if EIGEN_ARCH_ARM_OR_ARM64 && defined(__ARM_ARCH) && __ARM_ARCH >= 8
270 : : #define EIGEN_ARCH_ARMV8 1
271 : : #else
272 : : #define EIGEN_ARCH_ARMV8 0
273 : : #endif
274 : :
275 : :
276 : : /// \internal EIGEN_HAS_ARM64_FP16 set to 1 if the architecture provides an IEEE
277 : : /// compliant Arm fp16 type
278 : : #if EIGEN_ARCH_ARM64
279 : : #ifndef EIGEN_HAS_ARM64_FP16
280 : : #if defined(__ARM_FP16_FORMAT_IEEE)
281 : : #define EIGEN_HAS_ARM64_FP16 1
282 : : #else
283 : : #define EIGEN_HAS_ARM64_FP16 0
284 : : #endif
285 : : #endif
286 : : #endif
287 : :
288 : : /// \internal EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC set to 1 if the architecture
289 : : /// supports Neon vector intrinsics for fp16.
290 : : #if EIGEN_ARCH_ARM64
291 : : #ifndef EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC
292 : : #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
293 : : #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 1
294 : : #else
295 : : #define EIGEN_HAS_ARM64_FP16_VECTOR_ARITHMETIC 0
296 : : #endif
297 : : #endif
298 : : #endif
299 : :
300 : : /// \internal EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC set to 1 if the architecture
301 : : /// supports Neon scalar intrinsics for fp16.
302 : : #if EIGEN_ARCH_ARM64
303 : : #ifndef EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC
304 : : #if defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
305 : : #define EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC 1
306 : : #endif
307 : : #endif
308 : : #endif
309 : :
310 : : /// \internal EIGEN_ARCH_MIPS set to 1 if the architecture is MIPS
311 : : #if defined(__mips__) || defined(__mips)
312 : : #define EIGEN_ARCH_MIPS 1
313 : : #else
314 : : #define EIGEN_ARCH_MIPS 0
315 : : #endif
316 : :
317 : : /// \internal EIGEN_ARCH_SPARC set to 1 if the architecture is SPARC
318 : : #if defined(__sparc__) || defined(__sparc)
319 : : #define EIGEN_ARCH_SPARC 1
320 : : #else
321 : : #define EIGEN_ARCH_SPARC 0
322 : : #endif
323 : :
324 : : /// \internal EIGEN_ARCH_IA64 set to 1 if the architecture is Intel Itanium
325 : : #if defined(__ia64__)
326 : : #define EIGEN_ARCH_IA64 1
327 : : #else
328 : : #define EIGEN_ARCH_IA64 0
329 : : #endif
330 : :
331 : : /// \internal EIGEN_ARCH_PPC set to 1 if the architecture is PowerPC
332 : : #if defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)
333 : : #define EIGEN_ARCH_PPC 1
334 : : #else
335 : : #define EIGEN_ARCH_PPC 0
336 : : #endif
337 : :
338 : :
339 : :
340 : : //------------------------------------------------------------------------------------------
341 : : // Operating system identification, EIGEN_OS_*
342 : : //------------------------------------------------------------------------------------------
343 : :
344 : : /// \internal EIGEN_OS_UNIX set to 1 if the OS is a unix variant
345 : : #if defined(__unix__) || defined(__unix)
346 : : #define EIGEN_OS_UNIX 1
347 : : #else
348 : : #define EIGEN_OS_UNIX 0
349 : : #endif
350 : :
351 : : /// \internal EIGEN_OS_LINUX set to 1 if the OS is based on Linux kernel
352 : : #if defined(__linux__)
353 : : #define EIGEN_OS_LINUX 1
354 : : #else
355 : : #define EIGEN_OS_LINUX 0
356 : : #endif
357 : :
358 : : /// \internal EIGEN_OS_ANDROID set to 1 if the OS is Android
359 : : // note: ANDROID is defined when using ndk_build, __ANDROID__ is defined when using a standalone toolchain.
360 : : #if defined(__ANDROID__) || defined(ANDROID)
361 : : #define EIGEN_OS_ANDROID 1
362 : : #else
363 : : #define EIGEN_OS_ANDROID 0
364 : : #endif
365 : :
366 : : /// \internal EIGEN_OS_GNULINUX set to 1 if the OS is GNU Linux and not Linux-based OS (e.g., not android)
367 : : #if defined(__gnu_linux__) && !(EIGEN_OS_ANDROID)
368 : : #define EIGEN_OS_GNULINUX 1
369 : : #else
370 : : #define EIGEN_OS_GNULINUX 0
371 : : #endif
372 : :
373 : : /// \internal EIGEN_OS_BSD set to 1 if the OS is a BSD variant
374 : : #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
375 : : #define EIGEN_OS_BSD 1
376 : : #else
377 : : #define EIGEN_OS_BSD 0
378 : : #endif
379 : :
380 : : /// \internal EIGEN_OS_MAC set to 1 if the OS is MacOS
381 : : #if defined(__APPLE__)
382 : : #define EIGEN_OS_MAC 1
383 : : #else
384 : : #define EIGEN_OS_MAC 0
385 : : #endif
386 : :
387 : : /// \internal EIGEN_OS_QNX set to 1 if the OS is QNX
388 : : #if defined(__QNX__)
389 : : #define EIGEN_OS_QNX 1
390 : : #else
391 : : #define EIGEN_OS_QNX 0
392 : : #endif
393 : :
394 : : /// \internal EIGEN_OS_WIN set to 1 if the OS is Windows based
395 : : #if defined(_WIN32)
396 : : #define EIGEN_OS_WIN 1
397 : : #else
398 : : #define EIGEN_OS_WIN 0
399 : : #endif
400 : :
401 : : /// \internal EIGEN_OS_WIN64 set to 1 if the OS is Windows 64bits
402 : : #if defined(_WIN64)
403 : : #define EIGEN_OS_WIN64 1
404 : : #else
405 : : #define EIGEN_OS_WIN64 0
406 : : #endif
407 : :
408 : : /// \internal EIGEN_OS_WINCE set to 1 if the OS is Windows CE
409 : : #if defined(_WIN32_WCE)
410 : : #define EIGEN_OS_WINCE 1
411 : : #else
412 : : #define EIGEN_OS_WINCE 0
413 : : #endif
414 : :
415 : : /// \internal EIGEN_OS_CYGWIN set to 1 if the OS is Windows/Cygwin
416 : : #if defined(__CYGWIN__)
417 : : #define EIGEN_OS_CYGWIN 1
418 : : #else
419 : : #define EIGEN_OS_CYGWIN 0
420 : : #endif
421 : :
422 : : /// \internal EIGEN_OS_WIN_STRICT set to 1 if the OS is really Windows and not some variants
423 : : #if EIGEN_OS_WIN && !( EIGEN_OS_WINCE || EIGEN_OS_CYGWIN )
424 : : #define EIGEN_OS_WIN_STRICT 1
425 : : #else
426 : : #define EIGEN_OS_WIN_STRICT 0
427 : : #endif
428 : :
429 : : /// \internal EIGEN_OS_SUN set to __SUNPRO_C if the OS is SUN
430 : : // compiler solaris __SUNPRO_C
431 : : // version studio
432 : : // 5.7 10 0x570
433 : : // 5.8 11 0x580
434 : : // 5.9 12 0x590
435 : : // 5.10 12.1 0x5100
436 : : // 5.11 12.2 0x5110
437 : : // 5.12 12.3 0x5120
438 : : #if (defined(sun) || defined(__sun)) && !(defined(__SVR4) || defined(__svr4__))
439 : : #define EIGEN_OS_SUN __SUNPRO_C
440 : : #else
441 : : #define EIGEN_OS_SUN 0
442 : : #endif
443 : :
444 : : /// \internal EIGEN_OS_SOLARIS set to 1 if the OS is Solaris
445 : : #if (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__))
446 : : #define EIGEN_OS_SOLARIS 1
447 : : #else
448 : : #define EIGEN_OS_SOLARIS 0
449 : : #endif
450 : :
451 : :
452 : : //------------------------------------------------------------------------------------------
453 : : // Detect GPU compilers and architectures
454 : : //------------------------------------------------------------------------------------------
455 : :
456 : : // NVCC is not supported as the target platform for HIPCC
457 : : // Note that this also makes EIGEN_CUDACC and EIGEN_HIPCC mutually exclusive
458 : : #if defined(__NVCC__) && defined(__HIPCC__)
459 : : #error "NVCC as the target platform for HIPCC is currently not supported."
460 : : #endif
461 : :
462 : : #if defined(__CUDACC__) && !defined(EIGEN_NO_CUDA)
463 : : // Means the compiler is either nvcc or clang with CUDA enabled
464 : : #define EIGEN_CUDACC __CUDACC__
465 : : #endif
466 : :
467 : : #if defined(__CUDA_ARCH__) && !defined(EIGEN_NO_CUDA)
468 : : // Means we are generating code for the device
469 : : #define EIGEN_CUDA_ARCH __CUDA_ARCH__
470 : : #endif
471 : :
472 : : #if defined(EIGEN_CUDACC)
473 : : #include <cuda.h>
474 : : #define EIGEN_CUDA_SDK_VER (CUDA_VERSION * 10)
475 : : #else
476 : : #define EIGEN_CUDA_SDK_VER 0
477 : : #endif
478 : :
479 : : #if defined(__HIPCC__) && !defined(EIGEN_NO_HIP)
480 : : // Means the compiler is HIPCC (analogous to EIGEN_CUDACC, but for HIP)
481 : : #define EIGEN_HIPCC __HIPCC__
482 : :
483 : : // We need to include hip_runtime.h here because it pulls in
484 : : // ++ hip_common.h which contains the define for __HIP_DEVICE_COMPILE__
485 : : // ++ host_defines.h which contains the defines for the __host__ and __device__ macros
486 : : #include <hip/hip_runtime.h>
487 : :
488 : : #if defined(__HIP_DEVICE_COMPILE__)
489 : : // analogous to EIGEN_CUDA_ARCH, but for HIP
490 : : #define EIGEN_HIP_DEVICE_COMPILE __HIP_DEVICE_COMPILE__
491 : : #endif
492 : :
493 : : // For HIP (ROCm 3.5 and higher), we need to explicitly set the launch_bounds attribute
494 : : // value to 1024. The compiler assigns a default value of 256 when the attribute is not
495 : : // specified. This results in failures on the HIP platform, for cases when a GPU kernel
496 : : // without an explicit launch_bounds attribute is called with a threads_per_block value
497 : : // greater than 256.
498 : : //
499 : : // This is a regression in functioanlity and is expected to be fixed within the next
500 : : // couple of ROCm releases (compiler will go back to using 1024 value as the default)
501 : : //
502 : : // In the meantime, we will use a "only enabled for HIP" macro to set the launch_bounds
503 : : // attribute.
504 : :
505 : : #define EIGEN_HIP_LAUNCH_BOUNDS_1024 __launch_bounds__(1024)
506 : :
507 : : #endif
508 : :
509 : : #if !defined(EIGEN_HIP_LAUNCH_BOUNDS_1024)
510 : : #define EIGEN_HIP_LAUNCH_BOUNDS_1024
511 : : #endif // !defined(EIGEN_HIP_LAUNCH_BOUNDS_1024)
512 : :
513 : : // Unify CUDA/HIPCC
514 : :
515 : : #if defined(EIGEN_CUDACC) || defined(EIGEN_HIPCC)
516 : : //
517 : : // If either EIGEN_CUDACC or EIGEN_HIPCC is defined, then define EIGEN_GPUCC
518 : : //
519 : : #define EIGEN_GPUCC
520 : : //
521 : : // EIGEN_HIPCC implies the HIP compiler and is used to tweak Eigen code for use in HIP kernels
522 : : // EIGEN_CUDACC implies the CUDA compiler and is used to tweak Eigen code for use in CUDA kernels
523 : : //
524 : : // In most cases the same tweaks are required to the Eigen code to enable in both the HIP and CUDA kernels.
525 : : // For those cases, the corresponding code should be guarded with
526 : : // #if defined(EIGEN_GPUCC)
527 : : // instead of
528 : : // #if defined(EIGEN_CUDACC) || defined(EIGEN_HIPCC)
529 : : //
530 : : // For cases where the tweak is specific to HIP, the code should be guarded with
531 : : // #if defined(EIGEN_HIPCC)
532 : : //
533 : : // For cases where the tweak is specific to CUDA, the code should be guarded with
534 : : // #if defined(EIGEN_CUDACC)
535 : : //
536 : : #endif
537 : :
538 : : #if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIP_DEVICE_COMPILE)
539 : : //
540 : : // If either EIGEN_CUDA_ARCH or EIGEN_HIP_DEVICE_COMPILE is defined, then define EIGEN_GPU_COMPILE_PHASE
541 : : //
542 : : #define EIGEN_GPU_COMPILE_PHASE
543 : : //
544 : : // GPU compilers (HIPCC, NVCC) typically do two passes over the source code,
545 : : // + one to compile the source for the "host" (ie CPU)
546 : : // + another to compile the source for the "device" (ie. GPU)
547 : : //
548 : : // Code that needs to enabled only during the either the "host" or "device" compilation phase
549 : : // needs to be guarded with a macro that indicates the current compilation phase
550 : : //
551 : : // EIGEN_HIP_DEVICE_COMPILE implies the device compilation phase in HIP
552 : : // EIGEN_CUDA_ARCH implies the device compilation phase in CUDA
553 : : //
554 : : // In most cases, the "host" / "device" specific code is the same for both HIP and CUDA
555 : : // For those cases, the code should be guarded with
556 : : // #if defined(EIGEN_GPU_COMPILE_PHASE)
557 : : // instead of
558 : : // #if defined(EIGEN_CUDA_ARCH) || defined(EIGEN_HIP_DEVICE_COMPILE)
559 : : //
560 : : // For cases where the tweak is specific to HIP, the code should be guarded with
561 : : // #if defined(EIGEN_HIP_DEVICE_COMPILE)
562 : : //
563 : : // For cases where the tweak is specific to CUDA, the code should be guarded with
564 : : // #if defined(EIGEN_CUDA_ARCH)
565 : : //
566 : : #endif
567 : :
568 : : #if defined(EIGEN_USE_SYCL) && defined(__SYCL_DEVICE_ONLY__)
569 : : // EIGEN_USE_SYCL is a user-defined macro while __SYCL_DEVICE_ONLY__ is a compiler-defined macro.
570 : : // In most cases we want to check if both macros are defined which can be done using the define below.
571 : : #define SYCL_DEVICE_ONLY
572 : : #endif
573 : :
574 : : //------------------------------------------------------------------------------------------
575 : : // Detect Compiler/Architecture/OS specific features
576 : : //------------------------------------------------------------------------------------------
577 : :
578 : : #if EIGEN_GNUC_AT_MOST(4,3) && !EIGEN_COMP_CLANG
579 : : // see bug 89
580 : : #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0
581 : : #else
582 : : #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 1
583 : : #endif
584 : :
585 : : // Cross compiler wrapper around LLVM's __has_builtin
586 : : #ifdef __has_builtin
587 : : # define EIGEN_HAS_BUILTIN(x) __has_builtin(x)
588 : : #else
589 : : # define EIGEN_HAS_BUILTIN(x) 0
590 : : #endif
591 : :
592 : : // A Clang feature extension to determine compiler features.
593 : : // We use it to determine 'cxx_rvalue_references'
594 : : #ifndef __has_feature
595 : : # define __has_feature(x) 0
596 : : #endif
597 : :
598 : : // Some old compilers do not support template specializations like:
599 : : // template<typename T,int N> void foo(const T x[N]);
600 : : #if !( EIGEN_COMP_CLANG && ( (EIGEN_COMP_CLANG<309) \
601 : : || (defined(__apple_build_version__) && (__apple_build_version__ < 9000000))) \
602 : : || EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC<49)
603 : : #define EIGEN_HAS_STATIC_ARRAY_TEMPLATE 1
604 : : #else
605 : : #define EIGEN_HAS_STATIC_ARRAY_TEMPLATE 0
606 : : #endif
607 : :
608 : : // The macro EIGEN_CPLUSPLUS is a replacement for __cplusplus/_MSVC_LANG that
609 : : // works for both platforms, indicating the C++ standard version number.
610 : : //
611 : : // With MSVC, without defining /Zc:__cplusplus, the __cplusplus macro will
612 : : // report 199711L regardless of the language standard specified via /std.
613 : : // We need to rely on _MSVC_LANG instead, which is only available after
614 : : // VS2015.3.
615 : : #if EIGEN_COMP_MSVC_LANG > 0
616 : : #define EIGEN_CPLUSPLUS EIGEN_COMP_MSVC_LANG
617 : : #elif EIGEN_COMP_MSVC >= 1900
618 : : #define EIGEN_CPLUSPLUS 201103L
619 : : #elif defined(__cplusplus)
620 : : #define EIGEN_CPLUSPLUS __cplusplus
621 : : #else
622 : : #define EIGEN_CPLUSPLUS 0
623 : : #endif
624 : :
625 : : // The macro EIGEN_COMP_CXXVER defines the c++ verson expected by the compiler.
626 : : // For instance, if compiling with gcc and -std=c++17, then EIGEN_COMP_CXXVER
627 : : // is defined to 17.
628 : : #if EIGEN_CPLUSPLUS > 201703L
629 : : #define EIGEN_COMP_CXXVER 20
630 : : #elif EIGEN_CPLUSPLUS > 201402L
631 : : #define EIGEN_COMP_CXXVER 17
632 : : #elif EIGEN_CPLUSPLUS > 201103L
633 : : #define EIGEN_COMP_CXXVER 14
634 : : #elif EIGEN_CPLUSPLUS >= 201103L
635 : : #define EIGEN_COMP_CXXVER 11
636 : : #else
637 : : #define EIGEN_COMP_CXXVER 03
638 : : #endif
639 : :
640 : : #ifndef EIGEN_HAS_CXX14_VARIABLE_TEMPLATES
641 : : #if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 && EIGEN_MAX_CPP_VER>=14
642 : : #define EIGEN_HAS_CXX14_VARIABLE_TEMPLATES 1
643 : : #else
644 : : #define EIGEN_HAS_CXX14_VARIABLE_TEMPLATES 0
645 : : #endif
646 : : #endif
647 : :
648 : :
649 : : // The macros EIGEN_HAS_CXX?? defines a rough estimate of available c++ features
650 : : // but in practice we should not rely on them but rather on the availabilty of
651 : : // individual features as defined later.
652 : : // This is why there is no EIGEN_HAS_CXX17.
653 : : // FIXME: get rid of EIGEN_HAS_CXX14 and maybe even EIGEN_HAS_CXX11.
654 : : #if EIGEN_MAX_CPP_VER>=11 && EIGEN_COMP_CXXVER>=11
655 : : #define EIGEN_HAS_CXX11 1
656 : : #else
657 : : #define EIGEN_HAS_CXX11 0
658 : : #endif
659 : :
660 : : #if EIGEN_MAX_CPP_VER>=14 && EIGEN_COMP_CXXVER>=14
661 : : #define EIGEN_HAS_CXX14 1
662 : : #else
663 : : #define EIGEN_HAS_CXX14 0
664 : : #endif
665 : :
666 : : // Do we support r-value references?
667 : : #ifndef EIGEN_HAS_RVALUE_REFERENCES
668 : : #if EIGEN_MAX_CPP_VER>=11 && \
669 : : (__has_feature(cxx_rvalue_references) || \
670 : : (EIGEN_COMP_CXXVER >= 11) || (EIGEN_COMP_MSVC >= 1600))
671 : : #define EIGEN_HAS_RVALUE_REFERENCES 1
672 : : #else
673 : : #define EIGEN_HAS_RVALUE_REFERENCES 0
674 : : #endif
675 : : #endif
676 : :
677 : : // Does the compiler support C99?
678 : : // Need to include <cmath> to make sure _GLIBCXX_USE_C99 gets defined
679 : : #include <cmath>
680 : : #ifndef EIGEN_HAS_C99_MATH
681 : : #if EIGEN_MAX_CPP_VER>=11 && \
682 : : ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)) \
683 : : || (defined(__GNUC__) && defined(_GLIBCXX_USE_C99)) \
684 : : || (defined(_LIBCPP_VERSION) && !defined(_MSC_VER)) \
685 : : || (EIGEN_COMP_MSVC >= 1900) || defined(SYCL_DEVICE_ONLY))
686 : : #define EIGEN_HAS_C99_MATH 1
687 : : #else
688 : : #define EIGEN_HAS_C99_MATH 0
689 : : #endif
690 : : #endif
691 : :
692 : : // Does the compiler support result_of?
693 : : // result_of was deprecated in c++17 and removed in c++ 20
694 : : #ifndef EIGEN_HAS_STD_RESULT_OF
695 : : #if EIGEN_HAS_CXX11 && EIGEN_COMP_CXXVER < 17
696 : : #define EIGEN_HAS_STD_RESULT_OF 1
697 : : #else
698 : : #define EIGEN_HAS_STD_RESULT_OF 0
699 : : #endif
700 : : #endif
701 : :
702 : : // Does the compiler support std::hash?
703 : : #ifndef EIGEN_HAS_STD_HASH
704 : : // The std::hash struct is defined in C++11 but is not labelled as a __device__
705 : : // function and is not constexpr, so cannot be used on device.
706 : : #if EIGEN_HAS_CXX11 && !defined(EIGEN_GPU_COMPILE_PHASE)
707 : : #define EIGEN_HAS_STD_HASH 1
708 : : #else
709 : : #define EIGEN_HAS_STD_HASH 0
710 : : #endif
711 : : #endif // EIGEN_HAS_STD_HASH
712 : :
713 : : #ifndef EIGEN_HAS_STD_INVOKE_RESULT
714 : : #if EIGEN_MAX_CPP_VER >= 17 && EIGEN_COMP_CXXVER >= 17
715 : : #define EIGEN_HAS_STD_INVOKE_RESULT 1
716 : : #else
717 : : #define EIGEN_HAS_STD_INVOKE_RESULT 0
718 : : #endif
719 : : #endif
720 : :
721 : : #ifndef EIGEN_HAS_ALIGNAS
722 : : #if EIGEN_MAX_CPP_VER>=11 && EIGEN_HAS_CXX11 && \
723 : : ( __has_feature(cxx_alignas) \
724 : : || EIGEN_HAS_CXX14 \
725 : : || (EIGEN_COMP_MSVC >= 1800) \
726 : : || (EIGEN_GNUC_AT_LEAST(4,8)) \
727 : : || (EIGEN_COMP_CLANG>=305) \
728 : : || (EIGEN_COMP_ICC>=1500) \
729 : : || (EIGEN_COMP_PGI>=1500) \
730 : : || (EIGEN_COMP_SUNCC>=0x5130))
731 : : #define EIGEN_HAS_ALIGNAS 1
732 : : #else
733 : : #define EIGEN_HAS_ALIGNAS 0
734 : : #endif
735 : : #endif
736 : :
737 : : // Does the compiler support type_traits?
738 : : // - full support of type traits was added only to GCC 5.1.0.
739 : : // - 20150626 corresponds to the last release of 4.x libstdc++
740 : : #ifndef EIGEN_HAS_TYPE_TRAITS
741 : : #if EIGEN_MAX_CPP_VER>=11 && (EIGEN_HAS_CXX11 || EIGEN_COMP_MSVC >= 1700) \
742 : : && ((!EIGEN_COMP_GNUC_STRICT) || EIGEN_GNUC_AT_LEAST(5, 1)) \
743 : : && ((!defined(__GLIBCXX__)) || __GLIBCXX__ > 20150626)
744 : : #define EIGEN_HAS_TYPE_TRAITS 1
745 : : #define EIGEN_INCLUDE_TYPE_TRAITS
746 : : #else
747 : : #define EIGEN_HAS_TYPE_TRAITS 0
748 : : #endif
749 : : #endif
750 : :
751 : : // Does the compiler support variadic templates?
752 : : #ifndef EIGEN_HAS_VARIADIC_TEMPLATES
753 : : #if EIGEN_MAX_CPP_VER>=11 && (EIGEN_COMP_CXXVER >= 11) \
754 : : && (!defined(__NVCC__) || !EIGEN_ARCH_ARM_OR_ARM64 || (EIGEN_COMP_NVCC >= 80000) )
755 : : // ^^ Disable the use of variadic templates when compiling with versions of nvcc older than 8.0 on ARM devices:
756 : : // this prevents nvcc from crashing when compiling Eigen on Tegra X1
757 : : #define EIGEN_HAS_VARIADIC_TEMPLATES 1
758 : : #elif EIGEN_MAX_CPP_VER>=11 && (EIGEN_COMP_CXXVER >= 11) && defined(SYCL_DEVICE_ONLY)
759 : : #define EIGEN_HAS_VARIADIC_TEMPLATES 1
760 : : #else
761 : : #define EIGEN_HAS_VARIADIC_TEMPLATES 0
762 : : #endif
763 : : #endif
764 : :
765 : : // Does the compiler fully support const expressions? (as in c++14)
766 : : #ifndef EIGEN_HAS_CONSTEXPR
767 : : #if defined(EIGEN_CUDACC)
768 : : // Const expressions are supported provided that c++11 is enabled and we're using either clang or nvcc 7.5 or above
769 : : #if EIGEN_MAX_CPP_VER>=14 && (EIGEN_COMP_CXXVER >= 11 && (EIGEN_COMP_CLANG || EIGEN_COMP_NVCC >= 70500))
770 : : #define EIGEN_HAS_CONSTEXPR 1
771 : : #endif
772 : : #elif EIGEN_MAX_CPP_VER>=14 && (__has_feature(cxx_relaxed_constexpr) || (EIGEN_COMP_CXXVER >= 14) || \
773 : : (EIGEN_GNUC_AT_LEAST(4,8) && (EIGEN_COMP_CXXVER >= 11)) || \
774 : : (EIGEN_COMP_CLANG >= 306 && (EIGEN_COMP_CXXVER >= 11)))
775 : : #define EIGEN_HAS_CONSTEXPR 1
776 : : #endif
777 : :
778 : : #ifndef EIGEN_HAS_CONSTEXPR
779 : : #define EIGEN_HAS_CONSTEXPR 0
780 : : #endif
781 : :
782 : : #endif // EIGEN_HAS_CONSTEXPR
783 : :
784 : : #if EIGEN_HAS_CONSTEXPR
785 : : #define EIGEN_CONSTEXPR constexpr
786 : : #else
787 : : #define EIGEN_CONSTEXPR
788 : : #endif
789 : :
790 : : // Does the compiler support C++11 math?
791 : : // Let's be conservative and enable the default C++11 implementation only if we are sure it exists
792 : : #ifndef EIGEN_HAS_CXX11_MATH
793 : : #if EIGEN_MAX_CPP_VER>=11 && ((EIGEN_COMP_CXXVER > 11) || (EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC) \
794 : : && (EIGEN_ARCH_i386_OR_x86_64) && (EIGEN_OS_GNULINUX || EIGEN_OS_WIN_STRICT || EIGEN_OS_MAC))
795 : : #define EIGEN_HAS_CXX11_MATH 1
796 : : #else
797 : : #define EIGEN_HAS_CXX11_MATH 0
798 : : #endif
799 : : #endif
800 : :
801 : : // Does the compiler support proper C++11 containers?
802 : : #ifndef EIGEN_HAS_CXX11_CONTAINERS
803 : : #if EIGEN_MAX_CPP_VER>=11 && \
804 : : ((EIGEN_COMP_CXXVER > 11) \
805 : : || ((EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC>=1400)))
806 : : #define EIGEN_HAS_CXX11_CONTAINERS 1
807 : : #else
808 : : #define EIGEN_HAS_CXX11_CONTAINERS 0
809 : : #endif
810 : : #endif
811 : :
812 : : // Does the compiler support C++11 noexcept?
813 : : #ifndef EIGEN_HAS_CXX11_NOEXCEPT
814 : : #if EIGEN_MAX_CPP_VER>=11 && \
815 : : (__has_feature(cxx_noexcept) \
816 : : || (EIGEN_COMP_CXXVER > 11) \
817 : : || ((EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_MSVC || EIGEN_COMP_ICC>=1400)))
818 : : #define EIGEN_HAS_CXX11_NOEXCEPT 1
819 : : #else
820 : : #define EIGEN_HAS_CXX11_NOEXCEPT 0
821 : : #endif
822 : : #endif
823 : :
824 : : #ifndef EIGEN_HAS_CXX11_ATOMIC
825 : : #if EIGEN_MAX_CPP_VER>=11 && \
826 : : (__has_feature(cxx_atomic) \
827 : : || (EIGEN_COMP_CXXVER > 11) \
828 : : || ((EIGEN_COMP_CXXVER == 11) && (EIGEN_COMP_MSVC==0 || EIGEN_COMP_MSVC >= 1700)))
829 : : #define EIGEN_HAS_CXX11_ATOMIC 1
830 : : #else
831 : : #define EIGEN_HAS_CXX11_ATOMIC 0
832 : : #endif
833 : : #endif
834 : :
835 : : #ifndef EIGEN_HAS_CXX11_OVERRIDE_FINAL
836 : : #if EIGEN_MAX_CPP_VER>=11 && \
837 : : (EIGEN_COMP_CXXVER >= 11 || EIGEN_COMP_MSVC >= 1700)
838 : : #define EIGEN_HAS_CXX11_OVERRIDE_FINAL 1
839 : : #else
840 : : #define EIGEN_HAS_CXX11_OVERRIDE_FINAL 0
841 : : #endif
842 : : #endif
843 : :
844 : : // NOTE: the required Apple's clang version is very conservative
845 : : // and it could be that XCode 9 works just fine.
846 : : // NOTE: the MSVC version is based on https://en.cppreference.com/w/cpp/compiler_support
847 : : // and not tested.
848 : : #ifndef EIGEN_HAS_CXX17_OVERALIGN
849 : : #if EIGEN_MAX_CPP_VER>=17 && EIGEN_COMP_CXXVER>=17 && ( \
850 : : (EIGEN_COMP_MSVC >= 1912) \
851 : : || (EIGEN_GNUC_AT_LEAST(7,0)) \
852 : : || ((!defined(__apple_build_version__)) && (EIGEN_COMP_CLANG>=500)) \
853 : : || (( defined(__apple_build_version__)) && (__apple_build_version__>=10000000)) \
854 : : )
855 : : #define EIGEN_HAS_CXX17_OVERALIGN 1
856 : : #else
857 : : #define EIGEN_HAS_CXX17_OVERALIGN 0
858 : : #endif
859 : : #endif
860 : :
861 : : #if defined(EIGEN_CUDACC) && EIGEN_HAS_CONSTEXPR
862 : : // While available already with c++11, this is useful mostly starting with c++14 and relaxed constexpr rules
863 : : #if defined(__NVCC__)
864 : : // nvcc considers constexpr functions as __host__ __device__ with the option --expt-relaxed-constexpr
865 : : #ifdef __CUDACC_RELAXED_CONSTEXPR__
866 : : #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
867 : : #endif
868 : : #elif defined(__clang__) && defined(__CUDA__) && __has_feature(cxx_relaxed_constexpr)
869 : : // clang++ always considers constexpr functions as implicitly __host__ __device__
870 : : #define EIGEN_CONSTEXPR_ARE_DEVICE_FUNC
871 : : #endif
872 : : #endif
873 : :
874 : : // Does the compiler support the __int128 and __uint128_t extensions for 128-bit
875 : : // integer arithmetic?
876 : : //
877 : : // Clang and GCC define __SIZEOF_INT128__ when these extensions are supported,
878 : : // but we avoid using them in certain cases:
879 : : //
880 : : // * Building using Clang for Windows, where the Clang runtime library has
881 : : // 128-bit support only on LP64 architectures, but Windows is LLP64.
882 : : #ifndef EIGEN_HAS_BUILTIN_INT128
883 : : #if defined(__SIZEOF_INT128__) && !(EIGEN_OS_WIN && EIGEN_COMP_CLANG)
884 : : #define EIGEN_HAS_BUILTIN_INT128 1
885 : : #else
886 : : #define EIGEN_HAS_BUILTIN_INT128 0
887 : : #endif
888 : : #endif
889 : :
890 : : //------------------------------------------------------------------------------------------
891 : : // Preprocessor programming helpers
892 : : //------------------------------------------------------------------------------------------
893 : :
894 : : // This macro can be used to prevent from macro expansion, e.g.:
895 : : // std::max EIGEN_NOT_A_MACRO(a,b)
896 : : #define EIGEN_NOT_A_MACRO
897 : :
898 : : #define EIGEN_DEBUG_VAR(x) std::cerr << #x << " = " << x << std::endl;
899 : :
900 : : // concatenate two tokens
901 : : #define EIGEN_CAT2(a,b) a ## b
902 : : #define EIGEN_CAT(a,b) EIGEN_CAT2(a,b)
903 : :
904 : : #define EIGEN_COMMA ,
905 : :
906 : : // convert a token to a string
907 : : #define EIGEN_MAKESTRING2(a) #a
908 : : #define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a)
909 : :
910 : : // EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC,
911 : : // but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline
912 : : // but GCC is still doing fine with just inline.
913 : : #ifndef EIGEN_STRONG_INLINE
914 : : #if (EIGEN_COMP_MSVC || EIGEN_COMP_ICC) && !defined(EIGEN_GPUCC)
915 : : #define EIGEN_STRONG_INLINE __forceinline
916 : : #else
917 : : #define EIGEN_STRONG_INLINE inline
918 : : #endif
919 : : #endif
920 : :
921 : : // EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible
922 : : // attribute to maximize inlining. This should only be used when really necessary: in particular,
923 : : // it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times.
924 : : // FIXME with the always_inline attribute,
925 : : // gcc 3.4.x and 4.1 reports the following compilation error:
926 : : // Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval<Derived> Eigen::MatrixBase<Scalar, Derived>::eval() const'
927 : : // : function body not available
928 : : // See also bug 1367
929 : : #if EIGEN_GNUC_AT_LEAST(4,2) && !defined(SYCL_DEVICE_ONLY)
930 : : #define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline
931 : : #else
932 : : #define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE
933 : : #endif
934 : :
935 : : #if EIGEN_COMP_GNUC
936 : : #define EIGEN_DONT_INLINE __attribute__((noinline))
937 : : #elif EIGEN_COMP_MSVC
938 : : #define EIGEN_DONT_INLINE __declspec(noinline)
939 : : #else
940 : : #define EIGEN_DONT_INLINE
941 : : #endif
942 : :
943 : : #if EIGEN_COMP_GNUC
944 : : #define EIGEN_PERMISSIVE_EXPR __extension__
945 : : #else
946 : : #define EIGEN_PERMISSIVE_EXPR
947 : : #endif
948 : :
949 : : // GPU stuff
950 : :
951 : : // Disable some features when compiling with GPU compilers (NVCC/clang-cuda/SYCL/HIPCC)
952 : : #if defined(EIGEN_CUDACC) || defined(SYCL_DEVICE_ONLY) || defined(EIGEN_HIPCC)
953 : : // Do not try asserts on device code
954 : : #ifndef EIGEN_NO_DEBUG
955 : : #define EIGEN_NO_DEBUG
956 : : #endif
957 : :
958 : : #ifdef EIGEN_INTERNAL_DEBUGGING
959 : : #undef EIGEN_INTERNAL_DEBUGGING
960 : : #endif
961 : :
962 : : #ifdef EIGEN_EXCEPTIONS
963 : : #undef EIGEN_EXCEPTIONS
964 : : #endif
965 : : #endif
966 : :
967 : : #if defined(SYCL_DEVICE_ONLY)
968 : : #ifndef EIGEN_DONT_VECTORIZE
969 : : #define EIGEN_DONT_VECTORIZE
970 : : #endif
971 : : #define EIGEN_DEVICE_FUNC __attribute__((flatten)) __attribute__((always_inline))
972 : : // All functions callable from CUDA/HIP code must be qualified with __device__
973 : : #elif defined(EIGEN_GPUCC)
974 : : #define EIGEN_DEVICE_FUNC __host__ __device__
975 : : #else
976 : : #define EIGEN_DEVICE_FUNC
977 : : #endif
978 : :
979 : :
980 : : // this macro allows to get rid of linking errors about multiply defined functions.
981 : : // - static is not very good because it prevents definitions from different object files to be merged.
982 : : // So static causes the resulting linked executable to be bloated with multiple copies of the same function.
983 : : // - inline is not perfect either as it unwantedly hints the compiler toward inlining the function.
984 : : #define EIGEN_DECLARE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC
985 : : #define EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_DEVICE_FUNC inline
986 : :
987 : : #ifdef NDEBUG
988 : : # ifndef EIGEN_NO_DEBUG
989 : : # define EIGEN_NO_DEBUG
990 : : # endif
991 : : #endif
992 : :
993 : : // eigen_plain_assert is where we implement the workaround for the assert() bug in GCC <= 4.3, see bug 89
994 : : #ifdef EIGEN_NO_DEBUG
995 : : #ifdef SYCL_DEVICE_ONLY // used to silence the warning on SYCL device
996 : : #define eigen_plain_assert(x) EIGEN_UNUSED_VARIABLE(x)
997 : : #else
998 : : #define eigen_plain_assert(x)
999 : : #endif
1000 : : #else
1001 : : #if EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO
1002 : : namespace Eigen {
1003 : : namespace internal {
1004 : : inline bool copy_bool(bool b) { return b; }
1005 : : }
1006 : : }
1007 : : #define eigen_plain_assert(x) assert(x)
1008 : : #else
1009 : : // work around bug 89
1010 : : #include <cstdlib> // for abort
1011 : : #include <iostream> // for std::cerr
1012 : :
1013 : : namespace Eigen {
1014 : : namespace internal {
1015 : : // trivial function copying a bool. Must be EIGEN_DONT_INLINE, so we implement it after including Eigen headers.
1016 : : // see bug 89.
1017 : : namespace {
1018 : : EIGEN_DONT_INLINE bool copy_bool(bool b) { return b; }
1019 : : }
1020 : : inline void assert_fail(const char *condition, const char *function, const char *file, int line)
1021 : : {
1022 : : std::cerr << "assertion failed: " << condition << " in function " << function << " at " << file << ":" << line << std::endl;
1023 : : abort();
1024 : : }
1025 : : }
1026 : : }
1027 : : #define eigen_plain_assert(x) \
1028 : : do { \
1029 : : if(!Eigen::internal::copy_bool(x)) \
1030 : : Eigen::internal::assert_fail(EIGEN_MAKESTRING(x), __PRETTY_FUNCTION__, __FILE__, __LINE__); \
1031 : : } while(false)
1032 : : #endif
1033 : : #endif
1034 : :
1035 : : // eigen_assert can be overridden
1036 : : #ifndef eigen_assert
1037 : : #define eigen_assert(x) eigen_plain_assert(x)
1038 : : #endif
1039 : :
1040 : : #ifdef EIGEN_INTERNAL_DEBUGGING
1041 : : #define eigen_internal_assert(x) eigen_assert(x)
1042 : : #else
1043 : : #define eigen_internal_assert(x)
1044 : : #endif
1045 : :
1046 : : #ifdef EIGEN_NO_DEBUG
1047 : : #define EIGEN_ONLY_USED_FOR_DEBUG(x) EIGEN_UNUSED_VARIABLE(x)
1048 : : #else
1049 : : #define EIGEN_ONLY_USED_FOR_DEBUG(x)
1050 : : #endif
1051 : :
1052 : : #ifndef EIGEN_NO_DEPRECATED_WARNING
1053 : : #if EIGEN_COMP_GNUC
1054 : : #define EIGEN_DEPRECATED __attribute__((deprecated))
1055 : : #elif EIGEN_COMP_MSVC
1056 : : #define EIGEN_DEPRECATED __declspec(deprecated)
1057 : : #else
1058 : : #define EIGEN_DEPRECATED
1059 : : #endif
1060 : : #else
1061 : : #define EIGEN_DEPRECATED
1062 : : #endif
1063 : :
1064 : : #if EIGEN_COMP_GNUC
1065 : : #define EIGEN_UNUSED __attribute__((unused))
1066 : : #else
1067 : : #define EIGEN_UNUSED
1068 : : #endif
1069 : :
1070 : : // Suppresses 'unused variable' warnings.
1071 : : namespace Eigen {
1072 : : namespace internal {
1073 : 212149 : template<typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void ignore_unused_variable(const T&) {}
1074 : : }
1075 : : }
1076 : : #define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);
1077 : :
1078 : : #if !defined(EIGEN_ASM_COMMENT)
1079 : : #if EIGEN_COMP_GNUC && (EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64)
1080 : : #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
1081 : : #else
1082 : : #define EIGEN_ASM_COMMENT(X)
1083 : : #endif
1084 : : #endif
1085 : :
1086 : :
1087 : : // Acts as a barrier preventing operations involving `X` from crossing. This
1088 : : // occurs, for example, in the fast rounding trick where a magic constant is
1089 : : // added then subtracted, which is otherwise compiled away with -ffast-math.
1090 : : //
1091 : : // See bug 1674
1092 : : #if !defined(EIGEN_OPTIMIZATION_BARRIER)
1093 : : #if EIGEN_COMP_GNUC
1094 : : // According to https://gcc.gnu.org/onlinedocs/gcc/Constraints.html:
1095 : : // X: Any operand whatsoever.
1096 : : // r: A register operand is allowed provided that it is in a general
1097 : : // register.
1098 : : // g: Any register, memory or immediate integer operand is allowed, except
1099 : : // for registers that are not general registers.
1100 : : // w: (AArch32/AArch64) Floating point register, Advanced SIMD vector
1101 : : // register or SVE vector register.
1102 : : // x: (SSE) Any SSE register.
1103 : : // (AArch64) Like w, but restricted to registers 0 to 15 inclusive.
1104 : : // v: (PowerPC) An Altivec vector register.
1105 : : // wa:(PowerPC) A VSX register.
1106 : : //
1107 : : // "X" (uppercase) should work for all cases, though this seems to fail for
1108 : : // some versions of GCC for arm/aarch64 with
1109 : : // "error: inconsistent operand constraints in an 'asm'"
1110 : : // Clang x86_64/arm/aarch64 seems to require "g" to support both scalars and
1111 : : // vectors, otherwise
1112 : : // "error: non-trivial scalar-to-vector conversion, possible invalid
1113 : : // constraint for vector type"
1114 : : //
1115 : : // GCC for ppc64le generates an internal compiler error with x/X/g.
1116 : : // GCC for AVX generates an internal compiler error with X.
1117 : : //
1118 : : // Tested on icc/gcc/clang for sse, avx, avx2, avx512dq
1119 : : // gcc for arm, aarch64,
1120 : : // gcc for ppc64le,
1121 : : // both vectors and scalars.
1122 : : //
1123 : : // Note that this is restricted to plain types - this will not work
1124 : : // directly for std::complex<T>, Eigen::half, Eigen::bfloat16. For these,
1125 : : // you will need to apply to the underlying POD type.
1126 : : #if EIGEN_ARCH_PPC && EIGEN_COMP_GNUC_STRICT
1127 : : // This seems to be broken on clang. Packet4f is loaded into a single
1128 : : // register rather than a vector, zeroing out some entries. Integer
1129 : : // types also generate a compile error.
1130 : : // General, Altivec, VSX.
1131 : : #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+r,v,wa" (X));
1132 : : #elif EIGEN_ARCH_ARM_OR_ARM64
1133 : : // General, NEON.
1134 : : #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,w" (X));
1135 : : #elif EIGEN_ARCH_i386_OR_x86_64
1136 : : // General, SSE.
1137 : : #define EIGEN_OPTIMIZATION_BARRIER(X) __asm__ ("" : "+g,x" (X));
1138 : : #else
1139 : : // Not implemented for other architectures.
1140 : : #define EIGEN_OPTIMIZATION_BARRIER(X)
1141 : : #endif
1142 : : #else
1143 : : // Not implemented for other compilers.
1144 : : #define EIGEN_OPTIMIZATION_BARRIER(X)
1145 : : #endif
1146 : : #endif
1147 : :
1148 : : #if EIGEN_COMP_MSVC
1149 : : // NOTE MSVC often gives C4127 warnings with compiletime if statements. See bug 1362.
1150 : : // This workaround is ugly, but it does the job.
1151 : : # define EIGEN_CONST_CONDITIONAL(cond) (void)0, cond
1152 : : #else
1153 : : # define EIGEN_CONST_CONDITIONAL(cond) cond
1154 : : #endif
1155 : :
1156 : : #ifdef EIGEN_DONT_USE_RESTRICT_KEYWORD
1157 : : #define EIGEN_RESTRICT
1158 : : #endif
1159 : : #ifndef EIGEN_RESTRICT
1160 : : #define EIGEN_RESTRICT __restrict
1161 : : #endif
1162 : :
1163 : :
1164 : : #ifndef EIGEN_DEFAULT_IO_FORMAT
1165 : : #ifdef EIGEN_MAKING_DOCS
1166 : : // format used in Eigen's documentation
1167 : : // needed to define it here as escaping characters in CMake add_definition's argument seems very problematic.
1168 : : #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat(3, 0, " ", "\n", "", "")
1169 : : #else
1170 : : #define EIGEN_DEFAULT_IO_FORMAT Eigen::IOFormat()
1171 : : #endif
1172 : : #endif
1173 : :
1174 : : // just an empty macro !
1175 : : #define EIGEN_EMPTY
1176 : :
1177 : :
1178 : : // When compiling CUDA/HIP device code with NVCC or HIPCC
1179 : : // pull in math functions from the global namespace.
1180 : : // In host mode, and when device code is compiled with clang,
1181 : : // use the std versions.
1182 : : #if (defined(EIGEN_CUDA_ARCH) && defined(__NVCC__)) || defined(EIGEN_HIP_DEVICE_COMPILE)
1183 : : #define EIGEN_USING_STD(FUNC) using ::FUNC;
1184 : : #else
1185 : : #define EIGEN_USING_STD(FUNC) using std::FUNC;
1186 : : #endif
1187 : :
1188 : : #if EIGEN_COMP_MSVC_STRICT && (EIGEN_COMP_MSVC < 1900 || (EIGEN_COMP_MSVC == 1900 && EIGEN_COMP_NVCC))
1189 : : // For older MSVC versions, as well as 1900 && CUDA 8, using the base operator is necessary,
1190 : : // otherwise we get duplicate definition errors
1191 : : // For later MSVC versions, we require explicit operator= definition, otherwise we get
1192 : : // use of implicitly deleted operator errors.
1193 : : // (cf Bugs 920, 1000, 1324, 2291)
1194 : : #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1195 : : using Base::operator =;
1196 : : #elif EIGEN_COMP_CLANG // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
1197 : : #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1198 : : using Base::operator =; \
1199 : : EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) { Base::operator=(other); return *this; } \
1200 : : template <typename OtherDerived> \
1201 : : EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const DenseBase<OtherDerived>& other) { Base::operator=(other.derived()); return *this; }
1202 : : #else
1203 : : #define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1204 : : using Base::operator =; \
1205 : : EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator=(const Derived& other) \
1206 : : { \
1207 : : Base::operator=(other); \
1208 : : return *this; \
1209 : : }
1210 : : #endif
1211 : :
1212 : :
1213 : : /**
1214 : : * \internal
1215 : : * \brief Macro to explicitly define the default copy constructor.
1216 : : * This is necessary, because the implicit definition is deprecated if the copy-assignment is overridden.
1217 : : */
1218 : : #if EIGEN_HAS_CXX11
1219 : : #define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS) CLASS(const CLASS&) = default;
1220 : : #else
1221 : : #define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
1222 : : #endif
1223 : :
1224 : :
1225 : :
1226 : : /** \internal
1227 : : * \brief Macro to manually inherit assignment operators.
1228 : : * This is necessary, because the implicitly defined assignment operator gets deleted when a custom operator= is defined.
1229 : : * With C++11 or later this also default-implements the copy-constructor
1230 : : */
1231 : : #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
1232 : : EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
1233 : : EIGEN_DEFAULT_COPY_CONSTRUCTOR(Derived)
1234 : :
1235 : : /** \internal
1236 : : * \brief Macro to manually define default constructors and destructors.
1237 : : * This is necessary when the copy constructor is re-defined.
1238 : : * For empty helper classes this should usually be protected, to avoid accidentally creating empty objects.
1239 : : *
1240 : : * Hiding the default destructor lead to problems in C++03 mode together with boost::multiprecision
1241 : : */
1242 : : #if EIGEN_HAS_CXX11
1243 : : #define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \
1244 : : Derived() = default; \
1245 : : ~Derived() = default;
1246 : : #else
1247 : : #define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived) \
1248 : : Derived() {}; \
1249 : : /* ~Derived() {}; */
1250 : : #endif
1251 : :
1252 : :
1253 : :
1254 : :
1255 : :
1256 : : /**
1257 : : * Just a side note. Commenting within defines works only by documenting
1258 : : * behind the object (via '!<'). Comments cannot be multi-line and thus
1259 : : * we have these extra long lines. What is confusing doxygen over here is
1260 : : * that we use '\' and basically have a bunch of typedefs with their
1261 : : * documentation in a single line.
1262 : : **/
1263 : :
1264 : : #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
1265 : : typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \
1266 : : typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \
1267 : : typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \
1268 : : typedef typename Eigen::internal::ref_selector<Derived>::type Nested; \
1269 : : typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \
1270 : : typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \
1271 : : enum CompileTimeTraits \
1272 : : { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \
1273 : : ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \
1274 : : Flags = Eigen::internal::traits<Derived>::Flags, \
1275 : : SizeAtCompileTime = Base::SizeAtCompileTime, \
1276 : : MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
1277 : : IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
1278 : : using Base::derived; \
1279 : : using Base::const_cast_derived;
1280 : :
1281 : :
1282 : : // FIXME Maybe the EIGEN_DENSE_PUBLIC_INTERFACE could be removed as importing PacketScalar is rarely needed
1283 : : #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \
1284 : : EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
1285 : : typedef typename Base::PacketScalar PacketScalar;
1286 : :
1287 : :
1288 : : #define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
1289 : : #define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b)
1290 : :
1291 : : // EIGEN_SIZE_MIN_PREFER_DYNAMIC gives the min between compile-time sizes. 0 has absolute priority, followed by 1,
1292 : : // followed by Dynamic, followed by other finite values. The reason for giving Dynamic the priority over
1293 : : // finite values is that min(3, Dynamic) should be Dynamic, since that could be anything between 0 and 3.
1294 : : #define EIGEN_SIZE_MIN_PREFER_DYNAMIC(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
1295 : : : ((int)a == 1 || (int)b == 1) ? 1 \
1296 : : : ((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
1297 : : : ((int)a <= (int)b) ? (int)a : (int)b)
1298 : :
1299 : : // EIGEN_SIZE_MIN_PREFER_FIXED is a variant of EIGEN_SIZE_MIN_PREFER_DYNAMIC comparing MaxSizes. The difference is that finite values
1300 : : // now have priority over Dynamic, so that min(3, Dynamic) gives 3. Indeed, whatever the actual value is
1301 : : // (between 0 and 3), it is not more than 3.
1302 : : #define EIGEN_SIZE_MIN_PREFER_FIXED(a,b) (((int)a == 0 || (int)b == 0) ? 0 \
1303 : : : ((int)a == 1 || (int)b == 1) ? 1 \
1304 : : : ((int)a == Dynamic && (int)b == Dynamic) ? Dynamic \
1305 : : : ((int)a == Dynamic) ? (int)b \
1306 : : : ((int)b == Dynamic) ? (int)a \
1307 : : : ((int)a <= (int)b) ? (int)a : (int)b)
1308 : :
1309 : : // see EIGEN_SIZE_MIN_PREFER_DYNAMIC. No need for a separate variant for MaxSizes here.
1310 : : #define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
1311 : : : ((int)a >= (int)b) ? (int)a : (int)b)
1312 : :
1313 : : #define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
1314 : :
1315 : : #define EIGEN_IMPLIES(a,b) (!(a) || (b))
1316 : :
1317 : : #if EIGEN_HAS_BUILTIN(__builtin_expect) || EIGEN_COMP_GNUC
1318 : : #define EIGEN_PREDICT_FALSE(x) (__builtin_expect(x, false))
1319 : : #define EIGEN_PREDICT_TRUE(x) (__builtin_expect(false || (x), true))
1320 : : #else
1321 : : #define EIGEN_PREDICT_FALSE(x) (x)
1322 : : #define EIGEN_PREDICT_TRUE(x) (x)
1323 : : #endif
1324 : :
1325 : : // the expression type of a standard coefficient wise binary operation
1326 : : #define EIGEN_CWISE_BINARY_RETURN_TYPE(LHS,RHS,OPNAME) \
1327 : : CwiseBinaryOp< \
1328 : : EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)< \
1329 : : typename internal::traits<LHS>::Scalar, \
1330 : : typename internal::traits<RHS>::Scalar \
1331 : : >, \
1332 : : const LHS, \
1333 : : const RHS \
1334 : : >
1335 : :
1336 : : #define EIGEN_MAKE_CWISE_BINARY_OP(METHOD,OPNAME) \
1337 : : template<typename OtherDerived> \
1338 : : EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME) \
1339 : : (METHOD)(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const \
1340 : : { \
1341 : : return EIGEN_CWISE_BINARY_RETURN_TYPE(Derived,OtherDerived,OPNAME)(derived(), other.derived()); \
1342 : : }
1343 : :
1344 : : #define EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,TYPEA,TYPEB) \
1345 : : (Eigen::internal::has_ReturnType<Eigen::ScalarBinaryOpTraits<TYPEA,TYPEB,EIGEN_CAT(EIGEN_CAT(Eigen::internal::scalar_,OPNAME),_op)<TYPEA,TYPEB> > >::value)
1346 : :
1347 : : #define EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(EXPR,SCALAR,OPNAME) \
1348 : : CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<typename internal::traits<EXPR>::Scalar,SCALAR>, const EXPR, \
1349 : : const typename internal::plain_constant_type<EXPR,SCALAR>::type>
1350 : :
1351 : : #define EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(SCALAR,EXPR,OPNAME) \
1352 : : CwiseBinaryOp<EIGEN_CAT(EIGEN_CAT(internal::scalar_,OPNAME),_op)<SCALAR,typename internal::traits<EXPR>::Scalar>, \
1353 : : const typename internal::plain_constant_type<EXPR,SCALAR>::type, const EXPR>
1354 : :
1355 : : // Workaround for MSVC 2010 (see ML thread "patch with compile for for MSVC 2010")
1356 : : #if EIGEN_COMP_MSVC_STRICT && (EIGEN_COMP_MSVC_STRICT<=1600)
1357 : : #define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) typename internal::enable_if<true,X>::type
1358 : : #else
1359 : : #define EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(X) X
1360 : : #endif
1361 : :
1362 : : #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) \
1363 : : template <typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE \
1364 : : EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(const EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type,OPNAME))\
1365 : : (METHOD)(const T& scalar) const { \
1366 : : typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,Scalar,T)>::type PromotedT; \
1367 : : return EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Derived,PromotedT,OPNAME)(derived(), \
1368 : : typename internal::plain_constant_type<Derived,PromotedT>::type(derived().rows(), derived().cols(), internal::scalar_constant_op<PromotedT>(scalar))); \
1369 : : }
1370 : :
1371 : : #define EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
1372 : : template <typename T> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE friend \
1373 : : EIGEN_MSVC10_WORKAROUND_BINARYOP_RETURN_TYPE(const EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(typename internal::promote_scalar_arg<Scalar EIGEN_COMMA T EIGEN_COMMA EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type,Derived,OPNAME)) \
1374 : : (METHOD)(const T& scalar, const StorageBaseType& matrix) { \
1375 : : typedef typename internal::promote_scalar_arg<Scalar,T,EIGEN_SCALAR_BINARY_SUPPORTED(OPNAME,T,Scalar)>::type PromotedT; \
1376 : : return EIGEN_SCALAR_BINARYOP_EXPR_RETURN_TYPE(PromotedT,Derived,OPNAME)( \
1377 : : typename internal::plain_constant_type<Derived,PromotedT>::type(matrix.derived().rows(), matrix.derived().cols(), internal::scalar_constant_op<PromotedT>(scalar)), matrix.derived()); \
1378 : : }
1379 : :
1380 : : #define EIGEN_MAKE_SCALAR_BINARY_OP(METHOD,OPNAME) \
1381 : : EIGEN_MAKE_SCALAR_BINARY_OP_ONTHELEFT(METHOD,OPNAME) \
1382 : : EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME)
1383 : :
1384 : :
1385 : : #if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_CUDA_ARCH) && !defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_USE_SYCL) && !defined(EIGEN_HIP_DEVICE_COMPILE)
1386 : : #define EIGEN_EXCEPTIONS
1387 : : #endif
1388 : :
1389 : :
1390 : : #ifdef EIGEN_EXCEPTIONS
1391 : : # define EIGEN_THROW_X(X) throw X
1392 : : # define EIGEN_THROW throw
1393 : : # define EIGEN_TRY try
1394 : : # define EIGEN_CATCH(X) catch (X)
1395 : : #else
1396 : : # if defined(EIGEN_CUDA_ARCH)
1397 : : # define EIGEN_THROW_X(X) asm("trap;")
1398 : : # define EIGEN_THROW asm("trap;")
1399 : : # elif defined(EIGEN_HIP_DEVICE_COMPILE)
1400 : : # define EIGEN_THROW_X(X) asm("s_trap 0")
1401 : : # define EIGEN_THROW asm("s_trap 0")
1402 : : # else
1403 : : # define EIGEN_THROW_X(X) std::abort()
1404 : : # define EIGEN_THROW std::abort()
1405 : : # endif
1406 : : # define EIGEN_TRY if (true)
1407 : : # define EIGEN_CATCH(X) else
1408 : : #endif
1409 : :
1410 : :
1411 : : #if EIGEN_HAS_CXX11_NOEXCEPT
1412 : : # define EIGEN_INCLUDE_TYPE_TRAITS
1413 : : # define EIGEN_NOEXCEPT noexcept
1414 : : # define EIGEN_NOEXCEPT_IF(x) noexcept(x)
1415 : : # define EIGEN_NO_THROW noexcept(true)
1416 : : # define EIGEN_EXCEPTION_SPEC(X) noexcept(false)
1417 : : #else
1418 : : # define EIGEN_NOEXCEPT
1419 : : # define EIGEN_NOEXCEPT_IF(x)
1420 : : # define EIGEN_NO_THROW throw()
1421 : : # if EIGEN_COMP_MSVC || EIGEN_COMP_CXXVER>=17
1422 : : // MSVC does not support exception specifications (warning C4290),
1423 : : // and they are deprecated in c++11 anyway. This is even an error in c++17.
1424 : : # define EIGEN_EXCEPTION_SPEC(X) throw()
1425 : : # else
1426 : : # define EIGEN_EXCEPTION_SPEC(X) throw(X)
1427 : : # endif
1428 : : #endif
1429 : :
1430 : : #if EIGEN_HAS_VARIADIC_TEMPLATES
1431 : : // The all function is used to enable a variadic version of eigen_assert which can take a parameter pack as its input.
1432 : : namespace Eigen {
1433 : : namespace internal {
1434 : :
1435 : : inline bool all(){ return true; }
1436 : :
1437 : : template<typename T, typename ...Ts>
1438 : : bool all(T t, Ts ... ts){ return t && all(ts...); }
1439 : :
1440 : : }
1441 : : }
1442 : : #endif
1443 : :
1444 : : #if EIGEN_HAS_CXX11_OVERRIDE_FINAL
1445 : : // provide override and final specifiers if they are available:
1446 : : # define EIGEN_OVERRIDE override
1447 : : # define EIGEN_FINAL final
1448 : : #else
1449 : : # define EIGEN_OVERRIDE
1450 : : # define EIGEN_FINAL
1451 : : #endif
1452 : :
1453 : : // Wrapping #pragma unroll in a macro since it is required for SYCL
1454 : : #if defined(SYCL_DEVICE_ONLY)
1455 : : #if defined(_MSC_VER)
1456 : : #define EIGEN_UNROLL_LOOP __pragma(unroll)
1457 : : #else
1458 : : #define EIGEN_UNROLL_LOOP _Pragma("unroll")
1459 : : #endif
1460 : : #else
1461 : : #define EIGEN_UNROLL_LOOP
1462 : : #endif
1463 : :
1464 : : #endif // EIGEN_MACROS_H
|