SIMD concepts — portable SIMD programming abstractions.
1#include <experimental/simd>2namespace stdx = std::experimental;34// SIMD width5std::cout << stdx::simd<float>::size(); // Hardware-dependent67// Fixed width8stdx::simd<float, stdx::fixed_size<4>> v4; // Always 4 elements910// Masked operations11stdx::simd<int> a({1, 2, 3, 4});12stdx::simd<int> b({5, 6, 7, 8});13stdx::simd_mask<int> mask = a > 2;14auto result = stdx::where(mask, a + b, a);1516// Reductions17float sum = stdx::reduce(v); // Sum18float max = stdx::hmax(v); // Horizontal max19float min = stdx::hmin(v); // Horizontal min2021// Math functions22auto sin_vals = stdx::sin(v); // Vectorized sin23auto sqrt_vals = stdx::sqrt(v); // Vectorized sqrt2425// Memory operations26stdx::simd<int> data;27data.copy_to(ptr); // Aligned store28data.copy_from(ptr); // Aligned load2930// Blend (conditional select)31auto blended = stdx::blend(mask, a, b);
SIMD types: