Performance: SIMD, Vectorization and Performance Tuning [video]
youtube.com
youtube.com
Here's a list of my requirements:
1. Built-in types for floating point and integer vectors (compile time constant width). E.g. float32x4_t or int64x2_t. Maybe have some matrix types too.
2. Normal infix operators for arithmetic (+, -, /). You can do this with C [1]. Built-in syntax for vector shuffles (can't do this in C) [2].
3. Compile time polymorphism to make vector-width agnostic code. If you write sin4f and sin8f (in C), they are line-by-line identical except for types. You should be able to write a single sin() function that works for any vector width
4. A standard library that has all the usual libm math functions (sin, cos, log, exp, asin, atanh, etc). I could do with less-than-perfect precision for performance (at least if -ffast-math is enabled)
5. A standard library for some basic vector and matrix operations for static-sized vectors and matrices. E.g. dot product, matrixmatrix product, matrixvector product, inverse matrix, etc.
I put some hope on Rust, which has been working on some SIMD stuff. But the current iteration doesn't fulfill most of my requirements.
[0] https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
[1] You can do this:
typedef float float32x4_t __attribute__((vector_size(16)));
float32x4_t a = { 1, 2, 3, 4 }, b = { 5, 6, 7, 8 }, c = (a+b)*(a-b);
[2] You'll need some #ifdefs around __builtin_shuffle (GCC) and __builtin_shufflevector (Clang). Something like my_vec.xxyy, similar to GLSL, would be nicer.Another option in the area is OpenMP. It has a wider base of users and contributors, but I think the abstractions are not as good.
If you can move to a completely new programming language, then Chapel is built to easily scale up across large supercomputer clusters.
I want explicit SIMD with 2/4/8/16 wide vectors, primarily to be used with 3d graphics and physics calculations.
> libsimdpp is a portable header-only zero-overhead C++ wrapper around single-instruction multiple-data (SIMD) intrinsics found in many compilers. The library presents a single interface over several instruction sets in such a way that the same source code may be compiled for different instruction sets. The resulting object files then may be hooked into internal dynamic dispatch mechanism.
> The library resolves differences between instruction sets by implementing the missing functionality as a combination of several intrinsics. Moreover, the library supplies a lot of additional, commonly used functionality, such as various variants of matrix transpositions, interleaving loads/stores, optimized compile-time shuffling instructions, etc. Each of these are implemented in the most efficient manner for the target instruction set. Finally, it's possible to fall back to native intrinsics when necessary, without compromising maintanability.
It might be great for some uses, but it's not what I'm looking for.
https://msdn.microsoft.com/en-us/library/dn858218(v=vs.111)....
Intel has contributed to the @simd macro in the language, and I think that if you just use the builtin type it "knows what to do". You do have to prefix with the @simd macro (feels similar to the "#pragma"s talked about in the talk)
https://software.intel.com/en-us/articles/vectorization-in-j...
OpenCL is still missing the vector width polymorphism. The others are more or less covered.
This is a matter of language standardization and some implementation work. I'm not aware of anyone working on this.