ConfigureVectorization.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2018 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2020, Arm Limited and Contributors
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_CONFIGURE_VECTORIZATION_H
12 #define EIGEN_CONFIGURE_VECTORIZATION_H
13 
14 //------------------------------------------------------------------------------------------
15 // Static and dynamic alignment control
16 //
17 // The main purpose of this section is to define EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES
18 // as the maximal boundary in bytes on which dynamically and statically allocated data may be alignment respectively.
19 // The values of EIGEN_MAX_ALIGN_BYTES and EIGEN_MAX_STATIC_ALIGN_BYTES can be specified by the user. If not,
20 // a default value is automatically computed based on architecture, compiler, and OS.
21 //
22 // This section also defines macros EIGEN_ALIGN_TO_BOUNDARY(N) and the shortcuts EIGEN_ALIGN{8,16,32,_MAX}
23 // to be used to declare statically aligned buffers.
24 //------------------------------------------------------------------------------------------
25 
26 /* EIGEN_ALIGN_TO_BOUNDARY(n) forces data to be n-byte aligned. This is used to satisfy SIMD requirements.
27  * However, we do that EVEN if vectorization (EIGEN_VECTORIZE) is disabled,
28  * so that vectorization doesn't affect binary compatibility.
29  *
30  * If we made alignment depend on whether or not EIGEN_VECTORIZE is defined, it would be impossible to link
31  * vectorized and non-vectorized code.
32  */
33 #if (defined EIGEN_CUDACC)
34 #define EIGEN_ALIGN_TO_BOUNDARY(n) __align__(n)
35 #define EIGEN_ALIGNOF(x) __alignof(x)
36 #else
37 #define EIGEN_ALIGN_TO_BOUNDARY(n) alignas(n)
38 #define EIGEN_ALIGNOF(x) alignof(x)
39 #endif
40 
41 // Align to the boundary that avoids false sharing.
42 // https://en.cppreference.com/w/cpp/thread/hardware_destructive_interference_size
43 #ifdef __cpp_lib_hardware_interference_size
44 #include <new>
45 #define EIGEN_ALIGN_TO_AVOID_FALSE_SHARING EIGEN_ALIGN_TO_BOUNDARY(std::hardware_destructive_interference_size)
46 #else
47 // Overalign for the cache line size of 128 bytes (Apple M1)
48 #define EIGEN_ALIGN_TO_AVOID_FALSE_SHARING EIGEN_ALIGN_TO_BOUNDARY(128)
49 #endif
50 
51 // If the user explicitly disable vectorization, then we also disable alignment
52 #if defined(EIGEN_DONT_VECTORIZE)
53 #if defined(EIGEN_GPUCC)
54 // GPU code is always vectorized and requires memory alignment for
55 // statically allocated buffers.
56 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 16
57 #else
58 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 0
59 #endif
60 #elif defined(__AVX512F__)
61 // 64 bytes static alignment is preferred only if really required
62 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 64
63 #elif defined(__AVX__)
64 // 32 bytes static alignment is preferred only if really required
65 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 32
66 #elif defined __HVX__ && (__HVX_LENGTH__ == 128)
67 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 128
68 #else
69 #define EIGEN_IDEAL_MAX_ALIGN_BYTES 16
70 #endif
71 
72 // EIGEN_MIN_ALIGN_BYTES defines the minimal value for which the notion of explicit alignment makes sense
73 #define EIGEN_MIN_ALIGN_BYTES 16
74 
75 // Defined the boundary (in bytes) on which the data needs to be aligned. Note
76 // that unless EIGEN_ALIGN is defined and not equal to 0, the data may not be
77 // aligned at all regardless of the value of this #define.
78 
79 #if (defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)) && defined(EIGEN_MAX_STATIC_ALIGN_BYTES) && \
80  EIGEN_MAX_STATIC_ALIGN_BYTES > 0
81 #error EIGEN_MAX_STATIC_ALIGN_BYTES and EIGEN_DONT_ALIGN[_STATICALLY] are both defined with EIGEN_MAX_STATIC_ALIGN_BYTES!=0. Use EIGEN_MAX_STATIC_ALIGN_BYTES=0 as a synonym of EIGEN_DONT_ALIGN_STATICALLY.
82 #endif
83 
84 // EIGEN_DONT_ALIGN_STATICALLY and EIGEN_DONT_ALIGN are deprecated
85 // They imply EIGEN_MAX_STATIC_ALIGN_BYTES=0
86 #if defined(EIGEN_DONT_ALIGN_STATICALLY) || defined(EIGEN_DONT_ALIGN)
87 #ifdef EIGEN_MAX_STATIC_ALIGN_BYTES
88 #undef EIGEN_MAX_STATIC_ALIGN_BYTES
89 #endif
90 #define EIGEN_MAX_STATIC_ALIGN_BYTES 0
91 #endif
92 
93 #ifndef EIGEN_MAX_STATIC_ALIGN_BYTES
94 
95 // Try to automatically guess what is the best default value for EIGEN_MAX_STATIC_ALIGN_BYTES
96 
97 // 16 byte alignment is only useful for vectorization. Since it affects the ABI, we need to enable
98 // 16 byte alignment on all platforms where vectorization might be enabled. In theory we could always
99 // enable alignment, but it can be a cause of problems on some platforms, so we just disable it in
100 // certain common platform (compiler+architecture combinations) to avoid these problems.
101 // Only static alignment is really problematic (relies on nonstandard compiler extensions),
102 // try to keep heap alignment even when we have to disable static alignment.
103 #if EIGEN_COMP_GNUC && !(EIGEN_ARCH_i386_OR_x86_64 || EIGEN_ARCH_ARM_OR_ARM64 || EIGEN_ARCH_PPC || EIGEN_ARCH_IA64 || \
104  EIGEN_ARCH_MIPS || EIGEN_ARCH_LOONGARCH64)
105 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 1
106 #else
107 #define EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT 0
108 #endif
109 
110 // static alignment is completely disabled with GCC 3, Sun Studio, and QCC/QNX
111 #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT && !EIGEN_COMP_SUNCC && !EIGEN_OS_QNX
112 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 1
113 #else
114 #define EIGEN_ARCH_WANTS_STACK_ALIGNMENT 0
115 #endif
116 
117 #if EIGEN_ARCH_WANTS_STACK_ALIGNMENT
118 #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
119 #else
120 #define EIGEN_MAX_STATIC_ALIGN_BYTES 0
121 #endif
122 
123 #endif
124 
125 // If EIGEN_MAX_ALIGN_BYTES is defined, then it is considered as an upper bound for EIGEN_MAX_STATIC_ALIGN_BYTES
126 #if defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES < EIGEN_MAX_STATIC_ALIGN_BYTES
127 #undef EIGEN_MAX_STATIC_ALIGN_BYTES
128 #define EIGEN_MAX_STATIC_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES
129 #endif
130 
131 #if EIGEN_MAX_STATIC_ALIGN_BYTES == 0 && !defined(EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT)
132 #define EIGEN_DISABLE_UNALIGNED_ARRAY_ASSERT
133 #endif
134 
135 // At this stage, EIGEN_MAX_STATIC_ALIGN_BYTES>0 is the true test whether we want to align arrays on the stack or not.
136 // It takes into account both the user choice to explicitly enable/disable alignment (by setting
137 // EIGEN_MAX_STATIC_ALIGN_BYTES) and the architecture config (EIGEN_ARCH_WANTS_STACK_ALIGNMENT). Henceforth, only
138 // EIGEN_MAX_STATIC_ALIGN_BYTES should be used.
139 
140 // Shortcuts to EIGEN_ALIGN_TO_BOUNDARY
141 #define EIGEN_ALIGN8 EIGEN_ALIGN_TO_BOUNDARY(8)
142 #define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)
143 #define EIGEN_ALIGN32 EIGEN_ALIGN_TO_BOUNDARY(32)
144 #define EIGEN_ALIGN64 EIGEN_ALIGN_TO_BOUNDARY(64)
145 #if EIGEN_MAX_STATIC_ALIGN_BYTES > 0
146 #define EIGEN_ALIGN_MAX EIGEN_ALIGN_TO_BOUNDARY(EIGEN_MAX_STATIC_ALIGN_BYTES)
147 #else
148 #define EIGEN_ALIGN_MAX
149 #endif
150 
151 // Dynamic alignment control
152 
153 #if defined(EIGEN_DONT_ALIGN) && defined(EIGEN_MAX_ALIGN_BYTES) && EIGEN_MAX_ALIGN_BYTES > 0
154 #error EIGEN_MAX_ALIGN_BYTES and EIGEN_DONT_ALIGN are both defined with EIGEN_MAX_ALIGN_BYTES!=0. Use EIGEN_MAX_ALIGN_BYTES=0 as a synonym of EIGEN_DONT_ALIGN.
155 #endif
156 
157 #ifdef EIGEN_DONT_ALIGN
158 #ifdef EIGEN_MAX_ALIGN_BYTES
159 #undef EIGEN_MAX_ALIGN_BYTES
160 #endif
161 #define EIGEN_MAX_ALIGN_BYTES 0
162 #elif !defined(EIGEN_MAX_ALIGN_BYTES)
163 #define EIGEN_MAX_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
164 #endif
165 
166 #if EIGEN_IDEAL_MAX_ALIGN_BYTES > EIGEN_MAX_ALIGN_BYTES
167 #define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_IDEAL_MAX_ALIGN_BYTES
168 #else
169 #define EIGEN_DEFAULT_ALIGN_BYTES EIGEN_MAX_ALIGN_BYTES
170 #endif
171 
172 #ifndef EIGEN_UNALIGNED_VECTORIZE
173 #define EIGEN_UNALIGNED_VECTORIZE 1
174 #endif
175 
176 //----------------------------------------------------------------------
177 
178 // if alignment is disabled, then disable vectorization. Note: EIGEN_MAX_ALIGN_BYTES is the proper check, it takes into
179 // account both the user's will (EIGEN_MAX_ALIGN_BYTES,EIGEN_DONT_ALIGN) and our own platform checks
180 #if EIGEN_MAX_ALIGN_BYTES == 0
181 #ifndef EIGEN_DONT_VECTORIZE
182 #define EIGEN_DONT_VECTORIZE
183 #endif
184 #endif
185 
186 // The following (except #include <malloc.h> and _M_IX86_FP ??) can likely be
187 // removed as gcc 4.1 and msvc 2008 are not supported anyways.
188 #if EIGEN_COMP_MSVC
189 #include <malloc.h> // for _aligned_malloc -- need it regardless of whether vectorization is enabled
190 // a user reported that in 64-bit mode, MSVC doesn't care to define _M_IX86_FP.
191 #if (defined(_M_IX86_FP) && (_M_IX86_FP >= 2)) || EIGEN_ARCH_x86_64
192 #define EIGEN_SSE2_ON_MSVC_2008_OR_LATER
193 #endif
194 #else
195 #if defined(__SSE2__)
196 #define EIGEN_SSE2_ON_NON_MSVC
197 #endif
198 #endif
199 
200 #if !(defined(EIGEN_DONT_VECTORIZE) || defined(EIGEN_GPUCC))
201 
202 #if defined(EIGEN_SSE2_ON_NON_MSVC) || defined(EIGEN_SSE2_ON_MSVC_2008_OR_LATER)
203 
204 // Defines symbols for compile-time detection of which instructions are
205 // used.
206 // EIGEN_VECTORIZE_YY is defined if and only if the instruction set YY is used
207 #define EIGEN_VECTORIZE
208 #define EIGEN_VECTORIZE_SSE
209 #define EIGEN_VECTORIZE_SSE2
210 
211 // Detect sse3/ssse3/sse4:
212 // gcc and icc defines __SSE3__, ...
213 // there is no way to know about this on msvc. You can define EIGEN_VECTORIZE_SSE* if you
214 // want to force the use of those instructions with msvc.
215 #ifdef __SSE3__
216 #define EIGEN_VECTORIZE_SSE3
217 #endif
218 #ifdef __SSSE3__
219 #define EIGEN_VECTORIZE_SSSE3
220 #endif
221 #ifdef __SSE4_1__
222 #define EIGEN_VECTORIZE_SSE4_1
223 #endif
224 #ifdef __SSE4_2__
225 #define EIGEN_VECTORIZE_SSE4_2
226 #endif
227 #ifdef __AVX__
228 #ifndef EIGEN_USE_SYCL
229 #define EIGEN_VECTORIZE_AVX
230 #endif
231 #define EIGEN_VECTORIZE_SSE3
232 #define EIGEN_VECTORIZE_SSSE3
233 #define EIGEN_VECTORIZE_SSE4_1
234 #define EIGEN_VECTORIZE_SSE4_2
235 #endif
236 #ifdef __AVX2__
237 #ifndef EIGEN_USE_SYCL
238 #define EIGEN_VECTORIZE_AVX2
239 #define EIGEN_VECTORIZE_AVX
240 #endif
241 #define EIGEN_VECTORIZE_SSE3
242 #define EIGEN_VECTORIZE_SSSE3
243 #define EIGEN_VECTORIZE_SSE4_1
244 #define EIGEN_VECTORIZE_SSE4_2
245 #endif
246 #if defined(__FMA__) || (EIGEN_COMP_MSVC && defined(__AVX2__))
247 // MSVC does not expose a switch dedicated for FMA
248 // For MSVC, AVX2 => FMA
249 #define EIGEN_VECTORIZE_FMA
250 #endif
251 #if defined(__AVX512F__)
252 #ifndef EIGEN_VECTORIZE_FMA
253 #if EIGEN_COMP_GNUC
254 #error Please add -mfma to your compiler flags: compiling with -mavx512f alone without SSE/AVX FMA is not supported (bug 1638).
255 #else
256 #error Please enable FMA in your compiler flags (e.g. -mfma): compiling with AVX512 alone without SSE/AVX FMA is not supported (bug 1638).
257 #endif
258 #endif
259 #ifndef EIGEN_USE_SYCL
260 #define EIGEN_VECTORIZE_AVX512
261 #define EIGEN_VECTORIZE_AVX2
262 #define EIGEN_VECTORIZE_AVX
263 #endif
264 #define EIGEN_VECTORIZE_FMA
265 #define EIGEN_VECTORIZE_SSE3
266 #define EIGEN_VECTORIZE_SSSE3
267 #define EIGEN_VECTORIZE_SSE4_1
268 #define EIGEN_VECTORIZE_SSE4_2
269 #ifndef EIGEN_USE_SYCL
270 #ifdef __AVX512DQ__
271 #define EIGEN_VECTORIZE_AVX512DQ
272 #endif
273 #ifdef __AVX512ER__
274 #define EIGEN_VECTORIZE_AVX512ER
275 #endif
276 #ifdef __AVX512BF16__
277 #define EIGEN_VECTORIZE_AVX512BF16
278 #endif
279 #ifdef __AVX512VL__
280 #define EIGEN_VECTORIZE_AVX512VL
281 #endif
282 #ifdef __AVX512FP16__
283 #ifdef __AVX512VL__
284 #define EIGEN_VECTORIZE_AVX512FP16
285 #else
286 #if EIGEN_COMP_GNUC
287 #error Please add -mavx512vl to your compiler flags: compiling with -mavx512fp16 alone without AVX512-VL is not supported.
288 #else
289 #error Please enable AVX512-VL in your compiler flags (e.g. -mavx512vl): compiling with AVX512-FP16 alone without AVX512-VL is not supported.
290 #endif
291 #endif
292 #endif
293 #endif
294 #endif
295 
296 // Disable AVX support on broken xcode versions
297 #if (EIGEN_COMP_CLANGAPPLE == 11000033) && (__MAC_OS_X_VERSION_MIN_REQUIRED == 101500)
298 // A nasty bug in the clang compiler shipped with xcode in a common compilation situation
299 // when XCode 11.0 and Mac deployment target macOS 10.15 is https://trac.macports.org/ticket/58776#no1
300 #ifdef EIGEN_VECTORIZE_AVX
301 #undef EIGEN_VECTORIZE_AVX
302 #warning \
303  "Disabling AVX support: clang compiler shipped with XCode 11.[012] generates broken assembly with -macosx-version-min=10.15 and AVX enabled. "
304 #ifdef EIGEN_VECTORIZE_AVX2
305 #undef EIGEN_VECTORIZE_AVX2
306 #endif
307 #ifdef EIGEN_VECTORIZE_FMA
308 #undef EIGEN_VECTORIZE_FMA
309 #endif
310 #ifdef EIGEN_VECTORIZE_AVX512
311 #undef EIGEN_VECTORIZE_AVX512
312 #endif
313 #ifdef EIGEN_VECTORIZE_AVX512DQ
314 #undef EIGEN_VECTORIZE_AVX512DQ
315 #endif
316 #ifdef EIGEN_VECTORIZE_AVX512ER
317 #undef EIGEN_VECTORIZE_AVX512ER
318 #endif
319 #endif
320 // NOTE: Confirmed test failures in XCode 11.0, and XCode 11.2 with -macosx-version-min=10.15 and AVX
321 // NOTE using -macosx-version-min=10.15 with Xcode 11.0 results in runtime segmentation faults in many tests, 11.2
322 // produce core dumps in 3 tests NOTE using -macosx-version-min=10.14 produces functioning and passing tests in all
323 // cases NOTE __clang_version__ "11.0.0 (clang-1100.0.33.8)" XCode 11.0 <- Produces many segfault and core dumping
324 // tests
325 // with -macosx-version-min=10.15 and AVX
326 // NOTE __clang_version__ "11.0.0 (clang-1100.0.33.12)" XCode 11.2 <- Produces 3 core dumping tests with
327 // -macosx-version-min=10.15 and AVX
328 #endif
329 
330 // include files
331 
332 // This extern "C" works around a MINGW-w64 compilation issue
333 // https://sourceforge.net/tracker/index.php?func=detail&aid=3018394&group_id=202880&atid=983354
334 // In essence, intrin.h is included by windows.h and also declares intrinsics (just as emmintrin.h etc. below do).
335 // However, intrin.h uses an extern "C" declaration, and g++ thus complains of duplicate declarations
336 // with conflicting linkage. The linkage for intrinsics doesn't matter, but at that stage the compiler doesn't know;
337 // so, to avoid compile errors when windows.h is included after Eigen/Core, ensure intrinsics are extern "C" here too.
338 // notice that since these are C headers, the extern "C" is theoretically needed anyways.
339 extern "C" {
340 // In theory we should only include immintrin.h and not the other *mmintrin.h header files directly.
341 // Doing so triggers some issues with ICC. However old gcc versions seems to not have this file, thus:
342 #if EIGEN_COMP_ICC >= 1110 || EIGEN_COMP_EMSCRIPTEN
343 #include <immintrin.h>
344 #else
345 #include <mmintrin.h>
346 #include <emmintrin.h>
347 #include <xmmintrin.h>
348 #ifdef EIGEN_VECTORIZE_SSE3
349 #include <pmmintrin.h>
350 #endif
351 #ifdef EIGEN_VECTORIZE_SSSE3
352 #include <tmmintrin.h>
353 #endif
354 #ifdef EIGEN_VECTORIZE_SSE4_1
355 #include <smmintrin.h>
356 #endif
357 #ifdef EIGEN_VECTORIZE_SSE4_2
358 #include <nmmintrin.h>
359 #endif
360 #if defined(EIGEN_VECTORIZE_AVX) || defined(EIGEN_VECTORIZE_AVX512)
361 #include <immintrin.h>
362 #endif
363 #endif
364 } // end extern "C"
365 
366 #elif defined(__VSX__) && !defined(__APPLE__)
367 
368 #define EIGEN_VECTORIZE
369 #define EIGEN_VECTORIZE_VSX 1
370 #define EIGEN_VECTORIZE_FMA
371 #include <altivec.h>
372 // We need to #undef all these ugly tokens defined in <altivec.h>
373 // => use __vector instead of vector
374 #undef bool
375 #undef vector
376 #undef pixel
377 
378 #elif defined __ALTIVEC__
379 
380 #define EIGEN_VECTORIZE
381 #define EIGEN_VECTORIZE_ALTIVEC
382 #define EIGEN_VECTORIZE_FMA
383 #include <altivec.h>
384 // We need to #undef all these ugly tokens defined in <altivec.h>
385 // => use __vector instead of vector
386 #undef bool
387 #undef vector
388 #undef pixel
389 
390 #elif ((defined __ARM_NEON) || (defined __ARM_NEON__)) && !(defined EIGEN_ARM64_USE_SVE)
391 
392 #define EIGEN_VECTORIZE
393 #define EIGEN_VECTORIZE_NEON
394 #include <arm_neon.h>
395 
396 // We currently require SVE to be enabled explicitly via EIGEN_ARM64_USE_SVE and
397 // will not select the backend automatically
398 #elif (defined __ARM_FEATURE_SVE) && (defined EIGEN_ARM64_USE_SVE)
399 
400 #define EIGEN_VECTORIZE
401 #define EIGEN_VECTORIZE_SVE
402 #include <arm_sve.h>
403 
404 // Since we depend on knowing SVE vector lengths at compile-time, we need
405 // to ensure a fixed lengths is set
406 #if defined __ARM_FEATURE_SVE_BITS
407 #define EIGEN_ARM64_SVE_VL __ARM_FEATURE_SVE_BITS
408 #else
409 #error "Eigen requires a fixed SVE lector length but EIGEN_ARM64_SVE_VL is not set."
410 #endif
411 
412 #elif (defined __s390x__ && defined __VEC__)
413 
414 #define EIGEN_VECTORIZE
415 #define EIGEN_VECTORIZE_ZVECTOR
416 #include <vecintrin.h>
417 
418 #elif defined __mips_msa
419 
420 // Limit MSA optimizations to little-endian CPUs for now.
421 // TODO: Perhaps, eventually support MSA optimizations on big-endian CPUs?
422 #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
423 #if defined(__LP64__)
424 #define EIGEN_MIPS_64
425 #else
426 #define EIGEN_MIPS_32
427 #endif
428 #define EIGEN_VECTORIZE
429 #define EIGEN_VECTORIZE_MSA
430 #include <msa.h>
431 #endif
432 
433 #elif (defined __loongarch64 && defined __loongarch_sx)
434 
435 #define EIGEN_VECTORIZE
436 #define EIGEN_VECTORIZE_LSX
437 #include <lsxintrin.h>
438 
439 #elif defined __HVX__ && (__HVX_LENGTH__ == 128)
440 
441 #define EIGEN_VECTORIZE
442 #define EIGEN_VECTORIZE_HVX
443 #include <hexagon_types.h>
444 
445 #endif
446 #endif
447 
448 // Following the Arm ACLE arm_neon.h should also include arm_fp16.h but not all
449 // compilers seem to follow this. We therefore include it explicitly.
450 // See also: https://bugs.llvm.org/show_bug.cgi?id=47955
451 #if defined(EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC)
452 #include <arm_fp16.h>
453 #endif
454 
455 // Enable FMA for ARM.
456 #if defined(__ARM_FEATURE_FMA)
457 #define EIGEN_VECTORIZE_FMA
458 #endif
459 
460 #if defined(__F16C__) && !defined(EIGEN_GPUCC) && (!EIGEN_COMP_CLANG_STRICT || EIGEN_CLANG_STRICT_AT_LEAST(3, 8, 0))
461 // We can use the optimized fp16 to float and float to fp16 conversion routines
462 #define EIGEN_HAS_FP16_C
463 
464 #if EIGEN_COMP_GNUC
465 // Make sure immintrin.h is included, even if e.g. vectorization is
466 // explicitly disabled (see also issue #2395).
467 // Note that FP16C intrinsics for gcc and clang are included by immintrin.h,
468 // as opposed to emmintrin.h as suggested by Intel:
469 // https://software.intel.com/sites/landingpage/IntrinsicsGuide/#othertechs=FP16C&expand=1711
470 #include <immintrin.h>
471 #endif
472 #endif
473 
474 #if defined EIGEN_CUDACC
475 #define EIGEN_VECTORIZE_GPU
476 #include <vector_types.h>
477 #if EIGEN_CUDA_SDK_VER >= 70500
478 #define EIGEN_HAS_CUDA_FP16
479 #endif
480 #endif
481 
482 #if defined(EIGEN_HAS_CUDA_FP16)
483 #include <cuda_runtime_api.h>
484 #include <cuda_fp16.h>
485 #endif
486 
487 #if defined(EIGEN_HIPCC)
488 #define EIGEN_VECTORIZE_GPU
489 #include <hip/hip_vector_types.h>
490 #define EIGEN_HAS_HIP_FP16
491 #include <hip/hip_fp16.h>
492 #define EIGEN_HAS_HIP_BF16
493 #include <hip/hip_bfloat16.h>
494 #endif
495 
497 // IWYU pragma: private
498 #include "../InternalHeaderCheck.h"
499 
500 namespace Eigen {
501 
502 inline static const char *SimdInstructionSetsInUse(void) {
503 #if defined(EIGEN_VECTORIZE_AVX512)
504  return "AVX512, FMA, AVX2, AVX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
505 #elif defined(EIGEN_VECTORIZE_AVX)
506  return "AVX SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
507 #elif defined(EIGEN_VECTORIZE_SSE4_2)
508  return "SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
509 #elif defined(EIGEN_VECTORIZE_SSE4_1)
510  return "SSE, SSE2, SSE3, SSSE3, SSE4.1";
511 #elif defined(EIGEN_VECTORIZE_SSSE3)
512  return "SSE, SSE2, SSE3, SSSE3";
513 #elif defined(EIGEN_VECTORIZE_SSE3)
514  return "SSE, SSE2, SSE3";
515 #elif defined(EIGEN_VECTORIZE_SSE2)
516  return "SSE, SSE2";
517 #elif defined(EIGEN_VECTORIZE_ALTIVEC)
518  return "AltiVec";
519 #elif defined(EIGEN_VECTORIZE_VSX)
520  return "VSX";
521 #elif defined(EIGEN_VECTORIZE_NEON)
522  return "ARM NEON";
523 #elif defined(EIGEN_VECTORIZE_SVE)
524  return "ARM SVE";
525 #elif defined(EIGEN_VECTORIZE_ZVECTOR)
526  return "S390X ZVECTOR";
527 #elif defined(EIGEN_VECTORIZE_MSA)
528  return "MIPS MSA";
529 #elif defined(EIGEN_VECTORIZE_LSX)
530  return "LOONGARCH64 LSX";
531 #else
532  return "None";
533 #endif
534 }
535 
536 } // end namespace Eigen
537 
538 #endif // EIGEN_CONFIGURE_VECTORIZATION_H
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
static const char * SimdInstructionSetsInUse(void)
Definition: ConfigureVectorization.h:502