Halide icon indicating copy to clipboard operation
Halide copied to clipboard

arm_cpu_features.cpp is a no-op

Open steven-johnson opened this issue 2 years ago • 6 comments

We don't attempt to detect any features of the host CPU on arm; surely we can do better, at least on Android.

steven-johnson avatar Dec 05 '23 20:12 steven-johnson

I looked into this recently, and the state of host cpu feature sniffing on arm is woeful. There's an instruction for it, but it's privileged so user code can't run it. I checked xnnpack because I know it makes per-cpu decisions about what code to run, and it uses https://github.com/pytorch/cpuinfo which literally opens /proc/cpuinfo as a file and parses the string on linux-like targets.

abadams avatar Dec 05 '23 21:12 abadams

The Golang runtime uses hwcap bits for Android and sysctlEnabled() for Darwin. (IIRC Arm recommends avoiding /proc/cpuinfo in favor of hwcap on linux.)

steven-johnson avatar Dec 05 '23 21:12 steven-johnson

https://github.com/google/cpu_features is fairly well elaborated. I doubt we want to make it a dependency, but maybe providing the glue code to use it as an optional thing to add to one's build would be useful.

zvookin avatar Dec 05 '23 21:12 zvookin

Does this apply to AArch64, too? I see there's a comment in aarch64_cpu_features.cpp that reads:

// AArch64 has no CPU-specific Features.

But isn't ARMDotProd an AArch64 extension? We probably want to check for SVE/SVE2, too.

alexreinking avatar Jun 14 '24 21:06 alexreinking

Yes it does. The main problem here is that it fails to turn on armdotprod. I think that comment is from before we added dot product support.

abadams avatar Jun 14 '24 21:06 abadams

See #7901

abadams avatar Jun 14 '24 21:06 abadams