Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable AVX-512BW and AVX-512DQ target features in AVX-512 dispatch #629

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rten-simd/src/isa_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub mod macos {
// avx512f, as that is implied if the extensions are supported.
sysctl_bool(c"hw.optional.avx512vl").unwrap_or(false)
&& sysctl_bool(c"hw.optional.avx512bw").unwrap_or(false)
&& sysctl_bool(c"hw.optional.avx512dq").unwrap_or(false)
})
}

Expand Down Expand Up @@ -79,6 +80,7 @@ pub mod macos {
/// - AVX512F
/// - AVX512VL
/// - AVX512BW
/// - AVX512DQ
///
/// These features are available on Skylake (2016) and later.
/// See <https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#AVX-512_CPU_compatibility_table>.
Expand All @@ -90,6 +92,7 @@ pub fn is_avx512_supported() -> bool {
if is_x86_feature_detected!("avx512f")
&& is_x86_feature_detected!("avx512vl")
&& is_x86_feature_detected!("avx512bw")
&& is_x86_feature_detected!("avx512dq")
{
true
} else {
Expand Down
4 changes: 4 additions & 0 deletions rten-simd/src/safe/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ pub fn dispatch<Op: SimdOp>(op: Op) -> Op::Output {
{
#[cfg(feature = "avx512")]
{
// The target features enabled here must match those tested for by `Avx512Isa::new`.
#[target_feature(enable = "avx512f")]
#[target_feature(enable = "avx512vl")]
#[target_feature(enable = "avx512bw")]
#[target_feature(enable = "avx512dq")]
unsafe fn dispatch_avx512<Op: SimdOp>(isa: impl Isa, op: Op) -> Op::Output {
op.eval(isa)
}
Expand All @@ -49,6 +52,7 @@ pub fn dispatch<Op: SimdOp>(op: Op) -> Op::Output {
}
}

// The target features enabled here must match those tested for by `Avx2Isa::new`.
#[target_feature(enable = "avx2")]
#[target_feature(enable = "avx")]
#[target_feature(enable = "fma")]
Expand Down