The SIMDe header-only library provides fast, portable implementations of SIMD intrinsics on hardware which doesn't natively support them, such as calling SSE functions on ARM. There is no performance penalty if the hardware supports the native implementation (e.g., SSE/AVX runs at full speed on x86, NEON on ARM, etc.).
This makes porting code to other architectures much easier in a few key ways:
First, instead of forcing you to rewrite everything for each architecture, SIMDe lets you get a port up and running almost effortlessly. You can then start working on switching the most performance-critical sections to native intrinsics, improving performance gradually. SIMDe lets (for example) SSE/AVX and NEON code exist side-by-side, in the same implementation.
Second, SIMDe makes it easier to write code targeting ISA extensions you don't have convenient access to. You can run NEON code on your x86 machine without an emulator. Obviously you'll eventually want to test on the actual hardware you're targeting, but for most development, SIMDe can provide a much easier path.
SIMDe takes a very different approach from most other SIMD abstraction layers in that it aims to expose the entire functionality of the underlying instruction set. Instead of limiting functionality to the lowest common denominator, SIMDe tries to minimize the amount of effort required to port while still allowing you the space to optimize as needed.
The current focus is on writing complete portable implementations, though a large number of functions already have accelerated implementations using one (or more) of the following:
You can try SIMDe online using Compiler Explorer and an amalgamated SIMDe header.
There are currently complete implementations of the following instruction sets:
As well as partial support for many others; see the instruction-set-support label in the issue tracker for details on progress. If you'd like to be notified when an instruction set is available you may subscribe to the relevant issue.
If you have a project you're interested in using with SIMDe but we don't yet support all the functions you need, please file an issue with a list of what's missing so we know what to prioritize.
The default branch is protected so commits never reach it unless they have passed extensive CI checks. Status badges don't really make sense since they will always be green, but here are the links:
If you're adding a new build I suggest Cirrus CI, which is where we currently have the most room given the number of builds currently on the platform and the quotas for free/open-source usage. Alternately, feel free to set up another provider (such as Codefresh, Shippable, Bitrise, Werkaer, etc.).
Notice: we plan on changing the name of the default branch from "master" to something else soon; we are just trying to wait to see what name git settles on so we can be consistent.
First off, if you're reading this: thank you! Even considering contributing to SIMDe is very much appreciated!
SIMDe is a fairly large undertaking; there are a lot of functions to get through and a lot of opportunities for optimization on different platforms, so we're very happy for any help you can provide.
Programmers of all skill levels are welcome, there are lots of tasks which are pretty straightforward and don't require any special expertise.
If you're not sure how you'd like to contribute, please consider taking a look at the issue tracker. There is a good first issue tag if you want to ease into a your first contributions, but if you're interested in something else please get in touch via the issue tracker; we're happy to help you get a handle on whatever you are interested in.
If you're interested in implementing currently unimplemented functions, there is a guide explaining how to add new functions and how to quickly and easily get a test case in place. It's a bit rough right now, but if anything is unclear please feel free to use the issue tracker to ask about anything you're not clear on.
First, it is important to note that you do not need two separate
versions (one using SIMDe, the other native). If the native functions
are available SIMDe will use them, and compilers easily optimize away
any overhead from SIMDe; all they have to do is some basic inlining.
-O2 should be enough, but we strongly recommend
-O3 (or whatever
flag instructs your compiler to aggressizely optimize) since many of
the portable fallbacks are substantially faster with aggressive
auto-vectorization that isn't enabled at lower optimization levels.
Each instruction set has a separate file;
x86/mmx.h for MMX,
x86/sse.h for SSE,
x86/sse2.h for SSE2, and so on. Just include
the header for whichever instruction set(s) you want instead of the
native version (if you include the native version after SIMDe it will
result in compile-time errors if native aliases are enabled). SIMDe
will provide the fastest implementation it can given which extensions
you've enabled in your compiler (i.e., if you want to use NEON to
implement SSE, you may need to pass something like
for more information).
If you define
SIMDE_ENABLE_NATIVE_ALIASES before including SIMDe
you can use the same names as the native functions. Unfortunately,
this is somewhat error-prone due to portability issues in the APIs, so
it's recommended to only do this for testing. When
SIMDE_ENABLE_NATIVE_ALIASES is undefined only the versions prefixed
simde_ will be available; for example, the MMX
Since SIMDe is meant to be portable, many functions which assume types
are of a specific size have been altered to use fixed-width types
instead. For example, Intel's APIs use
char for signed 8-bit
char on ARM is generally unsigned. SIMDe uses
to make the API portable, but that means your code may require some
minor changes (such as using
int8_t instead of
char) to work on
That said, the changes are usually quite minor. It's often enough to just use search and replace, manual changes are required pretty infrequently.
For best performance, in addition to
-O3 (or whatever your compiler's
equivalent is), you should enable OpenMP 4 SIMD support by defining
SIMDE_ENABLE_OPENMP before including any SIMDe headers, and
enabling OpenMP support in your compiler. GCC and ICC both support a
flag to enable only OpenMP SIMD support instead of full OpenMP (the OpenMP
SIMD support doesn't require the OpenMP run-time library); for GCC the
-fopenmp-simd (requires GCC version 4.9 or later), for ICC
the flag is
-qopenmp-simd. SIMDe also supports
using Cilk Plus, GCC loop-specific
or clang pragma loop hint
though these are not nearly as effective as OpenMP SIMD and depending
on them will likely result in less efficient code.
SIMDe does depend on some C99 features, though the subset supported by MSVC also works. While we do our best to make sure we provide optimized implementations where they are supported, SIMDe does contain portable fallbacks which are designed to work on any C99 compiler.
Every commit is tested in CI on multiple compilers, platforms, and configurations, and our test coverage is extremely extensive. Currently tested compilers include:
I'm generally willing to accept patches to add support for other compilers, as long as they're not too disruptive, especially if we can get CI support going. We currently use Travis CI, AppVeyor, and Microsoft Azure Pipelines, but other CI platforms can be added as necessary.
The following architectures are tested in CI for every commit:
We would love to add more, so patches are extremely welcome!
_BitScanForward), not SIMD intrinsics.
If you know of any other related projects, please let us know!
Sometime features can't be emulated. If SIMDe is operating in native mode the functions will work as expected, but if there is no native support some caveats apply:
fesetround(), altering the global rounding mode.
simde_mm_setcsronly implement bits 13 and 14 (rounding mode).
simde_mm256_test*do not set the CF/ZF registers as there is no portable way to implement that functionality.
simde_mm256_zeroupperare not implemented as there is no portable way to implement that functionality.
Additionally, there are some known limitations which apply when using
native aliases (
Also, as mentioned earlier, while some APIs make assumptions about
basic types (e.g.,
int is 32 bits), SIMDe does not, so many types
have been altered to use portable fixed-width versions such as
If you find any other differences, please file an issue so we can either fix it or add it to the list above.
SIMDe uses resources provided for free by a number of organizations. While this shouldn't be taken to imply endorsement of SIMDe, we're tremendously grateful for their support:
Without such organizations donating resources, SIMDe wouldn't be nearly as useful or usable as it is today.
We would also like to thank anyone who has helped develop the myriad of software on which SIMDe relies, including compilers and analysis tools.
Finally, a special thank you to anyone who has contributed to SIMDe, filed bugs, provided suggestions, or helped with SIMDe development in any way.
SIMDe is distributed under an MIT-style license; see COPYING for details.
Thanks goes to these wonderful people (emoji key):
💻 🖋 📖 💡 🤔 💬 👀 ⚠️ ✅ 📢 🐛 🚇 🚧 📆
Michael R. Crusoe
🐛 💻 📋 🔍 🤔 🚇 📦 ⚠️
💻 ⚠️ 🐛 🤔
💻 🤔 📦 🚇 🚧 ⚠️ 🐛
Jesper Storm Bache
Yining Karl Li
This project follows the all-contributors specification. Contributions of any kind are welcome!