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
CUDApp / evidence / GEMM-TUNE-20261027 / perf-gemm-tiles.patch
| 1 | diff --git a/src/omega_gpu_gemm.c b/src/omega_gpu_gemm.c |
| 2 | index 42b47a7..b81a03f 100644 |
| 3 | --- a/src/omega_gpu_gemm.c |
| 4 | +++ b/src/omega_gpu_gemm.c |
| 5 | @@ -3,6 +3,7 @@ |
| 6 | #include "omega_bw_em.h" |
| 7 | #include "omega_bw_em_q.h" |
| 8 | #include "omega_gpu_session.h" |
| 9 | +#include "omega_gpu_mem_cached.h" |
| 10 | |
| 11 | #include <stdlib.h> |
| 12 | #include <string.h> |
| 13 | @@ -14,16 +15,26 @@ |
| 14 | static uint32_t esz(OmegaGpuGemmType t) { return t == OMEGA_GPU_GEMM_BF16 ? 2u : 1u; } |
| 15 | static uint32_t kstep(OmegaGpuGemmType t) { return t == OMEGA_GPU_GEMM_BF16 ? 16u : 32u; } |
| 16 | static int pow124(uint32_t v) { return v == 1u || v == 2u || v == 4u; } |
| 17 | +static int band_ok(uint32_t b) { return b <= 32u && (b & (b - 1u)) == 0u; } |
| 18 | |
| 19 | void omega_gpu_gemm_default_cfg(OmegaGpuGemmType type, OmegaGemmCfg *cfg) { |
| 20 | memset(cfg, 0, sizeof *cfg); |
| 21 | - cfg->type = type; cfg->rt = 2; cfg->ct = 4; cfg->wm = 2; cfg->wn = 2; cfg->stall = type == OMEGA_GPU_GEMM_BF16 ? 4u : 2u; |
| 22 | + /* rt 2 ct 4, 2 x 4 warps, column bands of 8 CTA tiles: the fastest of the GemmTune exploration sweeps on GB10 |
| 23 | + * (evidence/GEMM-TUNE-*); stall 4 bf16, 2 e4m3 as before */ |
| 24 | + cfg->type = type; cfg->rt = 2; cfg->ct = 4; cfg->wm = 2; cfg->wn = 4; cfg->band = 8; |
| 25 | + cfg->stall = type == OMEGA_GPU_GEMM_BF16 ? 4u : 2u; |
| 26 | } |
| 27 | |
| 28 | +/* registers of MAIN for operands and accumulators: two operand sets (4 rt + 2 ct quads) and rt ct accumulator quads; at most |
| 29 | + * 160 (rt 4 ct 4). Up to MAIN_REGS_DEFAULT they fit R2..R127 (BW_PHYS_GPR_MAX) beside the ~25 address and loop registers; |
| 30 | + * above it MAIN opts into BW_PHYS_GPR_HW_LIMIT (R2..R245). */ |
| 31 | +static uint32_t main_regs(const OmegaGemmCfg *c) { return 4u * (4u * c->rt + 2u * c->ct + c->rt * c->ct); } |
| 32 | +#define MAIN_REGS_DEFAULT 100u |
| 33 | + |
| 34 | int omega_gpu_gemm_cfg_ok(const OmegaGemmCfg *c) { |
| 35 | return c && (c->type == OMEGA_GPU_GEMM_BF16 || c->type == OMEGA_GPU_GEMM_E4M3) && pow124(c->rt) && pow124(c->ct) && |
| 36 | pow124(c->wm) && pow124(c->wn) && c->stall >= 1u && c->stall <= 15u && c->mutant >= 0 && c->mutant <= 3 && |
| 37 | - 4u * (4u * c->rt + 2u * c->ct + c->rt * c->ct) <= 100u; /* registers: two operand sets + accumulators, R2..R127 in all */ |
| 38 | + band_ok(c->band); |
| 39 | } |
| 40 | |
| 41 | /* ------------------------------------------------------------------ IR helpers */ |
| 42 | @@ -128,6 +139,19 @@ static int gen_main(Em *e, const OmegaGemmCfg *c) { |
| 43 | ldc32(e, M, 0x398); ldc32(e, N, 0x39c); ldc32(e, ks2, 0x3a0); |
| 44 | s2r(e, tid, BW_SR_TID_X); s2r(e, cx, BW_SR_CTAID_X); s2r(e, cy, BW_SR_CTAID_Y); |
| 45 | movi(e, one, 1); movrz(e, zr); |
| 46 | + if (c->band > 1u) { |
| 47 | + /* banded grid: ctaid.x = tile row * band + column within the band, ctaid.y = band; tile column = band * band index |
| 48 | + * + column within the band. The last band may stick out past the tile columns: those CTAs leave at once. */ |
| 49 | + int gx = V(e); |
| 50 | + if (e->err) return -1; |
| 51 | + ldc32(e, gx, 0x3a4); |
| 52 | + andi(e, tmp, cx, 0, c->band - 1u); |
| 53 | + imadi(e, rgb, cy, 0, c->band, tmp); |
| 54 | + shr(e, cy, cx, 0, (uint32_t)log2u(c->band)); |
| 55 | + isetp_ge_u32(e, rgb, gx); |
| 56 | + { BlackwellIRInsn x = I0(BW_IR_EXIT); x.predicate_p0 = true; emit(e, x, K_EXIT); } |
| 57 | + imadi(e, cx, rgb, 0, 1u, NOREG); |
| 58 | + } |
| 59 | shr(e, warp, tid, 0, 5); andi(e, lane, tid, 0, 31u); |
| 60 | /* warp (wm, wn) = (warp / WN, warp % WN); row groups rga = cy WM + wm, rgb = cx WN + wn */ |
| 61 | shr(e, tmp, warp, 0, (uint32_t)log2u(c->wn)); imadi(e, rga, cy, 0, c->wm, tmp); |
| 62 | @@ -197,6 +221,7 @@ static int gen_main(Em *e, const OmegaGemmCfg *c) { |
| 63 | int omega_gpu_gemm_codegen(const OmegaGemmCfg *cfg, OmegaGemmKind kind, BlackwellIRProgram *prog) { |
| 64 | if (!omega_gpu_gemm_cfg_ok(cfg) || !prog || (unsigned)kind >= OMEGA_GEMM_K_COUNT) return -1; |
| 65 | omega_bw_ir_init(prog); |
| 66 | + if (kind == OMEGA_GEMM_K_MAIN && main_regs(cfg) > MAIN_REGS_DEFAULT && omega_bw_ir_set_gpr_limit(prog, BW_PHYS_GPR_HW_LIMIT) != 0) return -1; |
| 67 | Em em; memset(&em, 0, sizeof em); em.p = prog; |
| 68 | int rc = kind == OMEGA_GEMM_K_MAIN ? gen_main(&em, cfg) : gen_pack(&em, cfg, kind == OMEGA_GEMM_K_PACK_B); |
| 69 | if (rc != 0 || em.err || em.depth != 0) return -1; |
| 70 | @@ -219,7 +244,9 @@ int omega_gpu_gemm_plan(const OmegaGemmCfg *c, uint32_t M, uint32_t N, uint32_t |
| 71 | p->bp_bytes = (uint64_t)(p->Np / gb) * p->KS2 * FB * FRAG + 2u * FB * FRAG; |
| 72 | p->grid[OMEGA_GEMM_K_PACK_A][0] = p->KS2; p->grid[OMEGA_GEMM_K_PACK_A][1] = p->Mp / ga; |
| 73 | p->grid[OMEGA_GEMM_K_PACK_B][0] = p->KS2; p->grid[OMEGA_GEMM_K_PACK_B][1] = p->Np / gb; |
| 74 | - p->grid[OMEGA_GEMM_K_MAIN][0] = p->Np / (gb * c->wn); p->grid[OMEGA_GEMM_K_MAIN][1] = p->Mp / (ga * c->wm); |
| 75 | + const uint32_t gx = p->Np / (gb * c->wn), gy = p->Mp / (ga * c->wm); |
| 76 | + p->grid[OMEGA_GEMM_K_MAIN][0] = gx; p->grid[OMEGA_GEMM_K_MAIN][1] = gy; |
| 77 | + if (c->band > 1u) { p->grid[OMEGA_GEMM_K_MAIN][0] = c->band * gy; p->grid[OMEGA_GEMM_K_MAIN][1] = (gx + c->band - 1u) / c->band; } |
| 78 | p->threads[OMEGA_GEMM_K_PACK_A] = p->threads[OMEGA_GEMM_K_PACK_B] = 128u; |
| 79 | p->threads[OMEGA_GEMM_K_MAIN] = 32u * c->wm * c->wn; |
| 80 | return OMEGA_GPU_GEMM_OK; |
| 81 | @@ -246,6 +273,7 @@ int omega_gpu_gemm_drive(const OmegaGemmCfg *c, unsigned layout, uint32_t M, uin |
| 82 | if (launch(ctx, OMEGA_GEMM_K_PACK_B, a, p.grid[1][0], p.grid[1][1], p.threads[1]) != 0) return OMEGA_GPU_GEMM_CHIP_FAIL; |
| 83 | memset(a, 0, sizeof a); |
| 84 | put64(a, 0, ap_va); put64(a, 2, bp_va); put64(a, 4, c_va); a[6] = M; a[7] = N; a[8] = p.KS2; |
| 85 | + a[9] = p.Np / (8u * c->ct * c->wn); |
| 86 | if (launch(ctx, OMEGA_GEMM_K_MAIN, a, p.grid[2][0], p.grid[2][1], p.threads[2]) != 0) return OMEGA_GPU_GEMM_CHIP_FAIL; |
| 87 | return OMEGA_GPU_GEMM_OK; |
| 88 | } |
| 89 | @@ -257,15 +285,50 @@ static struct { |
| 90 | OmegaGemmCfg cfg[2]; |
| 91 | OmegaGpuMem code[2][OMEGA_GEMM_K_COUNT]; |
| 92 | uint32_t gpr[2][OMEGA_GEMM_K_COUNT]; |
| 93 | + OmegaGpuMem pk; /* packed A | packed B, kept between calls and grown on demand */ |
| 94 | + int pk_cached; /* pk is GPU-cached (default; env AIEN_OMEGA_GEMM_PACK_CACHED=0 allocates it GPU-uncached) */ |
| 95 | int hooked; |
| 96 | } g; |
| 97 | |
| 98 | -/* lock held; the session calls it right before it closes the device (also in omega_gpu_session_recover): the kernels go |
| 99 | - * with the device, the next call builds them again on the new one */ |
| 100 | +/* lock held; the session calls it right before it closes the device (also in omega_gpu_session_recover): the kernels and |
| 101 | + * the packed scratch go with the device, the next call builds them again on the new one */ |
| 102 | static void on_session_close(void) { |
| 103 | for (unsigned t = 0; t < 2; t++) |
| 104 | for (unsigned k = 0; k < OMEGA_GEMM_K_COUNT; k++) if (g.code[t][k].cpu) omega_gpu_session_free(&g.code[t][k]); |
| 105 | memset(g.code, 0, sizeof g.code); |
| 106 | + if (g.pk.cpu) omega_gpu_session_free(&g.pk); |
| 107 | + memset(&g.pk, 0, sizeof g.pk); |
| 108 | +} |
| 109 | + |
| 110 | +/* lock held: without the hook a kernel or the scratch would outlive its device */ |
| 111 | +static int hook_locked(void) { |
| 112 | + if (!g.hooked) { |
| 113 | + if (omega_gpu_session_on_close(on_session_close) != 0) return -1; |
| 114 | + g.hooked = 1; |
| 115 | + } |
| 116 | + return 0; |
| 117 | +} |
| 118 | + |
| 119 | +/* lock held, device open. The packed operands are DEVICE-PRIVATE: PACK_A / PACK_B write them, MAIN reads them, the CPU never |
| 120 | + * touches them, so they may be GPU-cached (src/omega_gpu_platform_linux.c ref_dma_alloc: no CPU_READ, no HOST_POLLED; same |
| 121 | + * pattern as the decode graph's dbuf, src/omega_gpu_q36_graph.c). Every packed word MAIN uses is written by a PACK launch of |
| 122 | + * the same call before MAIN runs, so a line a previous call left in L2 is overwritten, never read. MAIN reads every packed |
| 123 | + * fragment once per CTA row or column it serves, so in L2 the reuse across CTAs no longer goes back to DRAM (GemmTune). When |
| 124 | + * the scratch grows, the old one is synced to the GPU before it is freed: that queues the L2 invalidate prefix |
| 125 | + * (omega #457) on the next submission, so no clean line of the freed pages survives into whatever reuses them. */ |
| 126 | +static int packed_locked(uint64_t bytes, OmegaGpuMem *out) { |
| 127 | + if (hook_locked() != 0) return -1; |
| 128 | + if (g.pk.cpu && g.pk.size >= bytes) { *out = g.pk; return 0; } |
| 129 | + if (g.pk.cpu) { |
| 130 | + if (g.pk_cached) (void)omega_gpu_session_sync_to_gpu(&g.pk); |
| 131 | + omega_gpu_session_free(&g.pk); |
| 132 | + memset(&g.pk, 0, sizeof g.pk); |
| 133 | + } |
| 134 | + const char *v = getenv("AIEN_OMEGA_GEMM_PACK_CACHED"); |
| 135 | + g.pk_cached = !(v && v[0] == '0' && v[1] == 0); |
| 136 | + if ((g.pk_cached ? omega_gpu_session_alloc_cached(bytes, &g.pk) : omega_gpu_session_alloc(bytes, &g.pk)) != 0) { memset(&g.pk, 0, sizeof g.pk); return -1; } |
| 137 | + *out = g.pk; |
| 138 | + return 0; |
| 139 | } |
| 140 | |
| 141 | static const OmegaGemmCfg *cfg_of(OmegaGpuGemmType t) { |
| 142 | @@ -298,10 +361,7 @@ const char *omega_gpu_gemm_rc_name(int rc) { |
| 143 | /* lock held */ |
| 144 | static int kernel_locked(OmegaGpuGemmType t, OmegaGemmKind k) { |
| 145 | if (g.code[t][k].cpu) return OMEGA_GPU_GEMM_OK; |
| 146 | - if (!g.hooked) { /* without the hook a kernel would outlive its device */ |
| 147 | - if (omega_gpu_session_on_close(on_session_close) != 0) return OMEGA_GPU_GEMM_CHIP_FAIL; |
| 148 | - g.hooked = 1; |
| 149 | - } |
| 150 | + if (hook_locked() != 0) return OMEGA_GPU_GEMM_CHIP_FAIL; |
| 151 | BlackwellIRProgram *prog = omega_gpu_host_calloc(1, sizeof *prog); |
| 152 | if (!prog) return OMEGA_GPU_GEMM_CODEGEN_FAIL; |
| 153 | int rc = OMEGA_GPU_GEMM_OK; |
| 154 | @@ -351,18 +411,20 @@ int omega_gpu_gemm(OmegaGpuGemmType type, unsigned layout, uint32_t M, uint32_t |
| 155 | OmegaGemmPlan p; |
| 156 | int rc = omega_gpu_gemm_plan(cfg, M, N, K, &p); |
| 157 | if (rc != OMEGA_GPU_GEMM_OK) { omega_gpu_session_unlock(); return rc; } |
| 158 | - /* one buffer: A | B | packed A | packed B | C (each 256-byte aligned; A and B carry 16 bytes of readable slack) */ |
| 159 | - const uint64_t oa = 0, ob = up16(p.a_bytes + 16u), oap = ob + up16(p.b_bytes + 16u), obp = oap + up16(p.ap_bytes), |
| 160 | - oc = obp + up16(p.bp_bytes), total = oc + (uint64_t)M * N * 4u; |
| 161 | - OmegaGpuMem m; |
| 162 | + /* GPU-uncached buffer, CPU-visible: A | B | C (each 256-byte aligned; A and B carry 16 bytes of readable slack). |
| 163 | + * The packed operands live in the scratch (packed_locked): packed A | packed B. */ |
| 164 | + const uint64_t oa = 0, ob = up16(p.a_bytes + 16u), oc = ob + up16(p.b_bytes + 16u), total = oc + (uint64_t)M * N * 4u; |
| 165 | + const uint64_t obp = up16(p.ap_bytes), pk_total = obp + p.bp_bytes; |
| 166 | + OmegaGpuMem m, pk; |
| 167 | if (!omega_gpu_session_open() || omega_gpu_session_alloc(total, &m) != 0) { omega_gpu_session_unlock(); return OMEGA_GPU_GEMM_CHIP_FAIL; } |
| 168 | + if (packed_locked(pk_total, &pk) != 0) { omega_gpu_session_free(&m); omega_gpu_session_unlock(); return OMEGA_GPU_GEMM_CHIP_FAIL; } |
| 169 | uint8_t *base = m.cpu; |
| 170 | memcpy(base + oa, A, p.a_bytes); memcpy(base + ob, B, p.b_bytes); |
| 171 | uint32_t *cw = (uint32_t *)(base + oc); |
| 172 | for (uint64_t i = 0; i < (uint64_t)M * N; i++) cw[i] = POISON; |
| 173 | ChipCtx cc = { type, 0, 0 }; |
| 174 | if (omega_gpu_session_sync_to_gpu(&m) != 0) rc = OMEGA_GPU_GEMM_CHIP_FAIL; |
| 175 | - else rc = omega_gpu_gemm_drive(cfg, layout, M, N, K, m.va + oa, m.va + ob, m.va + oap, m.va + obp, m.va + oc, chip_launch, &cc); |
| 176 | + else rc = omega_gpu_gemm_drive(cfg, layout, M, N, K, m.va + oa, m.va + ob, pk.va, pk.va + obp, m.va + oc, chip_launch, &cc); |
| 177 | if (rc == OMEGA_GPU_GEMM_OK && omega_gpu_session_sync_to_cpu(&m) != 0) rc = OMEGA_GPU_GEMM_CHIP_FAIL; |
| 178 | if (rc == OMEGA_GPU_GEMM_OK) { |
| 179 | uint64_t unwritten = 0; |
| 180 | diff --git a/src/omega_gpu_gemm.h b/src/omega_gpu_gemm.h |
| 181 | index 66a6b04..b71176c 100644 |
| 182 | --- a/src/omega_gpu_gemm.h |
| 183 | +++ b/src/omega_gpu_gemm.h |
| 184 | @@ -51,13 +51,15 @@ typedef enum { OMEGA_GEMM_K_PACK_A = 0, OMEGA_GEMM_K_PACK_B, OMEGA_GEMM_K_MAIN, |
| 185 | * stall: issue cycles after each tensor-core op (1 .. 15). |
| 186 | * mutant (red checks): 1 MAIN drops the second step of every k pair, 2 the packs let element 0 in past the edges (instead of zero), |
| 187 | * 3 MAIN stores each column pair swapped. */ |
| 188 | -typedef struct { OmegaGpuGemmType type; uint32_t rt, ct, wm, wn, stall; int mutant; } OmegaGemmCfg; |
| 189 | +/* band: MAIN visits its tiles in column bands of `band` CTA tiles (power of two up to 32; 0 or 1: plain row-major grid). |
| 190 | + * Consecutive CTAs then share one band of packed B while the rows of A stream past it, so the band stays in L2. */ |
| 191 | +typedef struct { OmegaGpuGemmType type; uint32_t rt, ct, wm, wn, stall; int mutant; uint32_t band; } OmegaGemmCfg; |
| 192 | void omega_gpu_gemm_default_cfg(OmegaGpuGemmType type, OmegaGemmCfg *cfg); |
| 193 | int omega_gpu_gemm_cfg_ok(const OmegaGemmCfg *cfg); |
| 194 | |
| 195 | /* Argument words (constant bank 0x380). Packs: src u64, dst u64, rows, kdim, row stride, k stride (elements), KS2. |
| 196 | - * MAIN: packed A u64, packed B u64, C u64, M, N, KS2. */ |
| 197 | -#define OMEGA_GPU_GEMM_ARGS_WORDS 9u |
| 198 | + * MAIN: packed A u64, packed B u64, C u64, M, N, KS2, tile columns (Np / (8 ct wn); the banded grid's bound). */ |
| 199 | +#define OMEGA_GPU_GEMM_ARGS_WORDS 10u |
| 200 | int omega_gpu_gemm_codegen(const OmegaGemmCfg *cfg, OmegaGemmKind kind, BlackwellIRProgram *prog); |
| 201 | |
| 202 | typedef struct { |
| 203 | diff --git a/tests/gpu_gemm_test.c b/tests/gpu_gemm_test.c |
| 204 | index a54fae2..b3388b7 100644 |
| 205 | --- a/tests/gpu_gemm_test.c |
| 206 | +++ b/tests/gpu_gemm_test.c |
| 207 | @@ -106,6 +106,10 @@ static void host_only(void) { |
| 208 | check(omega_gpu_gemm(OMEGA_GPU_GEMM_E4M3, 0, 1, 1, 1, NULL, b, c, NULL) == OMEGA_GPU_GEMM_BAD_ARGS, "NULL A refused"); |
| 209 | OmegaGemmCfg bad; omega_gpu_gemm_default_cfg(OMEGA_GPU_GEMM_BF16, &bad); bad.rt = 3; |
| 210 | check(!omega_gpu_gemm_cfg_ok(&bad), "a tile of 3 row tiles refused"); |
| 211 | + omega_gpu_gemm_default_cfg(OMEGA_GPU_GEMM_BF16, &bad); bad.band = 3; |
| 212 | + check(!omega_gpu_gemm_cfg_ok(&bad), "a band of 3 tiles refused"); |
| 213 | + bad.band = 64; |
| 214 | + check(!omega_gpu_gemm_cfg_ok(&bad), "a band of 64 tiles refused"); |
| 215 | |
| 216 | /* the model itself is a multiply: within 2^-20 of the exact sum, relative to the sum of the magnitudes */ |
| 217 | for (int t = 0; t < 2; t++) for (unsigned lay = 0; lay < 4; lay++) { |
| 218 | @@ -128,9 +132,9 @@ static void host_only(void) { |
| 219 | printf("%s\n", w); |
| 220 | } |
| 221 | |
| 222 | - const OmegaGemmCfg shapes[] = { { 0, 2, 4, 2, 2, 4, 0 }, { 0, 1, 1, 1, 1, 4, 0 }, { 0, 4, 1, 2, 2, 2, 0 }, { 0, 1, 4, 4, 1, 2, 0 }, { 0, 2, 2, 1, 4, 8, 0 } }; |
| 223 | - OmegaGemmCfg big; omega_gpu_gemm_default_cfg(OMEGA_GPU_GEMM_BF16, &big); big.rt = 4; big.ct = 2; |
| 224 | - check(!omega_gpu_gemm_cfg_ok(&big), "a tile past the register budget (rt 4 ct 2) refused"); |
| 225 | + /* rt 4 ct 2 and rt 4 ct 4 pass R127, so MAIN opts into the hardware register limit; band > 1 adds the banded grid */ |
| 226 | + const OmegaGemmCfg shapes[] = { { 0, 2, 4, 2, 2, 4, 0, 0 }, { 0, 1, 1, 1, 1, 4, 0, 0 }, { 0, 4, 1, 2, 2, 2, 0, 0 }, { 0, 1, 4, 4, 1, 2, 0, 0 }, |
| 227 | + { 0, 2, 2, 1, 4, 8, 0, 0 }, { 0, 4, 2, 2, 2, 4, 0, 0 }, { 0, 4, 4, 2, 2, 2, 0, 8 }, { 0, 2, 4, 2, 2, 4, 0, 32 } }; |
| 228 | for (int t = 0; t < 2; t++) |
| 229 | for (size_t s = 0; s < sizeof shapes / sizeof shapes[0]; s++) |
| 230 | for (int mut = 0; mut <= 3; mut++) |
| 231 | @@ -143,8 +147,8 @@ static void host_only(void) { |
| 232 | OmegaBlackwellKernel kk; memset(&kk, 0, sizeof kk); |
| 233 | int enc = code ? omega_blackwell_kernel_encode_into(p, code, bytes, &kk) : -1; |
| 234 | int np = enc == 0 ? omega_qmma_patch_code(p, code, bytes) : -1; |
| 235 | - snprintf(w, sizeof w, "%s rt %u ct %u wm %u wn %u kernel %d mutant %d: codegen %d, encode %d, qmma patches %d, %u gprs", tname(c.type), |
| 236 | - c.rt, c.ct, c.wm, c.wn, k, mut, rc, enc, np, (unsigned)kk.gpr_count); |
| 237 | + snprintf(w, sizeof w, "%s rt %u ct %u wm %u wn %u band %u kernel %d mutant %d: codegen %d, encode %d, qmma patches %d, %u gprs", tname(c.type), |
| 238 | + c.rt, c.ct, c.wm, c.wn, c.band, k, mut, rc, enc, np, (unsigned)kk.gpr_count); |
| 239 | check(rc == 0 && enc == 0 && kk.code_size == bytes && np >= 0 && (t == 1 || np == 0) && omega_bw_gpr_declared(kk.gpr_count) <= 255u, w); |
| 240 | if (mut == 0) printf("%s\n", w); |
| 241 | free(code); free(p); |
| 242 | @@ -203,7 +207,10 @@ static void sim_tier(void) { |
| 243 | static const uint32_t sh[][3] = { { 1, 1, 1 }, { 1, 1, 17 }, { 16, 8, 16 }, { 17, 9, 33 }, { 64, 64, 64 }, { 65, 63, 100 }, |
| 244 | { 3, 130, 70 }, { 100, 3, 257 }, { 129, 65, 31 }, { 31, 200, 129 } }; |
| 245 | const size_t nsh = sizeof sh / sizeof sh[0]; |
| 246 | - const OmegaGemmCfg cfgs[] = { { 0, 2, 4, 2, 2, 4, 0 }, { 0, 1, 1, 1, 1, 4, 0 }, { 0, 4, 1, 1, 4, 2, 0 } }; |
| 247 | + /* banded: band 8 with at most 4 tile columns (only the first band, half of it leaves), band 2 with 1..25 tile columns |
| 248 | + * (a last band of one column when odd) */ |
| 249 | + const OmegaGemmCfg cfgs[] = { { 0, 2, 4, 2, 4, 4, 0, 8 }, { 0, 2, 4, 2, 2, 4, 0, 0 }, { 0, 1, 1, 1, 1, 4, 0, 0 }, { 0, 4, 1, 1, 4, 2, 0, 0 }, |
| 250 | + { 0, 4, 4, 2, 2, 2, 0, 8 }, { 0, 1, 1, 1, 1, 4, 0, 2 } }; |
| 251 | void *A = malloc(300 * 300 * 2), *B = malloc(300 * 300 * 2); |
| 252 | float *C = malloc(300 * 300 * 4); |
| 253 | for (int t = 0; t < 2; t++) |
| 254 | @@ -223,12 +230,12 @@ static void sim_tier(void) { |
| 255 | runs++; |
| 256 | if (rc != 0 || bad) { |
| 257 | wrong++; |
| 258 | - snprintf(w, sizeof w, "sim %s rt %u ct %u wm %u wn %u, %ux%ux%u %s: rc %d, %" PRIu64 " wrong of %" PRIu64 " %s %s", tname(cfg.type), cfg.rt, |
| 259 | - cfg.ct, cfg.wm, cfg.wn, M, N, K, lname(lay), rc, bad, checked, first, c.err); |
| 260 | + snprintf(w, sizeof w, "sim %s rt %u ct %u wm %u wn %u band %u, %ux%ux%u %s: rc %d, %" PRIu64 " wrong of %" PRIu64 " %s %s", tname(cfg.type), cfg.rt, |
| 261 | + cfg.ct, cfg.wm, cfg.wn, cfg.band, M, N, K, lname(lay), rc, bad, checked, first, c.err); |
| 262 | check(0, w); |
| 263 | } |
| 264 | } |
| 265 | - snprintf(w, sizeof w, "simulator %s rt %u ct %u wm %u wn %u: %" PRIu64 " multiplies, %" PRIu64 " wrong", tname(cfg.type), cfg.rt, cfg.ct, cfg.wm, cfg.wn, runs, wrong); |
| 266 | + snprintf(w, sizeof w, "simulator %s rt %u ct %u wm %u wn %u band %u: %" PRIu64 " multiplies, %" PRIu64 " wrong", tname(cfg.type), cfg.rt, cfg.ct, cfg.wm, cfg.wn, cfg.band, runs, wrong); |
| 267 | check(wrong == 0, w); |
| 268 | printf("%s\n", w); |
| 269 | sim_free(&c); |