Hi all,
I have just released multiversion 0.5.0, the first version I consider "production ready".
This crate provides attribute macros for function multiversioning. In short, function multiversioning is when you compile different versions of a function for particular target platforms (such as Intel AVX or Arm Neon) and select the appropriate version at runtime. Commonly used with SIMD, function multiversioning allows runtime performance improvements on some platforms while maintaining compatibility with others.
A simple example of a function that squares a slice that automatically vectorizes using AVX and Neon:
#[multiversion::multiversion]
#[clone(target = "[x86|x86_64]+avx")]
#[clone(target = "arm+neon")]
fn square(x: &mut [f32]) {
for v in x {
*v *= *v;
}
}
square
is compiled both generically and for the AVX or Neon targets, depending on architecture. Calling square
the first time performs CPU feature detection and selects between one of the possible function versions. Subsequent calls do not need to repeat feature detection, and simply perform an indirect function call.
Any comments or feature requests would be appreciated!