From 83c1fb9fd3631921f7bd151c941ec25f50febe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Sep 2026 16:52:00 +0200 Subject: [PATCH 01/11] use cpu_features to detect Granite Rapids and newer --- init/eessi_archdetect.sh | 42 +++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index 1dbe6b51..fcb4ff10 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -70,6 +70,24 @@ get_cpuinfo(){ grep -i "$cpuinfo_pattern" ${EESSI_PROC_CPUINFO:-/proc/cpuinfo} | tail -n 1 | sed "s/$cpuinfo_pattern//i" } +# CPU specification of host system as reported by cpu_features +get_cpu_features(){ + # Return the value from list_cpu_features for the matching key + # 1: string with key pattern + + [ -z "$1" ] && log "ERROR" "get_cpu_features: missing key pattern in argument list" + cpu_features_pattern="^${1}\s*:\s*" + + if [ ! -z ${EESSI_CPU_FEATURES_FILE} ]; then + cpu_features_output=$(cat ${EESSI_CPU_FEATURES_FILE}) + else + cpu_features_output=$(list_cpu_features | sed '/^flags[[:space:]]*:/ s/,/ /g' | sed '/^flags[[:space:]]*:/ s/fma3/fma/g') # | grep flags | awk '{print $3}' | sed 's/,/ /g' | sed 's/fma3/fma/' + fi + + # case insensitive match of key pattern and delete key pattern from result + echo "${cpu_features_output}" | grep -i "$cpu_features_pattern" | tail -n 1 | sed "s/$cpu_features_pattern//i" +} + check_allinfirst(){ # Return true if all given arguments after the first are found in the first one # 1: reference string of space separated values @@ -168,26 +186,40 @@ cpupath(){ # each flag in this CPU specification must be found in the list of flags of the host check_allinfirst "${cpu_flags[*]}" ${arch_spec[2]} && best_arch_match=${arch_spec[0]} && \ all_arch_matches="$best_arch_match:$all_arch_matches" && \ - log "DEBUG" "cpupath: host CPU best match updated to $best_arch_match" + log "DEBUG" "cpupath: host CPU best match updated to $best_arch_match" fi done # Some Intel microarchitectures are flag-indistinguishable from an older one because their # new features are not exposed in /proc/cpuinfo. Granite Rapids (Xeon 6) shows the exact same # visible flags as Sapphire/Emerald Rapids (its extras like amx_fp16 are hidden by the kernel), - # so the flag match above lands on 'sapphirerapids'. Refine using the CPU model number - the - # only reliable discriminator on Linux. If no dedicated graniterapids subdir is shipped yet, - # downstream subdir resolution falls back to the next entry in the chain, so prepending is safe. + # so the flag match above lands on 'sapphirerapids'. + # Refine using the list_cpu_features tool from Google's cpu_features if available, + # and otherwise use the CPU model number. if [ "${best_arch_match}" == "x86_64/intel/sapphirerapids" ]; then local cpu_family=$(get_cpuinfo "cpu[ _]family") local cpu_model=$(get_cpuinfo "model") log "DEBUG" "cpupath: refining Sapphire Rapids match (family='$cpu_family', model='$cpu_model')" + if command -v "list_cpu_features" >/dev/null 2>&1; then + log "DEBUG" "Calling list_cpu_features tool to find all relevant CPU flags" >&2 + # cpu_features uses fma3 instead of fma, we simply replace it to ensure the matching still works + cpu_features_flags=$(get_cpu_features "$cpu_flag_tag" | sed 's/fma3/fma/') + log "DEBUG" "Flags reported by list_cpu_features: ${cpu_features_flags}" + for arch in "${cpu_arch_spec[@]}"; do + eval "arch_spec=$arch" + if [ "${cpu_vendor}x" == "${arch_spec[1]}x" ]; then + # each flag in this CPU specification must be found in the list of flags of the host + check_allinfirst "${cpu_features_flags[*]}" ${arch_spec[2]} && best_arch_match=${arch_spec[0]} && \ + all_arch_matches="$best_arch_match:$all_arch_matches" && \ + log "DEBUG" "cpupath: host CPU best match updated to $best_arch_match" + fi + done # Intel family 6 model numbers below come from the kernel's authoritative table # arch/x86/include/asm/intel-family.h (what the kernel itself uses for model dispatch): # INTEL_GRANITERAPIDS_X = IFM(6, 0xAD) -> family 6, model 173 (Granite Rapids-SP/AP) # INTEL_GRANITERAPIDS_D = IFM(6, 0xAE) -> family 6, model 174 (Granite Rapids-D) # (cf. INTEL_SAPPHIRERAPIDS_X = 0x8F/143, INTEL_EMERALDRAPIDS_X = 0xCF/207) - if [ "${cpu_family}" == "6" ] && { [ "${cpu_model}" == "173" ] || [ "${cpu_model}" == "174" ]; }; then + elif [ "${cpu_family}" == "6" ] && { [ "${cpu_model}" == "173" ] || [ "${cpu_model}" == "174" ]; }; then best_arch_match="x86_64/intel/graniterapids" all_arch_matches="$best_arch_match:$all_arch_matches" log "DEBUG" "cpupath: model $cpu_model identifies Granite Rapids; best match upgraded to $best_arch_match" From 1a30fa82989034161359a8609aaa4dd864e5fdb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Sep 2026 16:57:00 +0200 Subject: [PATCH 02/11] add comment about reformatting the output of cpu_features --- init/eessi_archdetect.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index fcb4ff10..990a4df3 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -81,6 +81,8 @@ get_cpu_features(){ if [ ! -z ${EESSI_CPU_FEATURES_FILE} ]; then cpu_features_output=$(cat ${EESSI_CPU_FEATURES_FILE}) else + # /proc/cpuinfo uses space-separated flags and uses "fma" instead of "fma3", + # so we reformat and rename things a bit here to make it easier to do the comparisons cpu_features_output=$(list_cpu_features | sed '/^flags[[:space:]]*:/ s/,/ /g' | sed '/^flags[[:space:]]*:/ s/fma3/fma/g') # | grep flags | awk '{print $3}' | sed 's/,/ /g' | sed 's/fma3/fma/' fi From 0ac6f7e403753b600d36f31f33e86dd7310c7726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Sep 2026 17:00:37 +0200 Subject: [PATCH 03/11] add graniterapids --- init/arch_specs/eessi_arch_x86.spec | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/init/arch_specs/eessi_arch_x86.spec b/init/arch_specs/eessi_arch_x86.spec index ad33ec76..ea17df25 100755 --- a/init/arch_specs/eessi_arch_x86.spec +++ b/init/arch_specs/eessi_arch_x86.spec @@ -1,12 +1,13 @@ # x86_64 CPU architecture specifications # The overview at https://github.com/InstLatx64/InstLatX64_Misc/tree/main/SIMD_Euler may be helpful in defining this list # Software path in EESSI | Vendor ID | List of defining CPU features -"x86_64/intel/haswell" "GenuineIntel" "avx2 fma" # Intel Haswell, Broadwell -"x86_64/intel/skylake_avx512" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl" # Intel Skylake -"x86_64/intel/cascadelake" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl avx512_vnni" # Intel Cascade Lake -"x86_64/intel/icelake" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl avx512_vnni avx512_vbmi2" # Intel Icelake Lake -"x86_64/intel/sapphirerapids" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl avx512_bf16 amx_tile" # Intel Sapphire/Emerald Rapids -"x86_64/amd/zen2" "AuthenticAMD" "avx2 fma" # AMD Rome -"x86_64/amd/zen3" "AuthenticAMD" "avx2 fma vaes" # AMD Milan, Milan-X -"x86_64/amd/zen4" "AuthenticAMD" "avx2 fma vaes avx512f avx512ifma" # AMD Genoa, Genoa-X -"x86_64/amd/zen5" "AuthenticAMD" "avx2 fma vaes avx512f avx512ifma avx512_vp2intersect avx_vnni movdiri" # AMD Turin +"x86_64/intel/haswell" "GenuineIntel" "avx2 fma" # Intel Haswell, Broadwell +"x86_64/intel/skylake_avx512" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl" # Intel Skylake +"x86_64/intel/cascadelake" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl avx512_vnni" # Intel Cascade Lake +"x86_64/intel/icelake" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl avx512_vnni avx512_vbmi2" # Intel Icelake Lake +"x86_64/intel/sapphirerapids" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl avx512_bf16 amx_tile" # Intel Sapphire/Emerald Rapids +"x86_64/intel/graniterapids" "GenuineIntel" "avx2 fma avx512f avx512bw avx512cd avx512dq avx512vl avx512_bf16 amx_tile amx_fp16" # Granite +"x86_64/amd/zen2" "AuthenticAMD" "avx2 fma" # AMD Rome +"x86_64/amd/zen3" "AuthenticAMD" "avx2 fma vaes" # AMD Milan, Milan-X +"x86_64/amd/zen4" "AuthenticAMD" "avx2 fma vaes avx512f avx512ifma" # AMD Genoa, Genoa-X +"x86_64/amd/zen5" "AuthenticAMD" "avx2 fma vaes avx512f avx512ifma avx512_vp2intersect avx_vnni movdiri" # AMD Turin From aef9de9b205791d8fa6e908244ba07b8539612e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Mon, 21 Sep 2026 15:56:52 +0200 Subject: [PATCH 04/11] improve error handling for cpu_features --- init/eessi_archdetect.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index 990a4df3..472619e4 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -80,14 +80,18 @@ get_cpu_features(){ if [ ! -z ${EESSI_CPU_FEATURES_FILE} ]; then cpu_features_output=$(cat ${EESSI_CPU_FEATURES_FILE}) - else + elif command -v "list_cpu_features" >/dev/null 2>&1; then # /proc/cpuinfo uses space-separated flags and uses "fma" instead of "fma3", # so we reformat and rename things a bit here to make it easier to do the comparisons - cpu_features_output=$(list_cpu_features | sed '/^flags[[:space:]]*:/ s/,/ /g' | sed '/^flags[[:space:]]*:/ s/fma3/fma/g') # | grep flags | awk '{print $3}' | sed 's/,/ /g' | sed 's/fma3/fma/' + cpu_features_output=$(list_cpu_features | sed '/^flags[[:space:]]*:/ s/,/ /g' | sed '/^flags[[:space:]]*:/ s/fma3/fma/g') + else + log "DEBUG" "cpu_features cannot be found" + return 1 fi # case insensitive match of key pattern and delete key pattern from result echo "${cpu_features_output}" | grep -i "$cpu_features_pattern" | tail -n 1 | sed "s/$cpu_features_pattern//i" + return 0 } check_allinfirst(){ @@ -202,11 +206,8 @@ cpupath(){ local cpu_family=$(get_cpuinfo "cpu[ _]family") local cpu_model=$(get_cpuinfo "model") log "DEBUG" "cpupath: refining Sapphire Rapids match (family='$cpu_family', model='$cpu_model')" - if command -v "list_cpu_features" >/dev/null 2>&1; then - log "DEBUG" "Calling list_cpu_features tool to find all relevant CPU flags" >&2 - # cpu_features uses fma3 instead of fma, we simply replace it to ensure the matching still works - cpu_features_flags=$(get_cpu_features "$cpu_flag_tag" | sed 's/fma3/fma/') - log "DEBUG" "Flags reported by list_cpu_features: ${cpu_features_flags}" + if cpu_features_flags=$(get_cpu_features "$cpu_flag_tag"); then + log "DEBUG" "Flags reported by list_cpu_features: ${cpu_features_flags}" for arch in "${cpu_arch_spec[@]}"; do eval "arch_spec=$arch" if [ "${cpu_vendor}x" == "${arch_spec[1]}x" ]; then From 5c594a35e0cdbc1e44ee367805e993e36021622e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 22 Sep 2026 09:56:01 +0200 Subject: [PATCH 05/11] enable graniterapids tests, check for cpu_features file --- .github/workflows/tests_archdetect.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests_archdetect.yml b/.github/workflows/tests_archdetect.yml index 81257a7f..1608ab59 100644 --- a/.github/workflows/tests_archdetect.yml +++ b/.github/workflows/tests_archdetect.yml @@ -12,6 +12,8 @@ jobs: strategy: matrix: proc_cpuinfo: + - x86_64/intel/graniterapids/AWS-Rocky9-6975PC + - x86_64/intel/graniterapids/Azure-Ubuntu24-6973P-C - x86_64/intel/haswell/archspec-linux-E5-2680-v3 - x86_64/intel/sapphirerapids/AWS-Rocky8-8488C - x86_64/intel/skylake_avx512/archspec-linux-6132 @@ -50,6 +52,9 @@ jobs: export EESSI_MACHINE_TYPE=${{matrix.proc_cpuinfo}} export EESSI_MACHINE_TYPE=${EESSI_MACHINE_TYPE%%/*} export EESSI_PROC_CPUINFO=./tests/archdetect/${{matrix.proc_cpuinfo}}.cpuinfo + if [[ -f ./tests/archdetect/${{matrix.proc_cpuinfo}}.cpu_features ]]; then + export EESSI_CPU_FEATURES_FILE=./tests/archdetect/${{matrix.proc_cpuinfo}}.cpu_features + fi # check that printing of best match works correctly CPU_ARCH=$(./init/eessi_archdetect.sh cpupath) if [[ $CPU_ARCH == "$( cat ./tests/archdetect/${{matrix.proc_cpuinfo}}.output )" ]]; then From 15bd97ea1b773e162c8aa442450b271d914924c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 22 Sep 2026 09:56:55 +0200 Subject: [PATCH 06/11] add AWS Graniterapids CPU info --- .../AWS-Rocky9-6975PC.all.output | 1 + .../AWS-Rocky9-6975PC.cpu_features | 8 ++++++ .../graniterapids/AWS-Rocky9-6975PC.cpuinfo | 26 +++++++++++++++++++ .../graniterapids/AWS-Rocky9-6975PC.output | 1 + 4 files changed, 36 insertions(+) create mode 100644 tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.all.output create mode 100644 tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpu_features create mode 100644 tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpuinfo create mode 100644 tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.output diff --git a/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.all.output b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.all.output new file mode 100644 index 00000000..5b9439a3 --- /dev/null +++ b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.all.output @@ -0,0 +1 @@ +x86_64/intel/graniterapids:x86_64/intel/sapphirerapids:x86_64/intel/icelake:x86_64/intel/cascadelake:x86_64/intel/skylake_avx512:x86_64/intel/haswell:x86_64/generic diff --git a/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpu_features b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpu_features new file mode 100644 index 00000000..04817563 --- /dev/null +++ b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpu_features @@ -0,0 +1,8 @@ +arch : x86 +brand : Intel(R) Xeon(R) 6975P-C +family : 6 (0x06) +model : 173 (0xAD) +stepping : 1 (0x01) +uarch : X86_UNKNOWN +flags : adx,aes,amx_bf16,amx_fp16,amx_int8,amx_tile,avx,avx2,avx512_bf16,avx512_fp16,avx512_second_fma,avx512bitalg,avx512bw,avx512cd,avx512dq,avx512f,avx512ifma,avx512vbmi,avx512vbmi2,avx512vl,avx512vnni,avx512vpopcntdq,avx_vnni,bmi1,bmi2,clflushopt,clfsh,clwb,cx16,cx8,erms,f16c,fma3,fpu,fs_rep_cmpsb_scasb,fs_rep_stosb,fz_rep_movsb,gfni,lzcnt,mmx,movbe,movdir64b,movdiri,pclmulqdq,popcnt,rdrnd,rdseed,sha,ss,sse,sse2,sse3,sse4_1,sse4_2,ssse3,tsc,vaes,vpclmulqdq +cache_info : {"level":1,"cache_type":"data","cache_size":49152,"ways":12,"line_size":64,"tlb_entries":64,"partitioning":1},{"level":1,"cache_type":"instruction","cache_size":65536,"ways":16,"line_size":64,"tlb_entries":64,"partitioning":1},{"level":2,"cache_type":"unified","cache_size":2097152,"ways":16,"line_size":64,"tlb_entries":2048,"partitioning":1},{"level":3,"cache_type":"unified","cache_size":503316480,"ways":16,"line_size":64,"tlb_entries":491520,"partitioning":1} diff --git a/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpuinfo b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpuinfo new file mode 100644 index 00000000..9d167cb8 --- /dev/null +++ b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.cpuinfo @@ -0,0 +1,26 @@ +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 173 +model name : Intel(R) Xeon(R) 6975P-C +stepping : 1 +microcode : 0x1000434 +cpu MHz : 2700.000 +cache size : 491520 KB +physical id : 0 +siblings : 16 +core id : 0 +cpu cores : 8 +apicid : 0 +initial apicid : 0 +fpu : yes +fpu_exception : yes +cpuid level : 36 +wp : yes +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd ida arat avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid bus_lock_detect cldemote movdiri movdir64b md_clear serialize amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities +bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs bhi spectre_v2_user +bogomips : 5400.00 +clflush size : 64 +cache_alignment : 64 +address sizes : 48 bits physical, 48 bits virtual +power management: diff --git a/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.output b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.output new file mode 100644 index 00000000..2633f463 --- /dev/null +++ b/tests/archdetect/x86_64/intel/graniterapids/AWS-Rocky9-6975PC.output @@ -0,0 +1 @@ +x86_64/intel/graniterapids From 5ba14f57aa4063ea71ff045f688aa9dd8e22992c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 22 Sep 2026 10:22:07 +0200 Subject: [PATCH 07/11] reformat cpu_features output after if statement --- init/eessi_archdetect.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index 472619e4..bf8b78fe 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -81,16 +81,18 @@ get_cpu_features(){ if [ ! -z ${EESSI_CPU_FEATURES_FILE} ]; then cpu_features_output=$(cat ${EESSI_CPU_FEATURES_FILE}) elif command -v "list_cpu_features" >/dev/null 2>&1; then - # /proc/cpuinfo uses space-separated flags and uses "fma" instead of "fma3", - # so we reformat and rename things a bit here to make it easier to do the comparisons - cpu_features_output=$(list_cpu_features | sed '/^flags[[:space:]]*:/ s/,/ /g' | sed '/^flags[[:space:]]*:/ s/fma3/fma/g') + cpu_features_output=$(list_cpu_features) else log "DEBUG" "cpu_features cannot be found" return 1 fi + # /proc/cpuinfo uses space-separated flags and uses "fma" instead of "fma3", + # so we reformat and rename things a bit here to make it easier to do the comparisons + cpu_features_reformatted=$(echo "${cpu_features_output}" | sed '/^flags[[:space:]]*:/ s/,/ /g' | sed '/^flags[[:space:]]*:/ s/fma3/fma/g') + # case insensitive match of key pattern and delete key pattern from result - echo "${cpu_features_output}" | grep -i "$cpu_features_pattern" | tail -n 1 | sed "s/$cpu_features_pattern//i" + echo "${cpu_features_reformatted}" | grep -i "$cpu_features_pattern" | tail -n 1 | sed "s/$cpu_features_pattern//i" return 0 } From fc0c27115d3d5567e2b9d465a09c46ae7e37196d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 22 Sep 2026 10:29:30 +0200 Subject: [PATCH 08/11] restore defaults when reiterating over list of CPUs --- init/eessi_archdetect.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index bf8b78fe..abb652ac 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -210,6 +210,11 @@ cpupath(){ log "DEBUG" "cpupath: refining Sapphire Rapids match (family='$cpu_family', model='$cpu_model')" if cpu_features_flags=$(get_cpu_features "$cpu_flag_tag"); then log "DEBUG" "Flags reported by list_cpu_features: ${cpu_features_flags}" + # Now that we have a (possibly) changed set of flags, reset the results to their defaults and + # reiterate over the supported CPU specifications to find the best match for host CPU. + # Order of the specifications matters, the last one to match will be selected + local best_arch_match="$machine_type/generic" + local all_arch_matches=$best_arch_match for arch in "${cpu_arch_spec[@]}"; do eval "arch_spec=$arch" if [ "${cpu_vendor}x" == "${arch_spec[1]}x" ]; then From ffa8270512f64da0863789e9563f154b7dcc16d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 22 Sep 2026 12:17:21 +0200 Subject: [PATCH 09/11] add mapping for CPU flag names, reformat the cpu_features output with that map --- init/eessi_archdetect.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index abb652ac..4585cb7f 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -24,6 +24,16 @@ LOG_LEVEL="WARN" # Default result type is a best match CPUPATH_RESULT="best" +# map CPU flag names from cpu_features to the ones used in /proc/cpuinfo +declare -A cpu_flags_name_map=( + [fma3]=fma + [avx512bitalg]=avx512_bitalg + [avx512vbmi2]=avx512_vbmi2 + [avx512vnni]=avx512_vnni + [avx512vpopcntdq]=avx512_vpopcntdq + [sha]=sha_ni +) + timestamp () { date "+%Y-%m-%d %H:%M:%S" } @@ -87,9 +97,25 @@ get_cpu_features(){ return 1 fi - # /proc/cpuinfo uses space-separated flags and uses "fma" instead of "fma3", + # /proc/cpuinfo uses space-separated flags and uses different names for some flags, # so we reformat and rename things a bit here to make it easier to do the comparisons - cpu_features_reformatted=$(echo "${cpu_features_output}" | sed '/^flags[[:space:]]*:/ s/,/ /g' | sed '/^flags[[:space:]]*:/ s/fma3/fma/g') + cpu_features_reformatted=$( + while IFS= read -r line; do + if [[ $line =~ ^(flags[[:space:]]*:[[:space:]]*)(.*)$ ]]; then + prefix=${BASH_REMATCH[1]} + flags=${BASH_REMATCH[2]} + + new_flags="" + for flag in $flags; do + new_flags+=" ${cpu_flags_name_map[$flag]:-$flag}" + done + + printf '%s%s\n' "$prefix" "${new_flags# }" + else + printf '%s\n' "$line" + fi + done <<< "${cpu_features_output}" + ) # case insensitive match of key pattern and delete key pattern from result echo "${cpu_features_reformatted}" | grep -i "$cpu_features_pattern" | tail -n 1 | sed "s/$cpu_features_pattern//i" From 6436d0c45ff9dfb30e20ffd1e4ba2bff1113f9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 22 Sep 2026 12:26:24 +0200 Subject: [PATCH 10/11] flags are comma-separated --- init/eessi_archdetect.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index 4585cb7f..ed2b1e27 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -106,11 +106,14 @@ get_cpu_features(){ flags=${BASH_REMATCH[2]} new_flags="" - for flag in $flags; do - new_flags+=" ${cpu_flags_name_map[$flag]:-$flag}" + IFS=',' read -ra flag_array <<< "$flags" + + for flag in "${flag_array[@]}"; do + new_flags+="${cpu_flags_name_map[$flag]:-$flag}," done - printf '%s%s\n' "$prefix" "${new_flags# }" + new_flags=${new_flags%,} + printf '%s%s\n' "$prefix" "$new_flags" else printf '%s\n' "$line" fi From c907d9bbf19bb0cef4f6e4afca328564de0dd00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Tue, 22 Sep 2026 12:27:01 +0200 Subject: [PATCH 11/11] but should become space-separated --- init/eessi_archdetect.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init/eessi_archdetect.sh b/init/eessi_archdetect.sh index ed2b1e27..78f9794a 100755 --- a/init/eessi_archdetect.sh +++ b/init/eessi_archdetect.sh @@ -109,11 +109,10 @@ get_cpu_features(){ IFS=',' read -ra flag_array <<< "$flags" for flag in "${flag_array[@]}"; do - new_flags+="${cpu_flags_name_map[$flag]:-$flag}," + new_flags+=" ${cpu_flags_name_map[$flag]:-$flag}" done - new_flags=${new_flags%,} - printf '%s%s\n' "$prefix" "$new_flags" + printf '%s%s\n' "$prefix" "${new_flags# }" else printf '%s\n' "$line" fi