diff --git a/libxe2/xe2_gemv_m2_esimd.cpp b/libxe2/xe2_gemv_m2_esimd.cpp index ca6971dd..16a54e88 100644 --- a/libxe2/xe2_gemv_m2_esimd.cpp +++ b/libxe2/xe2_gemv_m2_esimd.cpp @@ -59,13 +59,12 @@ int launch(sycl::queue& q, const half* ae, const uint8_t* codes0, const uint8_t* const simd mx = gather(emax, col * 4u); simd 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 e4, simd m4) SYCL_ESIMD_FUNCTION { simd line; /* [word 16][lane 16] */ _Pragma("unroll") for (int qd = 0; qd < 4; ++qd) line.template select<64, 1>(qd * 64) = gather((const uint32_t*)(cbase + g0 * 16 + qd * 16), coff); - const simd e4 = gather((const uint32_t*)(expe0 + g0), eoff); - const simd m4 = gather((const uint32_t*)(meta0 + g0), moff); /* the step's activation, 8 k-blocks of [mpad rows][16 k], loaded with the codes */ simd 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 E = gather((const uint32_t*)(expe0 + g0), eoff); + simd Mt = gather((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((const uint32_t*)(expe0 + g0), eoff), + gather((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) */