brotensor/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
7 / 7
100.0%
Branches:
-
-%
Functions:
1 / 1
100.0%

src/kernels/mir_gemm_skinny.h
Line Branch Exec Source
1 #pragma once
2
3 // Short-M 16-bit Tensor Core weight-streaming GEMM MIR builder (9 <= M <= 64):
4 // Y(M, N) = epilogue(X(M, K) @ W(N, K)^T + bias)
5 // 256 threads (8 warps), 128 output cols/CTA, 4-stage K=64 cp.async ring in
6 // dynamic shared memory, L2::evict_first cache policy for W, swizzled 16-byte
7 // shared fragment loads into m16n8k16 mma.sync, optional FP32 split-K partials.
8
9 #include "../jit/gpu_mir_emit_detail.h"
10
11 #include <cstdint>
12
13 namespace brotensor::kernels {
14
15 1 struct GemmSkinnySpec {
16 1 Dtype dt = Dtype::FP16;
17 1 std::uint8_t nt = 2; // 2..8 (covers ROWS = 8 * nt >= M)
18 1 std::uint8_t epi = 0; // 0=store, 1=accum, 2=geglu, 3=swiglu
19 1 std::uint8_t act = 0; // 0..5
20 1 bool has_bias = false;
21 1 bool has_partial = false;
22 };
23
24 constexpr std::uint32_t gemm_skinny_smem_bytes(std::uint8_t nt) noexcept {
25 const std::uint32_t rows = static_cast<std::uint32_t>(nt) * 8u;
26 const std::uint32_t ring = 4u * (128u + rows) * 128u;
27 const std::uint32_t tile = rows * 132u * 4u;
28 return ring > tile ? ring : tile;
29 }
30
31 // Params:
32 // ptrs (5): X(0), W(1), Y(2), bias(3), partial(4)
33 // ints (4): M(5), N(6), K(7), chunks_per_split(8)
34 brass::Function* build_gemm_skinny_mir(brass::Module& mod, const GemmSkinnySpec& spec);
35
36 } // namespace brotensor::kernels
37