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
omega-mv / gpu / nvidia / checks / bwctl.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/bwctl.om: the Omega port of CUDApp tests/bw_encode_control_test.c. Composed after |
| 3 | note gpu/nvidia/om/encoder/bw_enc_sm121.om (bw_enc_sm121) and gpu/nvidia/checks/lib.om; run with |
| 4 | note gpu/nvidia/checks/bwctl.tsv. Row, lowercase hex: e OP FORM CONTROL ACCEPTED W0 W1 W2 W3. |
| 5 | note The check encodes the old test's instruction: op OP, dst 4, src1 6, src2 8, src3 10, ureg 4, imm 2, |
| 6 | note predicate @P0 when FORM bit 0 is set, uniform when FORM bit 1 is set, control CONTROL, with every virtual |
| 7 | note register on the physical register of its own number (omega_blackwell_encode_one). The encoder must accept |
| 8 | note it exactly when ACCEPTED is 1 and give the four words W0..W3 of the C encoder; and, the old test's own |
| 9 | note property, an accepted word 3 carries CONTROL's stall, yield, scoreboard and wait bits (0x03fffe00). |
| 10 | text t_name "BWCTL" |
| 11 | const CTLF ulong 67108352 |
| 12 | fn cname to void |
| 13 | for i ulong len t_name bound 64 |
| 14 | ckoc ulong get t_name i |
| 15 | end |
| 16 | end |
| 17 | fn bwx i ulong to ulong |
| 18 | n = cklen i |
| 19 | if or eq n 0 gt n 16 |
| 20 | ckbad |
| 21 | end |
| 22 | v = ulong 0 |
| 23 | for j ulong n bound 16 |
| 24 | v = or shl v 4 cknib ckch i j |
| 25 | end |
| 26 | ret v |
| 27 | end |
| 28 | fn bww code view uchar 16384 k ulong to ulong |
| 29 | v = ulong 0 |
| 30 | for j ulong 4 |
| 31 | v = or v shl ulong get code add mul k 4 j mul j 8 |
| 32 | end |
| 33 | ret v |
| 34 | end |
| 35 | fn crow to bool |
| 36 | if or ne ckcnt 9 ne cklen 0 1 |
| 37 | ckbad |
| 38 | end |
| 39 | if ne ckch 0 0 101 |
| 40 | ckbad |
| 41 | end |
| 42 | form = bwx 2 |
| 43 | cw = bwx 3 |
| 44 | acc = bwx 4 |
| 45 | if or gt form 3 gt acc 1 |
| 46 | ckbad |
| 47 | end |
| 48 | ins = new ulong 8192 0 |
| 49 | phys = new ulong 288 0 |
| 50 | code = new uchar 16384 0 |
| 51 | for i ulong 256 |
| 52 | put phys i i |
| 53 | end |
| 54 | for i ulong 32 |
| 55 | put phys add 256 i i |
| 56 | end |
| 57 | put ins 0 bwx 1 |
| 58 | put ins 1 4 |
| 59 | put ins 2 6 |
| 60 | put ins 3 8 |
| 61 | put ins 4 10 |
| 62 | put ins 5 4 |
| 63 | put ins 6 or 2 shl cw 32 |
| 64 | put ins 7 or shr form 1 shl and form 1 1 |
| 65 | got = bw_enc_sm121 view ins view phys 1 0 edit code |
| 66 | if eq acc 0 |
| 67 | ret ne got 16 |
| 68 | end |
| 69 | if ne got 16 |
| 70 | ret false |
| 71 | end |
| 72 | ok = true |
| 73 | for k ulong 4 |
| 74 | if ne bww view code k bwx add k 5 |
| 75 | ok = false |
| 76 | end |
| 77 | end |
| 78 | if ne and bww view code 3 CTLF and cw CTLF |
| 79 | ok = false |
| 80 | end |
| 81 | ret ok |
| 82 | end |