interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / gpu / nvidia / checks / nmmq.om

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