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/bw_encode_control_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 / bw_encode_control_test.c` 50 lines ยท 2640 bytes Raw Blame History 1 /* 2 * bw_encode_control_test: every opcode the encoder accepts must carry the control word the emitter scheduled 3 * (BlackwellIRInsn.control: stall, yield, write / read scoreboards, wait mask) into the instruction's top word 4 * (omega-mv#545, 2026-10-18). The encoder's golden-word checks compare words 0..2 only, so an opcode that wrote a 5 * fixed word 3 kept its own wait mask and dropped the emitter's: IADD3 always waited on scoreboard 4 instead of the 6 * Q loads' scoreboards, the next MOVs overwrote the loads' address registers while loads were still queued, and the 7 * prefill attention faulted (Xid 13, Invalid Address Space) on the chip. 8 * 9 * Host only, no device. Exit 0 when every accepted opcode honours the control word. 10 */ 11 #include "omega_blackwell_codegen.h" 12 #include 13 #include 14 15 #define CTL_FIELD 0x03fffe00u /* stall 9..12, yield 13, wbar 14..16, rbar 17..19, wait 20..25 */ 16 17 static const uint32_t sentinels[] = { 18 (3u << 9) | (5u << 14) | (4u << 17) | (0x2au << 20), /* stall 3, wbar 5, rbar 4, wait 0x2a */ 19 (12u << 9) | 0x2000u | (2u << 14) | (7u << 17) | (0x15u << 20), /* stall 12, yield, wbar 2, rbar none, wait 0x15 */ 20 }; 21 22 int main(void) { 23 int checked = 0, refused = 0, bad = 0; 24 for (int op = 0; op <= (int)BW_IR_ATOMG_ADD_F32_STRONG_GPU; op++) { 25 for (int form = 0; form < 4; form++) { 26 const int pred = form & 1, uni = form >> 1; 27 int accepted_any = 0; 28 for (unsigned s = 0; s < sizeof sentinels / sizeof sentinels[0]; s++) { 29 BlackwellIRInsn in; 30 memset(&in, 0, sizeof in); 31 in.op = (BlackwellIROpcode)op; 32 in.dst_vreg = 4; in.src1_vreg = 6; in.src2_vreg = 8; in.src3_vreg = 10; in.ureg = 4; 33 in.imm = 2; in.predicate_p0 = pred != 0; in.is_uniform = uni != 0; 34 in.control = sentinels[s]; 35 uint32_t w[4] = { 0, 0, 0, 0 }; 36 if (omega_blackwell_encode_one(&in, w) != 0) continue; 37 accepted_any = 1; 38 checked++; 39 if ((w[3] & CTL_FIELD) != (sentinels[s] & CTL_FIELD)) { 40 bad++; 41 printf("FAIL: op %d%s%s: control 0x%08x encoded as 0x%08x\n", op, pred ? " (@P0)" : "", uni ? " (uniform)" : "", sentinels[s], w[3]); 42 } 43 } 44 if (!accepted_any && form == 0) refused++; 45 } 46 } 47 printf("bw_encode_control_test: %d encodings checked, %d opcodes refused (no operands), %d dropped the control word: %s\n", 48 checked, refused, bad, bad ? "FAIL" : "PASS"); 49 return bad ? 1 : 0; 50 }