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 / gemm_num.om

93 lines · 2350 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/gemm_num.om: the Omega port of CUDApp tests/gemm_ex_om_num_test.c. Composed after
3note gpu/nvidia/om/gemmex/num.om, gpu/nvidia/om/gemmex/probe.om and gpu/nvidia/checks/lib.om; run with
4note gpu/nvidia/checks/gemm_num.tsv, whose rows the C number formats of the old test wrote over a sweep.
5note Each row is one sweep and holds the FNV-1a-64 digest of every answer the C gave in it, so every answer is
6note compared without storing each one. The check regenerates the inputs and digests gx_probe's answers:
7note r OP X0 XEND STEP N DIGEST ops 0 to 4 at x = X0, X0+STEP, ... below XEND (N of them)
8note x N DIGEST op 5 over the first N words of the old test's xorshift stream (odd steps: an f32
9note widened to f64, its low 12 bits flipped on every other one of them)
10note b T N DIGEST op 6 for kind T over every 16-bit u (kind 0 reads u << 16 | u), N = 65536
11text t_name "GEMM_NUM"
12fn cname to void
13for i ulong len t_name bound 64
14ckoc ulong get t_name i
15end
16end
17fn gxfnv h ulong v ulong to ulong
18ret mul xor h v 1099511628211
19end
20fn gxsweep op ulong x0 ulong xend ulong step ulong n ulong to ulong
21h = ulong 14695981039346656037
22for j ulong n bound 4294967296
23h = gxfnv h gx_probe op add x0 mul j step
24end
25ret h
26end
27fn gxstream n ulong to ulong
28s = ulong 88172645463325252
29h = ulong 14695981039346656037
30for i ulong n bound 4294967296
31s = xor s shl s 13
32s = xor s shr s 7
33s = xor s shl s 17
34d = s
35if ne and i 1 0
36d = bitcast ulong f64 bitcast f32 uint shr s 32
37if eq and i 2 0
38d = xor d and s 4095
39end
40end
41h = gxfnv h gx_probe 5 d
42end
43ret h
44end
45fn gxbad t ulong to ulong
46h = ulong 14695981039346656037
47for u ulong 65536
48v = u
49if eq t 0
50v = or shl u 16 u
51end
52h = gxfnv h gx_probe 6 or shl t 32 v
53end
54ret h
55end
56fn crow to bool
57k = ckch 0 0
58if eq k 114
59if ne ckcnt 7
60ckbad
61end
62op = cknum 1
63x0 = cknum 2
64xend = cknum 3
65step = cknum 4
66if or or gt op 4 eq step 0 or ge x0 xend gt xend 4294967296
67ckbad
68end
69n = div add sub xend x0 sub step 1 step
70if ne n cknum 5
71ret false
72end
73ret eq gxsweep op x0 xend step n cknum 6
74end
75if eq k 120
76if ne ckcnt 3
77ckbad
78end
79ret eq gxstream cknum 1 cknum 2
80end
81if eq k 98
82if ne ckcnt 4
83ckbad
84end
85t = cknum 1
86if or gt t 4 ne cknum 2 65536
87ckbad
88end
89ret eq gxbad t cknum 3
90end
91ckbad
92ret false
93end