Skip to content

Commit

Permalink
Implemented runtime detection of xop target-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
sayantn authored and Amanieu committed Jul 6, 2024
1 parent d5c4073 commit 2227b97
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/std_detect/src/detect/arch/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,6 @@ features! {
/// MOVBE (Move Data After Swapping Bytes)
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ermsb: "ermsb";
/// ERMSB, Enhanced REP MOVSB and STOSB
@FEATURE: #[unstable(feature = "xop_target_feature", issue = "127208")] xop: "xop";
/// XOP: eXtended Operations (AMD)
}
1 change: 1 addition & 0 deletions crates/std_detect/src/detect/os/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
// These features are available on AMD arch CPUs:
enable(extended_proc_info_ecx, 6, Feature::sse4a);
enable(extended_proc_info_ecx, 21, Feature::tbm);
enable(extended_proc_info_ecx, 11, Feature::xop);
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/std_detect/tests/cpu-detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![cfg_attr(target_arch = "powerpc64", feature(stdarch_powerpc_feature_detection))]
#![cfg_attr(
any(target_arch = "x86", target_arch = "x86_64"),
feature(sha512_sm_x86, x86_amx_intrinsics)
feature(sha512_sm_x86, x86_amx_intrinsics, xop_target_feature)
)]
#![allow(clippy::unwrap_used, clippy::use_debug, clippy::print_stdout)]

Expand Down Expand Up @@ -264,6 +264,7 @@ fn x86_all() {
println!("amx-int8: {:?}", is_x86_feature_detected!("amx-int8"));
println!("amx-fp16: {:?}", is_x86_feature_detected!("amx-fp16"));
println!("amx-complex: {:?}", is_x86_feature_detected!("amx-complex"));
println!("xop: {:?}", is_x86_feature_detected!("xop"));
}

#[test]
Expand Down
4 changes: 3 additions & 1 deletion crates/std_detect/tests/x86-specific.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
stdarch_internal,
avx512_target_feature,
sha512_sm_x86,
x86_amx_intrinsics
x86_amx_intrinsics,
xop_target_feature
)]

extern crate cupid;
Expand Down Expand Up @@ -92,6 +93,7 @@ fn dump() {
println!("amx-int8: {:?}", is_x86_feature_detected!("amx-int8"));
println!("amx-fp16: {:?}", is_x86_feature_detected!("amx-fp16"));
println!("amx-complex: {:?}", is_x86_feature_detected!("amx-complex"));
println!("xop: {:?}", is_x86_feature_detected!("xop"));
}

#[cfg(feature = "std_detect_env_override")]
Expand Down

0 comments on commit 2227b97

Please sign in to comment.