Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/q36_dec_sim_test.c # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / q36_dec_sim_test.c` 254 lines ยท 18779 bytes Raw Blame History 1 /* 2 * q36_dec_sim_test: warp-simulator checks of the decode glue kernels at the Qwen3.6-35B-A3B MoE shapes (sc L306): 3 * RES COMBINE|NORM with 9 groups (8 routed experts + the shared expert in slot 8): x += sum_g w[g] * d[g], then 4 * y = RMSNorm(x) * nw * scale, against a double oracle; mutants 2 (expert 7 skipped) and 3 (shared slot skipped) 5 * must be caught. SWIGLU at width 512 over 9 groups (grid 2 x 9) against a double oracle; mutant 1 caught. 6 * GROUP (L312 v2, the stroke): N heads x 9 slots of expert ids to the grouped-GEMM segment tables and row maps, byte 7 * for byte against a host sort (heads 1, 2, 3, 8; all heads alike); mutants 1 (no tie-break), 2 (cnt short), 3 (empties 8 * unwritten) caught. 9 * COMBINE|NORM in the rows form (L356, one launch for N heads): bit-identical to the one-head program per head (1, 3, 10 * 8 heads); mutant 3 caught. 11 * Host only (no device). Verdict line last: "q36_dec_sim_test: N checks, F failed: PASS|FAIL". 12 */ 13 #include "omega_blackwell_codegen_dec.h" 14 #include "bw_warp_sim_k.h" 15 #include 16 #include 17 #include 18 #include 19 20 static int g_checks, g_failed; 21 #define CHECK(cond, ...) do { g_checks++; if (!(cond)) { g_failed++; printf("FAIL: "); printf(__VA_ARGS__); printf("\n"); } } while (0) 22 static uint32_t lcg(uint32_t *s) { *s = *s * 1664525u + 1013904223u; return *s; } 23 static float frand(uint32_t *s, float lo, float hi) { return lo + (hi - lo) * ((float)(lcg(s) >> 8) / `16777216`.0f); } 24 25 #define H 2048u 26 #define G 9u 27 #define I 512u 28 static const float EPS = 1e-6f; 29 static void put64(WsSim *s, uint32_t off, const void *p) { uintptr_t v = (uintptr_t)p; s->cbank[off / 4] = (uint32_t)v; s->cbank[off / 4 + 1] = (uint32_t)((uint64_t)v >> 32); } 30 31 /* worst relative error of x and y against the oracle, or -1 on a simulator error */ 32 static double combine_point(int mutant, uint32_t seed, float scale, char *msg, size_t n) { 33 static BlackwellIRProgram prog; 34 OmegaDecSpec sp = { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_COMBINE | OMEGA_DEC_RES_NORM, .mutant = mutant, .groups = G }; 35 if (omega_blackwell_codegen_dec_prog(&sp, &prog) != 0) { snprintf(msg, n, "codegen refused"); return -1; } 36 float *x = aligned_alloc(16, H * 4), *d = aligned_alloc(16, (size_t)G * H * 4), *w = aligned_alloc(16, 64), *nw = aligned_alloc(16, H * 4), *y = aligned_alloc(16, H * 4); 37 double *xr = malloc(H * sizeof(double)), *yr = malloc(H * sizeof(double)); 38 uint32_t s = seed; 39 for (unsigned i = 0; i < H; i++) { x[i] = frand(&s, -2.0f, 2.0f); nw[i] = frand(&s, 0.8f, 1.2f); y[i] = -999.0f; } 40 for (size_t i = 0; i < (size_t)G * H; i++) d[i] = frand(&s, -1.0f, 1.0f); 41 for (unsigned g = 0; g < 16; g++) w[g] = g < G ? frand(&s, 0.05f, 0.4f) : 0.0f; 42 for (unsigned i = 0; i < H; i++) { double m = 0; for (unsigned g = 0; g < G; g++) m += (double)w[g] * d[(size_t)g * H + i]; xr[i] = (double)x[i] + m; } 43 double ss = 0; for (unsigned i = 0; i < H; i++) ss += xr[i] * xr[i]; 44 const double r = 1.0 / sqrt(ss / H + (double)EPS); 45 for (unsigned i = 0; i < H; i++) yr[i] = xr[i] * r * nw[i] * scale; 46 WsSim sim; memset(&sim, 0, sizeof sim); 47 static uint8_t smem[OMEGA_DEC_SHARED_BYTES]; 48 sim.p = &prog; sim.threads = 256; sim.smem = smem; sim.smem_bytes = OMEGA_DEC_SHARED_BYTES; 49 put64(&sim, OMEGA_DEC_RES_X, x); put64(&sim, OMEGA_DEC_RES_A, d); put64(&sim, OMEGA_DEC_RES_W, w); put64(&sim, OMEGA_DEC_RES_NW, nw); put64(&sim, OMEGA_DEC_RES_Y, y); 50 memcpy(&sim.cbank[OMEGA_DEC_RES_EPS / 4], &EPS, 4); memcpy(&sim.cbank[OMEGA_DEC_RES_SCALE / 4], &scale, 4); 51 sim.nranges = 5; 52 sim.ranges[0] = (WsRange){ (uintptr_t)x, (uintptr_t)x + H * 4 }; sim.ranges[1] = (WsRange){ (uintptr_t)d, (uintptr_t)d + (size_t)G * H * 4 }; 53 sim.ranges[2] = (WsRange){ (uintptr_t)w, (uintptr_t)w + 64 }; sim.ranges[3] = (WsRange){ (uintptr_t)nw, (uintptr_t)nw + H * 4 }; 54 sim.ranges[4] = (WsRange){ (uintptr_t)y, (uintptr_t)y + H * 4 }; 55 double worst = -1; 56 if (ws_run(&sim, 1, 1) != 0) snprintf(msg, n, "sim: %.150s (pc %d)", sim.msg, sim.err_pc); 57 else { 58 worst = 0; 59 double xmax = 0, ymax = 0; for (unsigned i = 0; i < H; i++) { if (fabs(xr[i]) > xmax) xmax = fabs(xr[i]); if (fabs(yr[i]) > ymax) ymax = fabs(yr[i]); } 60 for (unsigned i = 0; i < H; i++) { 61 double ex = fabs((double)x[i] - xr[i]) / xmax, ey = fabs((double)y[i] - yr[i]) / ymax; 62 if (ex > worst) worst = ex; 63 if (ey > worst) worst = ey; 64 } 65 snprintf(msg, n, "x and y worst rel %.2e", worst); 66 } 67 free(x); free(d); free(w); free(nw); free(y); free(xr); free(yr); 68 return worst; 69 } 70 71 /* L356: COMBINE|NORM in the rows form (one launch for N heads) against the one-head program run on each head's slice: 72 * x and y must be bit-identical (the same arithmetic per row); the weights move by a 256-byte stride, the down outputs by 73 * 9 x 2048 floats per head. Returns the number of differing floats, or -1 on a simulator error. */ 74 static long rows_point(int mutant, uint32_t heads, uint32_t seed, char *msg, size_t n) { 75 static BlackwellIRProgram p1, pr; 76 const uint32_t WS = 256u; /* bytes between heads' weights (the router buffer stride is 256-aligned) */ 77 OmegaDecSpec s1 = { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_COMBINE | OMEGA_DEC_RES_NORM, .groups = G }; 78 OmegaDecSpec sr = { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_COMBINE | OMEGA_DEC_RES_NORM | OMEGA_DEC_RES_ROWS, .groups = G, .stride = WS, .mutant = mutant }; 79 if (omega_blackwell_codegen_dec_prog(&s1, &p1) != 0 || omega_blackwell_codegen_dec_prog(&sr, &pr) != 0) { snprintf(msg, n, "codegen refused"); return -1; } 80 const size_t NX = (size_t)heads * H, ND = (size_t)heads * G * H, NW = (size_t)heads * WS / 4u; 81 float *x0 = aligned_alloc(16, NX * 4), *x1 = aligned_alloc(16, NX * 4), *xr = aligned_alloc(16, NX * 4), *d = aligned_alloc(16, ND * 4); 82 float *w = aligned_alloc(16, NW * 4), *nw = aligned_alloc(16, H * 4), *y1 = aligned_alloc(16, NX * 4), *yr = aligned_alloc(16, NX * 4); 83 uint32_t s = seed; 84 for (size_t i = 0; i < NX; i++) { x0[i] = frand(&s, -2.0f, 2.0f); y1[i] = yr[i] = -999.0f; } 85 for (unsigned i = 0; i < H; i++) nw[i] = frand(&s, 0.8f, 1.2f); 86 for (size_t i = 0; i < ND; i++) d[i] = frand(&s, -1.0f, 1.0f); 87 for (size_t i = 0; i < NW; i++) w[i] = frand(&s, 0.05f, 0.4f); 88 memcpy(x1, x0, NX * 4); memcpy(xr, x0, NX * 4); 89 const float scale = `18446744073709551616`.0f; 90 static uint8_t smem[OMEGA_DEC_SHARED_BYTES]; 91 long bad = 0; 92 for (uint32_t h = 0; h <= heads && bad >= 0; h++) { /* h < heads: the one-head program on head h; h == heads: the rows program */ 93 WsSim sim; memset(&sim, 0, sizeof sim); 94 const int rows = h == heads; 95 sim.p = rows ? &pr : &p1; sim.threads = 256; sim.smem = smem; sim.smem_bytes = OMEGA_DEC_SHARED_BYTES; 96 float *xx = rows ? xr : x1 + (size_t)h * H, *yy = rows ? yr : y1 + (size_t)h * H; 97 put64(&sim, OMEGA_DEC_RES_X, xx); put64(&sim, OMEGA_DEC_RES_A, rows ? d : d + (size_t)h * G * H); 98 put64(&sim, OMEGA_DEC_RES_W, rows ? w : w + (size_t)h * WS / 4u); put64(&sim, OMEGA_DEC_RES_NW, nw); put64(&sim, OMEGA_DEC_RES_Y, yy); 99 memcpy(&sim.cbank[OMEGA_DEC_RES_EPS / 4], &EPS, 4); memcpy(&sim.cbank[OMEGA_DEC_RES_SCALE / 4], &scale, 4); 100 sim.nranges = 5; 101 sim.ranges[0] = (WsRange){ (uintptr_t)xx, (uintptr_t)xx + (rows ? NX : H) * 4 }; 102 sim.ranges[1] = (WsRange){ (uintptr_t)d, (uintptr_t)d + ND * 4 }; 103 sim.ranges[2] = (WsRange){ (uintptr_t)w, (uintptr_t)w + NW * 4 }; 104 sim.ranges[3] = (WsRange){ (uintptr_t)nw, (uintptr_t)nw + H * 4 }; 105 sim.ranges[4] = (WsRange){ (uintptr_t)yy, (uintptr_t)yy + (rows ? NX : H) * 4 }; 106 if (ws_run(&sim, 1, rows ? heads : 1) != 0) { snprintf(msg, n, "sim (%s): %.150s (pc %d)", rows ? "rows" : "one head", sim.msg, sim.err_pc); bad = -1; } 107 } 108 if (bad == 0) { 109 for (size_t i = 0; i < NX; i++) bad += memcmp(&x1[i], &xr[i], 4) != 0; 110 for (size_t i = 0; i < NX; i++) bad += memcmp(&y1[i], &yr[i], 4) != 0; 111 snprintf(msg, n, "%u heads: %ld of %zu x and y floats differ from the one-head program", heads, bad, 2 * NX); 112 } 113 free(x0); free(x1); free(xr); free(d); free(w); free(nw); free(y1); free(yr); 114 return bad; 115 } 116 117 static double swiglu_point(int mutant, uint32_t seed, char *msg, size_t n) { 118 static BlackwellIRProgram prog; 119 OmegaDecSpec sp = { .kind = OMEGA_DEC_SWIGLU, .mutant = mutant, .width = I }; 120 if (omega_blackwell_codegen_dec_prog(&sp, &prog) != 0) { snprintf(msg, n, "codegen refused"); return -1; } 121 float *gu = aligned_alloc(16, (size_t)G * 2 * I * 4), *act = aligned_alloc(16, (size_t)G * I * 4); 122 const float scale = `18446744073709551616`.0f; /* 2^64: the FP8 GEMV x' row */ 123 uint32_t s = seed; 124 for (size_t i = 0; i < (size_t)G * 2 * I; i++) gu[i] = frand(&s, -4.0f, 4.0f); 125 for (size_t i = 0; i < (size_t)G * I; i++) act[i] = -999.0f; 126 WsSim sim; memset(&sim, 0, sizeof sim); 127 static uint8_t smem[OMEGA_DEC_SHARED_BYTES]; 128 sim.p = &prog; sim.threads = 256; sim.smem = smem; sim.smem_bytes = OMEGA_DEC_SHARED_BYTES; 129 put64(&sim, OMEGA_DEC_SW_GU, gu); put64(&sim, OMEGA_DEC_SW_ACT, act); memcpy(&sim.cbank[OMEGA_DEC_SW_SCALE / 4], &scale, 4); 130 sim.nranges = 2; 131 sim.ranges[0] = (WsRange){ (uintptr_t)gu, (uintptr_t)gu + (size_t)G * 2 * I * 4 }; sim.ranges[1] = (WsRange){ (uintptr_t)act, (uintptr_t)act + (size_t)G * I * 4 }; 132 double worst = -1; 133 if (ws_run(&sim, I / 256u, G) != 0) snprintf(msg, n, "sim: %.150s (pc %d)", sim.msg, sim.err_pc); 134 else { 135 worst = 0; 136 for (unsigned g = 0; g < G; g++) for (unsigned c = 0; c < I; c++) { 137 const double v = gu[(size_t)g * 2 * I + c], u = gu[(size_t)g * 2 * I + I + c]; 138 const double ref = v / (1.0 + exp(-v)) * u * scale, got = act[(size_t)g * I + c]; 139 const double e = fabs(got - ref) / (fabs(ref) + 1e-3 * scale); 140 if (e > worst) worst = e; 141 } 142 snprintf(msg, n, "act worst rel %.2e", worst); 143 } 144 free(gu); free(act); 145 return worst; 146 } 147 148 /* GROUP (L312 v2): N heads x 9 slots of expert ids -> the two segment tables and the two maps, byte for byte against a 149 * host sort. all_same: every head picks the same 8 experts (9 segments of cnt N: the heaviest overlap). */ 150 typedef struct { uint64_t w, s; uint32_t row0, cnt, pad[2]; } Seg; 151 static uint64_t fake_w(uint32_t id) { return 0x100000ull + (uint64_t)id * 0x1000ull; } 152 static uint64_t fake_s(uint32_t id) { return 0x900000ull + (uint64_t)id * 0x100ull; } 153 static int group_point(int mutant, uint32_t heads, int all_same, uint32_t seed, char *msg, size_t n) { 154 static BlackwellIRProgram prog; 155 OmegaDecSpec sp = { .kind = OMEGA_DEC_GROUP, .mutant = mutant, .groups = G }; 156 if (omega_blackwell_codegen_dec_prog(&sp, &prog) != 0) { snprintf(msg, n, "codegen refused"); return -1; } 157 const uint32_t R = heads * G, STRIDE = 4096u, PAD = OMEGA_DEC_GR_PAD; 158 uint8_t *lb = aligned_alloc(16, (size_t)heads * STRIDE); memset(lb, 0, (size_t)heads * STRIDE); 159 Seg *sgu = aligned_alloc(16, (size_t)R * sizeof(Seg)), *sdn = aligned_alloc(16, (size_t)R * sizeof(Seg)); 160 uint32_t *xm = aligned_alloc(16, (size_t)(R + PAD) * 4), *ym = aligned_alloc(16, (size_t)(R + PAD) * 4); 161 memset(sgu, 0xEE, (size_t)R * sizeof(Seg)); memset(sdn, 0xEE, (size_t)R * sizeof(Seg)); memset(xm, 0xEE, (size_t)(R + PAD) * 4); memset(ym, 0xEE, (size_t)(R + PAD) * 4); 162 uint32_t s = seed, ids[16 * G]; 163 for (uint32_t h = 0; h < heads; h++) { 164 uint32_t *row = ids + h * G; 165 if (all_same && h) memcpy(row, ids, G * 4); 166 else { 167 for (uint32_t j = 0; j < 8; j++) { int dup; do { row[j] = lcg(&s) % 256u; dup = 0; for (uint32_t q = 0; q < j; q++) if (row[q] == row[j]) dup = 1; } while (dup); } 168 row[8] = 256u; /* the shared expert */ 169 } 170 uint32_t *idp = (uint32_t *)(lb + (size_t)h * STRIDE); uint64_t *tg = (uint64_t *)(lb + (size_t)h * STRIDE + 1024), *td = (uint64_t *)(lb + (size_t)h * STRIDE + 2048); 171 for (uint32_t j = 0; j < G; j++) { idp[j] = row[j]; tg[2 * j] = fake_w(row[j]); tg[2 * j + 1] = fake_s(row[j]); td[2 * j] = fake_w(row[j]) + 7u; td[2 * j + 1] = fake_s(row[j]) + 3u; } 172 } 173 /* host reference */ 174 Seg *egu = calloc(R, sizeof(Seg)), *edn = calloc(R, sizeof(Seg)); uint32_t *exm = calloc(R + PAD, 4), *eym = calloc(R + PAD, 4); 175 uint32_t rank[16 * G]; 176 for (uint32_t t = 0; t < R; t++) { uint32_t p = 0; for (uint32_t q = 0; q < R; q++) if (ids[q] * 128u + q < ids[t] * 128u + t) p++; rank[t] = p; exm[p] = t / G; eym[p] = t; } 177 uint32_t D = 0; 178 for (uint32_t t = 0; t < R; t++) { 179 int first = 1; uint32_t cnt = 0, below = 0; 180 for (uint32_t q = 0; q < R; q++) { if (ids[q] == ids[t]) { cnt++; if (q < t) first = 0; } } 181 if (!first) continue; 182 for (uint32_t q = 0; q < R; q++) { int fq = 1; for (uint32_t z = 0; z < q; z++) if (ids[z] == ids[q]) fq = 0; if (fq && ids[q] < ids[t]) below++; } 183 egu[below] = (Seg){ fake_w(ids[t]), fake_s(ids[t]), rank[t], cnt, { 0, 0 } }; 184 edn[below] = (Seg){ fake_w(ids[t]) + 7u, fake_s(ids[t]) + 3u, rank[t], cnt, { 0, 0 } }; 185 D++; 186 } 187 WsSim sim; memset(&sim, 0, sizeof sim); 188 static uint8_t smem[OMEGA_DEC_GR_SHARED_BYTES]; 189 sim.p = &prog; sim.threads = 256; sim.smem = smem; sim.smem_bytes = OMEGA_DEC_GR_SHARED_BYTES; 190 put64(&sim, OMEGA_DEC_GR_IDS, lb); put64(&sim, OMEGA_DEC_GR_TGU, lb + 1024); put64(&sim, OMEGA_DEC_GR_TDN, lb + 2048); 191 put64(&sim, OMEGA_DEC_GR_SGU, sgu); put64(&sim, OMEGA_DEC_GR_SDN, sdn); put64(&sim, OMEGA_DEC_GR_XMAP, xm); put64(&sim, OMEGA_DEC_GR_YMAP, ym); 192 sim.cbank[OMEGA_DEC_GR_STRIDE / 4] = STRIDE; sim.cbank[OMEGA_DEC_GR_HEADS / 4] = heads; 193 sim.nranges = 5; 194 sim.ranges[0] = (WsRange){ (uintptr_t)lb, (uintptr_t)lb + (size_t)heads * STRIDE }; 195 sim.ranges[1] = (WsRange){ (uintptr_t)sgu, (uintptr_t)sgu + (size_t)R * sizeof(Seg) }; sim.ranges[2] = (WsRange){ (uintptr_t)sdn, (uintptr_t)sdn + (size_t)R * sizeof(Seg) }; 196 sim.ranges[3] = (WsRange){ (uintptr_t)xm, (uintptr_t)xm + (size_t)(R + PAD) * 4 }; sim.ranges[4] = (WsRange){ (uintptr_t)ym, (uintptr_t)ym + (size_t)(R + PAD) * 4 }; 197 int bad = -1; 198 if (ws_run(&sim, 1, 1) != 0) snprintf(msg, n, "sim: %.150s (pc %d)", sim.msg, sim.err_pc); 199 else { 200 int bg = memcmp(sgu, egu, (size_t)R * sizeof(Seg)) != 0, bd = memcmp(sdn, edn, (size_t)R * sizeof(Seg)) != 0; 201 int bx = memcmp(xm, exm, (size_t)(R + PAD) * 4) != 0, by = memcmp(ym, eym, (size_t)(R + PAD) * 4) != 0; 202 bad = bg + bd + bx + by; 203 snprintf(msg, n, "heads %u rows %u distinct %u: seg_gu %s, seg_dn %s, xmap %s, ymap %s", heads, R, D, bg ? "WRONG" : "ok", bd ? "WRONG" : "ok", bx ? "WRONG" : "ok", by ? "WRONG" : "ok"); 204 } 205 free(lb); free(sgu); free(sdn); free(xm); free(ym); free(egu); free(edn); free(exm); free(eym); 206 return bad; 207 } 208 209 int main(void) { 210 char msg[300]; 211 { OmegaDecSpec sp = { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_ADD | OMEGA_DEC_RES_NORM, .groups = 9 }; CHECK(omega_dec_prog_stats(&sp, NULL, NULL) != 0, "groups 9 without COMBINE refused"); } 212 { OmegaDecSpec sp = { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_COMBINE, .groups = 7 }; CHECK(omega_dec_prog_stats(&sp, NULL, NULL) != 0, "groups 7 refused"); } 213 { OmegaDecSpec sp = { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_COMBINE, .mutant = 3 }; CHECK(omega_dec_prog_stats(&sp, NULL, NULL) != 0, "mutant 3 without the shared slot refused"); } 214 const struct { uint32_t seed; float scale; } pts[] = { { 1, 1.0f }, { 2, `18446744073709551616`.0f }, { 3, 1.0f } }; 215 for (unsigned i = 0; i < 3; i++) { 216 double w = combine_point(0, pts[i].seed, pts[i].scale, msg, sizeof msg); 217 CHECK(w >= 0 && w < 2e-6, "COMBINE|NORM 9 groups seed %u: %s", pts[i].seed, msg); 218 printf("COMBINE|NORM 9 groups seed %u scale %s: %s\n", pts[i].seed, pts[i].scale > 2.0f ? "2^64" : "1", msg); 219 } 220 for (int m = 2; m <= 3; m++) { 221 double w = combine_point(m, 7, 1.0f, msg, sizeof msg); 222 CHECK(w > 1e-3, "COMBINE mutant %d must be caught: %s", m, msg); 223 printf("COMBINE mutant %d: %s (%s)\n", m, w > 1e-3 ? "caught" : "NOT CAUGHT", msg); 224 } 225 for (uint32_t seed = 11; seed <= 12; seed++) { 226 double w = swiglu_point(0, seed, msg, sizeof msg); 227 CHECK(w >= 0 && w < 1e-5, "SWIGLU 512 x 9 seed %u: %s", seed, msg); 228 printf("SWIGLU width 512 x 9 groups seed %u: %s\n", seed, msg); 229 } 230 { double w = swiglu_point(1, 13, msg, sizeof msg); CHECK(w > 1e-3, "SWIGLU mutant 1 must be caught: %s", msg); printf("SWIGLU mutant 1: %s (%s)\n", w > 1e-3 ? "caught" : "NOT CAUGHT", msg); } 231 { OmegaDecSpec sp = { .kind = OMEGA_DEC_GROUP, .groups = 17 }; CHECK(omega_dec_prog_stats(&sp, NULL, NULL) != 0, "GROUP 17 slots refused"); } 232 { OmegaDecSpec sp = { .kind = OMEGA_DEC_GROUP, .groups = G }; uint32_t ins = 0, gp = 0; CHECK(omega_dec_prog_stats(&sp, &ins, &gp) == 0, "GROUP codegen"); printf("GROUP 9 slots: %u instructions, %u registers\n", ins, gp); } 233 const struct { uint32_t heads; int same; uint32_t seed; } gpts[] = { { 8, 0, 21 }, { 8, 1, 22 }, { 1, 0, 23 }, { 3, 0, 24 }, { 8, 0, 25 }, { 2, 1, 26 } }; 234 for (unsigned i = 0; i < sizeof gpts / sizeof gpts[0]; i++) { 235 int b = group_point(0, gpts[i].heads, gpts[i].same, gpts[i].seed, msg, sizeof msg); 236 CHECK(b == 0, "GROUP heads %u%s seed %u: %s", gpts[i].heads, gpts[i].same ? " all-same" : "", gpts[i].seed, msg); 237 printf("GROUP%s seed %u: %s\n", gpts[i].same ? " all-same" : "", gpts[i].seed, msg); 238 } 239 for (int m = 1; m <= 3; m++) { 240 int b = group_point(m, 8, 0, 27, msg, sizeof msg); 241 CHECK(b != 0, "GROUP mutant %d must be caught: %s", m, msg); 242 printf("GROUP mutant %d: %s (%s)\n", m, b != 0 ? "caught" : "NOT CAUGHT", msg); 243 } 244 { OmegaDecSpec sp = { .kind = OMEGA_DEC_RES, .mode = OMEGA_DEC_RES_COMBINE | OMEGA_DEC_RES_NORM | OMEGA_DEC_RES_ROWS, .groups = G, .stride = 8 }; 245 CHECK(omega_dec_prog_stats(&sp, NULL, NULL) != 0, "COMBINE rows with a weights stride not a multiple of 16 refused"); } 246 for (uint32_t hh = 1; hh <= 8; hh += hh < 3 ? 2 : 5) { 247 long b = rows_point(0, hh, 40 + hh, msg, sizeof msg); 248 CHECK(b == 0, "COMBINE|NORM rows: %s", msg); 249 printf("COMBINE|NORM rows (L356): %s\n", msg); 250 } 251 { long b = rows_point(3, 8, 49, msg, sizeof msg); CHECK(b > 0, "COMBINE rows mutant 3 must be caught: %s", msg); printf("COMBINE rows mutant 3: %s (%s)\n", b > 0 ? "caught" : "NOT CAUGHT", msg); } 252 printf("q36_dec_sim_test: %d checks, %d failed: %s\n", g_checks, g_failed, g_failed ? "FAIL" : "PASS"); 253 return g_failed ? 1 : 0; 254 }