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

Support for macOS/iOS with ARM64 CPU #121

Open
hjmallon opened this issue Aug 7, 2020 · 6 comments
Open

Support for macOS/iOS with ARM64 CPU #121

hjmallon opened this issue Aug 7, 2020 · 6 comments
Assignees
Labels
Apple M1 Apple M1 related issues enhancement New feature or request help wanted Extra attention is needed

Comments

@hjmallon
Copy link

hjmallon commented Aug 7, 2020

This may also help with iOS?

Here is part of the sysctl -a from an Apple DTK. These can be queried with sysctlbyname.

hw.optional.floatingpoint: 1
hw.optional.watchpoint: 4
hw.optional.breakpoint: 6
hw.optional.neon: 1
hw.optional.neon_hpfp: 1
hw.optional.neon_fp16: 1
hw.optional.armv8_1_atomics: 1
hw.optional.armv8_crc32: 1
hw.optional.armv8_2_fhm: 0
hw.optional.amx_version: 0
hw.optional.ucnormal_mem: 0
hw.optional.arm64: 1
@Mizux Mizux added the enhancement New feature or request label Aug 7, 2020
@gchatelet gchatelet added the help wanted Extra attention is needed label Sep 21, 2020
@sbehnke
Copy link

sbehnke commented Dec 21, 2020

On my M1 MacBook Pro 13" I have the following:

hw.optional.floatingpoint: 1
hw.optional.watchpoint: 4
hw.optional.breakpoint: 6
hw.optional.neon: 1
hw.optional.neon_hpfp: 1
hw.optional.neon_fp16: 1
hw.optional.armv8_1_atomics: 1
hw.optional.armv8_crc32: 1
hw.optional.armv8_2_fhm: 1
hw.optional.armv8_2_sha512: 1
hw.optional.armv8_2_sha3: 1
hw.optional.amx_version: 2
hw.optional.ucnormal_mem: 1
hw.optional.arm64: 1

I've started adding support to query these on my machine and have it detecting a few of them now, but I'm having a hard time mapping between the Arm Features struct and the Apple optional names. Is there a description for what these mean on the ArmFeature struct? Also, for something like hw.optional.armv8_2_sha512 and hw.optional.armv8_2_sha3 that don't appear to have any support in cpu_feature, should we extend the struct to support them?

@sbehnke
Copy link

sbehnke commented Dec 22, 2020

I figured out why it wasn't detecting as aarch64 and it appears to be matching a bit better now.

❯ ./list_cpu_features
arch            : aarch64
implementer     : 16777228 (0x100000C)
variant         :   2 (0x02)
part            : 458787763 (0x1B588BB3)
revision        :   2 (0x02)
flags           : asimdfhm,atomics,crc32,fp,fphp,sha3,sha512

It's getting there but I still need to fix the part that isn't coming from the flags.

@hjmallon
Copy link
Author

hjmallon commented Jan 4, 2021

@sbehnke
Copy link

sbehnke commented Jan 5, 2021

There are also tables here https://github.com/pytorch/cpuinfo/blob/master/src/arm/mach/init.c

I can certainly add a table entry for the M1 CPU, but do I just take the values from the docker instance of cpu_features? I'm not sure where to find a complete list of non-optional features implemented on the CPU.

@gchatelet
Copy link
Collaborator

To be clear, we are definitely interested in supporting Apple M1 but we are willing to wait a bit for the M1 build ecosystem to settle as it is unclear yet how to make it work with Universal2 builds.

@dkozel
Copy link

dkozel commented Jul 15, 2021

Is there any fix possible to resolve the compile issue? It'd be very preferable to report an empty list of CPU features than to fail to compile.

@gchatelet gchatelet added the Apple M1 Apple M1 related issues label Oct 18, 2021
toor1245 pushed a commit to toor1245/cpu_features that referenced this issue Aug 18, 2022
To add support AARCH64 for other operating systems such as macOS(Apple M1), ios, FreeBSD, Windows has been moved common logic from 
`src/impl_aarch64_linux_or_android.c` to `src/impl_aarch64__base_implementation.inl`, namely:
* Definitions for introspection
* `Aarch64Info` kEmptyAarch64Info field

Removed include "internal/bit_utils.h" from `src/impl_aarch64_linux_or_android.c`, since this include was not used. Also, include `cpuinfo_aarch64` has been removed  from linux implementation and replaced with `impl_aarch64__base_implementation.inl`, this include will be used for all other operating system impl as well

Added a compilation check that matches the base X86 implementation

Refs: google#121
See also: google#150, google#186, google#204
toor1245 pushed a commit to toor1245/cpu_features that referenced this issue Aug 18, 2022
To add support AARCH64 for other operating systems such as macOS(Apple M1), ios, FreeBSD, Windows has been moved common logic from 
`src/impl_aarch64_linux_or_android.c` to `src/impl_aarch64__base_implementation.inl`, namely:
* Definitions for introspection
* `Aarch64Info` kEmptyAarch64Info field

Removed include "internal/bit_utils.h" from `src/impl_aarch64_linux_or_android.c`, since this include was not used. Also, include `cpuinfo_aarch64` has been removed from linux implementation and replaced with `impl_aarch64__base_implementation.inl`, this include will be used for all other operating systems impl as well

Added a compilation check that matches the base X86 implementation

Refs: google#121
See also: google#150, google#186, google#204
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apple M1 Apple M1 related issues enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants
@sbehnke @gchatelet @dkozel @hjmallon @Mizux and others