Function multiversioning macro/attribute for Rust.
Add the following to your dependencies in Cargo.toml:
toml
[dependencies]
multiversion = "0.1"
Automatic function multiversioning with the target_clones
attribute, similar to GCC's target_clones
attribute:
```rust
use multiversion::target_clones;
fn square(x: &mut [f32]) { for v in x { *v *= *v; } } ```
Manual function multiversioning with the multiversion!
macro:
```rust
use multiversion::multiversion;
multiversion!{ fn square(x: &mut [f32]) "[x86|x8664]+avx" => squareavx, "x86+sse" => squaresse, default => squaregeneric, }
unsafe fn square_avx(x: &mut [f32]) { for v in x { *v *= *v; } }
unsafe fn square_sse(x: &mut [f32]) { for v in x { *v *= *v; } }
fn square_generic(x: &mut [f32]) { for v in x { *v *= *v; } } ```
Multiversion is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.