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 / arestg.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/arestg.om: the shared part of the arest checks that hold several units of one head (data, |
| 3 | note pack, tile, tern, bf16, pkh) or a unit of the packing(), prefill() and partition blocks of CUDApp |
| 4 | note tests/api_rest_diff.c and tests/api_rest_partitions.h. A check is the units' parts (gpu/units.tsv), lib.om, |
| 5 | note lib-om2.om, its arest-CHECK.om (text t_name, fn arop) and then this part. Rows: |
| 6 | note UNIT NY Q E R |
| 7 | note UNIT names the call; arop reads it (ckis 0) and gives the unit the Q words in its own layout. Q is at most 256 |
| 8 | note words of 16 hex digits (- for none); NY is the length of the unit's output view where the row sets it. E lists |
| 9 | note (index, value) word pairs: index i below 128 is output word i, index 128 + p is input word p of Q after the |
| 10 | note call (the views a unit edits). R is the unit's answer, one word, last so that the gate's table control changes |
| 11 | note a word. Where the old test fills a large array by a loop, Q holds the loop's parameters, arop ports the loop and |
| 12 | note output word 0 is the digest of the unit's output (ardg), which the table holds for the old test's expectation. |
| 13 | fn cname to void |
| 14 | for i ulong len t_name bound 64 |
| 15 | ckoc ulong get t_name i |
| 16 | end |
| 17 | end |
| 18 | note word j of field i, a run of 16 hex digits |
| 19 | fn arw i ulong j ulong to ulong |
| 20 | w = ulong 0 |
| 21 | for k ulong 8 |
| 22 | w = or shl w 8 ckhex i add mul j 8 k |
| 23 | end |
| 24 | ret w |
| 25 | end |
| 26 | note the digest: FNV-1a over whole elements, from ardg0 |
| 27 | fn ardg0 to ulong |
| 28 | ret 14695981039346656037 |
| 29 | end |
| 30 | fn ardg h ulong v ulong to ulong |
| 31 | ret mul xor h v 1099511628211 |
| 32 | end |
| 33 | fn crow to bool |
| 34 | if ne ckcnt 5 |
| 35 | ckbad |
| 36 | end |
| 37 | ny = cknum 1 |
| 38 | nb = ckhexn 2 |
| 39 | eb = ckhexn 3 |
| 40 | if or gt nb 2048 ne rem nb 8 0 |
| 41 | ckbad |
| 42 | end |
| 43 | if ne rem eb 16 0 |
| 44 | ckbad |
| 45 | end |
| 46 | if ne ckhexn 4 8 |
| 47 | ckbad |
| 48 | end |
| 49 | nq = div nb 8 |
| 50 | q = new ulong 256 0 |
| 51 | for j ulong nq bound 256 |
| 52 | put q j arw 2 j |
| 53 | end |
| 54 | o = new ulong 256 0 |
| 55 | r = arop q nq ny o |
| 56 | if ne r arw 4 0 |
| 57 | ret false |
| 58 | end |
| 59 | for j ulong div eb 16 bound 1099511627776 |
| 60 | k = arw 3 mul j 2 |
| 61 | if ge k 256 |
| 62 | ckbad |
| 63 | end |
| 64 | if ne get o k arw 3 add mul j 2 1 |
| 65 | ret false |
| 66 | end |
| 67 | end |
| 68 | ret true |
| 69 | end |