mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Merge pull request #4376 from Barinzaya/sysinfo-avx512
core:sys/info AVX-512 CPU Features
This commit is contained in:
@@ -28,6 +28,23 @@ CPU_Feature :: enum u64 {
|
|||||||
ssse3, // Supplemental streaming SIMD extension 3
|
ssse3, // Supplemental streaming SIMD extension 3
|
||||||
sse41, // Streaming SIMD extension 4 and 4.1
|
sse41, // Streaming SIMD extension 4 and 4.1
|
||||||
sse42, // Streaming SIMD extension 4 and 4.2
|
sse42, // Streaming SIMD extension 4 and 4.2
|
||||||
|
|
||||||
|
avx512bf16, // Vector Neural Network Instructions supporting bfloat16
|
||||||
|
avx512bitalg, // Bit Algorithms
|
||||||
|
avx512bw, // Byte and Word instructions
|
||||||
|
avx512cd, // Conflict Detection instructions
|
||||||
|
avx512dq, // Doubleword and Quadword instructions
|
||||||
|
avx512er, // Exponential and Reciprocal instructions
|
||||||
|
avx512f, // Foundation
|
||||||
|
avx512fp16, // Vector 16-bit float instructions
|
||||||
|
avx512ifma, // Integer Fused Multiply Add
|
||||||
|
avx512pf, // Prefetch instructions
|
||||||
|
avx512vbmi, // Vector Byte Manipulation Instructions
|
||||||
|
avx512vbmi2, // Vector Byte Manipulation Instructions 2
|
||||||
|
avx512vl, // Vector Length extensions
|
||||||
|
avx512vnni, // Vector Neural Network Instructions
|
||||||
|
avx512vp2intersect, // Vector Pair Intersection to a Pair of Mask Registers
|
||||||
|
avx512vpopcntdq, // Vector Population Count for Doubleword and Quadword
|
||||||
}
|
}
|
||||||
|
|
||||||
CPU_Features :: distinct bit_set[CPU_Feature; u64]
|
CPU_Features :: distinct bit_set[CPU_Feature; u64]
|
||||||
@@ -82,9 +99,11 @@ init_cpu_features :: proc "c" () {
|
|||||||
//
|
//
|
||||||
// See: crbug.com/375968
|
// See: crbug.com/375968
|
||||||
os_supports_avx := false
|
os_supports_avx := false
|
||||||
|
os_supports_avx512 := false
|
||||||
if .os_xsave in set && is_set(26, ecx1) {
|
if .os_xsave in set && is_set(26, ecx1) {
|
||||||
eax, _ := xgetbv(0)
|
eax, _ := xgetbv(0)
|
||||||
os_supports_avx = is_set(1, eax) && is_set(2, eax)
|
os_supports_avx = is_set(1, eax) && is_set(2, eax)
|
||||||
|
os_supports_avx512 = is_set(5, eax) && is_set(6, eax) && is_set(7, eax)
|
||||||
}
|
}
|
||||||
if os_supports_avx {
|
if os_supports_avx {
|
||||||
try_set(&set, .avx, 28, ecx1)
|
try_set(&set, .avx, 28, ecx1)
|
||||||
@@ -94,11 +113,37 @@ init_cpu_features :: proc "c" () {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ebx7, _, _ := cpuid(7, 0)
|
_, ebx7, ecx7, edx7 := cpuid(7, 0)
|
||||||
try_set(&set, .bmi1, 3, ebx7)
|
try_set(&set, .bmi1, 3, ebx7)
|
||||||
if os_supports_avx {
|
if os_supports_avx {
|
||||||
try_set(&set, .avx2, 5, ebx7)
|
try_set(&set, .avx2, 5, ebx7)
|
||||||
}
|
}
|
||||||
|
if os_supports_avx512 {
|
||||||
|
try_set(&set, .avx512f, 16, ebx7)
|
||||||
|
try_set(&set, .avx512dq, 17, ebx7)
|
||||||
|
try_set(&set, .avx512ifma, 21, ebx7)
|
||||||
|
try_set(&set, .avx512pf, 26, ebx7)
|
||||||
|
try_set(&set, .avx512er, 27, ebx7)
|
||||||
|
try_set(&set, .avx512cd, 28, ebx7)
|
||||||
|
try_set(&set, .avx512bw, 30, ebx7)
|
||||||
|
|
||||||
|
// XMM/YMM are also required for 128/256-bit instructions
|
||||||
|
if os_supports_avx {
|
||||||
|
try_set(&set, .avx512vl, 31, ebx7)
|
||||||
|
}
|
||||||
|
|
||||||
|
try_set(&set, .avx512vbmi, 1, ecx7)
|
||||||
|
try_set(&set, .avx512vbmi2, 6, ecx7)
|
||||||
|
try_set(&set, .avx512vnni, 11, ecx7)
|
||||||
|
try_set(&set, .avx512bitalg, 12, ecx7)
|
||||||
|
try_set(&set, .avx512vpopcntdq, 14, ecx7)
|
||||||
|
|
||||||
|
try_set(&set, .avx512vp2intersect, 8, edx7)
|
||||||
|
try_set(&set, .avx512fp16, 23, edx7)
|
||||||
|
|
||||||
|
eax7_1, _, _, _ := cpuid(7, 1)
|
||||||
|
try_set(&set, .avx512bf16, 5, eax7_1)
|
||||||
|
}
|
||||||
try_set(&set, .bmi2, 8, ebx7)
|
try_set(&set, .bmi2, 8, ebx7)
|
||||||
try_set(&set, .erms, 9, ebx7)
|
try_set(&set, .erms, 9, ebx7)
|
||||||
try_set(&set, .rdseed, 18, ebx7)
|
try_set(&set, .rdseed, 18, ebx7)
|
||||||
|
|||||||
Reference in New Issue
Block a user