interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tests / gpu_tgemm_test.c

272 lines · 18432 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2/* gpu_tgemm_test.c (trainer lane E1, 2026-10-16): device-resident bf16 training GEMM (omega_blackwell_codegen_tgemm.h,
3 * omega_gpu_tgemm_api.h). C[M][N] f32 = A[M][K] bf16 x B[K][N] bf16, row-major, NN.
4 * --host-only budgets of the production specs: instructions, allocator peak and declared registers (refused past 1000 / 128)
5 * --sim the kernel in the warp simulator (both fragment orders) bit-identical to the C emulation of the HMMA chain
6 * (tests/bw_hmma_model.h, GB10 member) over the whole output, tile K ranges (kb0, nkb), mutants 1-4 caught
7 * --chip (caller holds the GB10 quiet lock) every output against a double reference over the same bf16-rounded inputs
8 * (|got - ref| / max(sum |terms|, 1e-6) < 1e-5: the rule of gpu_matmul_api_test.c), first with uncached (host)
9 * buffers, then with GPU-cached device buffers (trainer rule R-8); bit-identical repeats, poison scan (every output
10 * written), negative control (mutant 4 differs), medians of chip time and whole-call time, TFLOPS and percent of
11 * the measured bf16 HMMA peak (--peak, default 117.26: evidence TGEMM-CUT1-5b10b824/peak.log, the gate window;
12 * peak-window1.log of the same day read 120.64; probe gpu_tc_peak_test)
13 * Verdict line last: "GPU_TGEMM: PASS|FAIL". */
14#include "omega_blackwell_codegen_tgemm.h"
15#include "omega_gpu_tgemm_api.h"
16#include "omega_gpu_prefill.h"
17#include "bw_hmma_model.h"
18#include "bw_warp_sim_tc.h"
19#include <math.h>
20#include <pthread.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24#include <time.h>
25#include <unistd.h>
26
27static const HmmaModel GB10 = { 16, 2, 0, 2, 0 };
28static uint64_t rng = 0x243f6a8885a308d3ull;
29static uint32_t rnd(void) { rng ^= rng << 13; rng ^= rng >> 7; rng ^= rng << 17; return (uint32_t)(rng >> 16); }
30static float frnd(void) { return ((float)(rnd() & 0xffffff) / 16777216.0f) * 2.0f - 1.0f; }
31static float u2f(uint32_t u) { float f; memcpy(&f, &u, 4); return f; }
32static uint32_t f2u(float f) { uint32_t u; memcpy(&u, &f, 4); return u; }
33static uint16_t bf16_rn(float f) { uint32_t u = f2u(f); if ((u & 0x7fffffffu) > 0x7f800000u) return 0x7fc0u; return (uint16_t)((u + 0x7fffu + ((u >> 16) & 1u)) >> 16); }
34static float bf(uint16_t h) { return u2f((uint32_t)h << 16); }
35static double now_ns(void) { struct timespec t; clock_gettime(CLOCK_MONOTONIC, &t); return (double)t.tv_sec * 1e9 + (double)t.tv_nsec; }
36
37typedef struct { uint32_t M, N, K; uint16_t *a, *b; } Prob;
38static void prob_make(Prob *p, uint32_t M, uint32_t N, uint32_t K) {
39 p->M = M; p->N = N; p->K = K;
40 p->a = malloc((size_t)M * K * 2); p->b = malloc((size_t)K * N * 2);
41 for (size_t i = 0; i < (size_t)M * K; i++) p->a[i] = bf16_rn(frnd() * (rnd() % 16 == 0 ? 8.0f : 1.0f));
42 for (size_t i = 0; i < (size_t)K * N; i++) p->b[i] = bf16_rn(frnd() * (rnd() % 16 == 0 ? 8.0f : 1.0f));
43}
44static void prob_free(Prob *p) { free(p->a); free(p->b); }
45
46/* the kernel's arithmetic for output (i, c) over blocks kb0 .. kb0 + nkb - 1: one fused 16-term HMMA per (32-k group, step) */
47static float emu(const Prob *p, uint32_t i, uint32_t c, uint32_t kb0, uint32_t nkb) {
48 float acc = 0.0f;
49 for (uint32_t G = kb0 * 4u; G < (kb0 + nkb) * 4u; G++) for (uint32_t s = 0; s < 2; s++) {
50 float a[16], b[16]; int m = 0;
51 for (uint32_t t = 0; t < 4; t++) for (uint32_t j = 0; j < 4; j++) {
52 const uint32_t k = G * 32u + 8u * t + 4u * s + j;
53 a[m] = bf(p->a[(size_t)i * p->K + k]); b[m] = bf(p->b[(size_t)k * p->N + c]); m++;
54 }
55 acc = hm_dot16(&GB10, a, b, acc);
56 }
57 return acc;
58}
59
60static int host_only(void) {
61 int fail = 0;
62 static const struct { OmegaTgemmSpec s; int production; } specs[] = {
63 { { 2304, 768, 8, 2, 16, 32, 1, 0, 0, 0 }, 1 }, { { 768, 3072, 8, 2, 16, 32, 1, 0, 0, 0 }, 1 }, { { 768, 50304, 4, 2, 8, 32, 1, 0, 0, 0 }, 1 } /* lm_head forward: n % 256 != 0 picks rt 4 x 8 warps */, { { 50304, 768, 4, 2, 8, 32, 1, 0, 0, 0 }, 0 },
64 { { 768, 2304, 4, 2, 16, 32, 2, 0, 0, 0 }, 0 }, { { 768, 768, 4, 2, 16, 32, 1, 0, 0, 0 }, 0 }, { { 768, 768, 4, 2, 8, 32, 1, 0, 0, 0 }, 0 }, { { 768, 768, 2, 2, 8, 32, 1, 0, 0, 0 }, 0 },
65 { { 768, 768, 8, 2, 8, 32, 1, 0, 0, 0 }, 0 },
66 };
67 static BlackwellIRProgram prog;
68 for (size_t i = 0; i < sizeof specs / sizeof specs[0]; i++) {
69 const OmegaTgemmSpec *s = &specs[i].s;
70 int rc = omega_blackwell_codegen_tgemm_prog(s, &prog);
71 uint32_t peak = rc == 0 ? prog.regalloc.peak_gpr_usage : 0, decl = omega_bw_gpr_declared(peak);
72 int ok = rc == 0 && prog.count <= OMEGA_TGEMM_MAX_INSNS && decl <= 128u && 32u * s->warps * decl <= 65536u;
73 printf("spec k %u n %u rt %u ct %u warps %u kc %u aqn %u: %s, %zu instructions, peak %u, declared %u, shared %u B -> %s%s\n", s->k, s->n, s->rt, s->ct, s->warps, s->kc, s->aqn,
74 rc ? "REFUSED" : "built", rc ? (size_t)0 : prog.count, peak, decl, omega_tgemm_shared_bytes(s), ok ? "fits" : "DOES NOT FIT", specs[i].production ? " (production)" : "");
75 if (!ok && specs[i].production) fail++;
76 }
77 return fail;
78}
79
80typedef struct { uint32_t M, N, K, rt, warps, aqn, kb0, nkb; } SimCase;
81static int sim_run(const Prob *p, const SimCase *c, int mutant, int order, float *y, char *msg, size_t msgn) {
82 static BlackwellIRProgram prog;
83 OmegaTgemmSpec sp = { p->K, p->N, c->rt, 2, c->warps, 32, c->aqn, OMEGA_TGEMM_LAYOUT_NN, OMEGA_TGEMM_EPI_F32, mutant };
84 if (omega_blackwell_codegen_tgemm_prog(&sp, &prog) != 0) { snprintf(msg, msgn, "codegen refused (spec_ok %d)", omega_tgemm_spec_ok(&sp)); return -1; }
85 const uint32_t bm = omega_tgemm_bm(&sp), span = omega_tgemm_span(&sp), nt = p->M / bm;
86 OmegaTgemmTile *tiles = calloc(nt, sizeof *tiles);
87 for (uint32_t t = 0; t < nt; t++) { tiles[t].c_va = (uintptr_t)y; tiles[t].row0 = t * bm; tiles[t].kb0 = c->kb0; tiles[t].nkb = c->nkb; }
88 memset(y, 0xee, (size_t)p->M * p->N * 4);
89 uint8_t *smem = malloc(omega_tgemm_shared_bytes(&sp));
90 static WsSim s; memset(&s, 0, sizeof s);
91 s.p = &prog; s.threads = 32u * sp.warps; s.smem = smem; s.smem_bytes = omega_tgemm_shared_bytes(&sp); s.order = order;
92 const uint64_t a[3] = { (uintptr_t)tiles, (uintptr_t)p->a, (uintptr_t)p->b };
93 for (int i = 0; i < 3; i++) { s.cbank[(0x380 + 8 * i) / 4] = (uint32_t)a[i]; s.cbank[(0x380 + 8 * i) / 4 + 1] = (uint32_t)(a[i] >> 32); }
94 s.ranges[0].lo = (uintptr_t)tiles; s.ranges[0].hi = (uintptr_t)(tiles + nt);
95 s.ranges[1].lo = (uintptr_t)p->a; s.ranges[1].hi = (uintptr_t)(p->a + (size_t)p->M * p->K);
96 s.ranges[2].lo = (uintptr_t)p->b; s.ranges[2].hi = (uintptr_t)(p->b + (size_t)p->K * p->N);
97 s.ranges[3].lo = (uintptr_t)y; s.ranges[3].hi = (uintptr_t)(y + (size_t)p->M * p->N);
98 s.nranges = 4;
99 int err = ws_run(&s, p->N / span, nt);
100 if (err) snprintf(msg, msgn, "simulator %s", s.msg);
101 free(tiles); free(smem);
102 return err ? -1 : 0;
103}
104static size_t sim_compare(const Prob *p, const float *y, uint32_t kb0, uint32_t nkb) {
105 size_t bad = 0;
106 for (uint32_t i = 0; i < p->M; i++) for (uint32_t c = 0; c < p->N; c++) {
107 const float want = emu(p, i, c, kb0, nkb);
108 if (f2u(y[(size_t)i * p->N + c]) != f2u(want)) { if (getenv("TGDBG") && bad < 8) printf(" row %u col %u got %.9g want %.9g\n", i, c, y[(size_t)i * p->N + c], want); bad++; }
109 }
110 return bad;
111}
112static int sim_tests(void) {
113 int fail = 0; char msg[256];
114 static const SimCase cs[] = {
115 { 128, 512, 256, 4, 16, 1, 0, 2 }, { 64, 256, 384, 2, 8, 1, 1, 2 }, { 128, 256, 128, 4, 16, 2, 0, 1 }, { 128, 256, 256, 4, 8, 2, 0, 2 }, { 256, 512, 128, 8, 16, 1, 0, 1 },
116 };
117 for (size_t c = 0; c < sizeof cs / sizeof cs[0]; c++) {
118 Prob p; prob_make(&p, cs[c].M, cs[c].N, cs[c].K);
119 float *y = malloc((size_t)p.M * p.N * 4);
120 for (int order = 0; order < 2; order++) {
121 int rc = sim_run(&p, &cs[c], 0, order, y, msg, sizeof msg);
122 size_t bad = rc ? 0 : sim_compare(&p, y, cs[c].kb0, cs[c].nkb);
123 printf("sim case %zu (M %u N %u K %u rt %u warps %u aqn %u blocks %u..%u) order %d: %s, %zu of %zu differ\n", c, p.M, p.N, p.K, cs[c].rt, cs[c].warps, cs[c].aqn,
124 cs[c].kb0, cs[c].kb0 + cs[c].nkb - 1, order, rc ? msg : "ran", bad, (size_t)p.M * p.N);
125 if (rc || bad) fail++;
126 }
127 if (c == 0) for (int m = 1; m <= 4; m++) {
128 int rc = sim_run(&p, &cs[c], m, 0, y, msg, sizeof msg);
129 size_t bad = rc ? 0 : sim_compare(&p, y, cs[c].kb0, cs[c].nkb);
130 printf("sim case %zu mutant %d: %s\n", c, m, rc ? msg : bad ? "caught" : "NOT CAUGHT");
131 if (rc || !bad) fail++;
132 }
133 free(y); prob_free(&p);
134 }
135 return fail;
136}
137
138/* ---- chip: double reference over the bf16 inputs, threaded over rows ---- */
139typedef struct { const Prob *p; const float *y; uint32_t r0, r1; size_t bad, emu_same; double worst; size_t bc4[4], br8[2], brt[4], bw[16], nan, shown; } RefJob;
140static void *ref_rows(void *arg) {
141 RefJob *j = arg; const Prob *p = j->p;
142 double *col = malloc((size_t)p->N * 16);
143 for (uint32_t i = j->r0; i < j->r1; i++) {
144 memset(col, 0, (size_t)p->N * 16);
145 const uint16_t *ar = p->a + (size_t)i * p->K;
146 for (uint32_t k = 0; k < p->K; k++) {
147 const double av = bf(ar[k]); const uint16_t *br = p->b + (size_t)k * p->N;
148 for (uint32_t c = 0; c < p->N; c++) { const double t = av * (double)bf(br[c]); col[2 * c] += t; col[2 * c + 1] += fabs(t); }
149 }
150 for (uint32_t c = 0; c < p->N; c++) {
151 const float got = j->y[(size_t)i * p->N + c];
152 const double scale = col[2 * c + 1] > 1e-6 ? col[2 * c + 1] : 1e-6, rel = fabs((double)got - col[2 * c]) / scale;
153 if (!(rel < 1e-5)) { j->bad++; j->bc4[c % 4]++; j->br8[(i >> 3) & 1]++; j->brt[(i >> 4) & 3]++; j->bw[(c % 256) / 16]++; j->nan += isnan(got) || isinf(got);
154 if (getenv("TGDBG") && j->shown < 6) { j->shown++; printf(" bad row %u col %u got %.9g ref %.9g emu %.9g\n", i, c, got, col[2 * c], emu(p, i, c, 0, p->K / 128u)); } }
155 if (rel > j->worst) j->worst = rel;
156 if (f2u(got) == f2u(emu(p, i, c, 0, p->K / 128u))) j->emu_same++;
157 }
158 }
159 free(col);
160 return NULL;
161}
162static size_t ref_check(const Prob *p, const float *y, size_t *emu_same, double *worst) {
163 long nproc = sysconf(_SC_NPROCESSORS_ONLN); int nt = nproc < 1 ? 1 : nproc > 32 ? 32 : (int)nproc;
164 pthread_t th[32]; RefJob jobs[32]; memset(jobs, 0, sizeof jobs);
165 for (int t = 0; t < nt; t++) { jobs[t].p = p; jobs[t].y = y; jobs[t].r0 = (uint32_t)((uint64_t)p->M * t / nt); jobs[t].r1 = (uint32_t)((uint64_t)p->M * (t + 1) / nt); pthread_create(&th[t], NULL, ref_rows, &jobs[t]); }
166 size_t bad = 0; *emu_same = 0; *worst = 0;
167 for (int t = 0; t < nt; t++) { pthread_join(th[t], NULL); bad += jobs[t].bad; *emu_same += jobs[t].emu_same; if (jobs[t].worst > *worst) *worst = jobs[t].worst; }
168 if (getenv("TGDBG") && bad) { size_t c4[4] = { 0 }, r8[2] = { 0 }, rt[4] = { 0 }, w[16] = { 0 }, nn = 0;
169 for (int t = 0; t < nt; t++) { for (int q = 0; q < 4; q++) { c4[q] += jobs[t].bc4[q]; rt[q] += jobs[t].brt[q]; } for (int q = 0; q < 2; q++) r8[q] += jobs[t].br8[q]; for (int q = 0; q < 16; q++) w[q] += jobs[t].bw[q]; nn += jobs[t].nan; }
170 printf(" bad by col%%4: %zu %zu %zu %zu; by row half: %zu %zu; by row tile: %zu %zu %zu %zu; nan/inf %zu\n bad by warp:", c4[0], c4[1], c4[2], c4[3], r8[0], r8[1], rt[0], rt[1], rt[2], rt[3], nn);
171 for (int q = 0; q < 16; q++) printf(" %zu", w[q]);
172 printf("\n"); }
173 return bad;
174}
175static int cmp_d(const void *a, const void *b) { double x = *(const double *)a, y = *(const double *)b; return x < y ? -1 : x > y; }
176
177static int chip_shape(uint32_t M, uint32_t N, uint32_t K, int cached, int reps, double peak, double gate_pct) {
178 Prob p; prob_make(&p, M, N, K);
179 const size_t ab = (size_t)M * K * 2, bb = (size_t)K * N * 2, cb = (size_t)M * N * 4;
180 OmegaGpuMem ad = { 0 }, bd = { 0 }, cd = { 0 };
181 int rc = cached ? omega_gpu_pf_alloc_dev(ab, &ad) : omega_gpu_pf_alloc_host(ab, &ad);
182 if (!rc) rc = cached ? omega_gpu_pf_alloc_dev(bb, &bd) : omega_gpu_pf_alloc_host(bb, &bd);
183 if (!rc) rc = cached ? omega_gpu_pf_alloc_dev(cb, &cd) : omega_gpu_pf_alloc_host(cb, &cd);
184 if (!rc) rc = omega_gpu_pf_upload(&ad, 0, p.a, ab);
185 if (!rc) rc = omega_gpu_pf_upload(&bd, 0, p.b, bb);
186 uint8_t *poison = malloc(cb); memset(poison, 0xff, cb);
187 float *y1 = malloc(cb), *y2 = malloc(cb);
188 if (!rc) rc = omega_gpu_pf_upload(&cd, 0, poison, cb);
189 if (rc) {
190 printf("shape %ux%ux%u setup: %s (%s)\n", M, N, K, omega_gpu_pf_rc_name(rc), omega_gpu_session_last_error());
191 free(poison); free(y1); free(y2); omega_gpu_pf_free(&ad); omega_gpu_pf_free(&bd); omega_gpu_pf_free(&cd); prob_free(&p);
192 return 1;
193 }
194 OmegaTgemmCall call = { OMEGA_TGEMM_LAYOUT_NN, OMEGA_TGEMM_EPI_F32, M, N, K, ad.va, bd.va, cd.va };
195 OmegaTgemmSpec sp;
196 if (omega_gpu_tgemm_spec(&call, &sp) != 0) {
197 printf("shape %ux%ux%u: spec refused\n", M, N, K);
198 free(poison); free(y1); free(y2); omega_gpu_pf_free(&ad); omega_gpu_pf_free(&bd); omega_gpu_pf_free(&cd); prob_free(&p);
199 return 1;
200 }
201 const char *kind = cached ? "cached" : "uncached";
202 int fail = 0;
203 if (reps > 64) reps = 64;
204 double chip[64], wall[64];
205 for (int r = 0; r < reps && !rc; r++) { uint64_t ns = 0; const double t0 = now_ns(); rc = omega_gpu_tgemm(&call, &ns); wall[r] = now_ns() - t0; chip[r] = (double)ns; }
206 if (!rc) rc = omega_gpu_pf_download(&cd, 0, y1, cb);
207 if (!rc) rc = omega_gpu_pf_upload(&cd, 0, poison, cb);
208 if (!rc) rc = omega_gpu_tgemm(&call, NULL);
209 if (!rc) rc = omega_gpu_pf_download(&cd, 0, y2, cb);
210 if (rc) { printf("shape %ux%ux%u %s run: %s (%s)\n", M, N, K, kind, omega_gpu_pf_rc_name(rc), omega_gpu_session_last_error()); fail++; }
211 else {
212 size_t left = 0; for (size_t i = 0; i < (size_t)M * N; i++) left += f2u(y1[i]) == 0xffffffffu;
213 const int same = !memcmp(y1, y2, cb);
214 size_t emu_same = 0; double worst = 0;
215 const double t0 = now_ns();
216 const size_t bad = ref_check(&p, y1, &emu_same, &worst);
217 qsort(chip, reps, 8, cmp_d); qsort(wall, reps, 8, cmp_d);
218 const double fl = 2.0 * M * N * K, mc = chip[reps / 2], mw = wall[reps / 2], tc = fl / mc / 1e3, tw = fl / mw / 1e3;
219 printf("TGEMM %ux%ux%u %s rt %u warps %u tiles %u grid_x %u: reference %zu of %zu outside 1e-5 (worst %.3g), %zu bit-identical to the emulation, repeats identical %s, poison left %zu (reference %.1f s)\n",
220 M, N, K, kind, sp.rt, sp.warps, M / omega_tgemm_bm(&sp), N / omega_tgemm_span(&sp), bad, (size_t)M * N, worst, emu_same, same ? "yes" : "NO", left, (now_ns() - t0) / 1e9);
221 printf("TGEMM %ux%ux%u %s: chip median %.3f ms (min %.3f) = %.2f TFLOPS = %.1f%% of peak %.2f; whole call median %.3f ms = %.2f TFLOPS = %.1f%%%s\n",
222 M, N, K, kind, mc / 1e6, chip[0] / 1e6, tc, 100.0 * tc / peak, peak, mw / 1e6, tw, 100.0 * tw / peak, cached && gate_pct > 0 ? (100.0 * tc / peak >= gate_pct ? " GATE ok" : " GATE FAIL") : "");
223 if (bad || !same || left) fail++;
224 if (cached && gate_pct > 0 && !(100.0 * tc / peak >= gate_pct)) fail++; /* the gate is on device-resident (GPU-cached) buffers; the uncached pass is the correctness-first step (R-8) */
225 if (!cached) { /* negative control: the parity-swapped kernel must give a different result (a comparison that cannot fail is no comparison) */
226 for (int m = 4; m >= 1; m -= 3) {
227 omega_gpu_tgemm_test_set_mutant(m);
228 int mrc = omega_gpu_tgemm(&call, NULL);
229 omega_gpu_tgemm_test_set_mutant(0);
230 if (!mrc) mrc = omega_gpu_pf_download(&cd, 0, y2, cb);
231 const int diff = !mrc && memcmp(y1, y2, cb) != 0;
232 printf("TGEMM %ux%ux%u mutant %d: %s\n", M, N, K, m, mrc ? "launch failed" : diff ? "caught" : "NOT CAUGHT");
233 if (!diff) fail++;
234 }
235 }
236 }
237 free(poison); free(y1); free(y2);
238 omega_gpu_pf_free(&ad); omega_gpu_pf_free(&bd); omega_gpu_pf_free(&cd);
239 prob_free(&p);
240 return fail;
241}
242
243int main(int argc, char **argv) {
244 int host = 1, sim = 1, chip = 0, reps = 7, cached_only = 0, uncached_only = 0; double peak = 117.26, gate = 0; const char *shape = NULL;
245 for (int i = 1; i < argc; i++) {
246 if (!strcmp(argv[i], "--host-only")) sim = 0;
247 else if (!strcmp(argv[i], "--sim")) host = 0;
248 else if (!strcmp(argv[i], "--chip")) { chip = 1; host = 0; sim = 0; }
249 else if (!strcmp(argv[i], "--shape") && i + 1 < argc) shape = argv[++i];
250 else if (!strcmp(argv[i], "--reps") && i + 1 < argc) reps = atoi(argv[++i]);
251 else if (!strcmp(argv[i], "--peak") && i + 1 < argc) peak = atof(argv[++i]);
252 else if (!strcmp(argv[i], "--gate") && i + 1 < argc) gate = atof(argv[++i]);
253 else if (!strcmp(argv[i], "--cached-only")) cached_only = 1;
254 else if (!strcmp(argv[i], "--mutant") && i + 1 < argc) omega_gpu_tgemm_test_set_mutant(atoi(argv[++i])); /* timing probes: results are wrong on purpose */
255 else if (!strcmp(argv[i], "--uncached-only")) uncached_only = 1;
256 else if (!strcmp(argv[i], "--shape-knob") && i + 3 < argc) { omega_gpu_tgemm_set_shape((uint32_t)atoi(argv[i + 1]), (uint32_t)atoi(argv[i + 2]), (uint32_t)atoi(argv[i + 3])); i += 3; }
257 }
258 int fail = 0;
259 if (host) fail += host_only();
260 if (sim) fail += sim_tests();
261 if (chip) {
262 static const char *gate_shapes[] = { "8192x768x2304", "8192x768x768", "8192x768x3072", "8192x3072x768" };
263 for (size_t s = 0; s < (shape ? 1u : sizeof gate_shapes / sizeof gate_shapes[0]); s++) {
264 unsigned M = 0, N = 0, K = 0;
265 if (sscanf(shape ? shape : gate_shapes[s], "%ux%ux%u", &M, &N, &K) != 3) { printf("bad shape\n"); fail++; break; }
266 if (!cached_only) fail += chip_shape(M, N, K, 0, reps, peak, gate);
267 if (!uncached_only) fail += chip_shape(M, N, K, 1, reps, peak, gate);
268 }
269 }
270 printf("GPU_TGEMM: %s\n", fail ? "FAIL" : "PASS");
271 return fail ? 1 : 0;
272}