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

132 lines · 3433 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/avv.om: the shared part of the avv-* checks, the view calls of CUDApp tests/attn_views_cases.c
3note (the fixture of tests/attn_views_diff.c) and sweeps around them, compared with the pending C bodies of
4note src/omega_attn_views.h (CUDAPP_MIGRATION_PENDING_ATTN_VIEWS). Each view unit carries om2 and is a program's head
5note alone, so each has its own check: the unit, lib.om, lib-om2.om, its avv-UNIT.om (text t_name, text t_au, fn
6note cname, fn avcap, fn avop) and then this part. Rows:
7note UNIT L n A B v X r h
8note A and B are two arrays of L elements, each given as a b m k c p1 v1 p2 v2: element i is (a*i + b) mod m, or
9note word i of X (16 hex digits each, - when unused) when m is 0 (A only); then c when k > 0 and i mod k is 0;
10note then v1 at i = p1 and v2 at i = p2; cut to the element width (and, for f32, taken as its bits). avop runs the
11note unit on the first n elements with the value v and must answer r; h is the FNV-1a digest
12note (h = (h xor e) * 1099511628211 from 1469598103934665603) of the L elements of the array the unit writes, or of
13note A for a unit that only reads. L above avcap (the largest local array of the element type, 4 MiB) is ckbad.
14note element i of the explicit list X
15fn avw i ulong to ulong
16w = ulong 0
17for j ulong 8
18w = or shl w 8 ckhex 22 add mul i 8 j
19end
20ret w
21end
22fn avx s view ulong 9 i ulong to ulong
23x = ulong 0
24if eq get s 2 0
25x = avw i
26else
27x = rem add mul get s 0 i get s 1 get s 2
28end
29k = get s 3
30if gt k 0
31if eq rem i k 0
32x = get s 4
33end
34end
35if eq i get s 5
36x = get s 6
37end
38if eq i get s 7
39x = get s 8
40end
41ret x
42end
43fn avgc d edit uchar * s view ulong 9 l ulong to void
44for i ulong l bound 1000003
45put d i uchar and avx s i 255
46end
47end
48fn avgs d edit ushort * s view ulong 9 l ulong to void
49for i ulong l bound 1000003
50put d i ushort and avx s i 65535
51end
52end
53fn avgu d edit uint * s view ulong 9 l ulong to void
54for i ulong l bound 1000003
55put d i uint and avx s i 4294967295
56end
57end
58fn avgf d edit f32 * s view ulong 9 l ulong to void
59for i ulong l bound 1000003
60put d i bitcast f32 uint and avx s i 4294967295
61end
62end
63fn avgl d edit ulong * s view ulong 9 l ulong to void
64for i ulong l bound 1000003
65put d i avx s i
66end
67end
68fn avhc d view uchar * l ulong to ulong
69h = ulong 1469598103934665603
70for i ulong l bound 1000003
71h = mul xor h ulong get d i 1099511628211
72end
73ret h
74end
75fn avhs d view ushort * l ulong to ulong
76h = ulong 1469598103934665603
77for i ulong l bound 1000003
78h = mul xor h ulong get d i 1099511628211
79end
80ret h
81end
82fn avhu d view uint * l ulong to ulong
83h = ulong 1469598103934665603
84for i ulong l bound 1000003
85h = mul xor h ulong get d i 1099511628211
86end
87ret h
88end
89fn avhf d view f32 * l ulong to ulong
90h = ulong 1469598103934665603
91for i ulong l bound 1000003
92h = mul xor h ulong bitcast uint get d i 1099511628211
93end
94ret h
95end
96fn avhl d view ulong * l ulong to ulong
97h = ulong 1469598103934665603
98for i ulong l bound 1000003
99h = mul xor h get d i 1099511628211
100end
101ret h
102end
103fn crow to bool
104if or ne ckcnt 25 not ckis 0 t_au
105ckbad
106end
107l = cknum 1
108n = cknum 2
109if or gt l avcap gt n l
110ckbad
111end
112a = new ulong 9 0
113b = new ulong 9 0
114for j ulong 9
115put a j cknum add 3 j
116put b j cknum add 12 j
117end
118if eq get b 2 0
119ckbad
120end
121if eq get a 2 0
122if ne ckhexn 22 mul l 8
123ckbad
124end
125end
126o = new ulong 2 0
127avop a b l n cknum 21 o
128if ne get o 0 cknum 23
129ret false
130end
131ret eq get o 1 cknum 24
132end