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 / arest-pack.om

123 lines · 2519 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/arest-pack.om: the units over gpu/nvidia/om/apirest/pack.om with apish_pack.om: arnan,
3note arscale, arfold, arfoldh, aracc, armag, as data_parts() and state_parts() of CUDApp
4note tests/api_rest_partitions.h call them; the fills are the test's own loops. Composed before arestg.om.
5text t_name "AREST-PACK"
6text t_nan "nan"
7text t_scale "scale"
8text t_fold "fold"
9text t_foldh "foldh"
10text t_acc "acc"
11text t_mag "mag"
12note h[i] = 0x3f00 + i % 128
13fn ax_hgen x edit ushort 65537 to void
14for i ulong 65537
15put x i ushort add 16128 rem i 128
16end
17end
18fn ax_dg y view f32 65537 n ulong to ulong
19h = ardg0
20for i ulong n bound 65537
21h = ardg h ulong bitcast uint get y i
22end
23ret h
24end
25note Q n; bytes[i] = (unsigned char)i; y starts as {UINT64_MAX, 0}
26fn ax_nan q view ulong 256 o edit ulong 256 to ulong
27n = get q 0
28if gt n 65537
29ckbad
30end
31x = new uchar 65537 0
32for i ulong 65537
33put x i uchar and i 255
34end
35y = new ulong 2 0
36put y 0 18446744073709551615
37r = arnan part x 0 n y
38put o 0 get y 0
39put o 1 get y 1
40ret r
41end
42note Q mut, n
43fn ax_scale q view ulong 256 o edit ulong 256 to ulong
44n = get q 1
45if gt n 65537
46ckbad
47end
48x = new ushort 65537 0
49ax_hgen x
50y = new f32 65537 7.0f32
51r = arscale get q 0 part x 0 n part y 0 n
52put o 0 ax_dg y n
53ret r
54end
55note Q n; a[i] = (float)(i % 127)
56fn ax_fold q view ulong 256 o edit ulong 256 to ulong
57n = get q 0
58if gt n 65537
59ckbad
60end
61x = new f32 65537 0.0f32
62for i ulong 65537
63put x i f32 rem i 127
64end
65y = new f32 65537 7.0f32
66r = arfold part x 0 n part y 0 n
67put o 0 ax_dg y n
68ret r
69end
70fn ax_foldh q view ulong 256 o edit ulong 256 to ulong
71n = get q 0
72if gt n 65537
73ckbad
74end
75x = new ushort 65537 0
76ax_hgen x
77y = new f32 65537 7.0f32
78r = arfoldh part x 0 n part y 0 n
79put o 0 ax_dg y n
80ret r
81end
82note Q n; w 0x38, scale {0x3f80, 0x4000}, x alternating 1, -1; m 0 is aracc, 1 is armag
83fn ax_acc q view ulong 256 m ulong to ulong
84n = get q 0
85if gt n 129
86ckbad
87end
88w = new uchar 129 56
89sc = new ushort 2 16256
90put sc 1 16384
91x = new f32 129 1.0f32
92for i ulong 129
93if eq rem i 2 1
94put x i -1.0f32
95end
96end
97if eq m 0
98ret aracc part w 0 n part sc 0 2 part x 0 n
99end
100ret armag part w 0 n part sc 0 2 part x 0 n
101end
102fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong
103if ckis 0 t_nan
104ret ax_nan q o
105end
106if ckis 0 t_scale
107ret ax_scale q o
108end
109if ckis 0 t_fold
110ret ax_fold q o
111end
112if ckis 0 t_foldh
113ret ax_foldh q o
114end
115if ckis 0 t_acc
116ret ax_acc q 0
117end
118if ckis 0 t_mag
119ret ax_acc q 1
120end
121ckbad
122ret 0
123end