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

Implement Missing Extended Features #181

Merged
merged 6 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ serde_json = { version = "1.0", optional = true }
termimad = { version = "0.25", optional = true }
clap = { version = "4.2", features = ["derive"], optional = true }

[target.'cfg(unix)'.dev-dependencies]
[dev-dependencies]
core_affinity = "0.8.0"
libc = { version = "0.2", default-features = false }
phf = { version = "0.11", features = ["macros"] }
Expand Down
6 changes: 6 additions & 0 deletions src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ pub fn markdown<R: crate::CpuIdReader>(cpuid: crate::CpuId<R>) {
"AVX512F: AVX-512 foundation instructions",
info.has_avx512f(),
),
RowGen::tuple("AVX512-4NNIW: 4NNIW instructions", info.has_avx512_4nniw()),
RowGen::tuple(
"AVX512-4FMAPS: 4FMAPS instructions",
info.has_avx512_4fmaps(),
),
RowGen::tuple("AMX_BF16: AMX_BF16 instructions", info.has_amx_bf16()),
gz marked this conversation as resolved.
Show resolved Hide resolved
RowGen::tuple(
"AVX512DQ: double & quadword instructions",
info.has_avx512dq(),
Expand Down
59 changes: 57 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@

#[cfg(not(test))]
mod std {
pub use core::ops;

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Coverage

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::ops`

Check warning on line 117 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::ops`
pub use core::option;

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Coverage

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::option`

Check warning on line 118 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `core::option`
}

/// Macro which queries cpuid directly.
Expand Down Expand Up @@ -521,7 +521,7 @@
_eax: res.eax,
ebx: ExtendedFeaturesEbx::from_bits_truncate(res.ebx),
ecx: ExtendedFeaturesEcx::from_bits_truncate(res.ecx),
_edx: res.edx,
edx: ExtendedFeaturesEdx::from_bits_truncate(res.edx),
})
} else {
None
Expand Down Expand Up @@ -3224,7 +3224,7 @@
_eax: u32,
ebx: ExtendedFeaturesEbx,
ecx: ExtendedFeaturesEcx,
_edx: u32,
edx: ExtendedFeaturesEdx,
}

impl ExtendedFeatures {
Expand Down Expand Up @@ -3671,6 +3671,42 @@
pub fn mawau_value(&self) -> u8 {
get_bits(self.ecx.bits(), 17, 21) as u8
}

/// Supports AVX512_4NNIW.
///
/// # Platforms
/// ❌ AMD (reserved) ✅ Intel
#[inline]
pub const fn has_avx512_4nniw(&self) -> bool {
self.edx.contains(ExtendedFeaturesEdx::AVX512_4VNNIW)
}

/// Supports AVX512_4FMAPS.
///
/// # Platforms
/// ❌ AMD (reserved) ✅ Intel
#[inline]
pub const fn has_avx512_4fmaps(&self) -> bool {
self.edx.contains(ExtendedFeaturesEdx::AVX512_4FMAPS)
}

/// Supports AMX_BF16.
///
/// # Platforms
/// ❌ AMD (reserved) ✅ Intel
#[inline]
pub const fn has_amx_bf16(&self) -> bool {
self.edx.contains(ExtendedFeaturesEdx::AMX_BF16)
}

/// Supports AVX_FP16.
///
/// # Platforms
/// ❌ AMD (reserved) ✅ Intel
#[inline]
pub const fn has_avx512_fp16(&self) -> bool {
self.edx.contains(ExtendedFeaturesEdx::AVX512_FP16)
}
}

impl Debug for ExtendedFeatures {
Expand Down Expand Up @@ -3808,6 +3844,25 @@
}
}

bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct ExtendedFeaturesEdx: u32 {
/// Bit 02: AVX512_4VNNIW. (Intel® Xeon Phi™ only).
const AVX512_4VNNIW = 1 << 2;
/// Bit 03: AVX512_4FMAPS. (Intel® Xeon Phi™ only).
const AVX512_4FMAPS = 1 << 3;
/// Bit 22: AMX-BF16. If 1, the processor supports tile computational operations on bfloat16 numbers.
const AMX_BF16 = 1 << 22;
/// Bit 23: AVX512_FP16.
const AVX512_FP16 = 1 << 23;
/// Bit 24: AMX-TILE. If 1, the processor supports tile architecture
const AMX_TILE = 1 << 24;
/// Bit 24: AMX-INT8. If 1, the processor supports tile computational operations on 8-bit integers.
mert-kurttutan marked this conversation as resolved.
Show resolved Hide resolved
const AMX_INT8 = 1 << 25;
}
}

/// Direct cache access info (LEAF=0x09).
///
/// # Platforms
Expand Down
4 changes: 2 additions & 2 deletions src/tests/i5_3337u.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn extended_features() {
_eax: 0,
ebx: ExtendedFeaturesEbx::from_bits_truncate(641),
ecx: ExtendedFeaturesEcx::from_bits_truncate(0),
_edx: 0,
edx: ExtendedFeaturesEdx::from_bits_truncate(0),
};
assert!(tpfeatures._eax == 0);
assert!(tpfeatures.has_fsgsbase());
Expand Down Expand Up @@ -273,7 +273,7 @@ fn extended_features() {
| ExtendedFeaturesEbx::CLFLUSHOPT
| ExtendedFeaturesEbx::PROCESSOR_TRACE,
ecx: ExtendedFeaturesEcx::from_bits_truncate(0),
_edx: 201326592,
edx: ExtendedFeaturesEdx::from_bits_truncate(201326592),
gz marked this conversation as resolved.
Show resolved Hide resolved
};

assert!(tpfeatures2.has_fsgsbase());
Expand Down
Loading