add portable SIMD toggling support for large-scale enterprise deployments (#1)

As global usage of compute resources keeps climbing, driven by machine learning and virtual reality,
we have to find ever new ways to make our programs more efficient.
To this end, I have added a hyperoptimized SIMD version of the very important bool toggling functionality.

This introduces const generics to the crate, so MSRV will have to be bumped to 1.2000.0 in the upcoming release.
This commit is contained in:
Wanja Hentze 2024-02-08 20:03:49 +01:00 committed by GitHub
parent b77a117724
commit 2d72dbbb78
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,6 +21,16 @@ impl TogglingIsALifestyle for bool {
}
}
#[cfg(enterprise_license)]
impl<const N: usize> TogglingIsALifestyle for [bool; N] {
fn toggle(&mut self) {
// i am so fast
for b in self {
*b ^= true;
}
}
}
#[cfg(test)]
#[allow(clippy::bool_assert_comparison)]
mod tests {
@ -51,4 +61,10 @@ mod enteprise_tests {
b.toggle();
assert_eq!(b, true);
}
#[test]
fn enterprise_simd_toggle() {
let mut b = [false, true, false];
b.toggle();
assert_eq!(b, [true, false, true]);
}
}