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

95 lines · 1799 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/arest-bf16.om: ar_bf16 (gpu/nvidia/om/apirest/bf16.om over apiviews/bf16.om) and artcperm
3note (tcperm.om), as data_parts() and misc_parts() of CUDApp tests/api_rest_partitions.h call them. Composed
4note before arestg.om.
5text t_name "AREST-BF16"
6text t_bf16 "bf16"
7text t_tcperm "tcperm"
8note the test's nine bit patterns
9fn ax_bits k ulong to uint
10if eq k 0
11ret 0
12end
13if eq k 1
14ret 1
15end
16if eq k 2
17ret 0x3f807fff
18end
19if eq k 3
20ret 0x3f808000
21end
22if eq k 4
23ret 0x3f808001
24end
25if eq k 5
26ret 0x7f800000
27end
28if eq k 6
29ret 0x7f800001
30end
31if eq k 7
32ret 0xfffffffe
33end
34ret 0xffffffff
35end
36note Q n and the output length; f[i] is pattern i % 9; output 0 the digest of the n bf16
37fn ax_bf16 q view ulong 256 nq ulong o edit ulong 256 to ulong
38n = get q 0
39yl = get q 1
40if or or ne nq 2 gt n 36 gt yl 40
41ckbad
42end
43x = new f32 36 0.0f32
44for i ulong 36
45put x i bitcast f32 ax_bits rem i 9
46end
47y = new ushort 40 0x5a5a
48r = ar_bf16 part x 0 n part y 0 yl
49if ne r 0
50ret r
51end
52h = ardg0
53for i ulong n bound 36
54h = ardg h ulong get y i
55end
56put o 0 h
57ret r
58end
59note Q the fill (0: (float)(i % 17), 1: (float)(i * 3)), m, the output length; output 0 the digest of the m bf16
60fn ax_tcperm q view ulong 256 nq ulong o edit ulong 256 to ulong
61m = get q 1
62yl = get q 2
63if or or ne nq 3 gt m 512 gt yl 512
64ckbad
65end
66x = new f32 512 0.0f32
67for i ulong 512
68if eq get q 0 0
69put x i f32 rem i 17
70else
71put x i f32 mul i 3
72end
73end
74y = new ushort 512 0x5a5a
75r = artcperm part x 0 m part y 0 yl
76if ne r 0
77ret r
78end
79h = ardg0
80for i ulong m bound 512
81h = ardg h ulong get y i
82end
83put o 0 h
84ret r
85end
86fn arop q view ulong 256 nq ulong ny ulong o edit ulong 256 to ulong
87if ckis 0 t_bf16
88ret ax_bf16 q nq o
89end
90if ckis 0 t_tcperm
91ret ax_tcperm q nq o
92end
93ckbad
94ret 0
95end