google / highway

Performance-portable, length-agnostic SIMD with runtime dispatch
Apache License 2.0
3.95k stars 305 forks source link

WARNING: CPU supports 0x6000000030000000, software requires 0x2000000034000000 #2199

Closed jgouly closed 1 month ago

jgouly commented 1 month ago

I updated Highway revisions and now get:

WARNING: CPU supports 0x6000000030000000, software requires 0x2000000034000000

This seems to be because of 8b7899dfcb8f5ae62be7e70903342b7be0f305d9. If it's doing runtime detection, I'm not sure why it has to warn?

jan-wassenberg commented 1 month ago

Thanks for reporting. This warning indicates that we are assuming support for targets that aren't actually supported, or that the detection logic has erroneously concluded a target is unavailable. In either case, it's good to understand and fix the cause.

The new NEON_BF16 target is indeed the trigger. It would be disabled unless we are compiling with Clang >= 17 or GCC >= 13.2. It should also only be used if the correct compiler flags are given. Can you confirm that adding the following at the top of your source file indeed triggers "all enabled"?

#if defined(__ARM_FEATURE_AES) &&                    \
    defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && \
    defined(__ARM_FEATURE_DOTPROD) &&                \
    defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)
#error "all enabled"
#endif

If so, then we have the case where we're wanting to use something but the detection fails. Is this on Apple? If so, we're checking

    if (HasCpuFeature("hw.optional.AdvSIMD_HPFPCvt") &&
        HasCpuFeature("hw.optional.arm.FEAT_DotProd") &&
        HasCpuFeature("hw.optional.arm.FEAT_BF16")) {

otherwise, we're checking getauxval(AT_HWCAP) for HWCAP_ASIMDHP | HWCAP_ASIMDDP | HWCAP_ASIMDBF16. Are any of those not set on your system?

jgouly commented 1 month ago

This is an Apple M2 machine running Asahi Linux.

HWCAP_ASIMDBF16 is actually an AArch32 hwcap https://github.com/torvalds/linux/blob/master/arch/arm64/include/asm/hwcap.h#L38

I think that should be replaced with HWCAP2_BF16: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h#L76

Testing that, and the WARNING disappears.

jan-wassenberg commented 1 month ago

Ah, thank you for pointing that out! Golly, that's an unexpected wart, given the naming. Fixing shortly :)