Skip to content

use cpu_features to detect Granite Rapids and newer - #307

Draft
bedroge wants to merge 3 commits into
EESSI:mainfrom
bedroge:archdetect_intel_detection
Draft

bedroge wants to merge 3 commits into
EESSI:mainfrom
bedroge:archdetect_intel_detection

Conversation

@bedroge

@bedroge bedroge commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

This is a first attempt to use Google's cpu_features tool to detect the CPU flags of Intel Sapphire Rapids CPUs or newer generations. This tool detects more flags than the ones reported in /proc/cpuinfo, and we can use it to properly distinguish e.g. Granite Rapids from Sapphire Rapids.

WIP, still needs:

  • cpu_features to be available somehow (compat layer?)
  • tests
  • some cleaning up

But the idea seems to work, tested on a Granite Rapids node (with an EB-installed cpu_features):

$ ./eessi_archdetect.sh -d cpupath
2026-09-18 14:41:57 [DEBUG] cpupath: Override variable set as '' 
2026-09-18 14:41:57 [DEBUG] cpupath: Host CPU architecture identified as 'x86_64'
2026-09-18 14:41:57 [DEBUG] cpupath: CPU vendor of host system: 'GenuineIntel'
2026-09-18 14:41:57 [DEBUG] cpupath: Known CPU vendors: GenuineIntel GenuineIntel GenuineIntel GenuineIntel GenuineIntel GenuineIntel AuthenticAMD AuthenticAMD AuthenticAMD AuthenticAMD
2026-09-18 14:41:57 [DEBUG] cpupath: CPU flags of host system: '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'
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/haswell
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/skylake_avx512
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/cascadelake
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/icelake
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/sapphirerapids
2026-09-18 14:41:57 [DEBUG] cpupath: refining Sapphire Rapids match (family='6', model='173')
2026-09-18 14:41:57 [DEBUG] Calling list_cpu_features tool to find all relevant CPU flags
2026-09-18 14:41:57 [DEBUG] Flags reported by list_cpu_features: 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 fma 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
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/haswell
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/skylake_avx512
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/sapphirerapids
2026-09-18 14:41:57 [DEBUG] cpupath: host CPU best match updated to x86_64/intel/graniterapids
2026-09-18 14:41:57 [INFO] cpupath: best match for host CPU: x86_64/intel/graniterapids
x86_64/intel/graniterapids

@bedroge bedroge linked an issue Sep 18, 2026 that may be closed by this pull request
@bedroge

bedroge commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

As a reference, this is what list_cpu_features reports on a GR node:

$ list_cpu_features 
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}

While /proc/cpuinfo has:

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:

And lscpu:

$ lscpu 
Architecture:                aarch64
  CPU op-mode(s):            32-bit, 64-bit
  Byte Order:                Little Endian
CPU(s):                      2
  On-line CPU(s) list:       0,1
Vendor ID:                   ARM
  Model name:                Neoverse-N1
    Model:                   1
    Thread(s) per core:      1
    Core(s) per socket:      2
    Socket(s):               1
    Stepping:                r3p1
    BogoMIPS:                243.75
    Flags:                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
Caches (sum of all):         
  L1d:                       128 KiB (2 instances)
  L1i:                       128 KiB (2 instances)
  L2:                        2 MiB (2 instances)
  L3:                        32 MiB (1 instance)
NUMA:                        
  NUMA node(s):              1
  NUMA node0 CPU(s):         0,1
Vulnerabilities:             
  Gather data sampling:      Not affected
  Indirect target selection: Not affected
  Itlb multihit:             Not affected
  L1tf:                      Not affected
  Mds:                       Not affected
  Meltdown:                  Not affected
  Mmio stale data:           Not affected
  Reg file data sampling:    Not affected
  Retbleed:                  Not affected
  Spec rstack overflow:      Not affected
  Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:                Mitigation; __user pointer sanitization
  Spectre v2:                Mitigation; CSV2, BHB
  Srbds:                     Not affected
  Tsa:                       Not affected
  Tsx async abort:           Not affected
  Vmscape:                   Not affected
[bedroge@login1 ~]$ srun -p x86-64-intel-grapids-node -c 16 --mem=0 --time=3-00:00:00 --pty /bin/bash
[bedroge@x86-64-intel-grapids-node1 ~]$ lscpu 
Architecture:                x86_64
  CPU op-mode(s):            32-bit, 64-bit
  Address sizes:             48 bits physical, 48 bits virtual
  Byte Order:                Little Endian
CPU(s):                      16
  On-line CPU(s) list:       0-15
Vendor ID:                   GenuineIntel
  Model name:                Intel(R) Xeon(R) 6975P-C
    CPU family:              6
    Model:                   173
    Thread(s) per core:      2
    Core(s) per socket:      8
    Socket(s):               1
    Stepping:                1
    BogoMIPS:                5400.00
    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_perf
                             mon 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 ts
                             c_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx
                             2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_v
                             nni 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
Virtualization features:     
  Hypervisor vendor:         KVM
  Virtualization type:       full
Caches (sum of all):         
  L1d:                       384 KiB (8 instances)
  L1i:                       512 KiB (8 instances)
  L2:                        16 MiB (8 instances)
  L3:                        480 MiB (1 instance)
NUMA:                        
  NUMA node(s):              1
  NUMA node0 CPU(s):         0-15
Vulnerabilities:             
  Gather data sampling:      Not affected
  Indirect target selection: Not affected
  Itlb multihit:             Not affected
  L1tf:                      Not affected
  Mds:                       Not affected
  Meltdown:                  Not affected
  Mmio stale data:           Not affected
  Reg file data sampling:    Not affected
  Retbleed:                  Not affected
  Spec rstack overflow:      Not affected
  Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS Not affected; BHI BHI_DIS_S
  Srbds:                     Not affected
  Tsa:                       Not affected
  Tsx async abort:           Not affected
  Vmscape:                   Not affected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix fallback mechanism in archdetect for new Intel CPUs

1 participant