Skip to content

cmake: build the Arm DOTPROD DNN kernels (vdotq_s32)#482

Open
czoli1976 wants to merge 1 commit into
xiph:mainfrom
czoli1976:cmake-arm-dnn-dotprod
Open

cmake: build the Arm DOTPROD DNN kernels (vdotq_s32)#482
czoli1976 wants to merge 1 commit into
xiph:mainfrom
czoli1976:cmake-arm-dnn-dotprod

Conversation

@czoli1976

Copy link
Copy Markdown

Summary

CMake builds never compiled the int8 dot-product DNN tier. cmake/OpusSources.cmake reads DNN_SOURCES_DOTPROD into ${dnn_sources_arm_dotprod}, but that variable was never added to a target, and CMake had no Arm DOTPROD detection at all. So CMake builds with DNN features (DRED / OSCE / Deep PLC) ran the multi-instruction vmull_s8 / vpadalq_s16 emulation in cgemv8x4 instead of the one-instruction vdotq_s32 — unlike the Autotools and Meson builds, which wire it correctly.

Fix

  • opus_detect_dotprod() in OpusFunctions.cmake — a compiler test for vdotq_s32 under -march=armv8.2-a+dotprod, mirroring opus_detect_neon().
  • OpusConfig.cmake — call it on Arm and set OPUS_MAY_HAVE_DOTPROD when supported.
  • CMakeLists.txt — when supported, define OPUS_ARM_MAY_HAVE_DOTPROD and (for DNN builds) compile ${dnn_sources_arm_dotprod} with the dotprod -march flag.

The kernel is dispatched at runtime via the existing RTCD table; non-DOTPROD targets keep the NEON path. This brings CMake in line with Autotools/Meson.

Verification (Apple M4)

  • cmake -DOPUS_DRED=ON: configure reports Check DOTPROD support by compiler ... Success, nnet_dotprod.c compiles with -march=armv8.2-a+dotprod, and compute_linear_dotprod is linked (previously absent).
  • Default (non-DNN) build unaffected.

Independent of, and complementary to, #471 / #478 (which gate the Arm DNN RTCD source / fix a Windows-ARM linker issue when DNN is disabled); this adds the DOTPROD tier when DNN is enabled.

CMake never compiled the int8 dot-product DNN tier: cmake/OpusSources.cmake
reads DNN_SOURCES_DOTPROD into ${dnn_sources_arm_dotprod}, but it was never
added to a target, and CMake had no Arm DOTPROD detection at all. As a
result, CMake builds with DNN features (DRED / OSCE / Deep PLC) ran the
multi-instruction vmull_s8 / vpadalq_s16 emulation in cgemv8x4 instead of the
one-instruction vdotq_s32 -- unlike the Autotools and Meson builds, which
wire it correctly.

Add an opus_detect_dotprod() compiler test (mirroring opus_detect_neon) and,
when supported, define OPUS_ARM_MAY_HAVE_DOTPROD and compile
${dnn_sources_arm_dotprod} (nnet_dotprod.c) with -march=armv8.2-a+dotprod.
The kernel is dispatched at runtime via the existing RTCD table; targets
without DOTPROD keep the NEON path.

Verified on Apple M4: `cmake -DOPUS_DRED=ON` now detects DOTPROD, compiles
nnet_dotprod.c with the flag, and links compute_linear_dotprod; the default
(non-DNN) build is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant