Skip to content

feat(simd): AVX2 integer SSIM horizontal moment accumulation - #145

Merged
lusoris merged 1 commit into
masterfrom
feat/integer-ssim-avx2
Jun 3, 2026
Merged

lusoris merged 1 commit into
masterfrom
feat/integer-ssim-avx2

Conversation

@lusoris

@lusoris lusoris commented May 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • meson test -C build --suite=fast — 50/50 pass locally (including test_integer_ssim_simd)
  • test_integer_ssim_simd — 4 sub-tests: 8bpc random (4 seeds), 16bpc random (4 seeds), uniform all-white/black, narrow width=1 (all boundary). All pass (bit-exact memcmp).
  • ADR-0784 places=4 contract satisfied: integer arithmetic, no float, no reduction order change.
  • Netflix golden gate: not required — integer SSIM dispatch is a pure performance change with guaranteed bit-exact output.

Deliverables checklist (ADR-0108)

  • Research digest: no digest needed: trivial (two pure-integer AVX2 kernels with existing CUDA precedent)
  • Decision matrix: ADR-0784 Alternatives considered
  • AGENTS.md invariant note: core/src/feature/x86/AGENTS.md updated with integer_ssim_moments_t layout invariant
  • Reproducer: meson test -C build --suite=fast -k integer_ssim_simd
  • Changelog fragment: changelog.d/performance/integer-ssim-avx2.md
  • Rebase notes: docs/rebase-notes.md entry added

No FFmpeg patch, public header, or ABI change.

Generated with Claude Code

@lusoris
lusoris force-pushed the feat/integer-ssim-avx2 branch from 3f426e5 to d59e2c9 Compare May 29, 2026 12:09
@lusoris
lusoris marked this pull request as ready for review May 31, 2026 13:44
@lusoris
lusoris marked this pull request as draft May 31, 2026 13:54
@lusoris
lusoris marked this pull request as ready for review May 31, 2026 14:04
@lusoris

lusoris commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of marathon cleanup 2026-05-31 (150 PRs merged today). Content likely superseded by sibling merges. Reopen if specific finding still needs work; bigger PRs preferred going forward per session feedback.

@lusoris lusoris closed this May 31, 2026
@lusoris
lusoris deleted the feat/integer-ssim-avx2 branch May 31, 2026 14:08
@lusoris
lusoris restored the feat/integer-ssim-avx2 branch May 31, 2026 18:45
@lusoris lusoris reopened this May 31, 2026
@lusoris
lusoris marked this pull request as draft May 31, 2026 18:50
Adds `integer_ssim_accumulate_row_avx2` (8bpc, 8-wide) and
`integer_ssim_accumulate_row_16_avx2` (16bpc, 4-wide) to vectorise the
dominant hot path in the `ssim` feature extractor. All accumulation is
in int32/int64 integer arithmetic, matching the scalar reference exactly.
Runtime-dispatched via `vmaf_get_cpu_flags()` in `IntegerSsimState.init()`;
scalar hosts (no AVX2, arm64, non-x86) are unaffected. Projected 4-6x
speedup on the horizontal pass for AVX2 hosts.

Includes:
- `core/src/feature/x86/integer_ssim_avx2.{c,h}` - AVX2 kernels
- `core/src/feature/integer_ssim.c` - dispatch wiring via function pointers
- `core/test/test_integer_ssim_simd.c` - 4 bit-exactness tests
- `docs/adr/0784-integer-ssim-avx2.md`, `docs/backends/x86/integer-ssim-avx2.md`

Rebased onto master (ef9bc22) from feat/integer-ssim-avx2
(d59e2c9); no shared history, changes extracted and applied cleanly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lusoris
lusoris force-pushed the feat/integer-ssim-avx2 branch from d59e2c9 to 8958c51 Compare June 3, 2026 15:37
@lusoris
lusoris marked this pull request as ready for review June 3, 2026 15:37
Copilot AI review requested due to automatic review settings June 3, 2026 15:37
@lusoris
lusoris merged commit 18ee824 into master Jun 3, 2026
44 of 72 checks passed
@lusoris
lusoris deleted the feat/integer-ssim-avx2 branch June 3, 2026 15:37
@lusoris
lusoris removed the request for review from Copilot June 3, 2026 15:59
lusoris added a commit that referenced this pull request Jun 6, 2026
…m_simd.c (#700)

On i686 no-asm builds (enable_asm=false), ARCH_X86 is not set in
config.h — src/meson.build only defines ARCH_X86 inside the
`if is_asm_enabled` block.  The scalar reference functions
scalar_accumulate_row_8() and scalar_accumulate_row_16() use
integer_ssim_moments_t unconditionally (they are the scalar reference
that any architecture can run), but the only include that brought in the
type was guarded by #if ARCH_X86 (via feature/x86/integer_ssim_avx2.h
-> ../integer_ssim.h).  On no-asm i686, that guard is false, so the
type was never defined, giving:

  test_integer_ssim_simd.c:102: error: unknown type name 'integer_ssim_moments_t'
  test_integer_ssim_simd.c:129: error: unknown type name 'integer_ssim_moments_t'

Fix: add an unconditional #include "integer_ssim.h" before the #if
ARCH_X86 block.  The shared header was introduced by ADR-1040 / PR #654
to solve the same class of problem in integer_ssim.c for macOS arm64;
the test file was not updated at that time.  The test's -I../src/feature
include path resolves the header without a path prefix.

The AVX2 function calls in the test remain inside #if ARCH_X86, so the
linker only needs those symbols when asm is enabled, which is correct.

Fixes: Build — Ubuntu i686 gcc (CPU, no-asm) (CI run 26953952042)
Introduced by: PR #145 (feat: AVX2 integer SSIM horizontal moment accumulation)
Partial-fix-of: ADR-1040 (which fixed integer_ssim.c but missed the test)

Co-authored-by: Lusoris <lusoris@pm.me>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@lusoris lusoris added this to the 1.0.0 — First release milestone Sep 4, 2026
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