libr4d: register form of the fused all-reduce writes with a wake store into the idle peer path

ar_hc_write / ar_gather_hc_write get a register form when every thread owns at most one
16-byte word (up to 12 rows of 2560, P2P instances): y, inj and h are loaded into registers
before the first atomic and not re-read after the handshake; LDS-only barriers instead of
__syncthreads; the flag poll is a relaxed system-scope load (the push check with retry behind
a system acquire stays). Before waiting on its chain turn each block stores one word into the
peer's memory: the P2P path between the cards goes idle after ~20 us, and the next store then
becomes visible ~4 us later; the wake store hides that. Wire format, flags, counters, check word
and arithmetic unchanged, mixable with the plain kernels on one instance; host-mailbox twins
keep the plain kernels. The chained wait the forms sit behind ends in r4d_chain_acquire (the
previous commit's s_dcache_inv). 63 new r4d_selftest cases: register form against plain form,
byte-identical, M = 1..8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Code000andClaude Opus 5.5 authored and StillDeadcode committed 2026-11-17 19:01:12 +01:00
1 parent cfec01ec8d
commit 304597970f
6 files changed
+474 -10

No files matched your search

+4
View File
@@ -322,6 +322,10 @@ void r4d_ar_oneshot_2rank_wht6(long peer_scratch, long my_scratch, long peer_fla
// is the engine's link word, ended once the peer's push has landed (r4d_ar_link_landed);
// `gate_ctr` is its block counter. The gather form below takes the same pair. A non-zero `chain`
// launches the chained form (r4d_chain.h), which the gather form has at decode heights.
// At a message of one 16B word a thread on a P2P instance (`stage` 0) both take their register
// form (r4d_ar_hc_write_reg_kernel), which also stores into the peer's wake word: `peer_flags` is
// then 3 * r4d_ar_max_blocks() words (the flags and two slots' check words) and one more line of
// 64 bytes behind them, as r4d_ar_entry.hip allocates it.
void r4d_ar_hc_write(long peer_scratch, long my_scratch, long peer_flags, long my_flags,
long seq_ctrs, long slot_stride16, long y, long inj, long h, long M, long n,
long hc, long irow, long hrow, long stream, long nblocks, long nthreads,