Skip to content
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

Refactor windows arm64 for auto cpu detection #283

Merged

Conversation

ozanMSFT
Copy link
Contributor

@ozanMSFT ozanMSFT commented Mar 14, 2025

Fixes #270


Before:

Error in cpuinfo: Unknown chip model name 'Snapdragon(R) CPU'.

After fix (tested with Pytorch 2.7.0 nightly):

No print - successful detection

Example detection (printed messages only for debugging purposes):

image

Refactoring Windows ARM64 CPU detection with the MIDR implementation.

In this way, Windows detection will use the same structure as Linux.

Previously, some pre-defined CPU information was stored hardcoded in the source code. Now, it is automatically reading MIDR and decoding it.

MIDR documentation

Value is stored in:

HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\CP 4000

CP 4000: MIDR_EL1
CP 4020: ID_AA64PFR0_EL1
CP 4021: ID_AA64PFR1_EL1
CP 4028: ID_AA64DFR0_EL1
CP 4029: ID_AA64DFR1_EL1
CP 402C: ID_AA64AFR0_EL1
CP 402D: ID_AA64AFR1_EL1
CP 4030: ID_AA64ISAR0_EL1
CP 4031: ID_AA64ISAR1_EL1
CP 4038: ID_AA64MMFR0_EL1
CP 4039: ID_AA64MMFR1_EL1
CP 403A: ID_AA64MMFR2_EL1

Missing Snapdragon Oryon is added.


Previously api.h and uarch.c were not used by Windows detection logic. However, to make it common with Linux, we are now using them.

Since restrict static is not supported by MSVC, I had to add following macro.

#ifdef _MSC_VER
#define RESTRICT_STATIC /* nothing for MSVC */
#else
#define RESTRICT_STATIC restrict static
#endif

@seemethere
Copy link
Member

LGTM

@seemethere seemethere merged commit d6120c7 into pytorch:main Mar 20, 2025
11 of 12 checks 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.

Enhancement: Refactoring Windows ARM64 - CPU Detection Logic
3 participants