#Generic SIMD Library
The Generic SIMD Library allowers users to write C++ SIMD codes that are portable across different SIMD ISAs.
##Running examples
//HelloSIMD.cpp
#include <iostream>
#include <gsimd.h>
int main (int argc, char* argv[])
{
svec<4,float> v1(1.1, 2.2, 3.3, 4.4);
svec<4,float> v2 = v1 * 2;
std::cout << "Hello World: " << v2 << std::endl;
return 0;
}
Let's use the example above to illustrate some of the basics features of the library:
- The entire generic SIMD library is included from the header file <gsimd.h>.
- Using proper platform-specific compiler flags, the code can be compiled by standard G++ into binaries for different target SIMD architectures.
- In this example, svec<4,float> is the SIMD vector abstraction provided by the library. It represents a vector of 4 floating-point values.
- Most operations on SIMD vectors use standard C++ operators such as "*" and "<<".
##Key features
The library provides:
-
Fixed-lane SIMD vectors. Our SIMD vectors are defined based on the number of elements per vector (fixed-lane) instead of the byte-length of a vector (fixed-width). This is the key diffence between our vector types and the ones defined in platform-specific intrinsics.
We choose fixed-lane vector because it is more natural to SIMDized parallel loops that involve data of different length such as int and double.
We intend to support vectors with arbitrary power-of-two lanes, but currently only 4-element vectors are supported. Vector of 2-, and 8-elements are under development.
-
Portable SIMD programming. The programming interface of the library is completely platform neutral. The library provides mapping from the interface to target SIMD platforms. The current release supports the following target platforms:
- SSE4.2
- VSX for P7
- Scalar emulation for non-SIMD platforms
-
Overloaded C++ semantics on SIMD vectors. We define SIMD vector operations based on semantics of C++ operators instead of platform-specific ISA semantics. This is because the semantics of C++ operators are platform independent. Secondly, C++ operators provide a slightly higher semantics than platform-specific intrinsics and are more natural to program since most users understand C++ operators well.
##More Information