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 / apirest / calc.om

236 lines · 4658 bytes Raw Blame History
1om2
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note Source-derived arithmetic plans; inputs 1..15, outputs 16..31.
4fn ar_c1 q edit ulong 32 to ulong
5put q 16 ulong div add uint get q 1 sub uint get q 2 1 uint get q 2
6put q 17 div get q 3 4
7ret 0
8end
9fn ar_c2 q edit ulong 32 to ulong
10nt = div get q 1 get q 4
11gx = div get q 2 get q 5
12th = mul 32 get q 6
13put q 16 nt
14put q 17 gx
15put q 18 th
16put q 19 mul mul th gx nt
17put q 20 and add mul nt 32 4095 18446744073709547520
18put q 21 div get q 3 128
19ret 0
20end
21fn ar_c3 q edit ulong 32 to ulong
22kb = div get q 3 128
23sc = mul div get q 2 128 kb
24wb = mul get q 2 get q 3
25rb = mul mul div get q 2 8 add kb 1 4
26put q 16 sc
27put q 17 wb
28put q 18 rb
29put q 19 mul get q 1 wb
30put q 20 mul get q 1 rb
31put q 21 and add mul get q 1 rb 15 18446744073709551600
32put q 22 mul get q 4 sc
33put q 23 mul get q 4 wb
34put q 24 mul get q 4 rb
35put q 25 mul sc 4
36put q 26 div mul get q 4 rb 4
37put q 27 div rb 4
38put q 28 add mul get q 1 rb 16
39put q 29 and mul get q 1 wb 18446744073709551600
40ret 0
41end
42fn ar_c4 q edit ulong 32 to ulong
43r = mul uint get q 2 2
44if ne rem uint get q 1 r 0
45ret 1
46end
47u = div uint get q 1 r
48gx = div add u sub uint get q 3 1 uint get q 3
49if gt gx uint get q 4
50gx = uint get q 4
51end
52if eq gx 0
53gx = 1
54end
55put q 16 ulong u
56put q 17 ulong gx
57put q 18 ulong mul gx uint get q 3
58put q 19 ulong sub uint 0 uint get q 5
59put q 20 ulong sub uint 0 uint get q 6
60put q 21 ulong sub uint 0 uint get q 7
61put q 22 ulong sub uint 0 uint get q 8
62put q 23 mul 32 get q 3
63ret 0
64end
65fn ar_c5 q edit ulong 32 to ulong
66put q 16 mul 32 get q 1
67put q 17 mul mul get q 2 get q 3 get q 4
68put q 18 mul mul get q 1 get q 2 32
69ret 0
70end
71fn ar_c6 q edit ulong 32 to ulong
72put q 16 mul get q 1 add mul get q 2 get q 3 mul mul div get q 2 128 div get q 3 128 4
73ret 0
74end
75fn ar_c7 q edit ulong 32 to ulong
76bm = mul 16 get q 5
77span = mul mul get q 7 8 get q 6
78put q 16 bm
79put q 17 span
80put q 18 mul 32 get q 7
81put q 19 mul mul get q 8 get q 3 2
82put q 20 mul mul get q 1 get q 2 4
83put q 21 mul get q 4 32
84put q 22 mul add get q 1 bm 4
85put q 23 mul get q 1 get q 2
86put q 24 mul get q 8 get q 3
87put q 25 div get q 2 span
88put q 26 mul bm 256
89put q 27 mul get q 4 4
90put q 28 add get q 1 bm
91ret 0
92end
93fn ar_c8 q edit ulong 32 to ulong
94gx = div add uint get q 2 sub uint get q 5 1 uint get q 5
95if gt ulong gx get q 6
96gx = uint get q 6
97end
98if eq gx 0
99gx = 1
100end
101put q 16 ulong gx
102put q 17 ulong mul gx uint get q 5
103put q 18 ulong mul 32 uint get q 5
104put q 19 mul get q 1 get q 2
105put q 20 mul add get q 1 get q 4 get q 3
106put q 21 mul mul add get q 1 get q 4 get q 3 4
107put q 22 mul mul get q 1 get q 2 4
108put q 23 mul get q 7 get q 3
109put q 24 mul mul get q 7 get q 3 4
110put q 25 mul get q 3 4
111put q 26 mul get q 1 get q 3
112put q 27 mul get q 4 get q 3
113put q 28 sub get q 9 get q 8
114put q 29 mul sub get q 9 get q 8 get q 3
115put q 30 mul get q 8 get q 2
116put q 31 mul mul get q 1 get q 3 4
117ret 0
118end
119fn ar_c9 q edit ulong 32 to ulong
120put q 16 div get q 1 16
121put q 17 div get q 2 8
122if eq get q 4 0
123ret 0
124end
125rb = div get q 16 get q 4
126nb = div get q 17 get q 5
127rows = get q 1
128if gt rb get q 3
129rows = mul mul get q 3 16 get q 4
130end
131gx = div get q 3 div div rows 16 get q 4
132if eq gx 0
133gx = 1
134end
135if gt gx nb
136gx = nb
137end
138put q 18 rows
139put q 19 gx
140put q 20 div div rows 16 get q 4
141ret 0
142end
143fn ar_c10 q edit ulong 32 to ulong
144put q 16 ulong mul mul uint get q 2 16 uint get q 3
145put q 17 mul mul get q 1 get q 2 128
146ret 0
147end
148fn ar_c11 q edit ulong 32 to ulong
149u = get q 2
150if ne get q 3 0
151for i ulong 32
152if le u 1
153break
154end
155if ge div div get q 1 16 u 2
156break
157end
158u = div u 2
159end
160end
161put q 16 u
162ret 0
163end
164fn ar_c12 q edit ulong 32 to ulong
165mp = ulong mul div add uint get q 1 15 16 16
166kp = ulong mul div add uint get q 2 15 16 16
167np = ulong mul div add uint get q 3 7 8 8
168put q 16 mp
169put q 17 kp
170put q 18 np
171put q 19 mul mul mp kp 2
172put q 20 mul mul mp np 4
173put q 21 mul mul kp np 2
174put q 22 mul get q 2 get q 3
175put q 23 mul mul get q 2 get q 3 2
176put q 24 div np 8
177put q 25 mul mul 64 kp 16
178ret 0
179end
180fn ar_c13 q edit ulong 32 to ulong
181kb = div get q 1 128
182g = get q 2
183gy = ulong 1
184if eq g 0
185g = kb
186else
187gy = div kb g
188end
189put q 16 kb
190put q 17 g
191put q 18 gy
192put q 19 mul 32 g
193ret 0
194end
195fn arcalc q edit ulong 32 to ulong
196if eq get q 0 1
197ret ar_c1 q
198end
199if eq get q 0 2
200ret ar_c2 q
201end
202if eq get q 0 3
203ret ar_c3 q
204end
205if eq get q 0 4
206ret ar_c4 q
207end
208if eq get q 0 5
209ret ar_c5 q
210end
211if eq get q 0 6
212ret ar_c6 q
213end
214if eq get q 0 7
215ret ar_c7 q
216end
217if eq get q 0 8
218ret ar_c8 q
219end
220if eq get q 0 9
221ret ar_c9 q
222end
223if eq get q 0 10
224ret ar_c10 q
225end
226if eq get q 0 11
227ret ar_c11 q
228end
229if eq get q 0 12
230ret ar_c12 q
231end
232if eq get q 0 13
233ret ar_c13 q
234end
235ret 1
236end