xsimd

C++ library for portable SIMD intrinsics wrappers and vectorization

brewmacoslinux
Try with needOr install directly
Source

About

Modern, portable C++ wrappers for SIMD intrinsics

Examples

write fast vector math code that works on any CPU$ cat > simd_example.cpp << 'EOF' #include <xsimd/xsimd.hpp> using namespace xsimd; auto v1 = batch<float>(1.0f, 2.0f, 3.0f, 4.0f); auto v2 = batch<float>(5.0f, 6.0f, 7.0f, 8.0f); auto result = v1 + v2; EOF
use SSE AVX and NEON instructions without manual assembly$ cat > CMakeLists.txt << 'EOF' find_package(xsimd REQUIRED) add_executable(myapp main.cpp) target_link_libraries(myapp PRIVATE xsimd::xsimd) EOF
compile code with automatic SIMD optimization$ c++ -std=c++14 -I$(brew --prefix xsimd)/include program.cpp -o program
check CPU SIMD capabilities at runtime$ cat > check_simd.cpp << 'EOF' #include <xsimd/xsimd.hpp> std::cout << xsimd::supported_architectures() << std::endl; EOF
parallelize array operations across multiple cores with vectorization$ cat > batch_ops.cpp << 'EOF' #include <xsimd/xsimd.hpp> using batch_type = xsimd::batch<double>; batch_type a = xsimd::load_aligned(ptr1); batch_type b = xsimd::load_aligned(ptr2); xsimd::store_aligned(ptr_out, a * b + xsimd::sqrt(a)); EOF