Files
daedalus-fourier/CMakeLists.txt
T
marfrit 8182e43c15 Phase 7 M4: mixed CPU+QPU beats pure 4-core NEON; project continues
The YELLOW-band gate test from phase1.md (concurrent CPU+QPU vs
pure-CPU baseline). tests/bench_concurrent.c is a pthread harness
that runs N NEON workers (pinned to cores 0..N-1) and optionally a
QPU dispatch loop on its own pinned thread; 8s time-based windows;
sums per-worker block counts.

Raw results on hertz (1920x1088, 32640 blocks/dispatch):

  Config                       Mblock/s   1080p FPS-eq
  NEON 1-core                  12.623     389.6
  NEON 4-core                   7.074     218.3   <- realistic CPU ceiling
  QPU only                      6.890     212.7
  MIXED NEON-3 + QPU            7.583     234.0   <- +7.2 % over NEON-4
  MIXED NEON-4 + QPU            7.739     238.9   <- +9.4 % oversubscribed

Headline findings beyond the gate test itself:

F1 — Pi 5 LPDDR4x saturates well before 4-core CPU scaling.
     NEON-1 (12.6) > NEON-4 (7.1): 4 cores deliver 0.56x the
     per-core throughput, not 4x. The realistic CPU ceiling for
     memory-bound IDCT work is ~7 Mblock/s aggregate, not the
     ~32 Mblock/s a naive 4x scaling would predict. This recasts
     phase7.md's R=0.92 framing: the right baseline is "4-core
     NEON saturated", which the QPU effectively matches (6.89
     vs 7.07) on its own.

F2 — QPU contributes meaningfully BECAUSE it doesn't fully share
     the CPU's bandwidth bottleneck (own access channel + v3d L2
     cache partially insulate it). Mixed adds the QPU's 0.51
     Mblock/s on top of an already-saturated CPU.

F3 — Oversubscribed mode (NEON-4 + QPU) is not harmful — per-NEON
     drops slightly but QPU adds more than the loss. Net +9 %.

F4 — Freed-core story is bigger than the throughput delta. In
     mixed NEON-3+QPU, the 4th core is 100 % free for entropy
     decode (Bool coder, ANS) which MUST run on CPU. Pure NEON-4
     has nothing left. Realistic decode pipeline gets more like
     a 30-50 % effective throughput uplift, not just 7 %.

Verdict per phase1.md YELLOW-band rule (mixed > pure-CPU): PASS.
Project continues to next-kernel cycle (recommend deblocking or
CDEF — same "small parallel block-level" workload class that
amortises the same M4 wins).

docs/phase7_M4.md captures the full M4 harness design, all 5
configs raw output, and the leaves-open items: M7 wall-power via
Himbeere plug, sustained-thermal test, realistic-bitstream
coefficient distribution, multi-frame async pipelining.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-18 12:18:36 +00:00

140 lines
5.1 KiB
CMake

# daedalus-fourier — Phase 3 baseline + (later) Phase 6 implementation.
#
# Builds:
# bench_neon_idct — NEON throughput baseline (Phase 3 M3) +
# bit-exact correctness gate (Phase 1 M1).
# bench_vulkan_dispatch — Vulkan compute dispatch-overhead baseline (M5).
#
# Linkage note: bench_neon_idct statically links the vendored
# FFmpeg n7.1.3 NEON snapshot (LGPL-2.1+); see
# external/ffmpeg-snapshot/PROVENANCE.md.
cmake_minimum_required(VERSION 3.20)
project(daedalus-fourier C ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
message(FATAL_ERROR
"daedalus-fourier targets aarch64 (Pi 5 / BCM2712). "
"Cross-compile not yet wired.")
endif()
add_compile_options(-Wall -Wextra -Wno-unused-parameter)
# ---- Vendored FFmpeg snapshot (LGPL-2.1+) -----------------------------------
set(FFSNAP ${CMAKE_SOURCE_DIR}/external/ffmpeg-snapshot)
# Assembly preamble (config.h shim + FFmpeg's asm helpers) used by the
# vendored .S file. -I flags expose:
# - FFSNAP/ so `#include "config.h"` finds our shim
# - FFSNAP/libavcodec/aarch64/ so `#include "neon.S"` finds the helper
# - FFSNAP/ so `#include "libavutil/aarch64/asm.S"`
# resolves against the vendored copy
set(FFASM_FLAGS
-I${FFSNAP}
-I${FFSNAP}/libavcodec/aarch64
-I${FFSNAP}
)
set(FFASM_SOURCES
${FFSNAP}/libavcodec/aarch64/vp9itxfm_neon.S
)
# Tell CMake/gas to preprocess .S sources.
set_source_files_properties(${FFASM_SOURCES} PROPERTIES
COMPILE_OPTIONS "${FFASM_FLAGS}"
LANGUAGE ASM)
# ---- NEON baseline microbench ----------------------------------------------
add_executable(bench_neon_idct
tests/bench_neon_idct.c
tests/vp9_idct8_ref.c
${FFASM_SOURCES}
)
target_compile_options(bench_neon_idct PRIVATE -O3 -march=armv8-a+simd)
# bench_neon_idct doesn't need vulkan/drm — pure CPU baseline.
# ---- Vulkan dispatch-overhead microbench (next chunk) ----------------------
# Stub: written in a follow-up step. Toggle ON with -DDAEDALUS_BUILD_VULKAN=ON
# once tests/bench_vulkan_dispatch.c exists.
option(DAEDALUS_BUILD_VULKAN "Build Vulkan compute-dispatch microbench" ON)
if (DAEDALUS_BUILD_VULKAN)
find_package(Vulkan REQUIRED)
# Compile GLSL compute shaders to SPIR-V via glslangValidator.
# The binary loads them at runtime from the build dir (cwd-relative).
find_program(GLSLANG_VALIDATOR
NAMES glslangValidator glslang
REQUIRED)
set(NOOP_SPV ${CMAKE_BINARY_DIR}/noop.spv)
add_custom_command(
OUTPUT ${NOOP_SPV}
COMMAND ${GLSLANG_VALIDATOR} -V -o ${NOOP_SPV}
${CMAKE_SOURCE_DIR}/tests/shaders/noop.comp
DEPENDS ${CMAKE_SOURCE_DIR}/tests/shaders/noop.comp
COMMENT "glslang: noop.comp -> noop.spv"
VERBATIM
)
set(IDCT8_SPV ${CMAKE_BINARY_DIR}/v3d_idct8.spv)
add_custom_command(
OUTPUT ${IDCT8_SPV}
COMMAND ${GLSLANG_VALIDATOR} -V --target-env vulkan1.3
-o ${IDCT8_SPV}
${CMAKE_SOURCE_DIR}/src/v3d_idct8.comp
DEPENDS ${CMAKE_SOURCE_DIR}/src/v3d_idct8.comp
COMMENT "glslang: v3d_idct8.comp -> v3d_idct8.spv"
VERBATIM
)
add_custom_target(daedalus_shaders ALL DEPENDS ${NOOP_SPV} ${IDCT8_SPV})
# v3d_runner — reusable Vulkan plumbing.
add_library(v3d_runner STATIC src/v3d_runner.c)
target_include_directories(v3d_runner PUBLIC src)
target_link_libraries(v3d_runner PUBLIC Vulkan::Vulkan)
target_compile_options(v3d_runner PRIVATE -O2)
add_executable(bench_vulkan_dispatch tests/bench_vulkan_dispatch.c)
add_dependencies(bench_vulkan_dispatch daedalus_shaders)
target_link_libraries(bench_vulkan_dispatch PRIVATE Vulkan::Vulkan)
target_compile_options(bench_vulkan_dispatch PRIVATE -O2)
add_executable(bench_v3d_idct
tests/bench_v3d_idct.c
tests/vp9_idct8_ref.c
)
add_dependencies(bench_v3d_idct daedalus_shaders)
target_link_libraries(bench_v3d_idct PRIVATE v3d_runner Vulkan::Vulkan)
target_compile_options(bench_v3d_idct PRIVATE -O2)
# M4 — concurrent CPU(NEON) + QPU bench. Links the FFmpeg NEON
# snapshot so we can run real NEON kernels on pinned CPU cores
# while the QPU runs its dispatch loop concurrently.
add_executable(bench_concurrent
tests/bench_concurrent.c
${FFASM_SOURCES}
)
add_dependencies(bench_concurrent daedalus_shaders)
target_link_libraries(bench_concurrent PRIVATE v3d_runner Vulkan::Vulkan pthread)
target_compile_options(bench_concurrent PRIVATE -O3 -march=armv8-a+simd)
endif()
# ---- Summary ----------------------------------------------------------------
message(STATUS "daedalus-fourier build configured for ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS " FFmpeg snapshot: ${FFSNAP}")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Targets: bench_neon_idct"
"$<$<BOOL:${DAEDALUS_BUILD_VULKAN}>:; bench_vulkan_dispatch>")