#[cfg(all(target_arch = "x86_64", feature = "avx2", target_feature = "avx2"))]
#[must_use]
#[expect(
clippy::missing_const_for_fn,
reason = "must be compatible with non-avx2 version"
)]
#[inline]
pub fn has_avx2() -> bool {
true
}
#[cfg(all(target_arch = "x86_64", feature = "avx2", not(target_feature = "avx2")))]
#[must_use]
#[inline]
pub fn has_avx2() -> bool {
is_x86_feature_detected!("avx2")
}
#[cfg(not(all(target_arch = "x86_64", feature = "avx2")))]
#[must_use]
#[expect(
clippy::missing_const_for_fn,
reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx2() -> bool {
false
}
#[cfg(all(
target_arch = "x86_64",
feature = "avx512",
all(
target_feature = "avx512f",
target_feature = "avx512cd",
target_feature = "avx512vl",
target_feature = "avx512dq",
target_feature = "avx512bw"
)
))]
#[must_use]
#[expect(
clippy::missing_const_for_fn,
reason = "must be compatible with non-avx2 version"
)]
#[inline]
pub fn has_avx512_skylake() -> bool {
true
}
#[cfg(all(
target_arch = "x86_64",
feature = "avx512",
not(all(
target_feature = "avx512f",
target_feature = "avx512cd",
target_feature = "avx512vl",
target_feature = "avx512dq",
target_feature = "avx512bw"
))
))]
#[must_use]
#[inline]
pub fn has_avx512_skylake() -> bool {
is_x86_feature_detected!("avx512f")
&& is_x86_feature_detected!("avx512cd")
&& is_x86_feature_detected!("avx512vl")
&& is_x86_feature_detected!("avx512dq")
&& is_x86_feature_detected!("avx512bw")
}
#[cfg(not(all(target_arch = "x86_64", feature = "avx512")))]
#[must_use]
#[expect(
clippy::missing_const_for_fn,
reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx512_skylake() -> bool {
false
}
#[cfg(all(
target_arch = "x86_64",
feature = "avx512",
all(
target_feature = "avx512vpopcntdq",
target_feature = "avx512ifma",
target_feature = "avx512vbmi",
target_feature = "avx512vnni",
target_feature = "avx512vbmi2",
target_feature = "avx512bitalg",
target_feature = "vpclmulqdq",
target_feature = "gfni",
target_feature = "vaes"
)
))]
#[must_use]
#[inline]
pub fn has_avx512_znver4() -> bool {
has_avx512_skylake()
}
#[cfg(all(
target_arch = "x86_64",
feature = "avx512",
not(all(
target_feature = "avx512vpopcntdq",
target_feature = "avx512ifma",
target_feature = "avx512vbmi",
target_feature = "avx512vnni",
target_feature = "avx512vbmi2",
target_feature = "avx512bitalg",
target_feature = "vpclmulqdq",
target_feature = "gfni",
target_feature = "vaes"
))
))]
#[must_use]
#[inline]
pub fn has_avx512_znver4() -> bool {
has_avx512_skylake()
&& is_x86_feature_detected!("avx512vpopcntdq")
&& is_x86_feature_detected!("avx512ifma")
&& is_x86_feature_detected!("avx512vbmi")
&& is_x86_feature_detected!("avx512vnni")
&& is_x86_feature_detected!("avx512vbmi2")
&& is_x86_feature_detected!("avx512bitalg")
&& is_x86_feature_detected!("vpclmulqdq")
&& is_x86_feature_detected!("gfni")
&& is_x86_feature_detected!("vaes")
}
#[cfg(not(all(target_arch = "x86_64", feature = "avx512")))]
#[must_use]
#[expect(
clippy::missing_const_for_fn,
reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx512_znver4() -> bool {
false
}
#[cfg(all(
target_arch = "x86_64",
feature = "avx512",
target_feature = "avx512vp2intersect"
))]
#[must_use]
#[inline]
pub fn has_avx512_znver5() -> bool {
has_avx512_znver4()
}
#[cfg(all(
target_arch = "x86_64",
feature = "avx512",
not(target_feature = "avx512vp2intersect")
))]
#[must_use]
#[inline]
pub fn has_avx512_znver5() -> bool {
has_avx512_znver4() && is_x86_feature_detected!("avx512vp2intersect")
}
#[cfg(not(all(target_arch = "x86_64", feature = "avx512")))]
#[must_use]
#[expect(
clippy::missing_const_for_fn,
reason = "must be compatible with non-avx2 version"
)]
#[allow(dead_code)]
#[inline]
pub fn has_avx512_znver5() -> bool {
false
}