pytorch / cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
BSD 2-Clause "Simplified" License
962 stars 306 forks source link

For Apple silicon, use machdep.cpu.brand_string in preference to decoding hw.machine #246

Open dlenski opened 1 month ago

dlenski commented 1 month ago

This functionality was implemented in #65 ("Updated package.name to also query machdep.cpu.brand_string if decode of hw.machine fails"), but then it was omitted from the subsequent #100, probably inadvertently.

Adding that functionality back here, so that the package/device name can be shown correctly on recent devices and macOS/iOS versions. I have reversed the order so that machdep.cpu.brand_string is checked before attempting to decode hw.machine, since the former appears to be more future-proof.

Before this change, on a recent MacBook Pro:

$ cpu-info
...
Debug (cpuinfo): hw.machine: arm64
Warning in cpuinfo: parsing "hw.machine" failed: Undefined error: 0
...
Packages:
    0:

After this change:

$ cpu-info
...
Debug (cpuinfo): machdep.cpu.brand_string: Apple M2 Pro
...
Packages:
    0: Apple M2 Pro
facebook-github-bot commented 1 month ago

Hi @dlenski!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!