On ggml-cpu: tweak ARM_NATIVE_FLAG native baseline arch when extensions need it - #27984
On ggml-cpu: tweak ARM_NATIVE_FLAG native baseline arch when extensions need it#27984cameronelliott wants to merge 1 commit into
Conversation
GGML_NATIVE detects extensions like dotprod/i8mm/sve/sme on the detected CPU and appends them to an -march=armv8-a (or 8.1-a) base. GCC's ACLE intrinsics for these extensions are declared always_inline against a minimum architecture version (e.g. dotprod needs armv8.2-a), so inlining fails with 'target specific option mismatch' when the translation unit's own baseline stays at armv8-a. Raise the base version token to the minimum the detected extensions require, matching the version thresholds already used by the GGML_CPU_ALL_VARIANTS path in this same file.
|
It might be worth posting the benchmarks I ran (some text below is AI output): Model:
This fix gives a 2.08x speedup over CPU-mode, using the default build command, with no extra |
| if ("${ARM_NATIVE_FLAG}" MATCHES "^-march=armv8(\\.[01])?-a") | ||
| set(ARM_NATIVE_MIN_ARCH "armv8-a") | ||
| if ("${ARM_NATIVE_FLAG}" MATCHES "\\+sme") | ||
| set(ARM_NATIVE_MIN_ARCH "armv9.2-a") |
There was a problem hiding this comment.
apple m4 might be broken because of that, did you check ?
Overview
When I tried to compile llama.cpp c841aee on my slightly rare situation,
which is Debian 12 (GCC 12.2.2) running under the Apple Virtualization.framework (under Orbstack tool), it fails to compile.
Issue #27982 contains full version info, and build failure log
In CMakeFile.txt, this raises the base version of ARM_NATIVE_MIN_ARCH given the extensions to work better on GCC 12.x, based upon ARM extension: (dotprod, i8mm, sve, sme)
So, for my hardware I have built and tested: dotprod(8.2-a) and i8mm(8.6-a)
I haven't personally verified these branches: sve2 and sme, but the should be fine given the GGML_CPU_ALL_VARIANTS block in the CMakefile
I tested on GCC 12.2.0 on Debian 12 under an Apple M5 Cpu under the Apple Virtualization.framework
Additional information
This code was provided by Claude Code, under my direction
Claude Code explanation
GGML_NATIVE detects extensions like dotprod/i8mm/sve/sme on the detected CPU and appends them to an -march=armv8-a (or 8.1-a) base. GCC's ACLE intrinsics for these extensions are declared always_inline against a minimum architecture version (e.g. dotprod needs armv8.2-a), so inlining fails with 'target specific option mismatch' when the translation unit's own baseline stays at armv8-a.
Raise the base version token to the minimum the detected extensions require, matching the version thresholds already used by the GGML_CPU_ALL_VARIANTS path in this same file.
This was authored by Cameron Elliott, human.