Skip to content
Open
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
15 changes: 11 additions & 4 deletions src/uucore/src/lib/features/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ impl TryFrom<&str> for HardwareFeature {

fn try_from(value: &str) -> Result<Self, Self::Error> {
use HardwareFeature::{Asimd, Avx2, Avx512, Pclmulqdq, Pmull, Sse2};
// TODO: like GNU, accept `PCLMULQDQ` for `Pclmulqdq` and `PMULL` for
Comment thread
AFaria20s marked this conversation as resolved.
Resolved
// `Pmull`.
match value {
"AVX512" | "AVX512F" => Ok(Avx512),
"AVX2" => Ok(Avx2),
"PCLMUL" | "PMULL" => Ok(Pclmulqdq),
"VMULL" => Ok(Pmull),
"PCLMUL" | "PCLMULQDQ" => Ok(Pclmulqdq),
"PMULL" | "VMULL" => Ok(Pmull),
"SSE2" => Ok(Sse2),
"ASIMD" => Ok(Asimd),
_ => Err(InvalidHardwareFeature),
Expand Down Expand Up @@ -371,6 +369,15 @@ mod tests {
assert_eq!(result, expected);
}

#[test]
fn test_parse_disabled_features_polynomial_multiply_names() {
let result = parse_disabled_features("glibc.cpu.hwcaps=-PCLMULQDQ,-PMULL");
assert_eq!(
result,
BTreeSet::from([HardwareFeature::Pclmulqdq, HardwareFeature::Pmull])
);
}

#[test]
fn test_parse_disabled_features_mixed() {
let result = parse_disabled_features("glibc.cpu.hwcaps=-AVX2,SSE2,-AVX512F");
Expand Down
Loading