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

76 lines · 1986 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/avpack.om: the Omega port of the host-data part of CUDApp tests/attn_views_diff.c that
3note the Omega units answer alone. Composed after gpu/nvidia/om/api/attn_bfexp.om (av_bfexp; it starts with
4note om2, so it comes first), gpu/nvidia/om/api/attn_args.om (av_pack), gpu/nvidia/om/api/attn_lay.om (av_lay)
5note and gpu/nvidia/checks/lib.om; run with gpu/nvidia/checks/avpack.tsv. Rows, tab separated, hex except NA,
6note NW and RC:
7note p NA NW RC A0..A31 av_pack of the test's p (p[i] = 0xdeadbeef12345678 ^ (i << 40)) into zeroed words
8note l MASK RC A0..A31 av_lay of the same p into zeroed words
9note b BF16 F32 av_bfexp of one bfloat16, the exact bits of the float (NaN payloads included)
10note Each row is the pending C of src/omega_attn_views.h (av_args, av_layout, av_bfexpand) at CUDApp 84b524ca.
11text t_name "AVPACK"
12fn cname to void
13for i ulong len t_name bound 64
14ckoc ulong get t_name i
15end
16end
17fn apx i ulong to ulong
18n = cklen i
19if or eq n 0 gt n 16
20ckbad
21end
22v = ulong 0
23for j ulong n bound 16
24v = or shl v 4 cknib ckch i j
25end
26ret v
27end
28note the row's answer RC (field f) and its 32 words (fields f + 1 on) against rc and a
29fn apcmp rc ulong a view uint 32 f ulong to bool
30if ne rc cknum f
31ret false
32end
33for i ulong 32
34if ne ulong get a i apx add add f 1 i
35ret false
36end
37end
38ret true
39end
40fn crow to bool
41k = ckch 0 0
42p = new ulong 32 0
43a = new uint 32 0
44s = new ushort 1 0
45d = new f32 1 f32 0
46if or eq k 112 eq k 108
47for i ulong 32
48put p i xor 16045690981402826360 shl i 40
49end
50nf = ulong 35
51if eq k 112
52nf = ulong 36
53end
54if or ne cklen 0 1 ne ckcnt nf
55ckbad
56end
57if eq k 112
58rc = av_pack view p edit a cknum 1 cknum 2
59ret apcmp rc view a 3
60end
61rl = av_lay view p edit a apx 1
62ret apcmp rl view a 2
63end
64if eq k 98
65if or ne ckcnt 3 ne cklen 0 1
66ckbad
67end
68put s 0 ushort apx 1
69if ne av_bfexp view s edit d 1 0
70ret false
71end
72ret eq ulong bitcast uint get d 0 apx 2
73end
74ckbad
75ret false
76end