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 / attnscan.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/attnscan.om: the scan block of CUDApp tests/attn_host_diff.c (its other blocks are |
| 3 | note gpu/nvidia/checks/attnhost.om; both units start with om2, so they cannot share one program). Composed |
| 4 | note after gpu/nvidia/om/scan/scan_check.om (sc_check) and gpu/nvidia/checks/lib.om; run with |
| 5 | note gpu/nvidia/checks/attnscan.tsv. Row, lowercase hex: s N CASE OP R: sc_check OP over the arrays the old |
| 6 | note test builds for CASE, N elements, answers R. CASE 0 x[i] = 17 when i rem 3 is 0, else 4294967295, w the |
| 7 | note running uint sums of x; 1 case 0 with bit 0 of w[N-1] flipped; 2 w[i] = i; 3 case 2 with w[0] = 1 and |
| 8 | note w[N-1] = 0; 4 every w[i] = 2141195181 (0x7fa00bad); 5 case 4 with w[N-1] = 2141195180; 6 case 4 with |
| 9 | note w[N-1] = 2141195182. Cases 2..6 pass w and a copy of w, as the old test passes w twice. The arrays are built here, |
| 10 | note not stored in the table. They are local arrays of 1000001 elements, the old test's largest N: a view is |
| 11 | note cut (part) only from a local array of constant size (a global is never an argument, error 19), and the |
| 12 | note local arrays of one function are at most 4 MiB (error 23), so x lives in a helper. A row with a larger N |
| 13 | note is refused as malformed (exit 2), never cut short. |
| 14 | text t_name "ATTNSCAN" |
| 15 | fn cname to void |
| 16 | for i ulong len t_name bound 64 |
| 17 | ckoc ulong get t_name i |
| 18 | end |
| 19 | end |
| 20 | fn asx i ulong to ulong |
| 21 | n = cklen i |
| 22 | if or eq n 0 gt n 16 |
| 23 | ckbad |
| 24 | end |
| 25 | v = ulong 0 |
| 26 | for j ulong n bound 16 |
| 27 | v = or shl v 4 cknib ckch i j |
| 28 | end |
| 29 | ret v |
| 30 | end |
| 31 | note cases 0 and 1: x lives in this frame, w in the caller's (4 MiB of local arrays per function) |
| 32 | fn sums w edit uint * cs ulong op ulong to ulong |
| 33 | sx = new uint 1000001 0 |
| 34 | n = len w |
| 35 | sum = uint 0 |
| 36 | for i ulong n bound 1000001 |
| 37 | v = uint 4294967295 |
| 38 | if eq rem i 3 0 |
| 39 | v = uint 17 |
| 40 | end |
| 41 | put sx i v |
| 42 | sum = add sum v |
| 43 | put w i sum |
| 44 | end |
| 45 | if and eq cs 1 gt n 0 |
| 46 | put w sub n 1 xor get w sub n 1 uint 1 |
| 47 | end |
| 48 | ret sc_check w part sx 0 n uint op |
| 49 | end |
| 50 | note cases 2..6: the old test passes w as both arrays; one array is never passed twice in a call (error 19), |
| 51 | note so x is a copy of w in this frame |
| 52 | fn twin w view uint * op ulong to ulong |
| 53 | sx = new uint 1000001 0 |
| 54 | n = len w |
| 55 | for i ulong n bound 1000001 |
| 56 | put sx i get w i |
| 57 | end |
| 58 | ret sc_check w part sx 0 n uint op |
| 59 | end |
| 60 | fn crow to bool |
| 61 | if or ne ckcnt 5 ne cklen 0 1 |
| 62 | ckbad |
| 63 | end |
| 64 | if ne ckch 0 0 115 |
| 65 | ckbad |
| 66 | end |
| 67 | sw = new uint 1000001 0 |
| 68 | n = asx 1 |
| 69 | cs = asx 2 |
| 70 | op = asx 3 |
| 71 | if or gt n len sw gt cs 6 |
| 72 | ckbad |
| 73 | end |
| 74 | if lt cs 2 |
| 75 | ret eq sums part sw 0 n cs op asx 4 |
| 76 | end |
| 77 | if lt cs 4 |
| 78 | for i ulong n bound 1000001 |
| 79 | put sw i uint i |
| 80 | end |
| 81 | if and eq cs 3 gt n 1 |
| 82 | put sw 0 uint 1 |
| 83 | put sw sub n 1 uint 0 |
| 84 | end |
| 85 | ret eq twin part sw 0 n op asx 4 |
| 86 | end |
| 87 | for i ulong n bound 1000001 |
| 88 | put sw i uint 2141195181 |
| 89 | end |
| 90 | if and eq cs 5 gt n 0 |
| 91 | put sw sub n 1 uint 2141195180 |
| 92 | end |
| 93 | if and eq cs 6 gt n 0 |
| 94 | put sw sub n 1 uint 2141195182 |
| 95 | end |
| 96 | ret eq twin part sw 0 n op asx 4 |
| 97 | end |