use diskann_wide::{Architecture, Const, SIMDFloat, SIMDMask, SIMDVector};
pub(super) const LANES: usize = 16;
pub(super) trait F32Vector<A: Architecture> {
type Vector;
}
impl<A: Architecture> F32Vector<A> for Const<4> {
type Vector = A::f32x4;
}
impl<A: Architecture> F32Vector<A> for Const<8> {
type Vector = A::f32x8;
}
impl<A: Architecture> F32Vector<A> for Const<16> {
type Vector = A::f32x16;
}
type DefaultVector<A> = <Const<LANES> as F32Vector<A>>::Vector;
pub(super) trait Simd: Architecture {
type Vector: SIMDVector<Arch = Self, Scalar = f32, ConstLanes = Const<LANES>> + SIMDFloat;
fn active_lanes(mask: <Self::Vector as SIMDVector>::Mask) -> u64;
}
impl<A> Simd for A
where
A: Architecture,
DefaultVector<A>: SIMDVector<Arch = A, Scalar = f32, ConstLanes = Const<LANES>> + SIMDFloat,
u64: From<
<<<DefaultVector<A> as SIMDVector>::Mask as SIMDMask>::BitMask as SIMDMask>::Underlying,
>,
{
type Vector = DefaultVector<A>;
#[inline(always)]
fn active_lanes(mask: <Self::Vector as SIMDVector>::Mask) -> u64 {
u64::from(mask.bitmask().to_underlying())
}
}