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-tern.om

87 lines · 1824 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/arest-tern.om: the units over gpu/nvidia/om/apirest/terndata.om: artern, artrits, arrev,
3note as data_parts() and misc_parts() of CUDApp tests/api_rest_partitions.h call them. Composed before arestg.om.
4text t_name "AREST-TERN"
5text t_tern "tern"
6text t_trits "trits"
7text t_rev "rev"
8note the test's trits in turn: 0, 1, -1 (byte 255)
9fn ax_tr i ulong to uchar
10k = rem i 3
11if eq k 2
12ret 255
13end
14ret uchar k
15end
16note Q the four q words (n, 32, layout, 2); w[i] = ax_tr i; NY the output length
17fn ax_tn a view ulong 4 ny ulong o edit ulong 256 to ulong
18w = new uchar 544 0
19for i ulong 544
20put w i ax_tr i
21end
22y = new uint 48 0xffffffff
23wn = mul get a 0 32
24r = artern a part w 0 wn part y 0 ny
25for i ulong 48
26put o i ulong get y i
27end
28ret r
29end
30fn ax_tern q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong
31if or or ne nq 4 gt get q 0 17 gt ny 48
32ckbad
33end
34a = new ulong 4 0
35for i ulong 4
36put a i get q i
37end
38ret ax_tn a ny o
39end
40note Q n and a flag: 1 sets the last trit to 2
41fn ax_trits q view ulong 256 nq ulong to ulong
42n = get q 0
43if or ne nq 2 gt n 33
44ckbad
45end
46w = new uchar 33 0
47for i ulong 33
48put w i ax_tr i
49end
50if eq get q 1 1
51if eq n 0
52ckbad
53end
54put w sub n 1 2
55end
56ret artrits part w 0 n
57end
58note Q n; x[i] = (float)(i % 127); the four outputs as bit patterns
59fn ax_rev q view ulong 256 nq ulong o edit ulong 256 to ulong
60n = get q 0
61if or ne nq 1 gt n 4
62ckbad
63end
64x = new f32 4 0.0f32
65for i ulong 4
66put x i f32 rem i 127
67end
68y = new f32 4 7.0f32
69r = arrev part x 0 n y
70for i ulong 4
71put o i ulong bitcast uint get y i
72end
73ret r
74end
75fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong
76if ckis 0 t_tern
77ret ax_tern q nq ny o
78end
79if ckis 0 t_trits
80ret ax_trits q nq
81end
82if ckis 0 t_rev
83ret ax_rev q nq o
84end
85ckbad
86ret 0
87end