Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

std-simd

> 编程语言
Open source

std::experimental::simd for GCC [ISO/IEC TS 19570:2018]

656 stars0 likes0 views
WebsiteGitHub

About

std::experimental::simd for GCC [ISO/IEC TS 19570:2018]

std::experimental::simd

portable, zero-overhead C++ types for explicitly data-parallel programming

Development here is going to move on to std::simd for C++26. For the TS implementation reach for GCC/libstdc++. std::experimental::simd is shipping with GCC since version 11.

This package implements ISO/IEC TS 19570:2018 Section 9 "Data-Parallel Types". The implementation derived from https://github.com/VcDevel/Vc.

By default, the install.sh script places the std::experimental::simd headers into the directory where the standard library of your C++ compiler (identified via $CXX) resides.

It is only tested and supported with GCC trunk, even though it may work with older GCC versions.

Target support

  • x86_64 is the main development platform and thoroughly tested. This includes support from SSE-only up to AVX512 on Xeon Phi or Xeon CPUs.
  • aarch64, arm, and ppc64le was tested and verified to work. No significant performance evaluation was done.
  • In any case, a fallback to correct execution via builtin arithmetic types is available for all targets.

Installation Instructions

bash
$ ./install.sh

Use --help to learn about the available options.

Example

Scalar Product

Let's start from the code for calculating a 3D scalar product using builtin floats:

cpp
using Vec3D = std::array;
float scalar_product(Vec3D a, Vec3D b) {
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}

Using simd, we can easily vectorize the code using the native_simd type (Compiler Explorer):

cpp
using std::experimental::native_simd;
using Vec3D = std::array, 3>;
native_simd scalar_product(Vec3D a, Vec3D b) {
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}

The above will scale to 1, 4, 8, 16, etc. scalar products calculated in parallel, depending on the target hardware's capabilities.

For comparison, the same vectorization using Intel SSE intrinsics is more verbose, uses prefix notation (i.e. function calls), and neither scales to AVX or AVX512, nor is it portable to different SIMD ISAs:

cpp
using Vec3D = std::array;
__m128 scalar_product(Vec3D a, Vec3D b) {
  return _mm_add_ps(_mm_add_ps(_mm_mul_ps(a[0], b[0]), _mm_mul_ps(a[1], b[1])),
                    _mm_mul_ps(a[2], b[2]));
}

Build Requirements

none. It's header-only.

However, to build the unit tests you will need:

  • cmake >= 3.0
  • GCC >= 9.1

To execute all AVX512 unit tests, you will need the Intel SDE.

Building the tests

bash
$ make test

This will create a build directory, run cmake, compile the tests, and execute the tests.

Documentation

https://en.cppreference.com/w/cpp/experimental/simd

Publications

  • J. Hoberock, "Working Draft, C++ Extensions for Parallelism Version 2", 2019
  • M. Kretz, "Extending C++ for Explicit Data-Parallel Programming via SIMD Vector Types", Goethe University Frankfurt, Dissertation, 2015.
  • P. Esterie, M. Gaunard, J. Falcou and J. Lapresté, "Exploiting Multimedia Extensions in C++: A Portable Approach," in Computing in Science & Engineering, vol. 14, no. 5, pp. 72-77, Sept.-Oct. 2012.
  • M. Kretz and V. Lindenstruth, "Vc: A C++ library for explicit vectorization", Software: Practice and Experience, 2011.
  • J. Falcou and J. Serot, "E.V.E., An Object Oriented SIMD Library.", Scalable Computing: Practice and Experience, vol. 6, no. 4, pp. 72-77, 2005.

License

The simd headers, tests, and benchmarks are released under the terms of the 3-clause BSD license.

Note that the code in libstdc++ is distributed under GPL3 with runtime library exception.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++avxavx512cpp17gcc

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言