add portable SIMD toggling support for large-scale enterprise deployments

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 18:57:04 +01:00 committed by Nilstrieb
parent b77a117724
commit 83b3b3394c

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]);
}
}