48 #define Vc_ICC __INTEL_COMPILER_BUILD_DATE
57 #define Vc_CLANG (__clang_major__ * 0x10000 + __clang_minor__ * 0x100 + __clang_patchlevel__)
66 #define Vc_GCC (__GNUC__ * 0x10000 + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
74 #define Vc_MSVC _MSC_FULL_VER
86 #define Vc_PASSING_VECTOR_BY_VALUE_IS_BROKEN 1
87 #undef Vc_PASSING_VECTOR_BY_VALUE_IS_BROKEN
93 #ifdef __INTEL_COMPILER
94 #define Vc_ICC __INTEL_COMPILER_BUILD_DATE
95 #elif defined(__OPENCC__)
97 #elif defined(__clang__)
98 #define Vc_CLANG (__clang_major__ * 0x10000 + __clang_minor__ * 0x100 + __clang_patchlevel__)
99 #elif defined(__GNUC__)
100 #define Vc_GCC (__GNUC__ * 0x10000 + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
101 #elif defined(_MSC_VER)
102 #define Vc_MSVC _MSC_FULL_VER
104 #define Vc_UNSUPPORTED_COMPILER 1
107 #if __cplusplus < 201103
108 #if (defined Vc_MSVC && Vc_MSVC >= 160000000)
111 #error "Vc requires support for C++11."
113 #elif __cplusplus >= 201402L
118 #if defined Vc_MSVC && defined _WIN32
120 #define Vc_PASSING_VECTOR_BY_VALUE_IS_BROKEN 1
122 #if defined(__GNUC__) && !defined(Vc_NO_INLINE_ASM)
126 #if defined(Vc_MSVC) && Vc_MSVC < 180000000
129 #include <xkeycheck.h>
131 #define constexpr inline __forceinline
133 #define Vc__NO_NOEXCEPT 1
138 # if Vc_GCC >= 0x40700 // && Vc_GCC < 0x408000)
140 # define Vc_HAVE_MAX_ALIGN_T 1
142 #elif !defined(Vc_CLANG) && !defined(Vc_ICC)
144 # define Vc_HAVE_STD_MAX_ALIGN_T 1
147 #if defined(Vc_GCC) || defined(Vc_CLANG)
148 #define Vc_USE_BUILTIN_VECTOR_TYPES 1
155 #define Scalar 0x00100000
156 #define SSE 0x00200000
157 #define SSE2 0x00300000
158 #define SSE3 0x00400000
159 #define SSSE3 0x00500000
160 #define SSE4_1 0x00600000
161 #define SSE4_2 0x00700000
162 #define AVX 0x00800000
163 #define AVX2 0x00900000
164 #define MIC 0x00A00000
166 #define XOP 0x00000001
167 #define FMA4 0x00000002
168 #define F16C 0x00000004
169 #define POPCNT 0x00000008
170 #define SSE4a 0x00000010
171 #define FMA 0x00000020
172 #define BMI2 0x00000040
174 #define IMPL_MASK 0xFFF00000
175 #define EXT_MASK 0x000FFFFF
189 # elif defined(_M_AMD64)
200 #if defined Vc_ICC && !defined __POPCNT__
201 # if defined __SSE4_2__ || defined __SSE4A__
202 # define __POPCNT__ 1
207 #error "You are using the old VC_IMPL macro. Since Vc 1.0 all Vc macros start with Vc_, i.e. a lower-case 'c'"
212 # if defined(__MIC__)
213 # define Vc_IMPL_MIC 1
214 # elif defined(__AVX2__)
215 # define Vc_IMPL_AVX2 1
216 # define Vc_IMPL_AVX 1
217 # elif defined(__AVX__)
218 # define Vc_IMPL_AVX 1
220 # if defined(__SSE4_2__)
221 # define Vc_IMPL_SSE 1
222 # define Vc_IMPL_SSE4_2 1
224 # if defined(__SSE4_1__)
225 # define Vc_IMPL_SSE 1
226 # define Vc_IMPL_SSE4_1 1
228 # if defined(__SSE3__)
229 # define Vc_IMPL_SSE 1
230 # define Vc_IMPL_SSE3 1
232 # if defined(__SSSE3__)
233 # define Vc_IMPL_SSE 1
234 # define Vc_IMPL_SSSE3 1
236 # if defined(__SSE2__)
237 # define Vc_IMPL_SSE 1
238 # define Vc_IMPL_SSE2 1
241 # if defined(Vc_IMPL_SSE)
244 # define Vc_IMPL_Scalar 1
247 # if !defined(Vc_IMPL_Scalar)
249 # define Vc_IMPL_FMA4 1
252 # define Vc_IMPL_XOP 1
255 # define Vc_IMPL_F16C 1
258 # define Vc_IMPL_POPCNT 1
261 # define Vc_IMPL_SSE4a 1
264 # define Vc_IMPL_FMA 1
267 # define Vc_IMPL_BMI2 1
273 # if (Vc_IMPL & IMPL_MASK) == MIC // MIC supersedes everything else
274 # define Vc_IMPL_MIC 1
276 # define Vc_IMPL_POPCNT 1
278 # elif (Vc_IMPL & IMPL_MASK) == AVX2 // AVX2 supersedes SSE
279 # define Vc_IMPL_AVX2 1
280 # define Vc_IMPL_AVX 1
281 # elif (Vc_IMPL & IMPL_MASK) == AVX // AVX supersedes SSE
282 # define Vc_IMPL_AVX 1
283 # elif (Vc_IMPL & IMPL_MASK) == Scalar
284 # define Vc_IMPL_Scalar 1
285 # elif (Vc_IMPL & IMPL_MASK) == SSE4_2
286 # define Vc_IMPL_SSE4_2 1
287 # define Vc_IMPL_SSE4_1 1
288 # define Vc_IMPL_SSSE3 1
289 # define Vc_IMPL_SSE3 1
290 # define Vc_IMPL_SSE2 1
291 # define Vc_IMPL_SSE 1
292 # elif (Vc_IMPL & IMPL_MASK) == SSE4_1
293 # define Vc_IMPL_SSE4_1 1
294 # define Vc_IMPL_SSSE3 1
295 # define Vc_IMPL_SSE3 1
296 # define Vc_IMPL_SSE2 1
297 # define Vc_IMPL_SSE 1
298 # elif (Vc_IMPL & IMPL_MASK) == SSSE3
299 # define Vc_IMPL_SSSE3 1
300 # define Vc_IMPL_SSE3 1
301 # define Vc_IMPL_SSE2 1
302 # define Vc_IMPL_SSE 1
303 # elif (Vc_IMPL & IMPL_MASK) == SSE3
304 # define Vc_IMPL_SSE3 1
305 # define Vc_IMPL_SSE2 1
306 # define Vc_IMPL_SSE 1
307 # elif (Vc_IMPL & IMPL_MASK) == SSE2
308 # define Vc_IMPL_SSE2 1
309 # define Vc_IMPL_SSE 1
310 # elif (Vc_IMPL & IMPL_MASK) == SSE
311 # define Vc_IMPL_SSE 1
312 # if defined(__SSE4_2__)
313 # define Vc_IMPL_SSE4_2 1
315 # if defined(__SSE4_1__)
316 # define Vc_IMPL_SSE4_1 1
318 # if defined(__SSE3__)
319 # define Vc_IMPL_SSE3 1
321 # if defined(__SSSE3__)
322 # define Vc_IMPL_SSSE3 1
324 # if defined(__SSE2__)
325 # define Vc_IMPL_SSE2 1
327 # elif (Vc_IMPL & IMPL_MASK) == 0 && (Vc_IMPL & SSE4a)
330 # define Vc_IMPL_SSE3 1
331 # define Vc_IMPL_SSE2 1
332 # define Vc_IMPL_SSE 1
335 # define Vc_IMPL_XOP 1
337 # if (Vc_IMPL & FMA4)
338 # define Vc_IMPL_FMA4 1
340 # if (Vc_IMPL & F16C)
341 # define Vc_IMPL_F16C 1
343 # if (!defined(Vc_IMPL_Scalar) && defined(__POPCNT__)) || (Vc_IMPL & POPCNT)
344 # define Vc_IMPL_POPCNT 1
346 # if (Vc_IMPL & SSE4a)
347 # define Vc_IMPL_SSE4a 1
350 # define Vc_IMPL_FMA 1
352 # if (Vc_IMPL & BMI2)
353 # define Vc_IMPL_BMI2 1
361 # define Vc_USE_VEX_CODING 1
366 # define Vc_IMPL_SSE4_2 1
367 # define Vc_IMPL_SSE4_1 1
368 # define Vc_IMPL_SSSE3 1
369 # define Vc_IMPL_SSE3 1
370 # define Vc_IMPL_SSE2 1
371 # define Vc_IMPL_SSE 1
374 #if defined(Vc_CLANG) && Vc_CLANG >= 0x30600 && Vc_CLANG < 0x30700
375 # if defined(Vc_IMPL_AVX)
376 # warning "clang 3.6.x miscompiles AVX code, frequently losing 50% of the data. Vc will fall back to SSE4 instead."
378 # if defined(Vc_IMPL_AVX2)
384 # if !defined(Vc_IMPL_Scalar) && !defined(Vc_IMPL_SSE) && !defined(Vc_IMPL_AVX) && !defined(Vc_IMPL_MIC)
385 # error "No suitable Vc implementation was selected! Probably Vc_IMPL was set to an invalid value."
386 # elif defined(Vc_IMPL_SSE) && !defined(Vc_IMPL_SSE2)
387 # error "SSE requested but no SSE2 support. Vc needs at least SSE2!"
413 #define Vc_DEFAULT_IMPL_MIC
414 #elif defined Vc_IMPL_AVX2
415 #define Vc_DEFAULT_IMPL_AVX2
416 #elif defined Vc_IMPL_AVX
417 #define Vc_DEFAULT_IMPL_AVX
418 #elif defined Vc_IMPL_SSE
419 #define Vc_DEFAULT_IMPL_SSE
420 #elif defined Vc_IMPL_Scalar
421 #define Vc_DEFAULT_IMPL_Scalar
423 #error "Preprocessor logic broken. Please report a bug."
426 #define Vc_VERSIONED_NAMESPACE Vc_1
428 namespace Vc_VERSIONED_NAMESPACE {}
429 namespace Vc = Vc_VERSIONED_NAMESPACE;
433 namespace Vc_VERSIONED_NAMESPACE
436 typedef signed char int8_t;
437 typedef unsigned char uint8_t;
438 typedef signed short int16_t;
439 typedef unsigned short uint16_t;
440 typedef signed int int32_t;
441 typedef unsigned int uint32_t;
442 typedef signed long long int64_t;
443 typedef unsigned long long uint64_t;
500 ImplementationMask = 0xfff
533 ExtraInstructionsMask = 0xfffff000u
549 return static_cast<Implementation>(Features & ImplementationMask);
554 return static_cast<unsigned int>(impl) == current();
562 return static_cast<unsigned int>(low) <= current() &&
563 static_cast<unsigned int>(high) >= current();
568 static constexpr
bool runs_on(
unsigned int extraInstructions)
570 return (extraInstructions & Features & ExtraInstructionsMask) ==
571 (Features & ExtraInstructionsMask);
581 #ifdef Vc_IMPL_Scalar
583 #elif defined(Vc_IMPL_MIC)
585 #elif defined(Vc_IMPL_AVX2)
587 #elif defined(Vc_IMPL_AVX)
589 #elif defined(Vc_IMPL_SSE4_2)
591 #elif defined(Vc_IMPL_SSE4_1)
593 #elif defined(Vc_IMPL_SSSE3)
595 #elif defined(Vc_IMPL_SSE3)
597 #elif defined(Vc_IMPL_SSE2)
609 #ifdef Vc_IMPL_POPCNT
618 #ifdef Vc_USE_VEX_CODING
626 #ifndef Vc_ENABLE_FLOAT_BIT_OPERATORS
627 #define Vc_ENABLE_FLOAT_BIT_OPERATORS 1
632 #endif // VC_GLOBAL_H_
ExtraInstructions
The list of available instructions is not easily described by a linear list of instruction sets...
Align on boundary of page sizes (e.g.
static constexpr bool is_between(Implementation low, Implementation high)
Returns whether the current Vc::Implementation implements at least low and at most high...
Support for FMA instructions (3 operand variant)
Implementation
Enum to identify a certain SIMD instruction set.
static constexpr bool runs_on(unsigned int extraInstructions)
Returns whether the current code would run on a CPU providing extraInstructions.
This class identifies the specific implementation Vc uses in the current translation unit in terms of...
Support for BMI2 instructions.
Support for XOP instructions.
MallocAlignment
Enum that specifies the alignment and padding restrictions to use for memory allocation with Vc::mall...
Support for the population count instruction.
Support for SSE4a instructions.
static constexpr bool is(Implementation impl)
Returns whether impl is the current Vc::Implementation.
ImplementationT< > CurrentImplementation
Identifies the Vc implementation used in the current translation unit.
x86 SSE + SSE2 + SSE3 + SSSE3 + SSE4.1 + SSE4.2
Align on boundary of cache line sizes (e.g.
Support for ternary instruction coding (VEX)
x86 SSE + SSE2 + SSE3 + SSSE3
Support for FMA4 instructions.
Vector Classes Namespace.
static constexpr Implementation current()
Returns the currently used Vc::Implementation.
uses only fundamental types
Align on boundary of vector sizes (e.g.
Support for float16 conversions in hardware.
x86 SSE + SSE2 + SSE3 + SSSE3 + SSE4.1