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 / bwhz.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/bwhz.om: the scoreboard hazard checker of gpu/nvidia/om/codegen/bw_hazard.om and |
| 3 | note bw_hazard_dec.om against the C it succeeds, src/omega_bw_hazard.c at 60b5d81e (DRA-606: a scoreboard barrier |
| 4 | note field holding 6 is refused, either field; src_pc is the smallest producer pc, whatever the visit order). |
| 5 | note Composed after bw_hazard.om, bw_hazard_dec.om and gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/bwhz.tsv. |
| 6 | note Rows, lowercase hex: |
| 7 | note d WORDS RC WBAR RBAR WAIT: hz_dec of the 16 bytes WORDS refuses (-1) exactly when RC is 1, and otherwise |
| 8 | note gives the write barrier, read barrier and wait mask of the C decode (record words 4, 5, 6). The oracle writes |
| 9 | note 0 0 0 for a refused row, and a refused row passes only with those zeros, so every byte of every row is read |
| 10 | note (the gate's table control changes the last byte of the first row, a refused one). |
| 11 | note j DT SV ST TAG: hz_jtag, the join's pc tag. l R RT PC TAG: hz_ltag, a late reader's. w V T TAG: hz_wtag, the |
| 12 | note tag of an entry after a wait. TAG is the C's expression on its own pmin (bwhz_oracle.c, README.md Oracles). |
| 13 | note The whole check, hz_chk, takes a 3203584-word wire: more than a program may hold in local arrays, and a global |
| 14 | note is never an argument, so it is not run here; README.md (bwhz) says how it was compared with the C. |
| 15 | text t_name "BWHZ" |
| 16 | fn cname to void |
| 17 | for i ulong len t_name bound 64 |
| 18 | ckoc ulong get t_name i |
| 19 | end |
| 20 | end |
| 21 | fn bzx i ulong to ulong |
| 22 | n = cklen i |
| 23 | if or eq n 0 gt n 16 |
| 24 | ckbad |
| 25 | end |
| 26 | v = ulong 0 |
| 27 | for j ulong n bound 16 |
| 28 | v = or shl v 4 cknib ckch i j |
| 29 | end |
| 30 | ret v |
| 31 | end |
| 32 | fn crow to bool |
| 33 | if ne cklen 0 1 |
| 34 | ckbad |
| 35 | end |
| 36 | k = ckch 0 0 |
| 37 | if eq k 106 |
| 38 | ret crowj |
| 39 | end |
| 40 | if eq k 108 |
| 41 | ret crowl |
| 42 | end |
| 43 | if eq k 119 |
| 44 | ret crowt |
| 45 | end |
| 46 | if ne k 100 |
| 47 | ckbad |
| 48 | end |
| 49 | ret crowd |
| 50 | end |
| 51 | fn crowd to bool |
| 52 | if ne ckcnt 6 |
| 53 | ckbad |
| 54 | end |
| 55 | if ne ckhexn 1 16 |
| 56 | ckbad |
| 57 | end |
| 58 | b = new uchar 16 0 |
| 59 | d = new ulong 24 0 |
| 60 | for j ulong 16 |
| 61 | put b j uchar ckhex 1 j |
| 62 | end |
| 63 | rc = hz_dec b d |
| 64 | rr = bzx 2 |
| 65 | if gt rr 1 |
| 66 | ckbad |
| 67 | end |
| 68 | if eq rr 1 |
| 69 | ok = eq rc long -1 |
| 70 | ok = and ok eq bzx 3 0 |
| 71 | ok = and ok eq bzx 4 0 |
| 72 | ret and ok eq bzx 5 0 |
| 73 | end |
| 74 | if ne rc 0 |
| 75 | ret false |
| 76 | end |
| 77 | ok = eq get d 4 bzx 3 |
| 78 | ok = and ok eq get d 5 bzx 4 |
| 79 | ret and ok eq get d 6 bzx 5 |
| 80 | end |
| 81 | fn crowj to bool |
| 82 | if ne ckcnt 5 |
| 83 | ckbad |
| 84 | end |
| 85 | t = hz_jtag bzx 1 bzx 2 bzx 3 |
| 86 | ret eq t bzx 4 |
| 87 | end |
| 88 | fn crowl to bool |
| 89 | if ne ckcnt 5 |
| 90 | ckbad |
| 91 | end |
| 92 | t = hz_ltag bzx 1 bzx 2 bzx 3 |
| 93 | ret eq t bzx 4 |
| 94 | end |
| 95 | fn crowt to bool |
| 96 | if ne ckcnt 4 |
| 97 | ckbad |
| 98 | end |
| 99 | t = hz_wtag bzx 1 bzx 2 |
| 100 | ret eq t bzx 3 |
| 101 | end |