From 6fb6cab08eea93b2e028b77aaca2a3b58c42a6f7 Mon Sep 17 00:00:00 2001 From: Richard Winterton Date: Thu, 30 Jan 2025 22:58:07 -0700 Subject: [PATCH 1/7] Update cpuinfo to support AVX10.2 ISA detection --- include/cpuinfo.h | 9 +++++++++ src/x86/isa.c | 7 +++++++ tools/cpuid-dump.c | 9 +++++++++ tools/isa-info.c | 1 + 4 files changed, 26 insertions(+) diff --git a/include/cpuinfo.h b/include/cpuinfo.h index 6eb4b8c3..ea3c1d07 100644 --- a/include/cpuinfo.h +++ b/include/cpuinfo.h @@ -821,6 +821,7 @@ struct cpuinfo_x86_isa { bool avx512_4vnniw; bool avx512_4fmaps; bool avx10_1; + bool avx10_2; bool amx_bf16; bool amx_tile; bool amx_int8; @@ -1444,6 +1445,14 @@ static inline bool cpuinfo_has_x86_avx10_1(void) { #endif } +static inline bool cpuinfo_has_x86_avx10_2(void) { +#if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 + return cpuinfo_isa.avx10_2; +#else + return false; +#endif +} + static inline bool cpuinfo_has_x86_hle(void) { #if CPUINFO_ARCH_X86 || CPUINFO_ARCH_X86_64 return cpuinfo_isa.hle; diff --git a/src/x86/isa.c b/src/x86/isa.c index 47a6afa3..c8b1c997 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -46,6 +46,8 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( (max_base_index >= 7) ? cpuidex(7, 0) : (struct cpuid_regs){0, 0, 0, 0}; const struct cpuid_regs structured_feature_info1 = (max_base_index >= 7) ? cpuidex(7, 1) : (struct cpuid_regs){0, 0, 0, 0}; + const struct cpuid_regs structured_feature_info2 = + (max_base_index >= 7) ? cpuidex(0x24, 0) : (struct cpuid_regs){0, 0, 0, 0}; const uint32_t processor_capacity_info_index = UINT32_C(0x80000008); const struct cpuid_regs processor_capacity_info = (max_extended_index >= processor_capacity_info_index) @@ -434,6 +436,11 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( */ isa.avx10_1 = avx512_regs && !!(structured_feature_info1.edx & UINT32_C(0x00080000)); + /* + * AVX 10.2 instructions: + */ + isa.avx10_2 = !!((structured_feature_info2.ebx & UINT32_C(0x0000007F)) >= 2) && isa.avx10_1; + /* * AVX512PF instructions: * - Intel: ebx[bit 26] in structured feature info (ecx = 0). diff --git a/tools/cpuid-dump.c b/tools/cpuid-dump.c index 87c403d5..1a65510f 100644 --- a/tools/cpuid-dump.c +++ b/tools/cpuid-dump.c @@ -123,6 +123,15 @@ int main(int argc, char** argv) { print_cpuidex(regs, eax, ecx); } break; + case UINT32_C(0x00000024): + for (uint32_t ecx = 0; ecx <= max_socid_index; ecx++) { + const struct cpuid_regs regs = cpuidex(eax, ecx); + if (ecx == 0) { + max_socid_index = regs.eax; + } + print_cpuidex(regs, eax, ecx); + } + break; default: print_cpuid(cpuidex(eax, 0), eax); break; diff --git a/tools/isa-info.c b/tools/isa-info.c index 96bcdd7a..21f94a5f 100644 --- a/tools/isa-info.c +++ b/tools/isa-info.c @@ -71,6 +71,7 @@ int main(int argc, char** argv) { printf("\tAVX512_4VNNIW: %s\n", cpuinfo_has_x86_avx512_4vnniw() ? "yes" : "no"); printf("\tAVX512_4FMAPS: %s\n", cpuinfo_has_x86_avx512_4fmaps() ? "yes" : "no"); printf("\tAVX10_1: %s\n", cpuinfo_has_x86_avx10_1() ? "yes" : "no"); + printf("\tAVX10_2: %s\n", cpuinfo_has_x86_avx10_2() ? "yes" : "no"); printf("\tAMX_BF16: %s\n", cpuinfo_has_x86_amx_bf16() ? "yes" : "no"); printf("\tAMX_TILE: %s\n", cpuinfo_has_x86_amx_tile() ? "yes" : "no"); printf("\tAMX_INT8: %s\n", cpuinfo_has_x86_amx_int8() ? "yes" : "no"); From 0c7c32f74c09b765be338b1890f3a2d337ee5273 Mon Sep 17 00:00:00 2001 From: Richard Winterton Date: Thu, 30 Jan 2025 23:17:31 -0700 Subject: [PATCH 2/7] Update isa.c This is the version for the AVX 10 in this case we are testing for AVX 10.2 but it covers the whole 8 bits. --- src/x86/isa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x86/isa.c b/src/x86/isa.c index c8b1c997..36383f52 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -439,7 +439,7 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * AVX 10.2 instructions: */ - isa.avx10_2 = !!((structured_feature_info2.ebx & UINT32_C(0x0000007F)) >= 2) && isa.avx10_1; + isa.avx10_2 = !!((structured_feature_info2.ebx & UINT32_C(0x000000FF)) >= 2) && isa.avx10_1; /* * AVX512PF instructions: From afc175a2086ece5e43d6bd01f83a5d6cc320b617 Mon Sep 17 00:00:00 2001 From: Richard Winterton Date: Thu, 30 Jan 2025 23:27:30 -0700 Subject: [PATCH 3/7] Update isa.c added comments to AVX 10 detection for both AVX10.1 and AVX10.2 --- src/x86/isa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/x86/isa.c b/src/x86/isa.c index 36383f52..37c62172 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -432,12 +432,14 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( isa.avx512f = avx512_regs && !!(structured_feature_info0.ebx & UINT32_C(0x00010000)); /* - * AVX 10.1 instructions: + * AVX 10.1 instructions: avx 10 isa supported. + * - Intel: edx[bit 19] in structured feature info (ecx = 1). */ isa.avx10_1 = avx512_regs && !!(structured_feature_info1.edx & UINT32_C(0x00080000)); /* - * AVX 10.2 instructions: + * AVX 10.2 instructions: avx 10 version information. + * - Intel: ebx[bits 0-7] in structured features info (eax = 24 ecx = 0). */ isa.avx10_2 = !!((structured_feature_info2.ebx & UINT32_C(0x000000FF)) >= 2) && isa.avx10_1; From 887531f15836fdb42089fd12f53d65e4318f8c04 Mon Sep 17 00:00:00 2001 From: Richard Winterton Date: Fri, 31 Jan 2025 09:27:04 -0700 Subject: [PATCH 4/7] Update isa.c per Frank's comment of unneeded !! for comparing version number >= 2 --- src/x86/isa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x86/isa.c b/src/x86/isa.c index 37c62172..d56982fe 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -441,7 +441,7 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( * AVX 10.2 instructions: avx 10 version information. * - Intel: ebx[bits 0-7] in structured features info (eax = 24 ecx = 0). */ - isa.avx10_2 = !!((structured_feature_info2.ebx & UINT32_C(0x000000FF)) >= 2) && isa.avx10_1; + isa.avx10_2 = ((structured_feature_info2.ebx & UINT32_C(0x000000FF)) >= 2) && isa.avx10_1; /* * AVX512PF instructions: From f375d2fdd676bf24d5a8afbff2e7b6186db992d0 Mon Sep 17 00:00:00 2001 From: Richard Winterton Date: Mon, 3 Feb 2025 15:04:58 -0700 Subject: [PATCH 5/7] Update isa.c fixed white spaces changing incorrect tab and space for alignment. --- src/x86/isa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x86/isa.c b/src/x86/isa.c index d56982fe..30be4538 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -46,7 +46,7 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( (max_base_index >= 7) ? cpuidex(7, 0) : (struct cpuid_regs){0, 0, 0, 0}; const struct cpuid_regs structured_feature_info1 = (max_base_index >= 7) ? cpuidex(7, 1) : (struct cpuid_regs){0, 0, 0, 0}; - const struct cpuid_regs structured_feature_info2 = + const struct cpuid_regs structured_feature_info2 = (max_base_index >= 7) ? cpuidex(0x24, 0) : (struct cpuid_regs){0, 0, 0, 0}; const uint32_t processor_capacity_info_index = UINT32_C(0x80000008); From 501b34bc067edaeae13d695105876bfeb1410c4e Mon Sep 17 00:00:00 2001 From: Richard Winterton Date: Mon, 3 Feb 2025 15:10:22 -0700 Subject: [PATCH 6/7] Update isa.c Update spaces to tabs to fix alignment issues. --- src/x86/isa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/x86/isa.c b/src/x86/isa.c index 30be4538..7f466b78 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -433,14 +433,14 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( /* * AVX 10.1 instructions: avx 10 isa supported. - * - Intel: edx[bit 19] in structured feature info (ecx = 1). + * - Intel: edx[bit 19] in structured feature info (ecx = 1). */ isa.avx10_1 = avx512_regs && !!(structured_feature_info1.edx & UINT32_C(0x00080000)); /* * AVX 10.2 instructions: avx 10 version information. - * - Intel: ebx[bits 0-7] in structured features info (eax = 24 ecx = 0). - */ + * - Intel: ebx[bits 0-7] in structured features info (eax = 24 ecx = 0). + */ isa.avx10_2 = ((structured_feature_info2.ebx & UINT32_C(0x000000FF)) >= 2) && isa.avx10_1; /* From 05dd959fa26c7e68fa229495a35f55e06a3b9655 Mon Sep 17 00:00:00 2001 From: Richard Winterton Date: Mon, 3 Feb 2025 15:37:06 -0700 Subject: [PATCH 7/7] Update isa.c fix the spaces to tab at line 50 to fix indenting issue. --- src/x86/isa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/x86/isa.c b/src/x86/isa.c index 7f466b78..377583b3 100644 --- a/src/x86/isa.c +++ b/src/x86/isa.c @@ -47,7 +47,7 @@ struct cpuinfo_x86_isa cpuinfo_x86_detect_isa( const struct cpuid_regs structured_feature_info1 = (max_base_index >= 7) ? cpuidex(7, 1) : (struct cpuid_regs){0, 0, 0, 0}; const struct cpuid_regs structured_feature_info2 = - (max_base_index >= 7) ? cpuidex(0x24, 0) : (struct cpuid_regs){0, 0, 0, 0}; + (max_base_index >= 7) ? cpuidex(0x24, 0) : (struct cpuid_regs){0, 0, 0, 0}; const uint32_t processor_capacity_info_index = UINT32_C(0x80000008); const struct cpuid_regs processor_capacity_info = (max_extended_index >= processor_capacity_info_index)