Skip to content

upscale: EASU row bands, per-pixel analysis, vector packing (1.5x) + simd coverage gate - #145

Merged
tannevaled merged 3 commits into
mainfrom
upscale/easu-bands
Nov 29, 2026
Merged

tannevaled merged 3 commits into
mainfrom
upscale/easu-bands

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Refs #141 (stays open: the gap to ffmpeg remains).

Algorithm-first speed-up of the EASU vector lane, one measured step at a time. Ryzen 9 7950X, one core (taskset), 720p to 1080p, GOEXPERIMENT=simd, 16 lanes, 20 iterations, rounds interleaved with the baseline build.

Step EASU only EASU+RCAS
base (v0.22.0) ~75 ms ~82 ms
1. source taps gathered once per source row (ring of 4 rows) 57.7 ms n/m
2. edge analysis once per source pixel, interpolated in x 58.2 / 59.3 ms 69.5 / 69.9 ms
3. vector RGBA packing 43.6 / 44.4 ms 54.9 / 54.4 ms

Step 2 is exact and cheaper in theory but measured no gain over step 1 (the profile shows the analysis is not the bottleneck); it is kept for the structure. Step 3 alone gives 14 ms.

Remaining profile (before step 3): scalar gather+lerp ~22%, input conversion (fromImage/finish) ~20%, EASU arithmetic ~31%. ffmpeg 6.1.1 same machine: bilinear 3.3 ms, bicubic 2.0 ms, lanczos 2.8 ms, so the gap is still about 20x. A generic 2D gather kernel is not added: the gather is not yet shown to be the single bottleneck.

Also: a CI step under GOEXPERIMENT=simd enforces 100% coverage of ./upscale for the vector lane; a test swaps the scalar kernels back in so the fallback is covered there. Vector output is tested against the scalar oracle within ErrorBound; packing is tested bit-exactly on NaN, infinities and quantisation edges.

🤖 Generated with Claude Code

tannevaled and others added 3 commits November 29, 2026 15:15
The 12 taps of an output pixel sit at fixed offsets from the "f" tap,
whose column is the same for every output row. Expand each source row to
output columns once (per dx in -1..2 and channel) in a ring of four rows,
so the taps of a whole vector are contiguous loads and consecutive output
rows reuse the expansion. Measured on fractal (core 13, EASU only,
720p to 1080p): 75.0 ms -> 57.7 ms.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…verage gate

The edge direction and length analysis is computed once per source pixel
(vectorised over source columns) and interpolated in x for each output
pixel, as in the reference shader's structure. The opaque RGBA packing is
vectorised (0xAABBGGRR words). On a Ryzen 9 7950X, one core, 720p to 1080p:
EASU+RCAS 69.7 ms -> 54.6 ms from packing alone.

A CI step under GOEXPERIMENT=simd enforces 100% statement coverage of
./upscale for the vector lane; a test swaps the scalar kernels back in so
the fallback is covered there too.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The per-source-pixel analysis loads vectors starting on the last pixels of
the luma plane; on AVX-512 (16 lanes) a 2x2 source made the load run past
the slice and panic (FuzzUpscale seed #1, caught by the simd CI lane). The
plane now keeps vecSlack spare floats in its capacity. The suite was run on
an AVX-512 machine (Ryzen 9 7950X) as well as on arm64.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 01de240 into main Nov 29, 2026
20 checks passed
@tannevaled
tannevaled deleted the upscale/easu-bands branch November 29, 2026 14:32
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