Repository navigation
Description
BaseLdtm::column spells its {0, 1, 8, 9} offsets as a literal array:
pub const fn column(lane: u32, value: usize) -> u32 {
2 * (lane % 4) + 16 * (value as u32 / 4) + [0, 1, 8, 9][value % 4]
}In a rolled walk that array is a local-memory array. #184's PTX caught it in
oxide-train's tile classifier, re-stored and read back by a runtime index on
every iteration of the vocabulary loop:
$L__BB13_5:
st.local.b32 [%rd6], 0;
st.local.b32 [%rd6+4], 1;
st.local.b32 [%rd6+8], 8;
st.local.b32 [%rd6+12], 9;
...
ld.local.b32 %r250, [%rd78];
It has an exact closed form. 16*(v/4) + [0,1,8,9][v%4] is 8*(v/2) + v%2
for every v — 0, 1, 8, 9, 16, 17, 24, 25, … — so the whole function is
2 * (lane % 4) + 8 * (value as u32 / 2) + value as u32 % 2which is arithmetic, folds anywhere, and passes value_columns_are_the_fragment_maps_offsets,
a_lanes_columns_are_its_quad_position and the rest of reg.rs' host tests
unchanged. It also reads better: {0, 1, 8, 9} is a pair every eight columns,
which is what CONTIGUOUS_VALUES = 2 already says out loud.
Why this is filed and not merged
It is not a local edit. Measured on its own (regcount, sm_100a, no other
change, against 5e4d3ff):
- 78 of 285 entry functions move, in both directions.
- 14 rows lose their stack frame outright — every
16x64ladder rung
144 B -> 0, every32x48rung 208 B -> 0, the32x64rungs 272 B -> 0 — and
some drop hard:ladder_probe_32x192_all_in_place251 -> 32 registers,
global_copy_probe_128_open_coded168 -> 72 with 16 B less frame. - 14 rows gain ptxas spill stores, some badly:
ladder_probe_32x128_fused168 regs / 0 spill -> 255 / 116-116,
ladder_probe_32x256_fused1704 -> 2160 spill stores. - Four of
regcount's twenty timed rungs come off their ladder twins
(32x96_assign,32x96_open_coded,48x64_assign,48x64_open_coded), so
the run goes red on_print_timed_twins—::ladder_benchwould be
timing a kernel the ladder table does not describe.
That last one is the blocker and it is the useful part: this change moves the
assign/open_coded pair by one to eight registers at two shapes, which is
exactly the kind of divergence #63's gate exists to catch. Somebody has to
decide whether the twins get re-paired or the ladder gets re-cut, and that is a
judgement about the ladder, not about the offset table.
#184 does not need this. Once RegTile::mask unrolls, value is a
constant, the index folds, and the array goes with it — measured: no .local
array survives in the classifier's masking walk on #191. What this issue is
about is the rolled walks that remain, which is #166's map-walk remainder,
and it should be measured together with them rather than alone.
What would close it
The arithmetic form, plus a regcount run that is green — either because the
four timed rungs are re-paired against the ladder they now price like, or
because the ladder's assign/open_coded twinning is restated. Both halves of
the table above are worth having in the same PR: the 14 frames it removes are
the reason to want it and the 14 spill regressions are the reason nobody should
land it as a cleanup.
Activity