file new in Git master
Cpu.hNamespace Corrade::
Namespaces
- namespace Corrade
- Root namespace.
- namespace Corrade::Cpu new in Git master
- Compile-time and runtime CPU instruction set detection and dispatch.
Classes
-
template<class T>struct Corrade::Cpu::TypeTraits
- Traits class for CPU detection tag types.
- struct Corrade::Cpu::ScalarT
- Scalar tag type.
- struct Corrade::Cpu::Sse2T
- SSE2 tag type.
- struct Corrade::Cpu::Sse3T
- SSE3 tag type.
- struct Corrade::Cpu::Ssse3T
- SSSE3 tag type.
- struct Corrade::Cpu::Sse41T
- SSE4.1 tag type.
- struct Corrade::Cpu::Sse42T
- SSE4.2 tag type.
- struct Corrade::Cpu::PopcntT
- POPCNT tag type.
- struct Corrade::Cpu::LzcntT
- LZCNT tag type.
- struct Corrade::Cpu::Bmi1T
- BMI1 tag type.
- struct Corrade::Cpu::Bmi2T
- BMI2 tag type.
- struct Corrade::Cpu::AvxT
- AVX tag type.
- struct Corrade::Cpu::AvxF16cT
- AVX F16C tag type.
- struct Corrade::Cpu::AvxFmaT
- AVX FMA tag type.
- struct Corrade::Cpu::Avx2T
- AVX2 tag type.
- struct Corrade::Cpu::Avx512fT
- AVX-512 Foundation tag type.
- struct Corrade::Cpu::NeonT
- NEON tag type.
- struct Corrade::Cpu::NeonFmaT
- NEON FMA tag type.
- struct Corrade::Cpu::NeonFp16T
- NEON FP16 tag type.
- struct Corrade::Cpu::Simd128T
- SIMD128 tag type.
- class Corrade::Cpu::Features
- Feature set.
Typedefs
- using DefaultBaseT = ScalarT
- Default base tag type.
- using DefaultExtraT = Implementation::Tags<0>
- Default extra tag type.
- using DefaultT = Implementation::Tags<static_cast<unsigned int>TypeTraits<DefaultBaseT>::Index)|DefaultExtraT::Value>
- Default tag type.
Functions
-
template<class T>auto tag() -> T constexpr
- Tag for a tag type.
-
template<class T>auto features() -> Features constexpr
- Feature set for a tag type.
- auto compiledFeatures() -> Features constexpr
- CPU instruction sets enabled at compile time.
- auto runtimeFeatures() -> Features
- Detect available CPU instruction sets at runtime.
Variables
- ScalarT Scalar constexpr
- Scalar tag.
- Sse2T Sse2 constexpr
- SSE2 tag.
- Sse3T Sse3 constexpr
- SSE3 tag.
- Ssse3T Ssse3 constexpr
- SSSE3 tag.
- Sse41T Sse41 constexpr
- SSE4.1 tag.
- Sse42T Sse42 constexpr
- SSE4.2 tag.
- PopcntT Popcnt constexpr
- POPCNT tag.
- LzcntT Lzcnt constexpr
- LZCNT tag.
- Bmi1T Bmi1 constexpr
- BMI1 tag.
- Bmi2T Bmi2 constexpr
- BMI2 tag.
- AvxT Avx constexpr
- AVX tag.
- AvxF16cT AvxF16c constexpr
- AVX F16C tag.
- AvxFmaT AvxFma constexpr
- AVX FMA tag.
- Avx2T Avx2 constexpr
- AVX2 tag.
- Avx512fT Avx512f constexpr
- AVX-512 Foundation tag.
- NeonT Neon constexpr
- NEON tag type.
- NeonFmaT NeonFma constexpr
- NEON FMA tag type.
- NeonFp16T NeonFp16 constexpr
- NEON FP16 tag type.
- Simd128T Simd128 constexpr
- SIMD128 tag type.
- DefaultBaseT DefaultBase constexpr
- Default base tag.
- DefaultExtraT DefaultExtra constexpr
- Default extra tags.
- DefaultT Default constexpr
- Default tags.
Defines
- #define CORRADE_CPU_DECLARE(tag) new in Git master
- Declare a CPU tag for a compile-time dispatch.
- #define CORRADE_CPU_SELECT(tag) new in Git master
- Select a CPU tag for a compile-time dispatch.
- #define CORRADE_CPU_DISPATCHER_BASE(function) new in Git master
- Create a function for a runtime dispatch on a base CPU instruction set.
- #define CORRADE_CPU_DISPATCHER(function, ...) new in Git master
- Create a function for a runtime dispatch on a base CPU instruction set and select extra instruction sets.
- #define CORRADE_CPU_DISPATCHED_POINTER(dispatcher, ...) new in Git master
- Create a runtime-dispatched function pointer.
- #define CORRADE_CPU_DISPATCHED_IFUNC(dispatcher, ...) new in Git master
- Create a runtime-dispatched function via GNU IFUNC.
- #define CORRADE_ENABLE_SSE2 new in Git master
- Enable SSE2 for given function.
- #define CORRADE_ENABLE_SSE3 new in Git master
- Enable SSE3 for given function.
- #define CORRADE_ENABLE_SSSE3 new in Git master
- Enable SSSE3 for given function.
- #define CORRADE_ENABLE_SSE41 new in Git master
- Enable SSE4.1 for given function.
- #define CORRADE_ENABLE_SSE42 new in Git master
- Enable SSE4.2 for given function.
- #define CORRADE_ENABLE_POPCNT new in Git master
- Enable POPCNT for given function.
- #define CORRADE_ENABLE_LZCNT new in Git master
- Enable LZCNT for given function.
- #define CORRADE_ENABLE_BMI1 new in Git master
- Enable BMI1 for given function.
- #define CORRADE_ENABLE_BMI2 new in Git master
- Enable BMI2 for given function.
- #define CORRADE_ENABLE_AVX new in Git master
- Enable AVX for given function.
- #define CORRADE_ENABLE_AVX_F16C new in Git master
- Enable AVX F16C for given function.
- #define CORRADE_ENABLE_AVX_FMA new in Git master
- Enable AVX FMA for given function.
- #define CORRADE_ENABLE_AVX2 new in Git master
- Enable AVX2 for given function.
- #define CORRADE_ENABLE_AVX512F new in Git master
- Enable AVX-512 Foundation for given function.
- #define CORRADE_ENABLE_NEON new in Git master
- Enable NEON for given function.
- #define CORRADE_ENABLE_NEON_FMA new in Git master
- Enable NEON FMA for given function.
- #define CORRADE_ENABLE_NEON_FP16 new in Git master
- Enable NEON FP16 for given function.
- #define CORRADE_ENABLE_SIMD128 new in Git master
- Enable SIMD128 for given function.
- #define CORRADE_ENABLE(...) new in Git master
- Enable multiple targets for given function.
Define documentation
#define CORRADE_CPU_DECLARE(tag) new in Git master
Declare a CPU tag for a compile-time dispatch.
Meant to be used to declare a function overload that uses given combination of CPU instruction sets. The CORRADE_
Internally, this macro expands to two function parameter declarations separated by a comma, one that ensures only an overload matching the desired instruction sets get picked, and one that assigns an absolute priority to this overload.
#define CORRADE_CPU_SELECT(tag) new in Git master
Select a CPU tag for a compile-time dispatch.
Meant to be used to select among function overloads declared with CORRADE_
Internally, this macro expands to two function parameter values separated by a comma, one that contains the desired instruction sets to filter the overloads against and another that converts the sets to an absolute priority to pick the best viable overload.
#define CORRADE_CPU_DISPATCHER_BASE(function) new in Git master
Create a function for a runtime dispatch on a base CPU instruction set.
Given a set of function overloads named function
that accept a CPU tag as a parameter, all returning a function pointer of the same type, creates a function with signature function(Cpu::Features)
which will select among the overloads using a runtime-specified Cpu::
This function works with just a single base CPU instruction tag such as Cpu::
#define CORRADE_CPU_DISPATCHER(function, ...) new in Git master
Create a function for a runtime dispatch on a base CPU instruction set and select extra instruction sets.
Given a set of function overloads named function
that accept a CPU tag combination wrapped in CORRADE_function(Cpu::Features)
which will select among the overloads using a runtime-specified Cpu::
For a dispatch using just the base instruction set use CORRADE_
#define CORRADE_CPU_DISPATCHED_POINTER(dispatcher, ...) new in Git master
Create a runtime-dispatched function pointer.
Assuming a dispatcher
was defined with either CORRADE_dispatcher
for Cpu::
The pointer can be changed afterwards, such as for testing purposes, See also CORRADE_
See Automatic cached dispatch for more information, usage example and overhead comparison.
#define CORRADE_CPU_DISPATCHED_IFUNC(dispatcher, ...) new in Git master
Create a runtime-dispatched function via GNU IFUNC.
Available only if CORRADE_dispatcher
was defined with either CORRADE_type
. The function uses the GNU IFUNC mechanism, which causes the function call to be resolved to a function pointer returned by dispatcher
for Cpu::
If CORRADE_
See Automatic cached dispatch for more information, usage example and overhead comparison.
#define CORRADE_ENABLE_SSE2 new in Git master
Enable SSE2 for given function.
On x86 GCC, Clang and clang-cl expands to __attribute__((__target__("sse2")))
, allowing use of SSE2 and earlier SSE instructions inside a function annotated with this macro without having to specify -msse2
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Implied by CORRADE_
#define CORRADE_ENABLE_SSE3 new in Git master
Enable SSE3 for given function.
On x86 GCC and Clang expands to __attribute__((__target__("sse3")))
, allowing use of SSE3 and earlier SSE intrinsics inside a function annotated with this macro without having to specify -msse3
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_SSSE3 new in Git master
Enable SSSE3 for given function.
On x86 GCC, Clang and clang-cl expands to __attribute__((__target__("ssse3")))
, allowing use of SSSE3 and earlier SSE instructions inside a function annotated with this macro without having to specify -mssse3
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_SSE41 new in Git master
Enable SSE4.1 for given function.
On x86 GCC, Clang and clang-cl expands to __attribute__((__target__("sse4.1")))
, allowing use of SSE4.1 and earlier SSE instructions inside a function annotated with this macro without having to specify -msse4.1
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_SSE42 new in Git master
Enable SSE4.2 for given function.
On x86 GCC, Clang and clang-cl expands to __attribute__((__target__("sse4.2")))
, allowing use of SSE4.2 and earlier SSE instructions inside a function annotated with this macro without having to specify -msse4.2
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_POPCNT new in Git master
Enable POPCNT for given function.
On x86 GCC, Clang and clang-cl expands to __attribute__((__target__("popcnt")))
, allowing use of the POPCNT instructions inside a function annotated with this macro without having to specify -mpopcnt
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Not defined on GCC 4.8, as there it's not generally possible to enable it alongside other instruction sets without running into linker errors. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Neither a superset nor implied by any other CORRADE_ENABLE_*
macro, so you may need to specify it together with others. See Enabling instruction sets for particular functions for more information and usage example.
#define CORRADE_ENABLE_LZCNT new in Git master
Enable LZCNT for given function.
On x86 GCC and Clang expands to __attribute__((__target__("lzcnt")))
, allowing use of the LZCNT instructions inside a function annotated with this macro without having to specify -mlzcnt
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants and POPCNT this macro is not defined on clang-cl, as there LZCNT, BMI1, BMI2, AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on GCC 4.8, as there it's not generally possible to enable it alongside unrelated instruction sets without running into linker errors. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Neither a superset nor implied by any other CORRADE_ENABLE_*
macro, so you may need to specify it together with others. See Enabling instruction sets for particular functions for more information and usage example.
#define CORRADE_ENABLE_BMI1 new in Git master
Enable BMI1 for given function.
On x86 GCC, Clang expands to __attribute__((__target__("bmi")))
, allowing use of the BMI1 instructions inside a function annotated with this macro without having to specify -mbmi
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants and POPCNT this macro is not defined on clang-cl, as there LZCNT, BMI1, BMI2, AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on GCC 4.8, as there it's not generally possible to enable it alongside unrelated instruction sets without running into linker errors. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Neither a superset nor implied by any other CORRADE_ENABLE_*
macro (not even CORRADE_
#define CORRADE_ENABLE_BMI2 new in Git master
Enable BMI2 for given function.
On x86 GCC, Clang expands to __attribute__((__target__("bmi2")))
, allowing use of the BMI2 instructions inside a function annotated with this macro without having to specify -mbmi2
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants and POPCNT this macro is not defined on clang-cl, as there LZCNT, BMI1, BMI2, AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on GCC 4.8, as there it's not generally possible to enable it alongside unrelated instruction sets without running into linker errors. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Neither a superset nor implied by any other CORRADE_ENABLE_*
macro (not even CORRADE_
#define CORRADE_ENABLE_AVX new in Git master
Enable AVX for given function.
On x86 GCC and Clang expands to __attribute__((__target__("avx")))
, allowing use of AVX and all earlier SSE instructions inside a function annotated with this macro without having to specify -mavx
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants this macro is not defined on clang-cl, as there AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_AVX_F16C new in Git master
Enable AVX F16C for given function.
On x86 GCC and Clang expands to __attribute__((__target__("f16c")))
, allowing use of F16C instructions inside a function annotated with this macro without having to specify -mf16c
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants this macro is not defined on clang-cl, as there AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on GCC 4.8, as there it's not generally possible to enable it alongside other instruction sets without running into linker errors. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_CORRADE_ENABLE_*
macro so you may need to specify it together with others. See Enabling instruction sets for particular functions for more information and usage example.
#define CORRADE_ENABLE_AVX_FMA new in Git master
Enable AVX FMA for given function.
On x86 GCC and Clang expands to __attribute__((__target__("fma")))
, allowing use of FMA instructions inside a function annotated with this macro without having to specify -mfma
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants this macro is not defined on clang-cl, as there AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on GCC 4.8, as there it's not generally possible to enable it alongside other instruction sets without running into linker errors. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_CORRADE_ENABLE_*
macro so you may need to specify it together with others. See Enabling instruction sets for particular functions for more information and usage example.
#define CORRADE_ENABLE_AVX2 new in Git master
Enable AVX2 for given function.
On x86 GCC and Clang expands to __attribute__((__target__("avx2")))
, allowing use of AVX2, FMA, F16C, AVX and all earlier SSE instructions inside a function annotated with this macro without having to specify -mavx2
for the whole compilation unit. On x86 MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants this macro is not defined on clang-cl, as there AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_AVX512F new in Git master
Enable AVX-512 Foundation for given function.
On x86 GCC 4.9+ and Clang expands to __attribute__((__target__("avx512f")))
, allowing use of AVX-512 Foundation and all earlier AVX and SSE instructions inside a function annotated with this macro without having to specify -mavx512f
for the whole compilation unit. On x86 MSVC 2017 15.3+ expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. Unlike the SSE variants this macro is not defined on clang-cl, as there AVX and newer intrinsics are provided only if enabled on compiler command line. Not defined on other compilers, earlier compiler versions without AVX-512 support or other architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_NEON new in Git master
Enable NEON for given function.
On 32-bit ARM GCC expands to __attribute__((__target__("fpu=neon")))
, allowing use of NEON instructions inside a function annotated with this macro without having to specify -mfpu=neon
for the whole compilation unit. On ARM MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. In contrast to GCC, this macro is not defined on Clang, as it makes the NEON intrinsics available only if enabled on compiler command line. Not defined on other compilers or architectures.
As a special case, if CORRADE_-mfpu=neon
is unrecognized).
Implied by CORRADE_
#define CORRADE_ENABLE_NEON_FMA new in Git master
Enable NEON FMA for given function.
On 32-bit ARM GCC expands to __attribute__((__target__("fpu=neon-vfpv4")))
, allowing use of NEON FMA instructions inside a function annotated with this macro without having to specify -mfpu=neon-vfpv4
for the whole compilation unit. On ARM MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. In contrast to GCC, this macro is not defined on Clang, as it makes the NEON FMA intrinsics available only if enabled on compiler command line. Not defined on other compilers or architectures.
As a special case, if CORRADE_-mfpu=neon-vfpv4
is unrecognized).
Superset of CORRADE_
#define CORRADE_ENABLE_NEON_FP16 new in Git master
Enable NEON FP16 for given function.
On ARM GCC expands to __attribute__((__target__("arch=armv8.2-a+fp16")))
, allowing use of ARMv8.2-a NEON FP16 vector arithmetic inside a function annotated with this macro without having to specify -march=armv8.2-a+fp16
for the whole compilation unit. On ARM MSVC expands to nothing, as the compiler doesn't restrict use of intrinsics in any way. In contrast to GCC, this macro is not defined on Clang, as it makes the NEON FP16 intrinsics available only if enabled on compiler command line. Not defined on other compilers or architectures.
As a special case, if CORRADE_
Superset of CORRADE_
#define CORRADE_ENABLE_SIMD128 new in Git master
Enable SIMD128 for given function.
Given that it's currently not possible to selectively use 128-bit SIMD in a WebAssembly module without causing a compilation error on runtimes that don't support it, this macro is only defined if CORRADE___attribute__((__target__("simd128")))
would be redundant if -msimd128
is passed on the command line.
The situation may change once the feature detection proposal is implemented, but likely only for instruction sets building on top of this one.
See Enabling instruction sets for particular functions for more information and usage example.
#define CORRADE_ENABLE(...) new in Git master
Enable multiple targets for given function.
Accepts a comma-separated list of CORRADE_ENABLE_*
macro suffixes, effectively enabling given combination. For the macro to work, all CORRADE_ENABLE_*
macros corresponding to the arguments have to be defined, the common usage pattern is thus in combination with an #ifdef
. See Enabling instruction sets for particular functions for more information and an example.
When multiple CORRADE_ENABLE_*
macros are specified one after another, Clang 8+ would pick only the first specified, and Clang before version 8 and GCC before version 12 only the last specified, ignoring the others. There the macro expands into a single combined __attribute__((__target__(...)))
attribute. For GCC 12+ and other compilers except MSVC it's just a shorthand for multiple CORRADE_ENABLE_*
macros one after another. On MSVC expands to nothing — there the functions aren't annotated in anyway and moreover the default preprocessor behavior would make this extremely tricky to implement.