Conversation
added 2 commits
September 18, 2026 22:13
ADR-0759 moved the four HIP integer ADM kernels that read AdmBufferHip (adm_csf_kernel_1_4, i4_adm_csf_kernel_1_4, i4_adm_cm_line_kernel, adm_cm_line_kernel_8) from the struct by value to a pointer to a device copy, in 31a51af (#101). The next merge, 92ea978 (#102, a CUDA ciede change cut from an older base), put the by-value signatures back, and every launch since has copied the 328-byte struct into the kernel arguments. This re-implements the decision on today's structure instead of reverting the revert. The design needs the struct to be the same on every launch. It is: s->buf is written only by adm_hip_alloc_buffers(), adm_hip_slice_bands() and adm_hip_slice_results() during init and by adm_hip_free_buffers() on teardown. submit() passes &s->buf to every launch helper, and no launch passes a modified copy; the scale 1-3 CSF and CM kernels get the scale as a separate argument and use the same i4 band pointers at every scale. adm_hip_upload_buf() allocates and uploads the copy at the end of adm_hip_init_device(), after the band and result slices are final, and the four launches pass &s->buf_dev. The copy is freed in close() and on both init failure paths. HIP output is byte-identical at %.17g before and after, with debug features, on 8, 10, 12 and 16-bit input, odd 575x323 and 197x101 frames, bright 16-bit noise, the 1080p 8-bit checkerboard pairs and a 60-frame 1080p 10-bit clip. The kernel argument segment of each kernel shrinks by 320 bytes. Per-thread scratch and VGPRs do not change because of the pointer: the 936 bytes on adm_cm_line_kernel_8 are VGPR spills (239 at the 128-register cap), not a copy of the struct. End-to-end 1080p 10-bit throughput is unchanged within run-to-run noise. adm_csf.hip had not been lint-cleaned yet, so this also takes it from 35 clang-tidy findings to 0: the device helpers move into an anonymous namespace, locals become const, and the band select becomes a helper. That restructure, not the pointer, lowers the two CSF kernels from 44 to 38 and 53 to 45 VGPRs. HIP tidy baseline tightened.
State row T-HIP-ADM-ADR0759-REVERTED-2026-09-18 closed (#102 as the reverting merge), changelog fragment, and a rebase note on keeping the pointer form and checking for it after a merge. The HIP AGENTS.md now describes the code as it is: the stale "P1 known issue" section that said the struct was still passed by value is gone, and the ADR-0759 invariant names buf_dev, adm_hip_upload_buf() and the launch argument, states the no-write-after-init precondition, and records the measured effect. Research-0759 gets a dated addendum: the revert, the real struct size (328 bytes), that the CUDA twin passes AdmBufferCuda by value, the gfx1036 runtime verification and the scratch, VGPR and fps measurements. ADR-0759's body is unchanged; it is accurate again.
Contributor
Author
|
Absorbed into the ADM stack train #1507, per your direction to fold this stack the way #1506 was folded. This PR targeted the one below it in a five-deep stack, so none of the five could merge until every one below had merged and been restacked — five sequential rebase-plus-CI rounds. #1507 is one. Your work is in it unchanged; that PR's description lists the six defects the fold itself surfaced, none of which an individual PR could see, because each gate only looks at the files its own PR touches. The branch stays on the remote. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-applies ADR-0759 (Accepted): the four HIP ADM kernels take
const AdmBufferHip * __restrict__again, instead of the 328-byte struct by value.31a51afb2(#101) implemented it, and the next merge,92ea978a4(#102, an unrelated CUDA ciede PR built from an older base), reverted every HIP hunk the same day. The HIP AGENTS.md note and an unreleased changelog fragment kept describing the by-pointer form ever since. Stacked on #1478; review #1476 and #1478 first.Precondition checked. One device copy uploaded at init is correct only if the struct never changes per launch. In today's
integer_adm_hip.c,s->bufis written only during init (adm_hip_alloc_buffers(),adm_hip_slice_bands(),adm_hip_slice_results()) and on teardown.submit_fex_hip()passes&s->bufunchanged to all four launch helpers, and no launch builds a modified copy.The change.
adm_hip_upload_buf()copies the struct to the device once, at the end ofadm_hip_init_device().(void *)&s->buf_dev.Measured honestly (gfx1036, from the HSACO metadata):
adm_csf_kernel_1_4i4_adm_csf_kernel_1_4i4_adm_cm_line_kerneladm_cm_line_kernel_8adm_csf.hip, not the pointer. Pointer-only and lint-only variants were built separately to tell the two apart.adm_cm_line_kernel_8(239 spilled at the 128-register cap), not a copy of the struct. That is a separate follow-up.Lint.
adm_csf.hiphad 35 clang-tidy findings; touching it meant taking it to 0 (baseline tightened).integer_adm_hip.candadm_cm.hipstay at 0.no docs needed: no user-visible change; scores are byte-identical and the extractor's options, output and supported inputs are unchanged.
Type
feat— new featurefix— bug fixperf— performance improvementrefactor— no behavior changedocs— documentation onlytest— test-onlybuild/ci— tooling / infraport— cherry-pick from upstream Netflix/vmafsycl/cuda/simd— backend-specificChecklist
make format && make lintis green locally: 0 clang-tidy findings and 0 uncited NOLINTs on the three touched sources (hip lane); cppcheck and pre-commit pass.meson test -C build: HIP fast suite 181 OK + 1 existing expected fail; all eight HIP ADM tests pass, includingtest_hip_adm_tiny_framesand the large parity test./cross-backend-diffand the worst ULP is ≤ 2: 0; HIP output byte-identical before and after on 14 cases (src01 at 8/10/12/16-bit, odd 575x323 and 197x101 at 8/10/16-bit, bright 16-bit noise, both 1080p checkerboard pairs, a 60-frame 1080p 10-bit clip).__ldg()extraction and putadm_cmout of scope)..c/.cpp/.cu/.h/.hpp, it has the appropriate license header (seeCONTRIBUTING.md): no new files.!orBREAKING CHANGE:and the migration path is documented below: not breaking.docs/adr/_index_fragments/<NNNN-slug>.mdand the slug is appended todocs/adr/_index_fragments/_order.txt: no new ADR; ADR-0759 is Accepted and becomes true again.Bug-status hygiene (ADR-0165)
docs/state.md:T-HIP-ADM-ADR0759-REVERTED-2026-09-18closed.Netflix golden-data gate (ADR-0024)
assertAlmostEqual(...)score in the Netflix golden Python tests.Deep-dive deliverables (ADR-0108)
docs/research/research-0759-hip-adm-buffer-by-pointer.mdgains a dated addendum correcting its size and CUDA-mirroring claims.core/src/feature/hip/AGENTS.md.changelog.d/fixed/hip-adm-buffer-by-pointer-reapplied.md.docs/rebase-notes.md.Reproducer
Known follow-ups
adm_cm_line_kernel_8spills 239 registers (936 bytes of scratch per thread) at the 128-VGPR cap;__launch_bounds__(128)alone still spills 112. A register-pressure pass is its own change.AdmFixedParametersHip(248 bytes) is still passed by value; ADR-0759 did not cover it.adm_decouple.hip(49 findings), a file deleted under ADR-1154; a full re-measure (L-41) will drop it.