Archived
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:
1 parent
cfec01ec8d
commit
304597970f
6 files changed
+474
-10
No files matched your search
@@ -109,3 +109,41 @@ __device__ __forceinline__ void r4d_ar_hc_write_word(const unsigned short* __res
|
||||
*hp = hv;
|
||||
}
|
||||
}
|
||||
|
||||
// The write's operands read ahead of the handshake, for a kernel whose threads each own one word
|
||||
// (r4d_ar_hc_write_reg_kernel): a row's gains and the word's hc stream words depend on nothing the
|
||||
// peer sends, so their loads ride under the push and the flag round trip instead of following the
|
||||
// reduce. r4d_ar_hc_write_apply is r4d_ar_hc_write_word over those registers: the same values in
|
||||
// the same arithmetic, so the same bytes.
|
||||
#define R4D_ARHC_MAX 8
|
||||
struct R4dArHcPre {
|
||||
float g[R4D_ARHC_MAX];
|
||||
int4 hv[R4D_ARHC_MAX];
|
||||
};
|
||||
__device__ __forceinline__ void r4d_ar_hc_write_load(const unsigned short* __restrict__ inj,
|
||||
const unsigned short* __restrict__ h, int row,
|
||||
int i0, int n, int hc, long irow, long hrow,
|
||||
R4dArHcPre& p) {
|
||||
#pragma unroll
|
||||
for (int c = 0; c < R4D_ARHC_MAX; ++c) {
|
||||
if (c >= hc) break;
|
||||
p.g[c] = bf2f(inj[(long)row * irow + c]);
|
||||
p.hv[c] = *reinterpret_cast<const int4*>(h + (long)row * hrow + (long)c * n + i0);
|
||||
}
|
||||
}
|
||||
__device__ __forceinline__ void r4d_ar_hc_write_apply(unsigned short* __restrict__ h, int row,
|
||||
int i0, int n, int hc, long hrow,
|
||||
const unsigned short* yv, R4dArHcPre& p) {
|
||||
float v[8];
|
||||
#pragma unroll
|
||||
for (int j = 0; j < 8; ++j) v[j] = bf2f(yv[j]);
|
||||
#pragma unroll
|
||||
for (int c = 0; c < R4D_ARHC_MAX; ++c) {
|
||||
if (c >= hc) break;
|
||||
int4 hv = p.hv[c];
|
||||
unsigned short* he = reinterpret_cast<unsigned short*>(&hv);
|
||||
#pragma unroll
|
||||
for (int j = 0; j < 8; ++j) he[j] = f2bf(bf2f(he[j]) + p.g[c] * v[j]);
|
||||
*reinterpret_cast<int4*>(h + (long)row * hrow + (long)c * n + i0) = hv;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user