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

Added Apple Silicon support to WoA #167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vladimir-aubrecht
Copy link

Added support for Apple Silicon.

@Maratyszcza
Copy link
Contributor

How do you differentiate M1/M1 Pro/M2/etc?

@vladimir-aubrecht
Copy link
Author

vladimir-aubrecht commented Jul 20, 2023

How do you differentiate M1/M1 Pro/M2/etc?

Great question, not so great answer ... 😕

I tried to preserve compatibility with current code and from that perspective all M1s are identical - they have same frequency and same types of high/low efficiency cores. This is not optimal, but if I did not miss something, returning more information - like amount of cores - would require breaking changes and this change at least prevents failures on M1s.

About distinguishing between M1 & M2, honestly I don't know. I don't have M2 to test it and did not find what string will be shown in Windows Registry for M2. I was hoping for different string or somebody updating the code when it will become problem.

@Maratyszcza
Copy link
Contributor

The current solution would likely produce wrong results on M2, which is a big no for cpuinfo. I'd rather have it report unknown that report wrong data. Please borrow an M2 Mac and try to figure out the answer. I found that SYSTEM_INFO::wProcessorLevel returned by GetSystemInfo seems to contain the "Part" component of the MIDR. Maybe this would be sufficient to distinguish M1, M2, and later cores.

@vladimir-aubrecht
Copy link
Author

@Maratyszcza I checked SYSTEM_INFO::wProcessorLevel and unfortunately it has value 0 on both M1 and M2. This could be due to running in VM as that is only way how to run Windows on M1 & M2 at this moment.

I tried to check also other attributes, but as far as I am aware of, there is no way how to distinguish M1 & M2 at this moment 😕 (you can check attached screenshots of Windows Registry + output of wmic cpu get which provides same value as SYSTEM_INFO::wProcessorLevel in Level field and more ...).

I am not sure how to follow up on this due to inability to distinguish between those CPUs. Do we need distinction between M1 & M2? I mean they are both Apple Silicon, so reporting Apple Silicon would be technically correct in all cases and it's more question of if we need distinction between them for something? What do you think?

Registry M1
Registry M2

WMIC M1
WMIC M2

@vladimir-aubrecht vladimir-aubrecht marked this pull request as ready for review August 1, 2023 13:25
@vladimir-aubrecht
Copy link
Author

@Maratyszcza Any ideas on how to proceed? Are you ok with suggested solution?

@Maratyszcza
Copy link
Contributor

Without the ability to distinguish variants of Apple Silicon all we can do is set vendor to cpuinfo_vendor_apple, as all other information is unreliable. Narrowing down this change to just the vendor setting would be acceptable, although not very useful.

I'd like to encourage you to check within Microsoft what other ways there can be to retrieve information about the cores. In particular, if you could get MIDR data for the cores, we could decode the microarchitecture and use them for ISA feature detection (e.g. Apple M2 supports BF16 and I8MM while Apple M1 doesn't).

@Maratyszcza
Copy link
Contributor

One hint might be the CP4020...CP5801 values reported in the registry. They are evidently different across M1 and M2, but it is unclear what they represent. CP4020 looks like MIDR, albeit a fake one, probably others are different system registers.

@Maratyszcza
Copy link
Contributor

This source snippet suggest that CP NNN these are indeed system registers.

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.

3 participants