brotensor/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
417 / 433
96.3%
Branches:
565 / 986
57.3%
Functions:
24 / 26
92.3%

src/kernels/mir_gemm_cm.cpp
Line Branch Exec Source
1 #include "mir_gemm_cm.h"
2
3 #include "mir_common.h"
4 #include "mir_coop_common.h"
5 #include "mir_math.h"
6 #include "mir_quant_helpers.h"
7 #include "../vulkan/shaders/op_codes.h"
8
9 #include <array>
10 #include <stdexcept>
11 #include <string>
12 #include <utility>
13 #include <vector>
14
15 namespace brotensor::kernels {
16
17 namespace {
18
19 212 int dt_eb(Dtype dt) { return dt == Dtype::FP32 ? 4 : 2; }
20
21 300 Value* batch_base(Ctx& c, Value* base, Value* stride, Value* z, int eb) {
22 300 return ptr_at(c, base, c.b.build_mul(z, stride), eb);
23 }
24
25 344 Value* load8_scalar(Ctx& c, Dtype dt, Value* base, Value* ld, Value* row, Value* row_ok,
26 Value* col, Value* ncols, bool apply_scale, const std::array<Value*, 8>& amul) {
27 344 Value* any_ok = c.b.build_and(row_ok, c.b.build_ult(col, ncols));
28
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 return emit_if_else_values(
29 344 c, any_ok, {Type::i32x4()},
30 688 [&]() -> std::vector<Value*> {
31 344 Value* idx = c.b.build_add(c.b.build_mul(row, ld), col);
32 344 std::array<Value*, 8> h{};
33
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 344 times.
3096 for (int e = 0; e < 8; ++e) {
34 2752 Value* ok = c.b.build_ult(c.b.build_add(col, c.i32(e)), ncols);
35
1/2
✓ Branch 0 taken 2752 times.
✗ Branch 1 not taken.
2752 Value* v = emit_if_else_values(
36 2752 c, ok, {Type::f32()},
37 5504 [&]() -> std::vector<Value*> {
38 2752 return {load_elem_dt(c, dt, base, c.b.build_add(idx, c.i32(e)))};
39 },
40 5504 [&]() -> std::vector<Value*> { return {c.f32(0.0f)}; })[0];
41
1/2
✓ Branch 0 taken 2752 times.
✗ Branch 1 not taken.
2752 if (apply_scale) v = c.b.build_mul(v, amul[static_cast<std::size_t>(e)]);
42 2752 h[static_cast<std::size_t>(e)] = v;
43 2752 }
44 344 return {emit_pack_f32x8_to_f16_v4(c, h)};
45 ✗ },
46 688 [&]() -> std::vector<Value*> { return {emit_v4_zero(c)}; })[0];
47 ✗ }
48
49 } // namespace
50
51 105 brass::Function* build_gemm_cm_mir(brass::Module& mod, const GemmCmSpec& s) {
52
1/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if (s.cfg_idx >= 4u) throw std::runtime_error("brotensor: mir_gemm_cm: invalid cfg_idx");
53 105 const GemmCmTile& cfg = kGemmCmTiles[s.cfg_idx];
54 105 const std::uint32_t BM = cfg.bm, BN = cfg.bn, BK = cfg.bk, WM = cfg.wm, WN = cfg.wn, WG = cfg.wg;
55 105 const std::uint32_t TM = WM / 16u, TN = WN / 16u;
56 105 const std::uint32_t NSG = (BM / WM) * (BN / WN);
57 105 const std::uint32_t LA = (BM * BK / 8u) / WG;
58 105 const std::uint32_t LB = (BN * BK / 8u) / WG;
59
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 93 times.
105 const std::uint32_t CA = s.ta ? (BM / 8u) : (BK / 8u);
60
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 84 times.
105 const std::uint32_t CB = s.nb ? (BN / 8u) : (BK / 8u);
61 105 const std::uint32_t SKA = CA + 1u;
62 105 const std::uint32_t SKB = CB + 1u;
63
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 93 times.
105 const std::uint32_t ASZ = (s.ta ? BK : BM) * SKA;
64
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 84 times.
105 const std::uint32_t BSZ = (s.nb ? BK : BN) * SKB;
65
3/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 100 times.
105 const Dtype dt_bias = (s.dt_a != Dtype::FP32 && s.dt_c == Dtype::FP32) ? s.dt_a : s.dt_c;
66
67
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
210 const std::string name = std::string("mir_gemm_cm_c") + std::to_string(s.cfg_idx) +
68
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 "_a" + std::to_string(static_cast<int>(s.dt_a)) +
69
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 "_b" + std::to_string(static_cast<int>(s.dt_b)) +
70
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 "_o" + std::to_string(static_cast<int>(s.dt_c)) +
71
6/12
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 105 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 105 times.
✗ Branch 11 not taken.
105 "_e" + std::to_string(s.epi) + "_x" + std::to_string(s.act) +
72
5/10
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 105 times.
✗ Branch 9 not taken.
210 "_q" + std::to_string(s.qb) + (s.ta ? "_ta" : "") + (s.nb ? "_nb" : "") +
73
4/6
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 (s.vec ? "_v" : "_s") + (s.direct ? "_d" : "") +
74
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 (s.has_bias ? "_bi" : "") + (s.scale_a ? "_sc" : "") +
75 105 (s.swizzle ? "_sw" : "");
76
77 105 const bool has_res = (s.epi == EPI_RESIDUAL_ADD);
78
6/12
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 105 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 105 times.
✗ Branch 11 not taken.
630 std::vector<Type> params = {
79 630 Type::ptr(), Type::ptr(), Type::ptr(), Type::ptr(), Type::ptr(), Type::ptr(),
80 };
81
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
105 if (has_res) params.push_back(Type::ptr());
82
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1260 times.
✓ Branch 2 taken 1260 times.
✗ Branch 3 not taken.
1365 for (int i = 0; i < 12; ++i) params.push_back(Type::i32());
83
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Function* fn = mod.create_function(name, Type::void_type(), brass::Span<const Type>(params));
84
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 brass::codegen::KernelBuilder kb(mod, fn);
85
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Ctx c(kb);
86
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 auto raw_p = entry_params(c, fn);
87 105 std::vector<Value*> p;
88
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 p.reserve(18);
89
3/4
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 630 times.
✗ Branch 3 not taken.
735 for (int i = 0; i < 6; ++i) p.push_back(raw_p[static_cast<std::size_t>(i)]);
90
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 103 times.
105 Value* residual_ptr = has_res ? raw_p[6] : nullptr;
91
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1260 times.
✓ Branch 2 taken 1260 times.
✗ Branch 3 not taken.
1365 for (int i = 0; i < 12; ++i) p.push_back(raw_p[static_cast<std::size_t>(6 + (has_res ? 1 : 0) + i)]);
92 // ptrs: 0:a 1:b 2:c 3:bias 4:scale 5:ascale [, residual_ptr]
93 // ints: 6:m 7:n 8:k 9:lda 10:ldb 11:ldc 12:sa 13:sb 14:sc 15:half_n 16:tm0 17:tn0
94
95
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Value* As = kb.shared_alloc_i32x4(2u * ASZ);
96
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Value* Bs = kb.shared_alloc_i32x4(2u * BSZ);
97
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
105 Value* s_fp8 = (s.qb == QF_FP8) ? kb.shared_alloc_f32(256u) : nullptr;
98
99
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 Value* tid = c.b.build_and(kb.tid_x(), c.i32(static_cast<int>(WG - 1u)));
100
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 Value* sg = c.b.build_and(kb.subgroup_id(), c.i32(static_cast<int>(NSG - 1u)));
101
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 Value* lane = c.b.build_and(kb.lane_id(), c.i32(31));
102
103
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1 time.
105 if (s_fp8) {
104
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 for (std::uint32_t off = 0; off < 256u; off += WG) {
105
4/6
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
2 Value* idx = (off == 0) ? tid : c.b.build_add(tid, c.i32(static_cast<int>(off)));
106
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 kb.shared_store_f32_indexed(s_fp8, idx, emit_fp8_e4m3_to_f32(c, idx));
107 2 }
108
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 kb.sync();
109 1 }
110
111
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Value* tx = kb.ctaid_x();
112
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Value* ty = kb.ctaid_y();
113
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 104 times.
105 if (s.swizzle) {
114
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 Value* num_n = kb.nctaid_x();
115
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 Value* num_m = kb.nctaid_y();
116
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
1 Value* flat = c.b.build_add(c.b.build_mul(ty, num_n), tx);
117
4/8
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
1 Value* slab_stride = smax_i32(c, c.i32(1), c.b.build_shl(num_n, c.i32(2)));
118
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 Value* slab_idx = c.b.build_udiv(flat, slab_stride);
119
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
1 Value* slab_m0 = c.b.build_shl(slab_idx, c.i32(2));
120
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 Value* rem = c.b.build_umod(flat, slab_stride);
121
5/10
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
1 Value* slab_h = smax_i32(c, c.i32(1), smin_i32(c, c.i32(4), c.b.build_sub(num_m, slab_m0)));
122
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 3 not taken.
1 ty = c.b.build_add(slab_m0, c.b.build_umod(rem, slab_h));
123
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 tx = c.b.build_udiv(rem, slab_h);
124 1 }
125
126
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Value* z = kb.ctaid_z();
127
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 Value* A = batch_base(c, p[0], p[12], z, dt_eb(s.dt_a));
128
3/4
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
105 Value* B = (s.qb != 0u) ? p[1] : batch_base(c, p[1], p[13], z, 2);
129
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 Value* C = batch_base(c, p[2], p[14], z, dt_eb(s.dt_c));
130
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
105 Value* R = has_res ? batch_base(c, residual_ptr, p[14], z, dt_eb(s.dt_c)) : nullptr;
131
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 Value* m0 = c.b.build_mul(c.b.build_add(ty, p[16]), c.i32(static_cast<int>(BM)));
132
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 94 times.
105 const std::uint32_t bn_step = (s.epi == EPI_SWIGLU) ? (BN / 2u) : BN;
133
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 Value* n0 = c.b.build_mul(c.b.build_add(tx, p[17]), c.i32(static_cast<int>(bn_step)));
134
4/8
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
105 Value* wm0 = c.b.build_mul(c.b.build_umod(sg, c.i32(static_cast<int>(BM / WM))), c.i32(static_cast<int>(WM)));
135
4/8
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
105 Value* wn0 = c.b.build_mul(c.b.build_udiv(sg, c.i32(static_cast<int>(BM / WM))), c.i32(static_cast<int>(WN)));
136
137 105 Value* AS = nullptr;
138
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 std::vector<std::array<Value*, 8>> amul(LA);
139
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 103 times.
105 if (s.scale_a) {
140
5/10
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
2 Value* as_off = c.b.build_select(c.b.build_ne(p[12], c.i32(0)), c.b.build_mul(z, p[6]), c.i32(0));
141
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 AS = ptr_at(c, p[5], as_off, 4);
142
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 for (std::uint32_t j = 0; j < LA; ++j) {
143
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
8 Value* i = (j == 0) ? tid : c.b.build_add(tid, c.i32(static_cast<int>(j * WG)));
144
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!s.ta) {
145
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 Value* r = c.b.build_udiv(i, c.i32(static_cast<int>(CA)));
146
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 Value* row = c.b.build_add(m0, r);
147
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 Value* ex = emit_if_else_values(
148
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 c, c.b.build_ult(row, p[6]), {Type::i32()},
149 16 [&]() -> std::vector<Value*> { return {kb.load_i32(ptr_at(c, AS, row, 4))}; },
150 16 [&]() -> std::vector<Value*> { return {c.i32(0)}; })[0];
151
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
8 Value* mv = kb.ldexp_f32(c.f32(1.0f), c.b.build_neg(ex));
152
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 8 times.
72 for (int e = 0; e < 8; ++e) amul[j][static_cast<std::size_t>(e)] = mv;
153 8 } else {
154
0/10
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Value* mb = c.b.build_add(m0, c.b.build_shl(c.b.build_umod(i, c.i32(static_cast<int>(CA))), c.i32(3)));
155
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ for (int e = 0; e < 8; ++e) {
156
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Value* row = c.b.build_add(mb, c.i32(e));
157
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Value* ex = emit_if_else_values(
158
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ c, c.b.build_ult(row, p[6]), {Type::i32()},
159 ✗ [&]() -> std::vector<Value*> { return {kb.load_i32(ptr_at(c, AS, row, 4))}; },
160 ✗ [&]() -> std::vector<Value*> { return {c.i32(0)}; })[0];
161
0/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ amul[j][static_cast<std::size_t>(e)] = kb.ldexp_f32(c.f32(1.0f), c.b.build_neg(ex));
162 ✗ }
163 }
164 8 }
165 2 }
166
167
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 std::vector<Value*> fa(TM), fb(TN), acc(TM * TN);
168
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 296 times.
✓ Branch 2 taken 296 times.
✗ Branch 3 not taken.
401 for (std::uint32_t i = 0; i < TM; ++i) fa[i] = kb.coop_alloc_a();
169
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
327 for (std::uint32_t j = 0; j < TN; ++j) fb[j] = kb.coop_alloc_b();
170
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 640 times.
745 for (std::uint32_t i = 0; i < TM * TN; ++i) {
171
1/2
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
640 acc[i] = kb.coop_alloc_acc();
172
2/4
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 640 times.
✗ Branch 3 not taken.
640 kb.coop_fill_acc(acc[i], c.f32(0.0f));
173 640 }
174
175 // Precompute per-chunk shared tile offsets & row/col coordinates fixed across K.
176
3/6
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
105 std::vector<Value*> a_r(LA), a_q(LA), a_smem(LA);
177
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 296 times.
401 for (std::uint32_t j = 0; j < LA; ++j) {
178
4/6
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 191 times.
✗ Branch 5 not taken.
296 Value* i = (j == 0) ? tid : c.b.build_add(tid, c.i32(static_cast<int>(j * WG)));
179
2/4
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 296 times.
✗ Branch 3 not taken.
296 a_r[j] = c.b.build_udiv(i, c.i32(static_cast<int>(CA)));
180
2/4
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 296 times.
✗ Branch 3 not taken.
296 a_q[j] = c.b.build_umod(i, c.i32(static_cast<int>(CA)));
181
3/6
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 296 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 296 times.
✗ Branch 5 not taken.
296 a_smem[j] = c.b.build_add(c.b.build_mul(a_r[j], c.i32(static_cast<int>(SKA))), a_q[j]);
182 296 }
183
5/10
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 105 times.
✗ Branch 9 not taken.
105 std::vector<Value*> b_r(LB), b_q(LB), b_smem(LB), b_row(LB), b_row_ok(LB);
184
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 222 times.
327 for (std::uint32_t j = 0; j < LB; ++j) {
185
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
222 Value* i = (j == 0) ? tid : c.b.build_add(tid, c.i32(static_cast<int>(j * WG)));
186
2/4
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
222 b_r[j] = c.b.build_udiv(i, c.i32(static_cast<int>(CB)));
187
2/4
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
222 b_q[j] = c.b.build_umod(i, c.i32(static_cast<int>(CB)));
188
3/6
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222 times.
✗ Branch 5 not taken.
222 b_smem[j] = c.b.build_add(c.b.build_mul(b_r[j], c.i32(static_cast<int>(SKB))), b_q[j]);
189
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 180 times.
222 if (!s.nb) {
190
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160 times.
180 if (s.epi == EPI_SWIGLU) {
191
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 Value* tb = c.b.build_lshr(b_r[j], c.i32(4));
192
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
40 Value* o = c.b.build_add(
193
5/10
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
40 n0, c.b.build_add(c.b.build_shl(c.b.build_lshr(tb, c.i32(1)), c.i32(4)),
194
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 c.b.build_and(b_r[j], c.i32(15))));
195
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 b_row_ok[j] = c.b.build_ult(o, p[15]);
196
5/10
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
40 Value* half_off = c.b.build_select(c.b.build_ne(c.b.build_and(tb, c.i32(1)), c.i32(0)),
197
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 p[15], c.i32(0));
198
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 b_row[j] = c.b.build_add(half_off, o);
199 20 } else {
200
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 b_row[j] = c.b.build_add(n0, b_r[j]);
201
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 b_row_ok[j] = c.b.build_ult(b_row[j], p[7]);
202 }
203 180 }
204 222 }
205
206 struct Loaded {
207 std::vector<Value*> ra, ra2, va;
208 std::vector<Value*> rb, vb, qk;
209 std::vector<QRawMir> rq;
210 };
211
212 315 auto load_tiles = [&](Value* k0) -> Loaded {
213 210 Loaded t;
214
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 t.ra.resize(LA);
215
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 t.va.resize(LA);
216
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
210 if (s.dt_a == Dtype::FP32 && s.vec) t.ra2.resize(LA);
217
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 t.rb.resize(LB);
218
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 t.vb.resize(LB);
219
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 176 times.
210 if (s.qb != 0u) {
220
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 t.rq.resize(LB);
221
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 t.qk.resize(LB);
222 34 }
223
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 210 times.
802 for (std::uint32_t j = 0; j < LA; ++j) {
224
4/6
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 520 times.
✗ Branch 5 not taken.
592 Value* row = s.ta ? c.b.build_add(k0, a_r[j]) : c.b.build_add(m0, a_r[j]);
225
4/6
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 520 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 520 times.
✗ Branch 5 not taken.
592 Value* row_ok = s.ta ? c.b.build_ult(row, p[8]) : c.b.build_ult(row, p[6]);
226
5/8
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 520 times.
✓ Branch 2 taken 592 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 592 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 592 times.
✗ Branch 7 not taken.
592 Value* col = c.b.build_add(s.ta ? m0 : k0, c.b.build_shl(a_q[j], c.i32(3)));
227
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 520 times.
592 Value* ncols = s.ta ? p[6] : p[8];
228
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 204 times.
592 if (s.vec) {
229
2/4
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
388 Value* ok = c.b.build_and(row_ok, c.b.build_ult(col, ncols));
230
4/8
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 388 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 388 times.
✗ Branch 7 not taken.
388 Value* idx = c.b.build_select(ok, c.b.build_add(c.b.build_mul(row, p[9]), col), c.i32(0));
231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 if (s.dt_a == Dtype::FP32) {
232
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Value* base_ptr = ptr_at(c, A, idx, 4);
233
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ t.ra[j] = kb.vload(Type::i32x4(), base_ptr);
234
0/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ t.ra2[j] = kb.vload(Type::i32x4(), c.b.build_add(base_ptr, kb.const_i64(16)));
235 ✗ } else {
236
2/4
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
388 t.ra[j] = kb.vload(Type::i32x4(), ptr_at(c, A, idx, 2));
237 }
238 388 t.va[j] = ok;
239 388 } else {
240
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 t.ra[j] = load8_scalar(c, s.dt_a, A, p[9], row, row_ok, col, ncols, s.scale_a, amul[j]);
241
1/2
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
204 t.va[j] = c.i32(1);
242 }
243 592 }
244
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 176 times.
210 if (s.qb != 0u) {
245
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 72 times.
106 for (std::uint32_t j = 0; j < LB; ++j) {
246
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
72 Value* col = c.b.build_add(k0, c.b.build_shl(b_q[j], c.i32(3)));
247
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 Value* ok = c.b.build_and(b_row_ok[j], c.b.build_ult(col, p[8]));
248
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 Value* srow = c.b.build_select(ok, b_row[j], c.i32(0));
249
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 Value* scol = c.b.build_select(ok, col, c.i32(0));
250
4/8
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 72 times.
✗ Branch 7 not taken.
72 Value* row_ptr = c.b.build_add(B, c.b.build_mul(c.b.build_zext_i64(srow), c.b.build_zext_i64(p[10])));
251 72 t.vb[j] = ok;
252 72 t.qk[j] = scol;
253
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 t.rq[j] = emit_qload8_mir(c, s.qb, s.vec, row_ptr, p[4], srow, scol, p[8]);
254 72 }
255 34 } else {
256
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 176 times.
548 for (std::uint32_t j = 0; j < LB; ++j) {
257
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
372 Value* row = s.nb ? c.b.build_add(k0, b_r[j]) : b_row[j];
258
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
372 Value* row_ok = s.nb ? c.b.build_ult(row, p[8]) : b_row_ok[j];
259
5/8
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 372 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 372 times.
✗ Branch 7 not taken.
372 Value* col = c.b.build_add(s.nb ? n0 : k0, c.b.build_shl(b_q[j], c.i32(3)));
260
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 288 times.
372 Value* ncols = s.nb ? p[7] : p[8];
261
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 140 times.
372 if (s.vec) {
262
2/4
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232 times.
✗ Branch 3 not taken.
232 Value* ok = c.b.build_and(row_ok, c.b.build_ult(col, ncols));
263
4/8
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 232 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 232 times.
✗ Branch 7 not taken.
232 Value* idx = c.b.build_select(ok, c.b.build_add(c.b.build_mul(row, p[10]), col), c.i32(0));
264
2/4
✓ Branch 0 taken 232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232 times.
✗ Branch 3 not taken.
232 t.rb[j] = kb.vload(Type::i32x4(), ptr_at(c, B, idx, 2));
265 232 t.vb[j] = ok;
266 232 } else {
267 140 std::array<Value*, 8> dummy{};
268
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 t.rb[j] = load8_scalar(c, s.dt_b, B, p[10], row, row_ok, col, ncols, false, dummy);
269
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 t.vb[j] = c.i32(1);
270 }
271 372 }
272 }
273 210 return t;
274
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 };
275
276 315 auto store_tiles = [&](Value* buf, const Loaded& t) {
277 210 Value* b01 = c.b.build_and(buf, c.i32(1));
278 210 Value* abase = c.b.build_mul(b01, c.i32(static_cast<int>(ASZ)));
279 210 Value* bbase = c.b.build_mul(b01, c.i32(static_cast<int>(BSZ)));
280 210 Value* z4 = emit_v4_zero(c);
281
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 210 times.
802 for (std::uint32_t j = 0; j < LA; ++j) {
282 592 Value* h = t.ra[j];
283
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 388 times.
592 if (s.vec) {
284
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if (s.dt_a == Dtype::FP32) {
285 ✗ h = emit_f32x8_to_f16x8_scaled(c, t.ra[j], t.ra2[j], amul[j]);
286
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 16 times.
388 } else if (s.dt_a == Dtype::BF16) {
287
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 h = s.scale_a ? emit_bf16x8_to_f16x8_scaled(c, h, amul[j]) : emit_bf16x8_to_f16x8(c, h);
288 16 }
289 388 h = emit_v4_select(c, t.va[j], h, z4);
290 388 }
291 592 kb.shared_store_i32x4_indexed(As, c.b.build_add(abase, a_smem[j]), h);
292 592 }
293
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 210 times.
654 for (std::uint32_t j = 0; j < LB; ++j) {
294 444 Value* h = nullptr;
295
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 372 times.
444 if (s.qb != 0u) {
296 72 h = emit_v4_select(c, t.vb[j], emit_qdecode8_f16_mir(c, s.qb, t.rq[j], t.qk[j], s_fp8), z4);
297 72 } else {
298 372 h = t.rb[j];
299
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 232 times.
372 if (s.vec) {
300
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 16 times.
232 if (s.dt_b == Dtype::BF16) h = emit_bf16x8_to_f16x8(c, h);
301 232 h = emit_v4_select(c, t.vb[j], h, z4);
302 232 }
303 }
304 444 kb.shared_store_i32x4_indexed(Bs, c.b.build_add(bbase, b_smem[j]), h);
305 444 }
306 210 };
307
308
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Value* stride_a = c.i32(static_cast<int>(SKA * 8u));
309
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 Value* stride_b = c.i32(static_cast<int>(SKB * 8u));
310 315 auto mma_tile = [&](Value* buf) {
311 210 Value* b01 = c.b.build_and(buf, c.i32(1));
312 210 Value* abase = c.b.build_mul(b01, c.i32(static_cast<int>(ASZ)));
313 210 Value* bbase = c.b.build_mul(b01, c.i32(static_cast<int>(BSZ)));
314
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 210 times.
630 for (std::uint32_t kk = 0; kk < BK / 16u; ++kk) {
315
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 420 times.
1604 for (std::uint32_t i = 0; i < TM; ++i) {
316 1184 Value* row_m = c.b.build_add(wm0, c.i32(static_cast<int>(i * 16u)));
317
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1040 times.
1184 Value* off = s.ta
318 144 ? c.b.build_add(c.i32(static_cast<int>(kk * 16u * SKA)), c.b.build_lshr(row_m, c.i32(3)))
319 1040 : c.b.build_add(c.b.build_mul(row_m, c.i32(static_cast<int>(SKA))), c.i32(static_cast<int>(kk * 2u)));
320 1184 Value* boff = c.b.build_shl(c.b.build_add(abase, off), c.i32(4));
321 1184 kb.coop_load_a(fa[i], c.b.build_add(As, boff), stride_a, s.ta);
322 1184 }
323
2/2
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 420 times.
1308 for (std::uint32_t j = 0; j < TN; ++j) {
324 888 Value* col_n = c.b.build_add(wn0, c.i32(static_cast<int>(j * 16u)));
325
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 720 times.
888 Value* off = s.nb
326 168 ? c.b.build_add(c.i32(static_cast<int>(kk * 16u * SKB)), c.b.build_lshr(col_n, c.i32(3)))
327 720 : c.b.build_add(c.b.build_mul(col_n, c.i32(static_cast<int>(SKB))), c.i32(static_cast<int>(kk * 2u)));
328 888 Value* boff = c.b.build_shl(c.b.build_add(bbase, off), c.i32(4));
329 888 kb.coop_load_b(fb[j], c.b.build_add(Bs, boff), stride_b, !s.nb);
330 888 }
331
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 420 times.
1604 for (std::uint32_t i = 0; i < TM; ++i) {
332
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 1184 times.
3744 for (std::uint32_t j = 0; j < TN; ++j) {
333 2560 kb.coop_mma(acc[i * TN + j], fa[i], fb[j]);
334 2560 }
335 1184 }
336 420 }
337 210 };
338
339
4/8
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
105 Value* nk = c.b.build_lshr(c.b.build_add(p[8], c.i32(static_cast<int>(BK - 1u))), c.i32(5));
340
4/8
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 105 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 105 times.
✗ Branch 7 not taken.
210 kb.if_then(c.b.build_ugt(nk, c.i32(0)), [&] {
341 105 Value* krot = c.i32(0);
342
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 104 times.
105 if (!s.swizzle) {
343 208 Value* krot_raw = c.b.build_mul(
344 104 c.b.build_add(tx, c.b.build_mul(ty, c.i32(5))), c.i32(37));
345 104 krot = c.b.build_umod(krot_raw, nk);
346 104 }
347
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 store_tiles(c.i32(0), load_tiles(c.b.build_shl(krot, c.i32(5))));
348 105 kb.sync();
349
350 105 Value* nk_m1 = c.b.build_sub(nk, c.i32(1));
351
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
210 kb.for_range(c.i32(0), nk_m1, c.i32(1), [&](Value* kt) {
352 105 Value* cur = c.b.build_and(kt, c.i32(1));
353 105 Value* nxt = c.b.build_xor(cur, c.i32(1));
354 210 Value* knxt = c.b.build_shl(c.b.build_umod(c.b.build_add(c.b.build_add(kt, c.i32(1)), krot), nk),
355 105 c.i32(5));
356 105 Loaded next_t = load_tiles(knxt);
357
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 mma_tile(cur);
358
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 store_tiles(nxt, next_t);
359
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 kb.sync();
360 105 });
361 105 mma_tile(c.b.build_and(nk_m1, c.i32(1)));
362 105 });
363
364 105 const std::uint32_t step = (s.epi == EPI_SWIGLU) ? 2u : 1u;
365
366
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 63 times.
105 if (s.direct) {
367
6/8
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 32 times.
✗ Branch 7 not taken.
42 Value* tmp_acc = (s.has_bias || s.epi == EPI_ACCUM || s.epi == EPI_RESIDUAL_ADD) ? kb.coop_alloc_acc() : nullptr;
368
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 122 times.
164 for (std::uint32_t i = 0; i < TM; ++i) {
369
3/6
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122 times.
✗ Branch 5 not taken.
122 Value* gm = c.b.build_add(c.b.build_add(m0, wm0), c.i32(static_cast<int>(i * 16u)));
370
1/2
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
122 Value* row_off = c.b.build_mul(gm, p[11]);
371
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 252 times.
374 for (std::uint32_t j = 0; j < TN; j += step) {
372 252 Value* r = acc[i * TN + j];
373
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 236 times.
504 Value* col = (s.epi == EPI_SWIGLU)
374
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
32 ? c.b.build_add(n0, c.b.build_shl(
375
6/12
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
16 c.b.build_lshr(c.b.build_add(c.b.build_lshr(wn0, c.i32(4)), c.i32(static_cast<int>(j))), c.i32(1)),
376
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 c.i32(4)))
377
3/6
✓ Branch 0 taken 236 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 236 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✗ Branch 5 not taken.
236 : c.b.build_add(c.b.build_add(n0, wn0), c.i32(static_cast<int>(j * 16u)));
378
2/4
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
252 Value* c_ptr = ptr_at(c, C, c.b.build_add(row_off, col), 2);
379
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 82 times.
252 if (s.has_bias) {
380
3/6
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
170 kb.coop_load_acc(tmp_acc, ptr_at(c, p[3], col, 2), c.i32(0), false, true);
381
1/2
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
170 kb.coop_add_acc(r, tmp_acc);
382 170 }
383
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 236 times.
252 if (s.epi == EPI_SWIGLU) {
384 16 Value* u = acc[i * TN + j + 1u];
385
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6 times.
16 if (s.has_bias) {
386
4/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
10 kb.coop_load_acc(tmp_acc, ptr_at(c, p[3], c.b.build_add(p[15], col), 2), c.i32(0), false, true);
387
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 kb.coop_add_acc(u, tmp_acc);
388 10 }
389
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
32 emit_coop_acc_map(c, r, [&](Value* idx, Value* rv) {
390 16 Value* uv = kb.coop_get_acc(u, idx);
391 16 return c.b.build_mul(c.b.build_mul(rv, emit_sigmoid(c, rv)), uv);
392 });
393
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 188 times.
252 } else if (s.act != LACT_NONE) {
394
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
96 emit_coop_acc_map(c, r, [&](Value*, Value* rv) { return emit_gemm_act(c, s.act, rv); });
395 48 }
396
4/4
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 188 times.
252 if (s.epi == EPI_ACCUM || s.epi == EPI_RESIDUAL_ADD) {
397
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 48 times.
80 Value* add_ptr = (s.epi == EPI_RESIDUAL_ADD)
398
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 ? ptr_at(c, R, c.b.build_add(row_off, col), 2)
399 48 : c_ptr;
400
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 kb.coop_load_acc(tmp_acc, add_ptr, p[11], false, true);
401
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 kb.coop_add_acc(r, tmp_acc);
402 64 }
403
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 kb.coop_store_acc(r, c_ptr, p[11], false, true);
404 252 }
405 122 }
406
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 c.b.build_ret_void();
407
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 return finalize_fn(fn);
408 }
409
410 // Shared-scratch epilogue aliasing As (2 x 256 floats = 128 i32x4 per subgroup).
411
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 kb.sync();
412
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 Value* sbase_v4 = c.b.build_shl(sg, c.i32(7)); // sg * 128 (in i32x4)
413
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 Value* sbase_f = c.b.build_shl(sbase_v4, c.i32(2)); // sg * 512 (in f32)
414
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 Value* sbase_bytes = c.b.build_shl(sbase_v4, c.i32(4));
415
4/8
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
63 Value* sbase2_bytes = c.b.build_shl(c.b.build_add(sbase_v4, c.i32(64)), c.i32(4));
416
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 Value* sbase2_f = c.b.build_add(sbase_f, c.i32(256));
417
418 575 auto row_mul = [&](Value* gm) -> Value* {
419
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 256 times.
512 if (!s.scale_a) return c.f32(1.0f);
420 256 return kb.ldexp_f32(c.f32(1.0f), kb.load_i32(ptr_at(c, AS, gm, 4)));
421 512 };
422 1919 auto bias_at = [&](Value* col) -> Value* {
423
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1600 times.
1856 if (!s.has_bias) return c.f32(0.0f);
424 1600 return load_elem_dt(c, dt_bias, p[3], col);
425 1856 };
426
427
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 174 times.
237 for (std::uint32_t i = 0; i < TM; ++i) {
428
3/6
✓ Branch 0 taken 174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 174 times.
✗ Branch 5 not taken.
174 Value* gm0 = c.b.build_add(c.b.build_add(m0, wm0), c.i32(static_cast<int>(i * 16u)));
429
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 356 times.
530 for (std::uint32_t j = 0; j < TN; j += step) {
430
3/6
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 356 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 356 times.
✗ Branch 5 not taken.
356 kb.coop_store_acc(acc[i * TN + j], c.b.build_add(As, sbase_bytes), c.i32(16), false, false);
431
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 340 times.
356 if (s.epi == EPI_SWIGLU) {
432
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 kb.coop_store_acc(acc[i * TN + j + 1u], c.b.build_add(As, sbase2_bytes), c.i32(16), false, false);
433 16 }
434
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 kb.subgroup_barrier();
435
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 324 times.
356 if (s.epi == EPI_GEGLU) {
436
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 128 times.
160 for (int e0 = 0; e0 < 128; e0 += 32) {
437
4/6
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
128 Value* e = (e0 == 0) ? lane : c.b.build_add(lane, c.i32(e0));
438
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 Value* rr = c.b.build_lshr(e, c.i32(3));
439
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
128 Value* pr = c.b.build_and(e, c.i32(7));
440
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 Value* gm = c.b.build_add(gm0, rr);
441
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
256 Value* nr = c.b.build_add(
442
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 c.b.build_add(n0, wn0),
443
4/8
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 128 times.
✗ Branch 7 not taken.
128 c.b.build_add(c.i32(static_cast<int>(j * 16u)), c.b.build_shl(pr, c.i32(1))));
444
5/10
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 128 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 128 times.
✗ Branch 9 not taken.
128 Value* ok = c.b.build_and(c.b.build_ult(gm, p[6]), c.b.build_ult(c.b.build_add(nr, c.i32(1)), p[7]));
445
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
256 kb.if_then(ok, [&] {
446 128 Value* sc = row_mul(gm);
447 128 Value* fidx = c.b.build_add(sbase_f, c.b.build_shl(e, c.i32(1)));
448 128 Value* av = c.b.build_add(c.b.build_mul(kb.shared_load_f32_from_v4(As, fidx), sc), bias_at(nr));
449 256 Value* gv = c.b.build_add(
450 128 c.b.build_mul(kb.shared_load_f32_from_v4(As, c.b.build_add(fidx, c.i32(1))), sc),
451 128 bias_at(c.b.build_add(nr, c.i32(1))));
452 128 Value* out_idx = c.b.build_add(c.b.build_mul(gm, p[11]), c.b.build_lshr(nr, c.i32(1)));
453 128 store_elem_dt(c, s.dt_c, C, out_idx, c.b.build_mul(av, emit_gelu_exact(c, gv)));
454 128 });
455 128 }
456
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 308 times.
356 } else if (s.epi == EPI_SWIGLU) {
457
6/12
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
16 Value* ob = c.b.build_lshr(c.b.build_add(c.b.build_lshr(wn0, c.i32(4)), c.i32(static_cast<int>(j))), c.i32(1));
458
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 Value* oc0 = c.b.build_add(n0, c.b.build_shl(ob, c.i32(4)));
459
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 128 times.
144 for (int e0 = 0; e0 < 256; e0 += 32) {
460
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✗ Branch 5 not taken.
128 Value* e = (e0 == 0) ? lane : c.b.build_add(lane, c.i32(e0));
461
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
128 Value* gm = c.b.build_add(gm0, c.b.build_lshr(e, c.i32(4)));
462
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
128 Value* oc = c.b.build_add(oc0, c.b.build_and(e, c.i32(15)));
463
3/6
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 128 times.
✗ Branch 5 not taken.
128 Value* ok = c.b.build_and(c.b.build_ult(gm, p[6]), c.b.build_ult(oc, p[15]));
464
2/4
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
256 kb.if_then(ok, [&] {
465 128 Value* sc = row_mul(gm);
466 256 Value* gv = c.b.build_add(
467 128 c.b.build_mul(kb.shared_load_f32_from_v4(As, c.b.build_add(sbase_f, e)), sc),
468 128 bias_at(oc));
469 256 Value* uv = c.b.build_add(
470 128 c.b.build_mul(kb.shared_load_f32_from_v4(As, c.b.build_add(sbase2_f, e)), sc),
471 128 bias_at(c.b.build_add(p[15], oc)));
472 128 Value* out_idx = c.b.build_add(c.b.build_mul(gm, p[11]), oc);
473 128 store_elem_dt(c, s.dt_c, C, out_idx, c.b.build_mul(c.b.build_mul(gv, emit_sigmoid(c, gv)), uv));
474 128 });
475 128 }
476 16 } else {
477
3/6
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 308 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 308 times.
✗ Branch 5 not taken.
308 Value* nc0 = c.b.build_add(c.b.build_add(n0, wn0), c.i32(static_cast<int>(j * 16u)));
478
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 2464 times.
2772 for (int e0 = 0; e0 < 256; e0 += 32) {
479
4/6
✓ Branch 0 taken 2156 times.
✓ Branch 1 taken 308 times.
✓ Branch 2 taken 2156 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2156 times.
✗ Branch 5 not taken.
2464 Value* e = (e0 == 0) ? lane : c.b.build_add(lane, c.i32(e0));
480
3/6
✓ Branch 0 taken 2464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2464 times.
✗ Branch 5 not taken.
2464 Value* gm = c.b.build_add(gm0, c.b.build_lshr(e, c.i32(4)));
481
3/6
✓ Branch 0 taken 2464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2464 times.
✗ Branch 5 not taken.
2464 Value* nc = c.b.build_add(nc0, c.b.build_and(e, c.i32(15)));
482
3/6
✓ Branch 0 taken 2464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2464 times.
✗ Branch 5 not taken.
2464 Value* ok = c.b.build_and(c.b.build_ult(gm, p[6]), c.b.build_ult(nc, p[7]));
483
2/4
✓ Branch 0 taken 2464 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2464 times.
4928 kb.if_then(ok, [&] {
484 2464 Value* v = kb.shared_load_f32_from_v4(As, c.b.build_add(sbase_f, e));
485
2/2
✓ Branch 0 taken 2208 times.
✓ Branch 1 taken 256 times.
2464 if (s.scale_a) v = c.b.build_mul(v, row_mul(gm));
486
2/2
✓ Branch 0 taken 1120 times.
✓ Branch 1 taken 1344 times.
2464 if (s.has_bias) v = c.b.build_add(v, bias_at(nc));
487
2/2
✓ Branch 0 taken 2080 times.
✓ Branch 1 taken 384 times.
2464 if (s.act != LACT_NONE) v = emit_gemm_act(c, s.act, v);
488 2464 Value* o = c.b.build_add(c.b.build_mul(gm, p[11]), nc);
489
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 1952 times.
2464 if (s.epi == EPI_ACCUM) v = c.b.build_add(v, load_elem_dt(c, s.dt_c, C, o));
490
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 128 times.
1952 else if (s.epi == EPI_RESIDUAL_ADD) v = c.b.build_add(v, load_elem_dt(c, s.dt_c, R, o));
491 2464 store_elem_dt(c, s.dt_c, C, o, v);
492 2464 });
493 2464 }
494 }
495
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 kb.subgroup_barrier();
496 356 }
497 174 }
498
499
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 c.b.build_ret_void();
500
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 return finalize_fn(fn);
501 105 }
502
503 } // namespace brotensor::kernels
504