Halide icon indicating copy to clipboard operation
Halide copied to clipboard

Detect ARM CPU features for host target and in runtime

Open alexreinking opened this issue 1 year ago • 6 comments

Adds feature detection to the runtime library and to the host target feature computation.

Not sure what the best way is to share code here. Not sure how best to test on Android or Windows/ARM, either.

Fixes #4727 Fixes #6106 Fixes #7901 Fixes #7979

alexreinking avatar Jun 16 '24 20:06 alexreinking

Not sure what the best way is to detect the ARMv8.1-A feature. It seems certain other features (e.g. sve/dotprod) imply it, or not (armv7s).

alexreinking avatar Jun 17 '24 15:06 alexreinking

Regarding the tutorial failures, lesson 15 uses the target string host-x86-64 to infer the OS

But with this PR, host will be something like arm-64-osx-arm_dot_prod-arm_fp16. This then becomes x86-64-osx-arm_dot_prod-arm_fp16-sse4 which makes no sense.

The fundamental issue is that "the host but on a different architecture" isn't a well-defined thing.

Brainstorming a few possible resolutions:

  1. Define changing the arch of a target to clear all arch-specific features
  2. Interpret host in the os-position to mean the host os and no more. The target string in the lesson would become x86-64-host.
    1. Bike-shed: use os or hostos in place of host?
  3. Change the lesson to use x86-64-linux instead of host-x86-64.

alexreinking avatar Jun 17 '24 17:06 alexreinking

Pending further discussion, I'm using this option to continue making progress:

Change the lesson to use x86-64-linux instead of host-x86-64.

alexreinking avatar Jun 17 '24 18:06 alexreinking

Ready to land?

steven-johnson avatar Jun 24 '24 15:06 steven-johnson

No, the windows ARM code is still just a guess. We're trying to figure out how to test it.

abadams avatar Jun 24 '24 17:06 abadams

I'm trying to test it inside a Windows 11 ARM VM via UTM

alexreinking avatar Jun 26 '24 13:06 alexreinking

With the latest commit, I have get_host_target confirmed working in the Windows 11 UTM VM. The changes to the LLVM runtime linker were necessary for building Halide with AArch64 but not ARM (to cut down on LLVM build times... building LLVM on ARM64 windows is a nightmare).

image

Related to #2282

alexreinking avatar Jul 08 '24 18:07 alexreinking

Review ping

alexreinking avatar Jul 12 '24 19:07 alexreinking