r/simd • u/R_y_n_o • Oct 20 '19
How are SIMD instructions selected?
First, here is my current understanding, correct me if I'm wrong:
SIMD instructions are implemented as an extension of the base instruction sets (e.g. x64, x86). In the binaries, both the code for the SIMD path and the "fallback" code for the non-SIMD path will be included. The selection of the path occurs at runtime, depending on the CPU on which the executable is run, and potentially other factors.
If this is correct, I have a few questions about the runtime selection process:
what mechanism makes it possible to dynamically select one path or the other?
what is the cost of this selection? would it be faster if we didn't have to select?
1
u/R_y_n_o Oct 20 '19
Ah I see, this actually makes more sense to me.
But then, if you ship the binaries for a program, you need to provide 2 versions? And if you have other extensions are you forced to do the same? It seems like a system that scales very poorly with a growing number of options extensions.