diff --git a/libxe2/xe2_gemm_zp.cpp b/libxe2/xe2_gemm_zp.cpp index 616babf0..745c9fd9 100644 --- a/libxe2/xe2_gemm_zp.cpp +++ b/libxe2/xe2_gemm_zp.cpp @@ -328,6 +328,8 @@ int zp_dpas(sycl::queue& q, const int8_t* ab, int64_t ars, const char* sab, uint int64_t group, int mm) { const int64_t G = K / group; const size_t wgs = (size_t)((N + 16 * kZpDpasSgs - 1) / (16 * kZpDpasSgs)); + const bool stage16 = K % 16 == 0 && 8 * (K / 16) <= 16 * kZpDpasSgs * kSub && ars % 16 == 0 && + rad_ptr_aligned(ab, 16); return submit([&] { q.submit([&](sycl::handler& h) { /* the activation as A columns: at[(k / 2) * 8 + m] is the pair (a[m][k], a[m][k + 1]) */ @@ -337,6 +339,28 @@ int zp_dpas(sycl::queue& q, const int8_t* ab, int64_t ars, const char* sab, uint const sycl::sub_group sg = it.get_sub_group(); const int s = (int)sg.get_group_linear_id(), lane = (int)sg.get_local_linear_id(); const int t = (int)it.get_local_id(0); + if (stage16) { + /* a lane 16 bytes of a row (8 pairs) at a time, every load issued before the + * first local store: `ab` is a generic pointer, so a load after a local store + * waits for it, and the pair a step form ran 80 round trips a work-group */ + constexpr int kPer = 16; /* items a lane: K <= kPer * 256 * 8 / 8 */ + const int64_t items = 8 * (K / 16); /* (row m, 8-pair block) */ + sycl::vec v[kPer]; +#pragma unroll + for (int u = 0; u < kPer; ++u) { + const int64_t idx = t + (int64_t)u * kZpDpasSgs * kSub; + const int64_t m = idx % 8, kb8 = idx / 8; + v[u] = idx < items && m < mm ? *(const sycl::vec*)(ab + m * ars + 16 * kb8) + : sycl::vec(0); + } +#pragma unroll + for (int u = 0; u < kPer; ++u) { + const int64_t idx = t + (int64_t)u * kZpDpasSgs * kSub; + if (idx >= items) break; + const int64_t m = idx % 8, kb8 = idx / 8; + for (int e = 0; e < 8; ++e) At[(kb8 * 8 + e) * 8 + m] = v[u][e]; + } + } else for (int64_t i = t; i < 4 * K; i += kZpDpasSgs * kSub) { const int64_t m = i % 8, kp = i / 8; uint16_t v = 0;