use cfg_if::cfg_if;
#[macro_export]
macro_rules! auto_lane_count {
($scalar: ty) => {{
cfg_if::cfg_if! {
if #[cfg(feature = "simd")] {
512 / 8 / std::mem::size_of::<$scalar>()
} else {
1
}
}
}}
}
cfg_if! {
if #[cfg(feature = "simd")] {
pub (crate) use std::simd::{
LaneCount,
Simd,
SimdElement,
SimdFloat,
SupportedLaneCount,
};
pub type AutoLaneCount<S> = LaneCount<{ auto_lane_count!(S) }>;
pub type AutoSimd<S> = Simd<S, { auto_lane_count!(S) }>;
pub trait AutoSimdElement: SimdElement {}
pub trait AutoSimdFloat: SimdFloat {}
pub trait AutoSupportedLaneCount: SupportedLaneCount {}
impl<S: SimdElement> AutoSimdElement for S {}
impl<S: SimdFloat> AutoSimdFloat for S {}
impl<S: SupportedLaneCount> AutoSupportedLaneCount for S {}
} else {
pub type AutoLaneCount<S> = S;
pub type AutoSimd<S> = S;
pub trait AutoSimdElement {}
pub trait AutoSimdFloat {
type Scalar;
}
pub trait AutoSupportedLaneCount {}
impl<S> AutoSimdElement for S {}
impl<P> AutoSimdFloat for P { type Scalar = P; }
impl<S> AutoSupportedLaneCount for AutoLaneCount<S> {}
}
}