Open jmgurney opened 1 year ago
It looks like there are many possible solutions to this:
sysctl
properties based on what it reads from the Main ID register (MIDR
), which is the ARM equivalent of the x86 CPUID instruction.sysctl
properties, specifically, we currently check hw.cpufamily
, but we could also check the additional properties:
hw.cpusubfamily
,hw.cpusubtype
,hw.cputype
, ormachdep.cpu.brand_string
The problem is that both A14 and M1 share a common micro-architecture (FIRESTORM_ICESTORM
is what hw.cpufamily
is set to on both A14 and M1), which might be more course-grained than we want. If we want more fine-grained details, then looking at other properties might be the best solution.
hw.cpufamily
== ARM_FIRESTORM_ICESTORM
== 0x1b588bb3
hw.cpusubfamily
:value | cpu model |
---|---|
2 | M1 |
4 | M1 Pro |
5 | M1 Max |
source: https://github.com/Dr-Noob/cpufetch/issues/139#issuecomment-1059933273
note: I can't find anything for M1 Ultra
or M2
cpu models
I can confirm sub family 4 on my M1 Pro:
$ sysctl hw.cpusubfamily
hw.cpusubfamily: 4
I found these part numbers in proc_reg.h:
Brand | SubFamily | MIDR Part Num | MIDR Part Num Desc | Efficiency/Performance |
---|---|---|---|---|
Apple A14 | 1 | 0x20 | MIDR_SICILY_ICESTORM | E-core |
Apple A14 | 1 | 0x21 | MIDR_SICILY_FIRESTORM | P-core |
Apple M1 | 2 | 0x22 | MIDR_TONGA_ICESTORM | E-core |
Apple M1 | 2 | 0x23 | MIDR_TONGA_FIRESTORM | P-core |
Apple M1 Pro | 4 | 0x24 | MIDR_JADE_CHOP_ICESTORM | E-core |
Apple M1 Pro | 4 | 0x25 | MIDR_JADE_CHOP_FIRESTORM | P-core |
Apple M1 Max | 5 | 0x28 | MIDR_JADE_DIE_ICESTORM | E-core |
Apple M1 Max | 5 | 0x29 | MIDR_JADE_DIE_FIRESTORM | P-core |
I'm just musing here, but I think that Firestorm is the name of the Performance core, Icestorm is the name of the Efficiency core, Firestorm-Icestorm is the name of the micro-architecture, and the others appear to be like code names for TDP?
I have an M2 MBA (2022), family value is:
hw.cpufamily: 0xda33d83d
hw.cpusubfamily: 2
Zig Version
0.11.0-dev.2249+dcdb87836
Steps to Reproduce and Observed Behavior
On a 2021 14-inch MBP (M1 Pro), Ventura 13.2, run:
Expected Behavior
I'd expect it to return "apple_m1" instead.