Repository navigation
Conversation
`tid_Y_colwise` was computed with a bare `% 4`, which is only correct because `BUFF_IN_DIM_Y / SCALE_DIM` happens to be 4 at the current `SCALE_DIM = 16`. It is an unexplained literal standing in for a derived quantity, and any change to the block size makes the index run past the input buffer: on a 32-element block the count is 2, so `tid_Y_colwise` reaches 3, `thread_offset_Y_colwise` reaches 96 against a 64-row `sIn`, and the derived `out_tr_thread_offset_X` reaches 48 against a `BUFF_OUT_TR_DIM_X` of 32 — the 8-byte shared store then crosses the row and writes past the end of `sOut_tr`. Behaviour is unchanged at `SCALE_DIM = 16` (the derived value is 4), so this is a correctness-of-expression change with no numerical effect. The `static_assert` pins the divisibility the derivation depends on.
Author
|
Closing this: on its own it is a no-op cleanup with no behavioural benefit, since |
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.
tid_Y_colwiseis computed with a bare% 4:That
4isBUFF_IN_DIM_Y / SCALE_DIM— the number ofSCALE_DIM-tall windows insIn— written outas a literal. It is correct today only because
BUFF_IN_DIM_Y / SCALE_DIM == 4atSCALE_DIM = 16.What goes wrong if the block size moves
At a 32-element block the window count is 2, so
tid_Y_colwisestill reaches 3 and the derivedoffsets walk past the buffers:
The 8-byte
st_shared_b64at column offset 32 or 48 crosses the row and runs off the end ofsOut_tr.sSFrowwiseis allocated immediately after that buffer, so the overflow lands in therowwise scale array: measured, rows 0/1 and 4/5 of every scale column are overwritten while rows 2/3
stay intact — matching the two overflow addresses exactly.
compute-sanitizer --tool memcheckreportsno error, because the store is in-bounds of the dynamic shared allocation as a whole.
The change
Derive the count instead of writing it out, and pin the divisibility it depends on:
At
SCALE_DIM = 16the derived value is 4, so behaviour and numerics are unchanged — this onlyremoves the hidden coupling. No functional dependency on the block size is introduced here; the
literal is simply replaced by what it always meant.