-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run-time feature detection #2
Comments
Once Rust has compile time constants in types, this could get even more awesome I think. |
I'm definitely interested in implementing this before 1.0.0, but I'd like to wait for stdsimd to mature a bit before jumping on it. I'll probably have methods for both static and dynamic dispatch to appease those who absolutely must save a branch. |
It would be great if one could figure out a way of doing the dispatch only once when an iterator is consumed. That is, |
Shouldn't the compiler also have support for this(run-time feature detection)? |
@lilianmoraru |
I'm genuinely curious what the use case for compile-time feature detection (as it is currently implemented?) would even be. Never in my life have I seen a project that provides different binaries depending on the CPU you want to run it on. I probably wouldn't even know which one to pick. |
@AndreKR it's the main way to not have the runtime cost of branching to pick the appropriate instruction set. A lot of (most?) software gets written internally by businesses for the same business, and they know what hardware they target so they don't need multiple binaries, or if they do it's simple like "last-gen" binary and "current-gen" binary. You pick the one closest to the actual CPU you know you'll be running on. |
Currently the vector size and the SIMD instructions to be used are fixed at compile-time. This is a good first step.
It allows me to write an algorithm once, and by changing a compiler-flag generate different versions of this algorithm for different target architectures (with different vector sizes, SIMD instructions, etc.).
I really like to be able to do this at compile-time within the same binary as well, so that I can write:
and monomorphize it for different instruction sets:
That way
input.simd_iter().map(my_generic_algorithm)
could monomorphizemy_generic_algorithm
forSSE
,SSE42
,AVX
, andAVX2
, and do run-time feature detection to detect the best that a given CPU supports at run-time, and then dispatch to that one.The text was updated successfully, but these errors were encountered: