Skip to content

Conversation

@dlenski
Copy link
Contributor

@dlenski dlenski commented May 22, 2024

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
Copy link
Contributor

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!

};
decode_package_name(packages[i].name);
if (!read_package_name_from_brand_string(packages[i].name))
decode_package_name_from_hw_machine(packages[i].name);
Copy link
Contributor Author

@dlenski dlenski May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic in decode_package_name_from_hw_machine has already become somewhat obsolete, which is why it makes sense to prefer read_package_name_from_brand_string wherever it succeeds on newer devices/OSes.

For example, the package in iPhone 15 Pro should be described as Apple A17 Pro, rather than simply A17 (which is what the current logic would show, according to the hw.machine values shown at: https://gist.github.com/adamawolf/3048717#file-apple_mobile_device_types-txt-L55-L56).

@dlenski
Copy link
Contributor Author

dlenski commented Nov 27, 2024

This PR does exactly what it says it does, but it has not received any review or comments for ~6 months.

I see that @gonnet has recently merged a PR for Apple/Mach (973ec72). Perhaps he could review this one as well? 😃

@dlenski
Copy link
Contributor Author

dlenski commented Dec 4, 2024

I fixed the clang-format violation from d8d9389 in 04efc5e (diff):

diff --git a/src/arm/mach/init.c b/src/arm/mach/init.c
index b37b6bb..c4e6521 100644
--- a/src/arm/mach/init.c
+++ b/src/arm/mach/init.c
@@ -109,7 +109,7 @@ static int read_package_name_from_brand_string(char* package_name) {
                return false;
        }

-       char *brand_string = alloca(size);
+       char* brand_string = alloca(size);
        if (sysctlbyname("machdep.cpu.brand_string", brand_string, &size, NULL, 0) != 0)
                goto sysctlfail;
        cpuinfo_log_debug("machdep.cpu.brand_string: %s", brand_string);

@malfet, @gonnet, could whoever trigger the PR workflows please retrigger it? 😅

…ding hw.machine

This functionality was implemented in pytorch#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 pytorch#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
@F0bes
Copy link

F0bes commented Mar 12, 2025

Hi there. I come from @PCSX2 and we depend on this library.
In hopes that this gets some attention, and so we can avoid manually patching the dependency, I just wanted to say that I've applied this patch locally and it works as expected. I'm using an Apple Mac Mini M4 Pro.
Thanks :)

@digantdesai digantdesai self-requested a review March 21, 2025 07:02
@digantdesai
Copy link
Contributor

Thanks. LGTM. Sorry for the delay.

@digantdesai digantdesai merged commit 5e3d244 into pytorch:main Mar 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants