diff --git a/libxe2/xe2_gemv_esimd.cpp b/libxe2/xe2_gemv_esimd.cpp index 88151bb0..690f2b2d 100644 --- a/libxe2/xe2_gemv_esimd.cpp +++ b/libxe2/xe2_gemv_esimd.cpp @@ -17,6 +17,8 @@ #include +#include + namespace xe2 { namespace { @@ -78,11 +80,14 @@ int launch(sycl::queue& q, const uint16_t* a, int64_t ars, int mm, const uint16_ } // namespace -/* The split count for N columns and K: the smallest divisor of K / 16 that gives ~8192 threads, at - * most kMaxS; 0 when K / 16 has none worth taking (the caller then keeps its SIMT form). */ +/* The split count for N columns and K: the smallest divisor of K / 16 that gives ~8192 threads and + * at most ~1024 of K a thread, at most kMaxS; 0 when K / 16 has none worth taking (the caller then + * keeps its SIMT form). The K bound is for wide outputs that fill the card at one split: a thread + * walking all of a long K alone is latency-bound (probe bfgl.cpp, M = 1, cold weights: logits + * N 248320 K 5120 S 1 7.27 ms, 350 GB/s -> S 5 4.21 ms, 604 GB/s; K 4096 S 1 5.78 -> S 4 3.39 ms). */ int gemv_esimd_splits(int64_t N, int64_t K) { const int64_t tiles = N / 16, steps = K / 16; - const int64_t want = (8192 + tiles - 1) / tiles; + const int64_t want = std::max((8192 + tiles - 1) / tiles, (K + 1023) / 1024); int best = 0; for (int s = 1; s <= kMaxS && s <= steps; ++s) { if (steps % s) continue;