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

69 lines · 1907 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/arest-pkh.om: cg_pklen and cg_pkh (gpu/nvidia/om/codegen/cg_pack_len.om, cg_pack_h.om),
3note as packing() of CUDApp tests/api_rest_diff.c calls them. Unit pk: Q the first eight q words (kind, m, k, mp,
4note kp, n, nt0, nt1); cg_pklen sets the source byte count and the destination count, then cg_pkh packs the test's
5note source (ushort i, or for kinds 3 and 4 the float (int)(i % 31 - 15), as little-endian bytes). Outputs: 0 the
6note digest of the packed ushorts, 1 the cg_pklen answer, 2 the destination count; the answer is cg_pkh's. Unit
7note pklen: Q the twelve q words, the answer cg_pklen's. The destination starts as zeros, as the test's does (memset):
8note the row 0 kinds write only row 0 of each block by contract. Composed before arestg.om.
9text t_name "AREST-PKH"
10text t_pk "pk"
11text t_pklen "pklen"
12fn ax_src s edit uchar 1156 kind ulong to void
13for i ulong 289
14if ge kind 3
15v = bitcast uint f32 sub long rem i 31 15
16p = mul i 4
17put s p uchar and v 255
18put s add p 1 uchar and shr v 8 255
19put s add p 2 uchar and shr v 16 255
20put s add p 3 uchar shr v 24
21else
22put s mul i 2 uchar and i 255
23put s add mul i 2 1 uchar shr i 8
24end
25end
26end
27fn ax_pk q view ulong 256 o edit ulong 256 to ulong
28p = new ulong 12 0
29for i ulong 8
30put p i get q i
31end
32rl = cg_pklen p
33put o 1 bitcast ulong rl
34sn = get p 8
35dn = get p 9
36put o 2 dn
37if ne rl 0
38ret 0
39end
40if or gt sn 1156 gt dn 1024
41ckbad
42end
43s = new uchar 1156 0
44ax_src s get p 0
45d = new ushort 1024 0
46r = cg_pkh p part s 0 sn part d 0 dn
47h = ardg0
48for i ulong dn bound 1024
49h = ardg h ulong get d i
50end
51put o 0 h
52ret bitcast ulong r
53end
54fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong
55if ckis 0 t_pk
56if ne nq 8
57ckbad
58end
59ret ax_pk q o
60end
61if or ne nq 12 not ckis 0 t_pklen
62ckbad
63end
64p = new ulong 12 0
65for i ulong 12
66put p i get q i
67end
68ret bitcast ulong cg_pklen p
69end