cpu_features icon indicating copy to clipboard operation
cpu_features copied to clipboard

Support for macOS/iOS with ARM64 CPU

Open hjmallon opened this issue 5 years ago • 6 comments

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

hjmallon avatar Aug 07 '20 09:08 hjmallon

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 avatar Dec 21 '20 23:12 sbehnke

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.

sbehnke avatar Dec 22 '20 02:12 sbehnke

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

hjmallon avatar Jan 04 '21 11:01 hjmallon

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.

sbehnke avatar Jan 05 '21 21:01 sbehnke

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.

gchatelet avatar May 21 '21 09:05 gchatelet

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.

dkozel avatar Jul 15 '21 11:07 dkozel