Many languages such as C or even C++ or C# or Java have no natively supported vector (SIMD) types or functionality. In such languages, one would have to either use non-standard extensions or third-party libraries to access vector types/instructions, or make due without them and just hope that their compiler is smart enough to auto-vectorize their code.
Parallelizing calculations can be a huge performance win, by using vector instructions that perform on multiple values at the same time instead of serial instructions that perform the calculations one at a time.
I cannot see how:
- It would be non-trivial for a compiler or runtime to check if vector instructions are available on the targeted processor and if not then simply fallback on non-vector instructions.
- Auto-vectorized code would be as dependable as hand-vectorized code.
- Semantics would differ that much on various processors, as vector types are just N of some type that can be operated on with arithmetic operators similar to regular types.
Why do many languages not provide a standard method to hand-vectorize code? Are there other reasons I am not considering? One could compare the hypothetical standardized SIMD types to optimization hints such as the C register
or inline
keyword; just a way to make vectorizable calculations easily identifiable to compilers.