|
dune-common 2.12-git
|

Files | |
| file | stdsimd.hh |
SIMD abstractions for std::experimental::simd | |
Detailed Description
This implements the vectorization interface for the types of the C++ Parallelism TS v2, namely std::experimental::simd<T, Abi> and std::experimental::simd_mask<T, Abi>, e.g. native_simd<double> or fixed_size_simd<double, 4>.
The types are specified in section 9 "Data-Parallel Types" of the Technical Specification "C++ Extensions for Parallelism Version 2" (ISO/IEC TS 19570:2018). A freely available reference is https://en.cppreference.com/w/cpp/experimental/simd. The types have been adopted into C++26 as std::simd.
As an application developer, you need to #include <dune/common/simd/stdsimd.hh>. It is only available if the standard library provides std::experimental::simd, which is indicated by the preprocessor macro DUNE_HAVE_CXX_EXPERIMENTAL_SIMD:
- If your program works both with and without it, wrap the use in
#if DUNE_HAVE_CXX_EXPERIMENTAL_SIMDand#endif. - If you write a unit test, in your
CMakeLists.txtusedune_add_test(... CMAKE_GUARD DUNE_HAVE_CXX_EXPERIMENTAL_SIMD).
No library or special compiler flags are needed. The number of lanes of native_simd<T> depends on the target architecture, so compile with e.g. -march=native to make use of the vector instructions of your CPU.
Rebinding a vector type to another scalar type yields std::experimental::rebind_simd_t, which may change the ABI tag, e.g. from native_simd<float> to a fixed_size_simd<double, N>. A rebind round trip therefore does not necessarily yield the original type.
Restrictions
The types follow the rules of the Parallelism TS, in particular:
- Element types are the arithmetic types except
bool. - Scalars are only broadcast implicitly if the conversion does not lose precision, e.g.
native_simd<float>() * 0.5does not compile; useScalar<V>(0.5). This also applies to operations of lanes ofdoublevectors withfloatvectors. - Masks with different element types cannot be combined.
- A mask cannot be copy-initialized from a
bool(M m = true;); useM m(true);.
Legal Statements / Impressum | Hosted by TU Dresden & Uni Heidelberg | Generated by
1.9.8