From faae86fba2c13ce617cc1a3f0351221643b4b438 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 4 Nov 2021 20:35:41 +0100 Subject: [PATCH 1/2] Add CPUIDs for Alder Lake and some other recent Intel cpus --- cpuid_x86.c | 188 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 138 insertions(+), 50 deletions(-) diff --git a/cpuid_x86.c b/cpuid_x86.c index 874acea80..72e95214e 100644 --- a/cpuid_x86.c +++ b/cpuid_x86.c @@ -1,3 +1,4 @@ +//{ /*********************************************************************/ /* Copyright 2009, 2010 The University of Texas at Austin. */ /* All rights reserved. */ @@ -1455,7 +1456,6 @@ int get_cpuname(void){ return CPUTYPE_NEHALEM; } break; - case 9: case 8: switch (model) { case 12: // Tiger Lake @@ -1475,30 +1475,70 @@ int get_cpuname(void){ return CPUTYPE_SANDYBRIDGE; else return CPUTYPE_NEHALEM; - } - case 10: //family 6 exmodel 10 - switch (model) { - case 5: // Comet Lake H and S - case 6: // Comet Lake U - if(support_avx2()) - return CPUTYPE_HASWELL; - if(support_avx()) - return CPUTYPE_SANDYBRIDGE; - else - return CPUTYPE_NEHALEM; - case 7: // Rocket Lake - if(support_avx512()) + case 15: // Sapphire Rapids + if(support_avx512_bf16()) + return CPUTYPE_COOPERLAKE; + if(support_avx512()) return CPUTYPE_SKYLAKEX; if(support_avx2()) return CPUTYPE_HASWELL; if(support_avx()) return CPUTYPE_SANDYBRIDGE; else - return CPUTYPE_NEHALEM; - } - break; - } + return CPUTYPE_NEHALEM; + } break; + case 9: + switch (model) { + case 7: // Alder Lake desktop + case 10: // Alder Lake mobile + if(support_avx2()) + return CPUTYPE_HASWELL; + if(support_avx()) + return CPUTYPE_SANDYBRIDGE; + else + return CPUTYPE_NEHALEM; + case 13: // Ice Lake NNPI + if(support_avx512()) + return CPUTYPE_SKYLAKEX; + if(support_avx2()) + return CPUTYPE_HASWELL; + if(support_avx()) + return CPUTYPE_SANDYBRIDGE; + else + return CPUTYPE_NEHALEM; + case 14: // Kaby Lake and refreshes + if(support_avx2()) + return CPUTYPE_HASWELL; + if(support_avx()) + return CPUTYPE_SANDYBRIDGE; + else + return CPUTYPE_NEHALEM; + } + break; + case 10: //family 6 exmodel 10 + switch (model) { + case 5: // Comet Lake H and S + case 6: // Comet Lake U + if(support_avx2()) + return CPUTYPE_HASWELL; + if(support_avx()) + return CPUTYPE_SANDYBRIDGE; + else + return CPUTYPE_NEHALEM; + case 7: // Rocket Lake + if(support_avx512()) + return CPUTYPE_SKYLAKEX; + if(support_avx2()) + return CPUTYPE_HASWELL; + if(support_avx()) + return CPUTYPE_SANDYBRIDGE; + else + return CPUTYPE_NEHALEM; + } + break; + } + break; case 0x7: return CPUTYPE_ITANIUM; case 0xf: @@ -2069,32 +2109,7 @@ int get_coretype(void){ return CORE_NEHALEM; } break; - case 10: - switch (model) { - case 5: // Comet Lake H and S - case 6: // Comet Lake U - if(support_avx()) - #ifndef NO_AVX2 - return CORE_HASWELL; - #else - return CORE_SANDYBRIDGE; - #endif - else - return CORE_NEHALEM; - case 7:// Rocket Lake -#ifndef NO_AVX512 - if(support_avx512()) - return CORE_SKYLAKEX; -#endif -#ifndef NO_AVX2 - if(support_avx2()) - return CORE_HASWELL; -#endif - if(support_avx()) - return CORE_SANDYBRIDGE; - else - return CORE_NEHALEM; - } + case 5: switch (model) { case 6: @@ -2148,6 +2163,7 @@ int get_coretype(void){ return CORE_NEHALEM; } break; + case 6: if (model == 6) #ifndef NO_AVX512 @@ -2162,7 +2178,7 @@ int get_coretype(void){ else return CORE_NEHALEM; #endif - if (model == 10) + if (model == 10 || model == 12) #ifndef NO_AVX512 if(support_avx512_bf16()) return CORE_COOPERLAKE; @@ -2178,10 +2194,11 @@ int get_coretype(void){ return CORE_NEHALEM; #endif break; + case 7: if (model == 10) return CORE_NEHALEM; - if (model == 14) + if (model == 13 || model == 14) // Ice Lake #ifndef NO_AVX512 return CORE_SKYLAKEX; #else @@ -2195,9 +2212,9 @@ int get_coretype(void){ return CORE_NEHALEM; #endif break; - case 9: + case 8: - if (model == 12 || model == 13) { // Tiger Lake + if (model == 12 || model == 13) { // Tiger Lake if(support_avx512()) return CORE_SKYLAKEX; if(support_avx2()) @@ -2207,7 +2224,7 @@ int get_coretype(void){ else return CORE_NEHALEM; } - if (model == 14) { // Kaby Lake + if (model == 14) { // Kaby Lake mobile if(support_avx()) #ifndef NO_AVX2 return CORE_HASWELL; @@ -2217,12 +2234,82 @@ int get_coretype(void){ else return CORE_NEHALEM; } - } + if (model == 15) { // Sapphire Rapids + if(support_avx512_bf16()) + return CPUTYPE_COOPERLAKE; + if(support_avx512()) + return CPUTYPE_SKYLAKEX; + if(support_avx2()) + return CPUTYPE_HASWELL; + if(support_avx()) + return CPUTYPE_SANDYBRIDGE; + else + return CPUTYPE_NEHALEM; + } break; + case 9: + if (model == 7 || model == 10) { // Alder Lake + if(support_avx2()) + return CORE_HASWELL; + if(support_avx()) + return CORE_SANDYBRIDGE; + else + return CORE_NEHALEM; + } + if (model == 13) { // Ice Lake NNPI + if(support_avx512()) + return CORE_SKYLAKEX; + if(support_avx2()) + return CORE_HASWELL; + if(support_avx()) + return CORE_SANDYBRIDGE; + else + return CORE_NEHALEM; + } + if (model == 14) { // Kaby Lake desktop + if(support_avx()) +#ifndef NO_AVX2 + return CORE_HASWELL; +#else + return CORE_SANDYBRIDGE; +#endif + else + return CORE_NEHALEM; + } + break; + + case 10: + switch (model) { + case 5: // Comet Lake H and S + case 6: // Comet Lake U + if(support_avx()) + #ifndef NO_AVX2 + return CORE_HASWELL; + #else + return CORE_SANDYBRIDGE; + #endif + else + return CORE_NEHALEM; + case 7:// Rocket Lake +#ifndef NO_AVX512 + if(support_avx512()) + return CORE_SKYLAKEX; +#endif +#ifndef NO_AVX2 + if(support_avx2()) + return CORE_HASWELL; +#endif + if(support_avx()) + return CORE_SANDYBRIDGE; + else + return CORE_NEHALEM; + } + case 15: if (model <= 0x2) return CORE_NORTHWOOD; else return CORE_PRESCOTT; + } } } @@ -2495,3 +2582,4 @@ void get_sse(void){ if (features & HAVE_FMA3 ) printf("HAVE_FMA3=1\n"); } +//} \ No newline at end of file From 08f8bb66c0bf13d28eefac27bfdc7bb7e0a3b46f Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 4 Nov 2021 20:36:39 +0100 Subject: [PATCH 2/2] Add CPUIDs for Alder Lake and other recent Intel cpus --- driver/others/dynamic.c | 51 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/driver/others/dynamic.c b/driver/others/dynamic.c index 9fa3d2dc2..653915aab 100644 --- a/driver/others/dynamic.c +++ b/driver/others/dynamic.c @@ -624,7 +624,7 @@ static gotoblas_t *get_coretype(void){ return &gotoblas_NEHALEM; } } - if (model == 10) { + if (model == 10 || model == 12){ // Ice Lake SP if(support_avx512_bf16()) return &gotoblas_COOPERLAKE; @@ -639,12 +639,12 @@ static gotoblas_t *get_coretype(void){ openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); return &gotoblas_NEHALEM; } - } + } return NULL; case 7: if (model == 10) // Goldmont Plus return &gotoblas_NEHALEM; - if (model == 14) { + if (model == 13 || model == 14) { // Ice Lake if (support_avx512()) return &gotoblas_SKYLAKEX; @@ -661,7 +661,6 @@ static gotoblas_t *get_coretype(void){ } } return NULL; - case 9: case 8: if (model == 12 || model == 13) { // Tiger Lake if (support_avx512()) @@ -689,6 +688,50 @@ static gotoblas_t *get_coretype(void){ return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels. } } + if (model == 15){ // Sapphire Rapids + if(support_avx512_bf16()) + return &gotoblas_COOPERLAKE; + if (support_avx512()) + return &gotoblas_SKYLAKEX; + if(support_avx2()) + return &gotoblas_HASWELL; + if(support_avx()) { + openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK); + return &gotoblas_SANDYBRIDGE; + } else { + openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); + return &gotoblas_NEHALEM; + } + } + return NULL; + + + case 9: + if (model == 7 || model == 10) { // Alder Lake + if(support_avx2()){ + openblas_warning(FALLBACK_VERBOSE, HASWELL_FALLBACK); + return &gotoblas_HASWELL; + } + if(support_avx()) { + openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK); + return &gotoblas_SANDYBRIDGE; + } else { + openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); + return &gotoblas_NEHALEM; + } + } + if (model == 14 ) { // Kaby Lake, Coffee Lake + if(support_avx2()) + return &gotoblas_HASWELL; + if(support_avx()) { + openblas_warning(FALLBACK_VERBOSE, SANDYBRIDGE_FALLBACK); + return &gotoblas_SANDYBRIDGE; + } else { + openblas_warning(FALLBACK_VERBOSE, NEHALEM_FALLBACK); + return &gotoblas_NEHALEM; //OS doesn't support AVX. Use old kernels. + } + } + return NULL; case 10: if (model == 5 || model == 6) { if(support_avx2())