floating_distance/
simd.rs1use cfg_if::cfg_if;
2
3#[macro_export]
20macro_rules! auto_lane_count {
21 ($scalar: ty) => {{
22 cfg_if::cfg_if! {
23 if #[cfg(feature = "simd")] {
24 512 / 8 / std::mem::size_of::<$scalar>()
25 } else {
26 1
27 }
28 }
29 }}
30}
31
32cfg_if! {
33if #[cfg(feature = "simd")] {
34 pub (crate) use std::simd::{
35 LaneCount,
36 Simd,
37 SimdElement,
38 SimdFloat,
39 SupportedLaneCount,
40 };
41
42 pub type AutoLaneCount<S> = LaneCount<{ auto_lane_count!(S) }>;
44 pub type AutoSimd<S> = Simd<S, { auto_lane_count!(S) }>;
46 pub trait AutoSimdElement: SimdElement {}
48 pub trait AutoSimdFloat: SimdFloat {}
50 pub trait AutoSupportedLaneCount: SupportedLaneCount {}
52
53 impl<S: SimdElement> AutoSimdElement for S {}
54 impl<S: SimdFloat> AutoSimdFloat for S {}
55 impl<S: SupportedLaneCount> AutoSupportedLaneCount for S {}
56
57} else {
58 pub type AutoLaneCount<S> = S;
60 pub type AutoSimd<S> = S;
62 pub trait AutoSimdElement {}
64 pub trait AutoSimdFloat {
66 type Scalar;
68 }
69 pub trait AutoSupportedLaneCount {}
71
72 impl<S> AutoSimdElement for S {}
73 impl<P> AutoSimdFloat for P { type Scalar = P; }
74 impl<S> AutoSupportedLaneCount for AutoLaneCount<S> {}
75}
76}