Dr-Noob / cpufetch

Simple yet fancy CPU architecture fetching tool
GNU General Public License v2.0
1.82k stars 99 forks source link

Apple M3 recognition support #210

Closed pthariensflame closed 6 months ago

pthariensflame commented 6 months ago

Currently cpufetch fails to recognize the microarchitecture on my M3 Max MacBook Pro

cpufetch:

[ERROR]: Found invalid cpu_family: 0x72015832
[VERSION]: cpufetch v1.04-30-g2fee (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

cpufetch --verbose:

[ERROR]: Found invalid cpu_family: 0x72015832
[VERSION]: cpufetch v1.04-30-g2fee (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

cpufetch --debug

[ERROR]: Found invalid cpu_family: 0x72015832
[VERSION]: cpufetch v1.04-30-g2fee (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

(All three appear identical.)

Data from https://github.com/AsahiLinux/m1n1/commit/c45da55256fd15bfe1b4ecbc5331624d3427ee1e#diff-f7b02bd90e8b50adc7540e051bab7ece88306d4e221428dadad91aeca622b2af might be useful?

Dr-Noob commented 6 months ago

Nice, thanks for the report and the (very useful!) link. I've pushed a commit into the apple branch. Can you check it out?

Onnwen commented 6 months ago

Same problem with M3 Pro:

Found invalid cpu_family: 0x5F4DEA93
[VERSION]: cpufetch v1.04 (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
Dr-Noob commented 6 months ago

It seems like they have changed how user space programs should detect different CPUs versions. I've added more commits to the branch so hopefully now it should work for all currently available M3 CPUs. Can you guys check apple branch and run both cpufetch and cpufetch --debug?

@Onnwen To get the latest version of cpufetch you need to compile from source (see this). You'll also need to get the apple branch so you would need:

git clone https://github.com/Dr-Noob/cpufetch
cd cpufetch
git checkout apple
make
./cpufetch
Onnwen commented 6 months ago

It seems like they have changed how user space programs should detect different CPUs versions. I've added more commits to the branch so hopefully now it should work for all currently available M3 CPUs. Can you guys check apple branch and run both cpufetch and cpufetch --debug?

@Onnwen To get the latest version of cpufetch you need to compile from source (see this). You'll also need to get the apple branch so you would need:

git clone https://github.com/Dr-Noob/cpufetch
cd cpufetch
git checkout apple
make
./cpufetch

Just tried, but it seems that the apple branch doesn't compile::

cc -Wall -Wextra -pedantic -DARCH_ARM -Wno-unused-parameter -std=c99 -fstack-protector-all -Wfloat-equal -Wshadow -Wpointer-arith -Wstrict-prototypes -DGIT_FULL_VERSION=\""v1.04-33-g727c"\" src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/arm/midr.c src/arm/uarch.c src/common/soc.c src/arm/soc.c src/arm/udev.c src/arm/sysctl.c -o cpufetch
src/arm/midr.c:428:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_PRO) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:432:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_MAX) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:437:55: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
      printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily);
                                                      ^~~~~~~~~~~~~
                                                      cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
3 errors generated.
make: *** [cpufetch] Error 1
Dr-Noob commented 6 months ago

It seems like they have changed how user space programs should detect different CPUs versions. I've added more commits to the branch so hopefully now it should work for all currently available M3 CPUs. Can you guys check apple branch and run both cpufetch and cpufetch --debug? @Onnwen To get the latest version of cpufetch you need to compile from source (see this). You'll also need to get the apple branch so you would need:

git clone https://github.com/Dr-Noob/cpufetch
cd cpufetch
git checkout apple
make
./cpufetch

Just tried, but it seems that the apple branch doesn't compile::

cc -Wall -Wextra -pedantic -DARCH_ARM -Wno-unused-parameter -std=c99 -fstack-protector-all -Wfloat-equal -Wshadow -Wpointer-arith -Wstrict-prototypes -DGIT_FULL_VERSION=\""v1.04-33-g727c"\" src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/arm/midr.c src/arm/uarch.c src/common/soc.c src/arm/soc.c src/arm/udev.c src/arm/sysctl.c -o cpufetch
src/arm/midr.c:428:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_PRO) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:432:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_MAX) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:437:55: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
      printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily);
                                                      ^~~~~~~~~~~~~
                                                      cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
3 errors generated.
make: *** [cpufetch] Error 1

Thanks for the quick response. I've just updated the apple branch, can you have a look again?

Onnwen commented 6 months ago

It seems like they have changed how user space programs should detect different CPUs versions. I've added more commits to the branch so hopefully now it should work for all currently available M3 CPUs. Can you guys check apple branch and run both cpufetch and cpufetch --debug? @Onnwen To get the latest version of cpufetch you need to compile from source (see this). You'll also need to get the apple branch so you would need:

git clone https://github.com/Dr-Noob/cpufetch
cd cpufetch
git checkout apple
make
./cpufetch

Just tried, but it seems that the apple branch doesn't compile::

cc -Wall -Wextra -pedantic -DARCH_ARM -Wno-unused-parameter -std=c99 -fstack-protector-all -Wfloat-equal -Wshadow -Wpointer-arith -Wstrict-prototypes -DGIT_FULL_VERSION=\""v1.04-33-g727c"\" src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/arm/midr.c src/arm/uarch.c src/common/soc.c src/arm/soc.c src/arm/udev.c src/arm/sysctl.c -o cpufetch
src/arm/midr.c:428:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_PRO) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:432:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_MAX) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:437:55: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
      printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily);
                                                      ^~~~~~~~~~~~~
                                                      cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
3 errors generated.
make: *** [cpufetch] Error 1

Thanks for the quick response. I've just updated the apple branch, can you have a look again?

Sure!

[ERROR]: Found invalid cpu_family: 0x5F4DEA93
[VERSION]: cpufetch v1.04-34-g2c1b (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            CPU 1:
                                                              Microarchitecture: Sawtooth
                                                              Max Frequency:     2.750 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            CPU 2:
                                                              Microarchitecture: Everest
                                                              Max Frequency:     4.050 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    81.60 GFLOP/s

verbose

[ERROR]: Found invalid cpu_family: 0x5F4DEA93
[VERSION]: cpufetch v1.04-34-g2c1b (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
cpufetch v1.04-34-g2c1b (macOS ARM build)
hw.cpufamily: 0x5F4DEA93
hw.cpusubfamily: 0x00000004
hw.physicalcpu: 12

debug same output as without parameters

Dr-Noob commented 6 months ago

It seems like they have changed how user space programs should detect different CPUs versions. I've added more commits to the branch so hopefully now it should work for all currently available M3 CPUs. Can you guys check apple branch and run both cpufetch and cpufetch --debug? @Onnwen To get the latest version of cpufetch you need to compile from source (see this). You'll also need to get the apple branch so you would need:

git clone https://github.com/Dr-Noob/cpufetch
cd cpufetch
git checkout apple
make
./cpufetch

Just tried, but it seems that the apple branch doesn't compile::

cc -Wall -Wextra -pedantic -DARCH_ARM -Wno-unused-parameter -std=c99 -fstack-protector-all -Wfloat-equal -Wshadow -Wpointer-arith -Wstrict-prototypes -DGIT_FULL_VERSION=\""v1.04-33-g727c"\" src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/arm/midr.c src/arm/uarch.c src/common/soc.c src/arm/soc.c src/arm/udev.c src/arm/sysctl.c -o cpufetch
src/arm/midr.c:428:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_PRO) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:432:13: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
    else if(cpu_subfamily == CPUFAMILY_ARM_EVEREST_SAWTOOTH_MAX) {
            ^~~~~~~~~~~~~
            cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
src/arm/midr.c:437:55: error: use of undeclared identifier 'cpu_subfamily'; did you mean 'cpu_family'?
      printBug("Found invalid cpu_subfamily: 0x%.8X", cpu_subfamily);
                                                      ^~~~~~~~~~~~~
                                                      cpu_family
src/arm/midr.c:353:12: note: 'cpu_family' declared here
  uint32_t cpu_family = get_sys_info_by_name("hw.cpufamily");
           ^
3 errors generated.
make: *** [cpufetch] Error 1

Thanks for the quick response. I've just updated the apple branch, can you have a look again?

Sure!

[ERROR]: Found invalid cpu_family: 0x5F4DEA93
[VERSION]: cpufetch v1.04-34-g2c1b (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            CPU 1:
                                                              Microarchitecture: Sawtooth
                                                              Max Frequency:     2.750 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            CPU 2:
                                                              Microarchitecture: Everest
                                                              Max Frequency:     4.050 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    81.60 GFLOP/s

verbose

[ERROR]: Found invalid cpu_family: 0x5F4DEA93
[VERSION]: cpufetch v1.04-34-g2c1b (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
cpufetch v1.04-34-g2c1b (macOS ARM build)
hw.cpufamily: 0x5F4DEA93
hw.cpusubfamily: 0x00000004
hw.physicalcpu: 12

debug same output as without parameters

What about now?

Onnwen commented 6 months ago

@Dr-Noob Similar as before:

[ERROR]: fill_soc: soc->soc_vendor == SOC_VENDOR_UNKOWN
[VERSION]: cpufetch v1.04-35-g5ffe (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            CPU 1:
                                                              Microarchitecture: Sawtooth
                                                              Max Frequency:     2.750 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            CPU 2:
                                                              Microarchitecture: Everest
                                                              Max Frequency:     4.050 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    81.60 GFLOP/s
[ERROR]: fill_soc: soc->soc_vendor == SOC_VENDOR_UNKOWN
[VERSION]: cpufetch v1.04-35-g5ffe (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
cpufetch v1.04-35-g5ffe (macOS ARM build)
hw.cpufamily: 0x5F4DEA93
hw.cpusubfamily: 0x00000004
hw.physicalcpu: 12
Dr-Noob commented 6 months ago

@Dr-Noob Similar as before:

[ERROR]: fill_soc: soc->soc_vendor == SOC_VENDOR_UNKOWN
[VERSION]: cpufetch v1.04-35-g5ffe (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            CPU 1:
                                                              Microarchitecture: Sawtooth
                                                              Max Frequency:     2.750 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            CPU 2:
                                                              Microarchitecture: Everest
                                                              Max Frequency:     4.050 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    81.60 GFLOP/s
[ERROR]: fill_soc: soc->soc_vendor == SOC_VENDOR_UNKOWN
[VERSION]: cpufetch v1.04-35-g5ffe (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
cpufetch v1.04-35-g5ffe (macOS ARM build)
hw.cpufamily: 0x5F4DEA93
hw.cpusubfamily: 0x00000004
hw.physicalcpu: 12

What about now? (Sorry for the spam, sometimes it's difficult to do this without the hardware to test it)

Onnwen commented 6 months ago

@Dr-Noob Similar as before:

[ERROR]: fill_soc: soc->soc_vendor == SOC_VENDOR_UNKOWN
[VERSION]: cpufetch v1.04-35-g5ffe (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues

                                                            SoC:                 Unknown
                                                            Technology:          Unknown
                                                            CPU 1:
                                                              Microarchitecture: Sawtooth
                                                              Max Frequency:     2.750 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            CPU 2:
                                                              Microarchitecture: Everest
                                                              Max Frequency:     4.050 GHz
                                                              Cores:             6 cores
                                                              Features:          NEON,SHA1,SHA2,AES,CRC32
                                                            Peak Performance:    81.60 GFLOP/s
[ERROR]: fill_soc: soc->soc_vendor == SOC_VENDOR_UNKOWN
[VERSION]: cpufetch v1.04-35-g5ffe (macOS ARM build)
Please, create a new issue with this error message, your smartphone/computer model, the output of 'cpufetch --verbose' and 'cpufetch --debug' on https://github.com/Dr-Noob/cpufetch/issues
cpufetch v1.04-35-g5ffe (macOS ARM build)
hw.cpufamily: 0x5F4DEA93
hw.cpusubfamily: 0x00000004
hw.physicalcpu: 12

What about now? (Sorry for the spam, sometimes it's difficult to do this without the hardware to test it)

I know, no problem! Happy to help out. Now it seems to work like a charm!

Screenshot 2023-12-24 alle 18 16 31
Dr-Noob commented 6 months ago

So everything looks good to me except for the peak performance. I've fixed that and merged everything into master. If you guys could confirm that everything works as expected I would greatly appreciate it - I'll close the issue, but feel free to reopen it if you find anything any issue. Thanks for your time!

pthariensflame commented 6 months ago

Works for me here too!


                   ."c.
                 ,xNMM.
                .lMM"           SoC:                 Apple M3 Max
                MM*             Technology:          3nm
     .;loddo;:.   olloddol;.    CPU 1:
   cKMMMMMMMMMMNWMMMMMMMMMMM0:    Microarchitecture: Sawtooth
 .KMMMMMMMMMMMMMMMMMMMMMMMW*      Max Frequency:     2.750 GHz
 XMMMMMMMMMMMMMMMMMMMMMMMX.       Cores:             12 cores
;MMMMMMMMMMMMMMMMMMMMMMMM:        Features:          NEON,SHA1,SHA2,AES,CRC32
:MMMMMMMMMMMMMMMMMMMMMMMM:      CPU 2:
.MMMMMMMMMMMMMMMMMMMMMMMMX.       Microarchitecture: Everest
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.     Max Frequency:     4.050 GHz
 'XMMMMMMMMMMMMMMMMMMMMMMMMMMk    Cores:             4 cores
  'XMMMMMMMMMMMMMMMMMMMMMMMMK.    Features:          NEON,SHA1,SHA2,AES,CRC32
    kMMMMMMMMMMMMMMMMMMMMMMd    Peak Performance:    327.60 GFLOP/s
     'KMMMMMMMWXXWMMMMMMMk.
       "cooc"*    "*coo'"