Normal C ++? No. std::valarray can bring your compiler to SIMD water, but it cannot make it drink.
OpenMP is the least "library" of a library: it is more of a language extension than a library, and all major C ++ compilers support it. While primarily and historically used for multi-core parallelism, OpenMP 4.0 introduced SIMD-specific constructs that can at least prompt your compiler to vectorize certain clearly-vectorized procedures, even with explicitly scalar routines. It can also help you identify aspects of your code that prevent compiler vectorization. (And besides ... you also don't want multi-core parallelism?)
double* dest; const double* src1, src2; #pragma omp simd for (int i = 0; i < n; i++) { dest[i] = src1[i] + src2[i]; }
To go to the last mile with operations with reduced accuracy, multi-level aggregation, masking without branches, etc., really requires an explicit connection to the base set of commands and is impossible with anything close to "simple C ++". OpenMP can get you pretty far.
source share