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 / arest.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/arest.om: the shared part of the arest-* checks, the launch(), cache() and steps() blocks of |
| 3 | note CUDApp tests/api_rest_diff.c. Each apirest unit carries om2 and is a program's head alone, so each has its own |
| 4 | note check: the unit's parts (gpu/units.tsv), lib.om, lib-om2.om, its arest-UNIT.om (text t_name, text t_au, fn |
| 5 | note arop) and then this part. Rows: |
| 6 | note UNIT NY Q E R |
| 7 | note Q is the call's input words (16 hex digits each, - for none), which arop gives the unit in its own layout; NY |
| 8 | note is the length of the unit's output view. E lists (index, value) word pairs, 16 hex digits each, that the |
| 9 | note outputs must hold: index i below 64 is output word i, index 64 + j is word j of an edited q after the call. R |
| 10 | note is the unit's answer, one word of 16 hex digits; it is last so that the gate's table control changes a word. |
| 11 | note The rows hold at most 64 input words and 64 output words, the largest of the calls. |
| 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 | note word j of field i, a run of 16 hex digits |
| 18 | fn arw i ulong j ulong to ulong |
| 19 | w = ulong 0 |
| 20 | for k ulong 8 |
| 21 | w = or shl w 8 ckhex i add mul j 8 k |
| 22 | end |
| 23 | ret w |
| 24 | end |
| 25 | fn crow to bool |
| 26 | if or ne ckcnt 5 not ckis 0 t_au |
| 27 | ckbad |
| 28 | end |
| 29 | ny = cknum 1 |
| 30 | nb = ckhexn 2 |
| 31 | eb = ckhexn 3 |
| 32 | if or or gt ny 64 gt nb 512 or ne rem nb 8 0 ne rem eb 16 0 |
| 33 | ckbad |
| 34 | end |
| 35 | if ne ckhexn 4 8 |
| 36 | ckbad |
| 37 | end |
| 38 | nq = div nb 8 |
| 39 | q = new ulong 64 0 |
| 40 | for j ulong nq bound 64 |
| 41 | put q j arw 2 j |
| 42 | end |
| 43 | o = new ulong 128 0 |
| 44 | r = arop q nq ny o |
| 45 | if ne r arw 4 0 |
| 46 | ret false |
| 47 | end |
| 48 | for j ulong div eb 16 bound 1099511627776 |
| 49 | k = arw 3 mul j 2 |
| 50 | if ge k 128 |
| 51 | ckbad |
| 52 | end |
| 53 | if ne get o k arw 3 add mul j 2 1 |
| 54 | ret false |
| 55 | end |
| 56 | end |
| 57 | ret true |
| 58 | end |