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 / numhost.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/numhost.om: the Omega port of CUDApp tests/ampere_numeric_host_test.c. Composed after |
| 3 | note the numeric_reduce unit (gpu/nvidia/om/numeric/numeric.om, tile.om, rest.om, reduce.om) and |
| 4 | note gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/numhost.tsv. Numbers are lowercase hex FP32 bits. |
| 5 | note o OM A B C OUT numeric_ref OM A B C must be OUT (OM: the dispatcher's op code, decimal) |
| 6 | note r OP N X1 .. XN OUT (OP and N decimal) numeric_reduce OP over the N values (one padded stage, N at most 32) must be OUT |
| 7 | text t_name "NUMHOST" |
| 8 | fn cname to void |
| 9 | for i ulong len t_name bound 64 |
| 10 | ckoc ulong get t_name i |
| 11 | end |
| 12 | end |
| 13 | fn nhx i ulong to ulong |
| 14 | n = cklen i |
| 15 | if or eq n 0 gt n 8 |
| 16 | ckbad |
| 17 | end |
| 18 | v = ulong 0 |
| 19 | for j ulong n bound 8 |
| 20 | v = or shl v 4 cknib ckch i j |
| 21 | end |
| 22 | ret v |
| 23 | end |
| 24 | fn nhred op ulong n ulong to bool |
| 25 | t = new ulong 32 0 |
| 26 | for i ulong n bound 32 |
| 27 | put t i nhx add 3 i |
| 28 | end |
| 29 | r = numeric_reduce op n view t 0 0 |
| 30 | ret eq r nhx add 3 n |
| 31 | end |
| 32 | fn crow to bool |
| 33 | k = ckch 0 0 |
| 34 | nc = ckcnt |
| 35 | if eq k 111 |
| 36 | if ne nc 6 |
| 37 | ckbad |
| 38 | end |
| 39 | ret eq numeric_ref cknum 1 nhx 2 nhx 3 nhx 4 nhx 5 |
| 40 | end |
| 41 | if ne k 114 |
| 42 | ckbad |
| 43 | end |
| 44 | n = cknum 2 |
| 45 | if or eq n 0 gt n 32 |
| 46 | ckbad |
| 47 | end |
| 48 | if ne nc add n 4 |
| 49 | ckbad |
| 50 | end |
| 51 | ret nhred cknum 1 n |
| 52 | end |