libxe2: verify GEMM loads exponents and metadata four steps a gather -- down 142 -> 131 us

EU stall sampling (unitrace --stall-sampling) put 43% of the kernel's samples on send stalls, the
memory request queue full, not on waits for data: 4-byte gathers of the exponents and metadata
were a third of its cache-line requests for an eighth of its bytes. 16 bytes a lane now cover
four steps; a split's tail keeps the per-step gathers, so the arithmetic and splits are as
before. rad-kbench against libref 50/50; greedy output identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-10-25 14:21:03 +01:00
1 parent 70e50f4758
commit 340231d007
1 file changed
+15 -3
+15 -3
View File
@@ -59,13 +59,12 @@ int launch(sycl::queue& q, const half* ae, const uint8_t* codes0, const uint8_t*
const simd<int32_t, 16> mx = gather<int32_t, 16>(emax, col * 4u);
simd<float, 128> c[MT];
_Pragma("unroll") for (int i = 0; i < MT; ++i) c[i] = 0.0f;
for (int64_t g0 = g0s; g0 < g1s; g0 += kKs) {
/* a step: kKs groups -- the code lines, the activation blocks, the decode and DPAS */
auto step = [&](int64_t g0, simd<uint32_t, 16> e4, simd<uint32_t, 16> m4) SYCL_ESIMD_FUNCTION {
simd<uint32_t, 256> line; /* [word 16][lane 16] */
_Pragma("unroll") for (int qd = 0; qd < 4; ++qd)
line.template select<64, 1>(qd * 64) =
gather<uint32_t, 64, 4>((const uint32_t*)(cbase + g0 * 16 + qd * 16), coff);
const simd<uint32_t, 16> e4 = gather<uint32_t, 16>((const uint32_t*)(expe0 + g0), eoff);
const simd<uint32_t, 16> m4 = gather<uint32_t, 16>((const uint32_t*)(meta0 + g0), moff);
/* the step's activation, 8 k-blocks of [mpad rows][16 k], loaded with the codes */
simd<half, kKs * 2 * MT * 128> As;
_Pragma("unroll") for (int b = 0; b < kKs * 2 * MT; ++b)
@@ -100,7 +99,20 @@ int launch(sycl::queue& q, const half* ae, const uint8_t* codes0, const uint8_t*
}
}
}
};
/* the exponents and metadata 16 bytes a lane, four steps' worth a gather (a 4-byte gather
* a step was a third of the kernel's memory messages for an eighth of its bytes); the
* tail of a split that is not 16 groups long a step at a time */
int64_t g0 = g0s;
for (; g0 + 4 * kKs <= g1s; g0 += 4 * kKs) {
simd<uint32_t, 64> E = gather<uint32_t, 64, 4>((const uint32_t*)(expe0 + g0), eoff);
simd<uint32_t, 64> Mt = gather<uint32_t, 64, 4>((const uint32_t*)(meta0 + g0), moff);
_Pragma("unroll") for (int s4 = 0; s4 < 4; ++s4)
step(g0 + kKs * s4, E.template select<16, 1>(s4 * 16), Mt.template select<16, 1>(s4 * 16));
}
for (; g0 < g1s; g0 += kKs)
step(g0, gather<uint32_t, 16>((const uint32_t*)(expe0 + g0), eoff),
gather<uint32_t, 16>((const uint32_t*)(meta0 + g0), moff));
const simd_mask<16> ok = (lane + (uint32_t)n0) < (uint32_t)N;
if (splits == 1) {
/* 2^(mx - 127) by bits (mx = 0: the subnormal 2^-127) */