interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / om / blackwell / scalar.om

141 lines · 2284 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Pure import-free policy shared by hosted and freestanding callers.
3note Operations preserve the original uint32 wire and IEEE bit semantics.
4const BEXP ulong 113
5fn bw_sub m ulong to ulong
6if lt m 2
7ret or shl sub BEXP 10 23 shl and shl m 10 1023 13
8end
9if lt m 4
10ret or shl sub BEXP 9 23 shl and shl m 9 1023 13
11end
12if lt m 8
13ret or shl sub BEXP 8 23 shl and shl m 8 1023 13
14end
15if lt m 16
16ret or shl sub BEXP 7 23 shl and shl m 7 1023 13
17end
18if lt m 32
19ret or shl sub BEXP 6 23 shl and shl m 6 1023 13
20end
21if lt m 64
22ret or shl sub BEXP 5 23 shl and shl m 5 1023 13
23end
24if lt m 128
25ret or shl sub BEXP 4 23 shl and shl m 4 1023 13
26end
27if lt m 256
28ret or shl sub BEXP 3 23 shl and shl m 3 1023 13
29end
30if lt m 512
31ret or shl sub BEXP 2 23 shl and shl m 2 1023 13
32end
33ret or shl sub BEXP 1 23 shl and shl m 1 1023 13
34end
35fn bw_half h ulong to ulong
36sign = shl and h 32768 16
37exp = and shr h 10 31
38mant = and h 1023
39if eq exp 0
40if eq mant 0
41ret sign
42end
43ret or sign bw_sub mant
44else
45if eq exp 31
46ret or sign or 2139095040 shl mant 13
47end
48end
49ret and or sign or shl add exp 112 23 shl mant 13 4294967295
50end
51fn bw_scalar op ulong x ulong y ulong z ulong w ulong v ulong to ulong
52if eq op 1
53ret bw_half x
54end
55if eq op 2
56ret shl and x 65535 16
57end
58if eq op 3
59if and eq and x 2139095040 2139095040 ne and x 8388607 0
60ret or shr x 16 64
61end
62ret and shr and add add x 32767 and shr x 16 1 4294967295 16 65535
63end
64if eq op 4
65if gt x sub sub 18446744073709551615 y 4095
66ret 0
67end
68b = and add add x y 4095 18446744073709547520
69if lt b 4096
70ret 4096
71end
72ret b
73end
74if eq op 7
75if eq y 0
76ret x
77end
78ret 18446744073709551615
79end
80if eq op 8
81if and eq x 0 eq y 0
82ret 0
83end
84ret 18446744073709551615
85end
86if eq op 9
87if and gt x 0 lt x 9223372036854775808
88ret sub x 1
89end
90ret 18446744073709551615
91end
92if eq op 10
93if ne x 0
94ret 2
95end
96ret 3
97end
98if eq op 11
99if ne x 0
100ret 14
101end
102ret 13
103end
104if eq op 12
105if eq y 0
106ret x
107end
108ret 0
109end
110if eq op 13
111if ne x 0
112ret 1
113end
114ret 0
115end
116if eq op 14
117if or gt x 32768 gt y 16384
118ret 0
119end
120if or ne z 384 or ne w 384 gt v 128
121ret 0
122end
123ret 1
124end
125if eq op 15
126if le x 4096
127ret 1
128end
129ret 0
130end
131if eq op 16
132if or eq x 0 or eq y 0 eq z 0
133ret 0
134end
135ret 1
136end
137if eq op 17
138ret mul x y
139end
140ret 18446744073709551615
141end