-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for the M1 Pro (fetching CPU info with sysctl) #139
Comments
Hi, thank you very much for your brief research on this and your suggestions. Regarding the cache, as I don't support cache sizes for any other ARM chip, at the moment I'm not interested in adding it just for M1. Funny thing that macOS let you know the cache sizes but, AFAIK, Linux does not. And you are right, cpufetch simply assumes that the CPU is the Apple M1 if the program was compiled for ARM and it detects a CPU with the M1 cores, but does not differentiate between M1 versions (when this was implemented, only M1 existed). I think the best thing to do is to write here my decisions on how I did this and why, and how am I going to approach this now that are different M1 versions, just for anybody interested in this (one of such will probably be myself in the future 😅). So be prepared for a somewhat long discussion (TL;DR included). I started looking for many sysctl dumps, even trying different computers by myself. I thought that Now you're suggesting to use I still keep the faith that this crappy design in Apple OS is not that crappy and that there is a way to do this properly do this even in older macOS. My bet is to use
Which correspond to: TL;DR: My best bet is to use |
Good to know! I merged the changes to the master branch, so I'm closing the issue. Thanks for noticing the problem and reporting back the result! |
Hi there,
Just learned about this (very cool) project, and noticed that the macOS version only supports the base M1 CPU and not the M1 Pro or M1 Max. Looking at the code related to macOS M1 support it looks like cpufetch is hard-coded to assume an M1 if it's running on arm64 macOS.
Checking on my own M1 Pro machine, it looks like the CPU name, number of performance/efficiency cores, feature support flags, cache sizes, etc. are all available through the system's sysctl library. Since I'm pretty sure you can access sysctl values directly in C, you could probably add more flexible & future-proof Apple Silicon support using the relevant field names.
Anyway, here are the names of the relevant fields (and their values) via
sysctl -a
on my Mac:In this case,
hw.perflevel1.logicalcpu
gives you the number of efficiency cores (2) andhw.perflevel1.logicalcpu
is the number of performance cores (8), andmachdep.cpu.brand_string
tells you whether it's a "Pro" or a "Max" chip. I've found a similar table for the standard M1 posted here for comparison. There's some info about calculating per-core cache sizes from these values here too.Some similar sysctl dumps I found for base M1s don't have the separate performance/efficiency core info fields though, so those fields might have been added in macOS 12 and thus need a fallback for macOS 11.
Hope this is helpful!
The text was updated successfully, but these errors were encountered: