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 / nmmq.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note gpu/nvidia/checks/nmmq.om: the walk of the matmul() block of CUDApp tests/api_attn_rest_diff.c. mm_init and |
| 3 | note mm_next (gpu/nvidia/om/api/) step the host matmul oracle of src/omega_gpu_matmul_api.c over the elements of C; |
| 4 | note the pending C oracle (CUDAPP_MIGRATION_PENDING_C_MATMUL_ORACLE_GUARD) walks for i < m, for j < n, reading |
| 5 | note c[i*n + j], m*k values of a and k*n of b. Rows: |
| 6 | note Q m k n GO AN BN VISITS |
| 7 | note mm_init on q = {0, 0, k, n, m, 0, 0, 0} must answer GO (1 when there is an element) and set |
| 8 | note q[6] = AN and q[7] = BN; then each mm_next step must stand on the next (i, j) of VISITS (2 bytes |
| 9 | note each as 4 hex digits, - when none) with q[5] = i*n + j, and answer false after the last. |
| 10 | note Both units carry om2, which a composed program has once, first: check nmmi takes mm_init.om as its head and |
| 11 | note nmm-next.om for mm_next, check nmmn mm_next.om and nmm-init.om. A walk over 4096 elements is refused (ckbad). |
| 12 | text t_name "NMMQ" |
| 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 value v (2 bytes) of the VISITS field |
| 19 | fn nqv v ulong to ulong |
| 20 | ret or shl ckhex 7 mul v 2 8 ckhex 7 add mul v 2 1 |
| 21 | end |
| 22 | note 1 when b, else 0 |
| 23 | fn nqb b bool to ulong |
| 24 | if b |
| 25 | ret 1 |
| 26 | end |
| 27 | ret 0 |
| 28 | end |
| 29 | fn crow to bool |
| 30 | q = new ulong 8 0 |
| 31 | if or or ne cklen 0 1 ne ckch 0 0 81 ne ckcnt 8 |
| 32 | ckbad |
| 33 | end |
| 34 | put q 4 cknum 1 |
| 35 | put q 2 cknum 2 |
| 36 | put q 3 cknum 3 |
| 37 | if or gt get q 4 4096 gt get q 3 4096 |
| 38 | ckbad |
| 39 | end |
| 40 | e = mul get q 4 get q 3 |
| 41 | if or gt e 4096 ne ckhexn 7 mul 4 e |
| 42 | ckbad |
| 43 | end |
| 44 | g = nqb mm_init q |
| 45 | if or ne g cknum 4 ne get q 6 cknum 5 |
| 46 | ret false |
| 47 | end |
| 48 | if ne get q 7 cknum 6 |
| 49 | ret false |
| 50 | end |
| 51 | for v ulong e bound 4096 |
| 52 | if eq g 0 |
| 53 | ret false |
| 54 | end |
| 55 | if or ne get q 0 nqv mul v 2 ne get q 1 nqv add mul v 2 1 |
| 56 | ret false |
| 57 | end |
| 58 | if ne get q 5 add mul get q 0 get q 3 get q 1 |
| 59 | ret false |
| 60 | end |
| 61 | g = nqb mm_next q |
| 62 | end |
| 63 | ret eq g 0 |
| 64 | end |