diff --git a/.crumb b/.crumb index 1499dabfb..83cad2ea8 100644 --- a/.crumb +++ b/.crumb @@ -48,7 +48,7 @@ }, { "digest": "7ef7796693f23ad68d9a5bcaaee0f635018f4371139a040ba202d4ce7083ede8", - "last_commit": "dd39bf71f", + "last_commit": "dcccc0211", "name": "docs", "purpose": "Directory docs. Purpose not yet described by a human." }, @@ -77,14 +77,14 @@ "purpose": "Directory spec. Purpose not yet described by a human." }, { - "digest": "199749684598b36b610b14a4c5b59703df5e53bba1db2b5939297c55ac423153", - "last_commit": "bf54b19fa", + "digest": "aaf5acb82fd4c720cd60c85fd6087f636c72a98e2f3740c9295dcfa525dc64d7", + "last_commit": "0575763e9", "name": "src", "purpose": "Directory src. Purpose not yet described by a human." }, { - "digest": "ea8ae97d49edc85af090218634c9bad13bcc91fa84f96e0d33fefe313704e111", - "last_commit": "dcccc0211", + "digest": "060352a843d719e700640477499fdc17ea661c3966abf9e059aedf8d90583e04", + "last_commit": "0575763e9", "name": "tests", "purpose": "Directory tests. Purpose not yet described by a human." }, @@ -95,15 +95,15 @@ "purpose": "Directory tools. Purpose not yet described by a human." } ], - "children_root": "sha256:8091287983f9252d3cbab774326dd2cc2641e8e724c75b7b59bbbb319ceb72c9", - "compiled_at": "2026-10-30T11:39:09Z", + "children_root": "sha256:0155c6fbf48664fa60e0b0660eb15d452aa15146443cedcbb5e028cbc18a612f", + "compiled_at": "2026-10-30T11:52:02Z", "compiler": "crumb-compile/1", - "digest": "sha256:f306d42dc3dbc0577c3b11b16545012d98dfa43bb7ab301755b8462ab21e5573", - "evidence_files": 12618, - "evidence_root": "sha256:29c85fbb0f76b7a90066e4294075f19d6125cce0336cfce58a53765ac33df4ee", - "files": 17830, - "generated_at_commit": "b1606299f4ba25fa437a99bc483ab14e2616400b", - "source_tree": "sha256:179f43aa914762cb0059ac027e75eb84becfdd538d8a160d4c31556317c77386" + "digest": "sha256:ac4b586178a485a5dcb8225803246ac14c3ab2feccdc3dd859790e30e837d40e", + "evidence_files": 12622, + "evidence_root": "sha256:b1a08e2ce56e6feada0d8a31f06fbd7adee57adc1c1ad8dec220293ee5d439f9", + "files": 17835, + "generated_at_commit": "0575763e91a5ada8d7c0102dafb6c966481f16d4", + "source_tree": "sha256:16a46ad0b18e168de8438ba8cb887a9bd2cae920be463892ff905c665fbcc3d5" }, "owner_lane": "", "provenance": { diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index dea84a7ef..4993e6fa3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -45,3 +45,4 @@ Update this table in the same commit as the work it credits. | Codex | Integrated FR-9 with compiler batch 3 and the latest quantity/diagnostic audit; preserved empty text and integer-bitcast behavior on x86 and kept seed bootstrap within its function budget by removing unused helpers and inlining one single-use helper. | | Codex | Fixed x86 quantity unary refusals and empty-text emission; added explicit per-target acceptance contracts, preserved historical failed experiments, and exercised missing diagnostic callers and stale-binding controls. | +| Grok 4.7 | Merged current main (b3dca0f1) into #514. The only conflict was the generated root `.crumb`; regenerated crumbs with the crumb.lock tool (d0f0b95d). | diff --git a/Makefile b/Makefile index 4e068c1de..a42b2b1f4 100644 --- a/Makefile +++ b/Makefile @@ -2463,6 +2463,17 @@ $(GPU_RECONV_TEST): tests/gpu_reconv_test.c tests/bw_warp_sim.h src/omega_gpu_el test-gpu-reconv: $(GPU_RECONV_TEST) ./$(GPU_RECONV_TEST) --host-only +# omega #492: IMAD.HI.U32 with a register Rc. The chip reads Rc as a 64-bit register pair (nvcc 13.0 +# sm_121 oracle, evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016; chip probe pending), so the four warp +# simulators refuse a non-RZ Rc instead of modelling a 32-bit one. One binary per simulator header. +.PHONY: test-gpu-imadhi-rc +GPU_IMADHI_SIMS = bw_warp_sim bw_warp_sim_tc bw_warp_sim_k bw_warp_sim_pa +GPU_IMADHI_TESTS = $(GPU_IMADHI_SIMS:%=$(OUT_DIR)/gpu_imadhi_rc_test_%) +$(OUT_DIR)/gpu_imadhi_rc_test_%: tests/gpu_imadhi_rc_test.c tests/%.h $(OUT_DIR)/libomega_gpu.a + $(CC) $(CFLAGS) -Itests -DSIM_HEADER='"$*.h"' -o $@ tests/gpu_imadhi_rc_test.c $(OUT_DIR)/libomega_gpu.a -lpthread -lm +test-gpu-imadhi-rc: $(GPU_IMADHI_TESTS) + @for t in $(GPU_IMADHI_TESTS); do ./$$t || exit 1; done + # FB-1 cut 5: native gqa_attention (f32 KV) and paged_attention (bf16 KV, + batch). # head_dim 128 (Qwen3-4B): the same battery with --hd 128 through both host simulators; GB10 parity PASS 126/0 # at 7dd92dc (evidence/FB1-CUT5-HD128-7dd92dc). diff --git a/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/SHA256SUMS b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/SHA256SUMS new file mode 100644 index 000000000..9204e57bd --- /dev/null +++ b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/SHA256SUMS @@ -0,0 +1,3 @@ +ee8fcfd06e08daa2df8b7c3169154cd48dca6020eb356e6b26a049704625970b k.cu +5de614784ef37401d29b3864536ebba6f0687924e1a4c5aa253923a097097faf k.sass +bdfae8c97a7f2b553bc5fd8891d113ee5a5e09818e3531e9bf58f80392df9a40 nvcc-version.txt diff --git a/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/k.cu b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/k.cu new file mode 100644 index 000000000..103f88e9e --- /dev/null +++ b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/k.cu @@ -0,0 +1,3 @@ +extern "C" __global__ void k_umulhi_plus_c(unsigned *o, unsigned a, unsigned b, unsigned c) { o[threadIdx.x] = __umulhi(a, b) + c; } +extern "C" __global__ void k_wide_hi(unsigned *o, unsigned a, unsigned b, unsigned long long c64) { o[threadIdx.x] = (unsigned)(((unsigned long long)a * b + c64) >> 32); } +extern "C" __global__ void k_wide_hi_c32(unsigned *o, unsigned a, unsigned b, unsigned c) { o[threadIdx.x] = (unsigned)(((unsigned long long)a * b + c) >> 32); } diff --git a/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/k.sass b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/k.sass new file mode 100644 index 000000000..072443115 --- /dev/null +++ b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/k.sass @@ -0,0 +1,120 @@ + .target sm_121 + + .elftype @"ET_EXEC" + + +//--------------------- .text.k_wide_hi_c32 -------------------------- + .section .text.k_wide_hi_c32,"ax",@progbits + .align 128 + .global k_wide_hi_c32 + .type k_wide_hi_c32,@function + .size k_wide_hi_c32,(.L_x_3 - k_wide_hi_c32) + .other k_wide_hi_c32,@"STO_CUDA_ENTRY STV_DEFAULT" +k_wide_hi_c32: +.text.k_wide_hi_c32: + /*0000*/ LDC R1, c[0x0][0x37c] ; + /*0010*/ S2R R5, SR_TID.X ; + /*0020*/ LDC.64 R2, c[0x0][0x380] ; + /*0030*/ LDCU UR4, c[0x0][0x390] ; + /*0040*/ LDCU.64 UR6, c[0x0][0x358] ; + /*0050*/ LDC.64 R6, c[0x0][0x388] ; + /*0060*/ UMOV UR5, URZ ; + /*0070*/ IMAD.WIDE.U32 R2, R5, 0x4, R2 ; + /*0080*/ IMAD.HI.U32 R5, R7, R6, UR4 ; + /*0090*/ STG.E desc[UR6][R2.64], R5 ; + /*00a0*/ EXIT ; +.L_x_0: + /*00b0*/ BRA `(.L_x_0); + /*00c0*/ NOP; + /*00d0*/ NOP; + /*00e0*/ NOP; + /*00f0*/ NOP; + /*0100*/ NOP; + /*0110*/ NOP; + /*0120*/ NOP; + /*0130*/ NOP; + /*0140*/ NOP; + /*0150*/ NOP; + /*0160*/ NOP; + /*0170*/ NOP; +.L_x_3: + + +//--------------------- .text.k_wide_hi -------------------------- + .section .text.k_wide_hi,"ax",@progbits + .align 128 + .global k_wide_hi + .type k_wide_hi,@function + .size k_wide_hi,(.L_x_4 - k_wide_hi) + .other k_wide_hi,@"STO_CUDA_ENTRY STV_DEFAULT" +k_wide_hi: +.text.k_wide_hi: + /*0000*/ LDC R1, c[0x0][0x37c] ; + /*0010*/ S2R R9, SR_TID.X ; + /*0020*/ LDC.64 R2, c[0x0][0x390] ; + /*0030*/ LDCU.64 UR4, c[0x0][0x358] ; + /*0040*/ LDC.64 R6, c[0x0][0x388] ; + /*0050*/ LDC.64 R4, c[0x0][0x380] ; + /*0060*/ IMAD.HI.U32 R7, R7, R6, R2 ; + /*0070*/ IMAD.WIDE.U32 R2, R9, 0x4, R4 ; + /*0080*/ STG.E desc[UR4][R2.64], R7 ; + /*0090*/ EXIT ; +.L_x_1: + /*00a0*/ BRA `(.L_x_1); + /*00b0*/ NOP; + /*00c0*/ NOP; + /*00d0*/ NOP; + /*00e0*/ NOP; + /*00f0*/ NOP; + /*0100*/ NOP; + /*0110*/ NOP; + /*0120*/ NOP; + /*0130*/ NOP; + /*0140*/ NOP; + /*0150*/ NOP; + /*0160*/ NOP; + /*0170*/ NOP; +.L_x_4: + + +//--------------------- .text.k_umulhi_plus_c -------------------------- + .section .text.k_umulhi_plus_c,"ax",@progbits + .align 128 + .global k_umulhi_plus_c + .type k_umulhi_plus_c,@function + .size k_umulhi_plus_c,(.L_x_5 - k_umulhi_plus_c) + .other k_umulhi_plus_c,@"STO_CUDA_ENTRY STV_DEFAULT" +k_umulhi_plus_c: +.text.k_umulhi_plus_c: + /*0000*/ LDC R1, c[0x0][0x37c] ; + /*0010*/ S2R R7, SR_TID.X ; + /*0020*/ LDC.64 R2, c[0x0][0x380] ; + /*0030*/ LDCU.64 UR4, c[0x0][0x358] ; + /*0040*/ HFMA2 R4, -RZ, RZ, 0, 0 ; + /*0050*/ LDC R5, c[0x0][0x390] ; + /*0060*/ LDC.64 R8, c[0x0][0x388] ; + /*0070*/ IMAD.WIDE.U32 R2, R7, 0x4, R2 ; + /*0080*/ IMAD.HI.U32 R5, R8, R9, R4 ; + /*0090*/ STG.E desc[UR4][R2.64], R5 ; + /*00a0*/ EXIT ; +.L_x_2: + /*00b0*/ BRA `(.L_x_2); + /*00c0*/ NOP; + /*00d0*/ NOP; + /*00e0*/ NOP; + /*00f0*/ NOP; + /*0100*/ NOP; + /*0110*/ NOP; + /*0120*/ NOP; + /*0130*/ NOP; + /*0140*/ NOP; + /*0150*/ NOP; + /*0160*/ NOP; + /*0170*/ NOP; +.L_x_5: + + +//--------------------- SYMBOLS -------------------------- + + .type .nv.reservedSmem.offset0,@object + .size .nv.reservedSmem.offset0,0x4 diff --git a/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/nvcc-version.txt b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/nvcc-version.txt new file mode 100644 index 000000000..bf3d20a17 --- /dev/null +++ b/evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/nvcc-version.txt @@ -0,0 +1,5 @@ +nvcc: NVIDIA (R) Cuda compiler driver +Copyright (c) 2005-2025 NVIDIA Corporation +Built on Wed_Aug_20_01:57:39_PM_PDT_2025 +Cuda compilation tools, release 13.0, V13.0.88 +Build cuda_13.0.r13.0/compiler.36424714_0 diff --git a/src/.crumb b/src/.crumb index d4d2a1953..7c4b83da7 100644 --- a/src/.crumb +++ b/src/.crumb @@ -188,14 +188,14 @@ } ], "children_root": "sha256:2f729945214be989a74d7c2064ae4ba3c2deb52ebea3f334b459198a7bd032ed", - "compiled_at": "2026-10-29T01:41:23Z", + "compiled_at": "2026-10-30T02:49:13Z", "compiler": "crumb-compile/1", - "digest": "sha256:199749684598b36b610b14a4c5b59703df5e53bba1db2b5939297c55ac423153", + "digest": "sha256:aaf5acb82fd4c720cd60c85fd6087f636c72a98e2f3740c9295dcfa525dc64d7", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 568, - "generated_at_commit": "28a7b749a6da68407af60a7cccaf34dc2e5eab48", - "source_tree": "sha256:28fa18bff3a59bc596555496f77a1b57ac83aebfac8b37e50d71cbc4c5dd00b1" + "generated_at_commit": "2cb1ccb5d3c1a1ce1cb94a7a3dd3c221395c4e15", + "source_tree": "sha256:7f1fef46a27e8baf5cf567bb590d417ede3767c5f07e714d0f0812af0645bb4b" }, "owner_lane": "", "provenance": { diff --git a/src/omega_blackwell_codegen.h b/src/omega_blackwell_codegen.h index 30ff38983..1f0b70eec 100644 --- a/src/omega_blackwell_codegen.h +++ b/src/omega_blackwell_codegen.h @@ -101,8 +101,12 @@ typedef enum { * truth table over Ra = 0xf0, Rb = 0xcc, Rc = 0xaa (a|b = 0xfc, ~(a|b) = 0x03) */ BW_IR_SHF_L_U32, /* SHF.L.U32 Rd, Ra, Rb, RZ: Rd = Ra << Rb, register amount (the form nvcc emits * for PTX shl.b32). Amounts >= 32 are NOT chip-verified: callers keep Rb < 32 */ - BW_IR_IMAD_HI_U32, /* IMAD.HI.U32 Rd, Ra, Rb, Rc: Rd = hi32(Ra * Rb) + Rc mod 2^32 (nvcc emits this - * word for __umulhi(a, b) + c) */ + BW_IR_IMAD_HI_U32, /* IMAD.HI.U32 Rd, Ra, Rb, Rc: Rd = hi32(Ra * Rb + Rc:Rc+1). Rc is a 64-bit register pair, + * NOT one 32-bit word: nvcc 13.0 zeroes the upper half before using a 32-bit c, puts + * __umulhi(a, b) + c through the pair {0, c}, and emits only even pair bases (R2, R4, UR4 + * in evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016). Odd-Rc chip behaviour is unknown until + * the chip probe (omega #492); until then the warp simulators refuse a non-RZ Rc. + * Callers pass Rc = RZ (src3_vreg = -1) */ /* Structured warp reconvergence (omega #308, 2026-10-05), additive. Words matched against * nvcc 13.0.88 -arch=sm_121 output (BSSY.RECONVERGENT / BSYNC.RECONVERGENT; the oracle * kernels are listed in docs/gpu-reconvergence-308.md) and the Mesa NAK encoder diff --git a/tests/.crumb b/tests/.crumb index 75dbe23b9..d7afac0d1 100644 --- a/tests/.crumb +++ b/tests/.crumb @@ -110,206 +110,206 @@ "children": [ { "digest": "2c1deaaa1bae6257789749edde641df61413250fe91ce6aa61a99dfb3b271306", - "last_commit": "28911be7a", + "last_commit": "d863780eb", "name": "algebra", "purpose": "Directory tests/algebra. Purpose not yet described by a human." }, { "digest": "63f086b68bb9ffc032cbd74931309ab34df3c8c341b57935e5db43d8bf475800", - "last_commit": "834ee93e4", + "last_commit": "d863780eb", "name": "ans", "purpose": "Tests 1-10 for ANS (docs/ans/INERTIAL_ALIGNMENT_SPEC_V1.md): freeze/digest, hostile reference mu" }, { "digest": "7b69a19958c5a5f55bba4fbc33bc6f26423358efd46311b0eacfe83bb665d4c1", - "last_commit": "1b0e2968c", + "last_commit": "450bbefd4", "name": "brownian", "purpose": "Directory tests/brownian. Purpose not yet described by a human." }, { "digest": "1cd97575b2b10d9313ca0df4997391612056754778bb2851bf052c146144f15e", - "last_commit": "30bb116cc", + "last_commit": "d863780eb", "name": "canonicalization", "purpose": "Directory tests/canonicalization. Purpose not yet described by a human." }, { "digest": "088f526f8cae115209dd0162f28669812483ce5c926e41e8810dada1eefcb81a", - "last_commit": "1edf41a5c", + "last_commit": "450bbefd4", "name": "compiler", "purpose": "Directory tests/compiler. Purpose not yet described by a human." }, { "digest": "9e372cfc9747befacdcf31bc8643356aaff861e81ee6640b4866170be67b5e6c", - "last_commit": "28b87934b", + "last_commit": "d863780eb", "name": "constraints", "purpose": "Directory tests/constraints. Purpose not yet described by a human." }, { "digest": "87a3efa5cd0aefa7821046f9a31594bfa0a109e95005a1e12f40c99a1bc6cd3d", - "last_commit": "49abb0247", + "last_commit": "d863780eb", "name": "crumbline", "purpose": "Directory tests/crumbline. Purpose not yet described by a human." }, { "digest": "10aa3424eded7768fee0bae0eedd062b9deac3279d2e5721439fd024493bc42b", - "last_commit": "00f54b6b1", + "last_commit": "d863780eb", "name": "dual_experiment", "purpose": "Tests for the DUAL applicability experiment: determinism (same seed, byte-identical results dige" }, { "digest": "758dde696afa847d9347fad76b0c4935e968f8af4551f0f9810ec2a37ad9847a", - "last_commit": "c819b3762", + "last_commit": "d863780eb", "name": "effect", "purpose": "Directory tests/effect. Purpose not yet described by a human." }, { "digest": "23e559d13ff664995baca31dc157a8cf5a860615f3ecb07a9a40fe4626b57ae3", - "last_commit": "1a147e40f", + "last_commit": "d863780eb", "name": "estimation", "purpose": "Directory tests/estimation. Purpose not yet described by a human." }, { "digest": "b7b6391caf653c76707a21f9969126abcbc730d1243259219225fdb9bc0084e0", - "last_commit": "3108fc2f5", + "last_commit": "d863780eb", "name": "fabric", "purpose": "Directory tests/fabric. Purpose not yet described by a human." }, { "digest": "defc52a44ea0f65ba5de3468de786148ba58d292ffa217fb95629a28a569a977", - "last_commit": "28b87934b", + "last_commit": "d863780eb", "name": "identity", "purpose": "Directory tests/identity. Purpose not yet described by a human." }, { "digest": "6ba43d622b712a4215767cab29425016f29cce4b28eb9e4961fc67fd20e9d765", - "last_commit": "4f55f45ed", + "last_commit": "d863780eb", "name": "language", "purpose": "Directory tests/language. Purpose not yet described by a human." }, { "digest": "54f43a3416595ff5d4e64bd12afe013359e706651c39c78e2896a5799638d263", - "last_commit": "30bb116cc", + "last_commit": "d863780eb", "name": "malformed", "purpose": "Directory tests/malformed. Purpose not yet described by a human." }, { "digest": "a03a4dd9a72f7b449342e562f6d9df1a3348fb03fb640b662956caf163dcd7e9", - "last_commit": "40d1ea378", + "last_commit": "d863780eb", "name": "numeric_native", "purpose": "Simulated M16 driver for numeric resource-lifecycle tests. No device execution or numeric parity" }, { "digest": "d958af5413726ddc48a47721800d9766939129f480b26492332ba094577837cb", - "last_commit": "6d8d92adc", + "last_commit": "d863780eb", "name": "osh", "purpose": "osh lexer host driver, vendored aien-protocols PR#16 draft vectors (5ae5292)" }, { "digest": "65e84051bb8dc00b180c6b06bec58103773785eebd6d6c69c9783de5fd0e2ba9", - "last_commit": "d550b705b", + "last_commit": "450bbefd4", "name": "path", "purpose": "Directory tests/path. Purpose not yet described by a human." }, { "digest": "51f14936b27d3d21379cf05ea1b6b532cf3175a40844dac85f023a61e7a0912c", - "last_commit": "5901baa51", + "last_commit": "d863780eb", "name": "physics0", "purpose": "PD-0 gates: world self-test, oracle calibration, learner L0/L1/NULL, mutations, OSC differential" }, { "digest": "c8524317c751fa8f464cabc31b760cef262abba822f1843482a02e239daa81b3", - "last_commit": "61c094113", + "last_commit": "d863780eb", "name": "polyglot", "purpose": "Directory tests/polyglot. Purpose not yet described by a human." }, { "digest": "6569e2cd6dbf6f792edb5d83bf0715df9dece42ca7bd9b3a291535de0492d3aa", - "last_commit": "3c82389f7", + "last_commit": "d863780eb", "name": "program", "purpose": "Directory tests/program. Purpose not yet described by a human." }, { "digest": "c549b5b82fd026d664b35e4b1a5d7fd2aaafa13b60b541cfbba87d7522517b1d", - "last_commit": "6fdc4c33a", + "last_commit": "d863780eb", "name": "r16_inventory", "purpose": "Directory tests/r16_inventory. Purpose not yet described by a human." }, { "digest": "855bd23e4c526fb49eeb430c4ea5967d3f2f9da3a5b3aa3ec9dae5b814b11a21", - "last_commit": "46b9cad0d", + "last_commit": "d863780eb", "name": "r16_negative", "purpose": "Directory tests/r16_negative. Purpose not yet described by a human." }, { "digest": "f21be04969cbf51de17118c4f81b103f712db56fd517a1f12dd0d3ac4ff3afe4", - "last_commit": "44d8c06c3", + "last_commit": "d863780eb", "name": "r16_surface", "purpose": "Directory tests/r16_surface. Purpose not yet described by a human." }, { "digest": "b0ba3448394d5f27958c38b7233ae389e5e437e327f0859749a774fb252d6b02", - "last_commit": "40d1ea378", + "last_commit": "d863780eb", "name": "realize", "purpose": "Directory tests/realize. Purpose not yet described by a human." }, { "digest": "157018d66de5bfd149015654cf0bda1346a9cfcefe5fd552c1d54859cd9ece81", - "last_commit": "30bb116cc", + "last_commit": "d863780eb", "name": "relations", "purpose": "Directory tests/relations. Purpose not yet described by a human." }, { "digest": "e5f68362c083510e34c41f65de3ba2d553eac8a52fbc3e4cc1f69314eac9cc32", - "last_commit": "dd67f6bd7", + "last_commit": "d863780eb", "name": "reservoir", "purpose": "Reservoir tests (omega#440): Gate 1 simulator and readout checks against an independent binary64" }, { "digest": "10d19641e4bb5b435ec6363d4ea7d3c1596af47d97b86f4de35d6ae57770241e", - "last_commit": "501d555cf", + "last_commit": "45f7d7691", "name": "runtime", "purpose": "Directory tests/runtime. Purpose not yet described by a human." }, { "digest": "467652c09505ecbd82d96a5e0e7ea24b19d9216cfd1dad7c60fa8258e47594c0", - "last_commit": "5ae192a43", + "last_commit": "d863780eb", "name": "searchtrace", "purpose": "Directory tests/searchtrace. Purpose not yet described by a human." }, { "digest": "e69616ad471704066a86bf2796776301179eada5c0aa36a7166b9aca788619f4", - "last_commit": "", + "last_commit": "ed8de5736", "name": "synapse", "purpose": "J1 parity driver for syn_codec.osc against the sealed Rust A1 corpus (aien-dev/synapse j1-codec-" }, { "digest": "5c97916fbf20310eff2e502c526337cb093e912cb48f18d44b0345ed8a3c3240", - "last_commit": "54826a37f", + "last_commit": "d863780eb", "name": "train", "purpose": "Directory tests/train. Purpose not yet described by a human." }, { "digest": "7679bd1c49c7e89d8c26ccf8dfb91478f4e6e2f584745806fa8d26061dbdbb9c", - "last_commit": "2564f57a9", + "last_commit": "d863780eb", "name": "turing", "purpose": "Directory tests/turing. Purpose not yet described by a human." }, { "digest": "930fcb9ce348c604424e5380796a77c3586a835b43d42b504325c36b12d166d7", - "last_commit": "fed4f0775", + "last_commit": "450bbefd4", "name": "visor", "purpose": "Directory tests/visor. Purpose not yet described by a human." } ], "children_root": "sha256:0c57282ff8cf1d34e5685e2729755f2978917e66debb5423961033be9d25c902", - "compiled_at": "2026-10-29T19:08:03Z", + "compiled_at": "2026-10-30T02:49:13Z", "compiler": "crumb-compile/1", - "digest": "sha256:ea8ae97d49edc85af090218634c9bad13bcc91fa84f96e0d33fefe313704e111", + "digest": "sha256:060352a843d719e700640477499fdc17ea661c3966abf9e059aedf8d90583e04", "evidence_files": 16, "evidence_root": "sha256:96d08097822ad95f4e562c19e0ba5df5a035774c48632f1832912c40a27bd27a", - "files": 1375, - "generated_at_commit": "8975287573f284dd2140b2f2b169619d3e145cf1", - "source_tree": "sha256:9548bc14096907b8a9ba4a0fd5092c442bf89f226c142a117753bb5ce59dc206" + "files": 1376, + "generated_at_commit": "2cb1ccb5d3c1a1ce1cb94a7a3dd3c221395c4e15", + "source_tree": "sha256:f37c9d192be40869a5ecb5658bf71a29e79db786899e4b94ecf241a49369974b" }, "owner_lane": "", "provenance": { diff --git a/tests/bw_warp_sim.h b/tests/bw_warp_sim.h index 41513c380..6d93828f3 100644 --- a/tests/bw_warp_sim.h +++ b/tests/bw_warp_sim.h @@ -44,6 +44,8 @@ * an exit jumped past it, or a target was corrupted) * WS_E_NEVER_JOINED the warp finished with a barrier still armed * WS_E_SELF_BRANCH, WS_E_PC, WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS + * WS_E_IMADHI_RC IMAD.HI.U32 with a register Rc: the chip reads Rc as a 64-bit pair (omega #492, + * nvcc oracle, chip probe pending), so a non-RZ Rc is refused, not modelled * Every error names the pc. Memory: global addresses are host pointers (optionally range * checked); shared memory is a per-CTA buffer poisoned at CTA start so a read of a word * nobody wrote shows up in the oracle comparison. @@ -71,12 +73,12 @@ enum { WS_OK = 0, WS_E_SHFL_SPLIT, WS_E_SHFL_EXITED, WS_E_BAR_SPLIT, WS_E_BSYNC_UNARMED, WS_E_BSSY_REARM, WS_E_JOIN_MISMATCH, WS_E_NONMEMBER, WS_E_STUCK, WS_E_NEVER_JOINED, WS_E_SELF_BRANCH, WS_E_PC, - WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS + WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS, WS_E_IMADHI_RC }; static const char *ws_err_name(int e) { static const char *const n[] = { "OK", "SHFL_SPLIT", "SHFL_EXITED", "BAR_SPLIT", "BSYNC_UNARMED", "BSSY_REARM", "JOIN_MISMATCH", "NONMEMBER", "STUCK", "NEVER_JOINED", "SELF_BRANCH", "PC", "OP", "SHIFT", "MEM", "SMEM", - "FRAGS", "BAR_TIMEOUT", "STEPS" }; + "FRAGS", "BAR_TIMEOUT", "STEPS", "IMADHI_RC" }; return (e >= 0 && e < (int)(sizeof n / sizeof n[0])) ? n[e] : "?"; } @@ -157,7 +159,9 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_MOV_RZ: ws_wrs(l, in->dst_vreg, in->dst_subreg, 0, p); break; case BW_IR_IMAD: ws_wrs(l, in->dst_vreg, in->dst_subreg, in->src2_vreg >= 0 ? a * b + c : a * in->imm + c, p); break; case BW_IR_IMAD_WIDE: ws_wr64(l, in->dst_vreg, (uint64_t)a * in->imm + ws_rd64(l, in->src3_vreg, p), p); break; - case BW_IR_IMAD_HI_U32: ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32) + c, p); break; + case BW_IR_IMAD_HI_U32: /* Rd = hi32(Ra * Rb) with Rc = RZ. The chip reads a register Rc as a 64-bit pair (omega #492): refused until a chip probe pins the model */ + if (in->src3_vreg >= 0) { ws_fail(s, WS_E_IMADHI_RC, pc, "IMAD.HI.U32 with a register Rc (the chip reads Rc as a 64-bit pair, not chip-probed): use RZ, or SHF.R + IADD3"); return; } + ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32), p); break; case BW_IR_IADD3: ws_wrs(l, in->dst_vreg, in->dst_subreg, a + b, p); break; /* the encoder's IADD3 has Rc = RZ */ case BW_IR_SHF_R: ws_wrs(l, in->dst_vreg, in->dst_subreg, a >> (in->imm & 31), p); break; case BW_IR_SHF_L_U32: if (b >= 32) { ws_fail(s, WS_E_SHIFT, pc, "SHF.L.U32 amount >= 32 (not chip-verified)"); return; } ws_wrs(l, in->dst_vreg, in->dst_subreg, a << b, p); break; diff --git a/tests/bw_warp_sim_k.h b/tests/bw_warp_sim_k.h index 9e39ed0bd..993875647 100644 --- a/tests/bw_warp_sim_k.h +++ b/tests/bw_warp_sim_k.h @@ -44,6 +44,8 @@ * an exit jumped past it, or a target was corrupted) * WS_E_NEVER_JOINED the warp finished with a barrier still armed * WS_E_SELF_BRANCH, WS_E_PC, WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS + * WS_E_IMADHI_RC IMAD.HI.U32 with a register Rc: the chip reads Rc as a 64-bit pair (omega #492, + * nvcc oracle, chip probe pending), so a non-RZ Rc is refused, not modelled * Every error names the pc. Memory: global addresses are host pointers (optionally range * checked); shared memory is a per-CTA buffer poisoned at CTA start so a read of a word * nobody wrote shows up in the oracle comparison. @@ -77,12 +79,12 @@ enum { WS_OK = 0, WS_E_SHFL_SPLIT, WS_E_SHFL_EXITED, WS_E_BAR_SPLIT, WS_E_BSYNC_UNARMED, WS_E_BSSY_REARM, WS_E_JOIN_MISMATCH, WS_E_NONMEMBER, WS_E_STUCK, WS_E_NEVER_JOINED, WS_E_SELF_BRANCH, WS_E_PC, - WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS + WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS, WS_E_IMADHI_RC }; static const char *ws_err_name(int e) { static const char *const n[] = { "OK", "SHFL_SPLIT", "SHFL_EXITED", "BAR_SPLIT", "BSYNC_UNARMED", "BSSY_REARM", "JOIN_MISMATCH", "NONMEMBER", "STUCK", "NEVER_JOINED", "SELF_BRANCH", "PC", "OP", "SHIFT", "MEM", "SMEM", - "FRAGS", "BAR_TIMEOUT", "STEPS" }; + "FRAGS", "BAR_TIMEOUT", "STEPS", "IMADHI_RC" }; return (e >= 0 && e < (int)(sizeof n / sizeof n[0])) ? n[e] : "?"; } @@ -164,7 +166,9 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_MOV_RZ: ws_wrs(l, in->dst_vreg, in->dst_subreg, 0, p); break; case BW_IR_IMAD: ws_wrs(l, in->dst_vreg, in->dst_subreg, in->src2_vreg >= 0 ? a * b + c : a * in->imm + c, p); break; case BW_IR_IMAD_WIDE: ws_wr64(l, in->dst_vreg, (uint64_t)a * in->imm + ws_rd64(l, in->src3_vreg, p), p); break; - case BW_IR_IMAD_HI_U32: ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32) + c, p); break; + case BW_IR_IMAD_HI_U32: /* Rd = hi32(Ra * Rb) with Rc = RZ. The chip reads a register Rc as a 64-bit pair (omega #492): refused until a chip probe pins the model */ + if (in->src3_vreg >= 0) { ws_fail(s, WS_E_IMADHI_RC, pc, "IMAD.HI.U32 with a register Rc (the chip reads Rc as a 64-bit pair, not chip-probed): use RZ, or SHF.R + IADD3"); return; } + ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32), p); break; case BW_IR_IADD3: ws_wrs(l, in->dst_vreg, in->dst_subreg, a + b, p); break; /* the encoder's IADD3 has Rc = RZ */ case BW_IR_SHF_R: ws_wrs(l, in->dst_vreg, in->dst_subreg, a >> (in->imm & 31), p); break; case BW_IR_SHF_L_U32: if (b >= 32) { ws_fail(s, WS_E_SHIFT, pc, "SHF.L.U32 amount >= 32 (not chip-verified)"); return; } ws_wrs(l, in->dst_vreg, in->dst_subreg, a << b, p); break; diff --git a/tests/bw_warp_sim_pa.h b/tests/bw_warp_sim_pa.h index 198c12f05..157e396cd 100644 --- a/tests/bw_warp_sim_pa.h +++ b/tests/bw_warp_sim_pa.h @@ -44,6 +44,8 @@ * an exit jumped past it, or a target was corrupted) * WS_E_NEVER_JOINED the warp finished with a barrier still armed * WS_E_SELF_BRANCH, WS_E_PC, WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS + * WS_E_IMADHI_RC IMAD.HI.U32 with a register Rc: the chip reads Rc as a 64-bit pair (omega #492, + * nvcc oracle, chip probe pending), so a non-RZ Rc is refused, not modelled * Every error names the pc. Memory: global addresses are host pointers (optionally range * checked); shared memory is a per-CTA buffer poisoned at CTA start so a read of a word * nobody wrote shows up in the oracle comparison. @@ -85,12 +87,12 @@ enum { WS_OK = 0, WS_E_SHFL_SPLIT, WS_E_SHFL_EXITED, WS_E_BAR_SPLIT, WS_E_BSYNC_UNARMED, WS_E_BSSY_REARM, WS_E_JOIN_MISMATCH, WS_E_NONMEMBER, WS_E_STUCK, WS_E_NEVER_JOINED, WS_E_SELF_BRANCH, WS_E_PC, - WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS + WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS, WS_E_IMADHI_RC }; static const char *ws_err_name(int e) { static const char *const n[] = { "OK", "SHFL_SPLIT", "SHFL_EXITED", "BAR_SPLIT", "BSYNC_UNARMED", "BSSY_REARM", "JOIN_MISMATCH", "NONMEMBER", "STUCK", "NEVER_JOINED", "SELF_BRANCH", "PC", "OP", "SHIFT", "MEM", "SMEM", - "FRAGS", "BAR_TIMEOUT", "STEPS" }; + "FRAGS", "BAR_TIMEOUT", "STEPS", "IMADHI_RC" }; return (e >= 0 && e < (int)(sizeof n / sizeof n[0])) ? n[e] : "?"; } @@ -173,7 +175,9 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_MOV_RZ: ws_wrs(l, in->dst_vreg, in->dst_subreg, 0, p); break; case BW_IR_IMAD: ws_wrs(l, in->dst_vreg, in->dst_subreg, in->src2_vreg >= 0 ? a * b + c : a * in->imm + c, p); break; case BW_IR_IMAD_WIDE: ws_wr64(l, in->dst_vreg, (uint64_t)a * in->imm + ws_rd64(l, in->src3_vreg, p), p); break; - case BW_IR_IMAD_HI_U32: ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32) + c, p); break; + case BW_IR_IMAD_HI_U32: /* Rd = hi32(Ra * Rb) with Rc = RZ. The chip reads a register Rc as a 64-bit pair (omega #492): refused until a chip probe pins the model */ + if (in->src3_vreg >= 0) { ws_fail(s, WS_E_IMADHI_RC, pc, "IMAD.HI.U32 with a register Rc (the chip reads Rc as a 64-bit pair, not chip-probed): use RZ, or SHF.R + IADD3"); return; } + ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32), p); break; case BW_IR_IADD3: ws_wrs(l, in->dst_vreg, in->dst_subreg, a + b, p); break; /* the encoder's IADD3 has Rc = RZ */ case BW_IR_SHF_R: ws_wrs(l, in->dst_vreg, in->dst_subreg, a >> (in->imm & 31), p); break; case BW_IR_SHF_L_U32: if (b >= 32) { ws_fail(s, WS_E_SHIFT, pc, "SHF.L.U32 amount >= 32 (not chip-verified)"); return; } ws_wrs(l, in->dst_vreg, in->dst_subreg, a << b, p); break; diff --git a/tests/bw_warp_sim_tc.h b/tests/bw_warp_sim_tc.h index bf662ea6b..a08e38b6a 100644 --- a/tests/bw_warp_sim_tc.h +++ b/tests/bw_warp_sim_tc.h @@ -44,6 +44,8 @@ * an exit jumped past it, or a target was corrupted) * WS_E_NEVER_JOINED the warp finished with a barrier still armed * WS_E_SELF_BRANCH, WS_E_PC, WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS + * WS_E_IMADHI_RC IMAD.HI.U32 with a register Rc: the chip reads Rc as a 64-bit pair (omega #492, + * nvcc oracle, chip probe pending), so a non-RZ Rc is refused, not modelled * Every error names the pc. Memory: global addresses are host pointers (optionally range * checked); shared memory is a per-CTA buffer poisoned at CTA start so a read of a word * nobody wrote shows up in the oracle comparison. @@ -86,12 +88,12 @@ static QmmaModel ws_qmma_model = { 32, 26, 0, 2, 0 }; /* chip-exact 262144/26214 enum { WS_OK = 0, WS_E_SHFL_SPLIT, WS_E_SHFL_EXITED, WS_E_BAR_SPLIT, WS_E_BSYNC_UNARMED, WS_E_BSSY_REARM, WS_E_JOIN_MISMATCH, WS_E_NONMEMBER, WS_E_STUCK, WS_E_NEVER_JOINED, WS_E_SELF_BRANCH, WS_E_PC, - WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS + WS_E_OP, WS_E_SHIFT, WS_E_MEM, WS_E_SMEM, WS_E_FRAGS, WS_E_BAR_TIMEOUT, WS_E_STEPS, WS_E_IMADHI_RC }; static const char *ws_err_name(int e) { static const char *const n[] = { "OK", "SHFL_SPLIT", "SHFL_EXITED", "BAR_SPLIT", "BSYNC_UNARMED", "BSSY_REARM", "JOIN_MISMATCH", "NONMEMBER", "STUCK", "NEVER_JOINED", "SELF_BRANCH", "PC", "OP", "SHIFT", "MEM", "SMEM", - "FRAGS", "BAR_TIMEOUT", "STEPS" }; + "FRAGS", "BAR_TIMEOUT", "STEPS", "IMADHI_RC" }; return (e >= 0 && e < (int)(sizeof n / sizeof n[0])) ? n[e] : "?"; } @@ -182,7 +184,9 @@ static void ws_lane_exec(WsSim *s, WsLane *l, const BlackwellIRInsn *in, int pc, case BW_IR_MOV_RZ: ws_wrs(l, in->dst_vreg, in->dst_subreg, 0, p); break; case BW_IR_IMAD: ws_wrs(l, in->dst_vreg, in->dst_subreg, in->src2_vreg >= 0 ? a * b + c : a * in->imm + c, p); break; case BW_IR_IMAD_WIDE: ws_wr64(l, in->dst_vreg, (uint64_t)a * in->imm + ws_rd64(l, in->src3_vreg, p), p); break; - case BW_IR_IMAD_HI_U32: ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32) + c, p); break; + case BW_IR_IMAD_HI_U32: /* Rd = hi32(Ra * Rb) with Rc = RZ. The chip reads a register Rc as a 64-bit pair (omega #492): refused until a chip probe pins the model */ + if (in->src3_vreg >= 0) { ws_fail(s, WS_E_IMADHI_RC, pc, "IMAD.HI.U32 with a register Rc (the chip reads Rc as a 64-bit pair, not chip-probed): use RZ, or SHF.R + IADD3"); return; } + ws_wrs(l, in->dst_vreg, in->dst_subreg, (uint32_t)(((uint64_t)a * b) >> 32), p); break; case BW_IR_IADD3: ws_wrs(l, in->dst_vreg, in->dst_subreg, a + b, p); break; /* the encoder's IADD3 has Rc = RZ */ case BW_IR_SHF_R: ws_wrs(l, in->dst_vreg, in->dst_subreg, a >> (in->imm & 31), p); break; case BW_IR_SHF_L_U32: if (b >= 32) { ws_fail(s, WS_E_SHIFT, pc, "SHF.L.U32 amount >= 32 (not chip-verified)"); return; } ws_wrs(l, in->dst_vreg, in->dst_subreg, a << b, p); break; diff --git a/tests/gpu_imadhi_rc_test.c b/tests/gpu_imadhi_rc_test.c new file mode 100644 index 000000000..179596a27 --- /dev/null +++ b/tests/gpu_imadhi_rc_test.c @@ -0,0 +1,106 @@ +/* omega #492: IMAD.HI.U32 with a register Rc through one host warp simulator (host-only, no chip). + * + * The chip reads the Rc of IMAD.HI.U32 as a 64-bit register pair, not as one 32-bit word. + * Receipt (manufacturer's compiler, not a chip run): nvcc 13.0 for sm_121 emits, for + * hi32(a * b + c64) IMAD.HI.U32 R7, R7, R6, R2 with R2:R3 = c64 (no separate add), + * hi32(a * b + (u64)c32) UMOV UR5, URZ ; IMAD.HI.U32 R5, R7, R6, UR4 (upper half zeroed first), + * __umulhi(a, b) + c32 Rc pair = {lo 0, hi c32}, so the add lands in the high word. + * Listing and source: evidence/IMADHI-RC-ORACLE-nvcc13.0-20261016/. The first version of the + * trainer GEMM (PR #487) used IMAD.HI.U32 with a register Rc, passed the simulators (32-bit Rc) + * and gave wrong odd columns on the chip. A chip probe of the exact pair semantics is still + * pending (lane E3), so the simulators refuse a non-RZ Rc instead of modelling it. + * + * This file is compiled once per simulator header: -DSIM_HEADER='"bw_warp_sim_k.h"' and so on + * (Makefile target test-gpu-imadhi-rc). The four headers share their static names, so one + * translation unit holds one simulator. + * + * Checks (each runs the one-instruction kernel on one warp and stores Rd): + * 1. Rc = RZ: the simulator runs and Rd = hi32(Ra * Rb) (control, the one live user today) + * 2. Rc = register: the encoder emits a non-RZ Rc (the chip would read a pair) and the + * simulator refuses with WS_E_IMADHI_RC naming the pc. Before the fix it returned + * hi32(Ra * Rb) + Rc.lo, the 32-bit model the chip does not implement. + */ +#include +#include +#include +#include +#include "omega_blackwell_codegen.h" +#ifndef SIM_HEADER +#error "compile with -DSIM_HEADER='\"bw_warp_sim.h\"' (or _tc, _k, _pa)" +#endif +#include SIM_HEADER + +enum { V_OUT = 0, V_A, V_B, V_C, V_D, NV }; +enum { CB_OUT = 0x380 }; + +static void ins(BlackwellIRProgram *p, BlackwellIROpcode op, int d, int a, int b, int c, uint32_t imm, uint8_t dsub) { + BlackwellIRInsn *i = &p->insns[p->count++]; + memset(i, 0, sizeof *i); + i->op = op; i->dst_vreg = d; i->src1_vreg = a; i->src2_vreg = b; i->src3_vreg = c; i->ureg = -1; i->imm = imm; i->dst_subreg = dsub; +} + +/* out[tid] = IMAD.HI.U32(a, b, rc ? {chi:clo} : RZ) */ +static void build(BlackwellIRProgram *p, uint32_t a, uint32_t b, uint32_t clo, uint32_t chi, int rc) { + memset(p, 0, sizeof *p); + ins(p, BW_IR_LDC64, V_OUT, -1, -1, -1, CB_OUT, 0); + ins(p, BW_IR_MOV_IMM, V_A, -1, -1, -1, a, 0); + ins(p, BW_IR_MOV_IMM, V_B, -1, -1, -1, b, 0); + ins(p, BW_IR_MOV_IMM, V_C, -1, -1, -1, clo, 0); + ins(p, BW_IR_MOV_IMM, V_C, -1, -1, -1, chi, 1); + ins(p, BW_IR_IMAD_HI_U32, V_D, V_A, V_B, rc ? V_C : -1, 0, 0); + ins(p, BW_IR_STG_E, -1, V_OUT, V_D, -1, 0, 0); + ins(p, BW_IR_EXIT, -1, -1, -1, -1, 0, 0); + /* physical registers: out pair R2:R3, a R4, b R5, c pair R6:R7 (even-aligned), d R8 */ + static const int phys[NV] = { 2, 4, 5, 6, 8 }; + p->regalloc.num_vregs = NV; + for (int v = 0; v < NV; v++) p->regalloc.vreg_to_phys[v] = phys[v]; +} + +static int run(const BlackwellIRProgram *p, uint32_t *out, char *msg, size_t msglen) { + WsSim s; memset(&s, 0, sizeof s); + static uint8_t smem[1024]; + s.p = p; s.threads = 32; s.smem = smem; s.smem_bytes = sizeof smem; + uint64_t oa = (uintptr_t)out; + s.cbank[CB_OUT / 4] = (uint32_t)oa; s.cbank[CB_OUT / 4 + 1] = (uint32_t)(oa >> 32); + s.ranges[0] = (WsRange){ (uintptr_t)oa, (uintptr_t)oa + 4 }; s.nranges = 1; + int err = ws_run(&s, 1, 1); + snprintf(msg, msglen, "%s", s.msg); + return err ? s.err : 0; +} + +int main(void) { + const uint32_t A = 0xdeadbeefu, B = 0x10000u, CLO = 0x1234u, CHI = 0x5678u; /* B = 2^16 is the tgemm pack */ + const uint32_t hi_ab = (uint32_t)(((uint64_t)A * B) >> 32); + const uint32_t pair_model = (uint32_t)((((uint64_t)A * B) + (((uint64_t)CHI << 32) | CLO)) >> 32); + int fails = 0; char msg[200]; uint32_t out; + BlackwellIRProgram *p = calloc(1, sizeof *p); + printf("sim %s: hi32(a*b) 0x%08x, nvcc pair model 0x%08x (chip probe pending), old 32-bit model 0x%08x\n", + SIM_HEADER, hi_ab, pair_model, hi_ab + CLO); + + /* 1. Rc = RZ: runs, Rd = hi32(a * b) */ + build(p, A, B, CLO, CHI, 0); out = 0xffbadbadu; + int err = run(p, &out, msg, sizeof msg); + if (err || out != hi_ab) { fails++; printf("FAIL rc=RZ: err %d (%s) out 0x%08x want 0x%08x\n", err, msg, out, hi_ab); } + else printf("PASS rc=RZ: Rd = hi32(a*b) = 0x%08x\n", out); + + /* 2. Rc = register pair: the word carries a non-RZ Rc, the simulator must refuse */ + build(p, A, B, CLO, CHI, 1); + BlackwellIRInsn e = p->insns[5]; e.dst_vreg = 8; e.src1_vreg = 4; e.src2_vreg = 5; e.src3_vreg = 6; /* physical numbers for the encoder */ + uint32_t w[4] = { 0, 0, 0, 0 }; + if (omega_blackwell_encode_one(&e, w) != 0 || (w[0] & 0xffffu) != 0x7227u || (w[2] & 0xffu) != 6u) { + fails++; printf("FAIL encode: IMAD.HI.U32 R8, R4, R5, R6 -> %08x %08x %08x %08x (want opcode 7227, Rc byte 06)\n", w[0], w[1], w[2], w[3]); + } else printf("PASS encode: IMAD.HI.U32 R8, R4, R5, R6 carries Rc = R6 (the chip reads R6:R7)\n"); + out = 0xffbadbadu; + err = run(p, &out, msg, sizeof msg); + if (err != WS_E_IMADHI_RC) { + fails++; + printf("FAIL rc=R6: simulator did not refuse (err %d%s%s), out 0x%08x: a 32-bit Rc model the chip does not implement\n", + err, err ? " " : "", err ? msg : "", out); + } else if (!strstr(msg, "IMAD.HI.U32") || !strstr(msg, "at pc 5")) { + fails++; printf("FAIL rc=R6: refused but the message does not name the instruction and pc: %s\n", msg); + } else printf("PASS rc=R6: refused: %s\n", msg); + + free(p); + printf("%s %s\n", fails ? "FAIL" : "PASS", SIM_HEADER); + return fails ? 1 : 0; +}