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 / codegen / cg_qmma.om

425 lines · 6717 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Qmma builder records follow omega_gpu_om_ir.h; meta contains allocation and loop events.
3note Scalars in spec: kind, mutant/niter, wait/chains, stall, threads.
4const NR ulong 18446744073709551615
5fn omega_cg_qmma_offset c ulong q ulong to ulong
6ret add mul c 16 mul q 4
7end
8fn omega_cg_qmma_cw st ulong wb ulong rb ulong wt ulong to ulong
9ret or or shl st 9 shl wb 14 or shl rb 17 shl wt 20
10end
11fn omega_cg_qmma_v m edit ulong 512 k ulong to ulong
12v = get m 1
13if ge v 256
14put m 4 1
15ret NR
16end
17put m add 64 v k
18put m 1 add v 1
19ret v
20end
21fn omega_cg_qmma_i x edit ulong 16 op ulong to void
22for i ulong 16
23put x i 0
24end
25put x 0 op
26for i ulong 5
27put x add i 1 NR
28end
29end
30fn omega_cg_qmma_emit b edit ulong 8192 m edit ulong 512 x edit ulong 16 k ulong to void
31wt = get m 3
32st = ulong 6
33wb = ulong 7
34rb = ulong 7
35pn = ulong 0
36yld = ulong 0
37if eq k 1
38st = 14
39end
40if or eq k 2 eq k 3
41st = 4
42wb = 0
43rb = 1
44pn = or get m 3 3
45yld = 8192
46if eq k 2
47pn = 3
48else
49wt = and wt 2
50end
51end
52if eq k 4
53st = 4
54wb = 2
55pn = 4
56yld = 8192
57end
58if eq k 5
59st = 4
60rb = 1
61pn = 2
62yld = 8192
63end
64if or eq k 7 eq k 8
65st = 5
66if ne get x 9 0
67pn = wt
68end
69end
70if eq k 11
71st = get x 7
72end
73put x 7 or omega_cg_qmma_cw st wb rb wt yld
74put m 3 pn
75n = get m 0
76if ge n 1024
77put m 4 2
78ret
79end
80omega_cg_qmma_pack b x n
81put m 0 add n 1
82end
83fn omega_cg_qmma_build s view ulong 8 b edit ulong 8192 m edit ulong 512 to ulong
84x = new ulong 16 0
85r = new ulong 32 0
86for i ulong 512
87put m i 0
88end
89kind = get s 0
90if gt kind 2
91ret 1
92end
93if eq kind 0
94if or gt get s 1 1 gt get s 2 16
95ret 1
96end
97end
98if eq kind 1
99if eq get s 1 0
100ret 1
101end
102if eq get s 2 0
103ret 1
104end
105if gt get s 2 16
106ret 1
107end
108if or eq get s 3 0 gt get s 3 15
109ret 1
110end
111if eq get s 4 0
112ret 1
113end
114if ne rem get s 4 32 0
115ret 1
116end
117if gt get s 4 1024
118ret 1
119end
120end
121put m 2 1
122put m 320 2
123note All registers are allocated in the same order as the independent C oracle.
124if eq kind 0
125for i ulong 12
126k = ulong 2
127if or eq i 2 eq i 3
128k = 1
129end
130if eq i 8
131k = 4
132end
133if or eq i 10 eq i 11
134k = 4
135end
136put r i omega_cg_qmma_v m k
137end
138else
139if eq kind 1
140for i ulong 7
141k = ulong 1
142if eq i 0
143k = 2
144end
145if eq i 5
146k = 4
147end
148if eq i 6
149k = 2
150end
151put r i omega_cg_qmma_v m k
152end
153for i ulong get s 2
154put r add i 8 omega_cg_qmma_v m 4
155end
156else
157for i ulong 7
158k = ulong 1
159if or lt i 2 eq i 5
160k = 2
161end
162put r i omega_cg_qmma_v m k
163end
164end
165end
166omega_cg_qmma_i x 7
167put x 1 0
168put x 6 856
169put x 8 1
170omega_cg_qmma_emit b m x 4
171omega_cg_qmma_i x 5
172put x 1 get r 0
173put x 6 896
174omega_cg_qmma_emit b m x 2
175if ne kind 1
176omega_cg_qmma_i x 5
177put x 1 get r 1
178put x 6 904
179omega_cg_qmma_emit b m x 2
180end
181for i ulong 2
182omega_cg_qmma_i x 3
183put x 1 get r add i 2
184if eq kind 1
185put x 1 get r add i 1
186end
187put x 6 33
188if eq i 1
189put x 6 37
190end
191omega_cg_qmma_emit b m x 2
192end
193if eq kind 0
194omega_cg_qmma_i x 9
195put x 1 get r 6
196put x 2 get r 3
197put x 4 get r 0
198put x 6 1280
199omega_cg_qmma_emit b m x 0
200omega_cg_qmma_i x 9
201put x 1 get r 4
202put x 2 get r 2
203put x 4 get r 6
204put x 6 16
205omega_cg_qmma_emit b m x 0
206omega_cg_qmma_i x 9
207put x 1 get r 7
208put x 2 get r 2
209put x 4 get r 6
210put x 6 8
211omega_cg_qmma_emit b m x 0
212omega_cg_qmma_i x 9
213put x 1 get r 5
214put x 2 get r 3
215put x 4 get r 1
216put x 6 512
217omega_cg_qmma_emit b m x 0
218omega_cg_qmma_i x 9
219put x 1 get r 5
220put x 2 get r 2
221put x 4 get r 5
222put x 6 16
223omega_cg_qmma_emit b m x 0
224for i ulong 3
225omega_cg_qmma_i x 57
226put x 1 get r 8
227put x 2 get r 4
228put x 5 0
229if eq i 1
230put x 1 get r 10
231put x 6 768
232end
233if eq i 2
234put x 0 56
235put x 1 get r 9
236put x 2 get r 7
237put x 6 512
238end
239k = ulong 3
240if eq i 0
241k = 2
242end
243omega_cg_qmma_emit b m x k
244end
245omega_cg_qmma_i x 16
246put x 1 get r 11
247put x 2 get r 8
248put x 3 get r 9
249if eq get s 1 0
250put x 4 get r 10
251end
252put x 6 1362114610
253put x 7 15
254omega_cg_qmma_emit b m x 11
255for i ulong get s 2
256omega_cg_qmma_i x 0
257put x 7 15
258omega_cg_qmma_emit b m x 11
259end
260for i ulong 4
261omega_cg_qmma_i x 12
262put x 2 get r 5
263put x 3 get r 11
264put x 13 i
265put x 6 mul i 4
266put x 5 0
267omega_cg_qmma_emit b m x 5
268end
269end
270if eq kind 1
271omega_cg_qmma_i x 2
272put x 1 get r 3
273put x 6 1
274omega_cg_qmma_emit b m x 0
275for i ulong 6
276omega_cg_qmma_i x 2
277put x 1 get r 5
278put x 11 i
279if ge i 4
280put x 1 get r 6
281put x 11 sub i 4
282end
283put x 6 943208504
284omega_cg_qmma_emit b m x 0
285end
286for c ulong get s 2
287for q ulong 4
288omega_cg_qmma_i x 1
289put x 1 get r add c 8
290put x 11 q
291omega_cg_qmma_emit b m x 0
292end
293end
294omega_cg_qmma_i x 2
295put x 1 get r 4
296put x 6 get s 1
297omega_cg_qmma_emit b m x 0
298put m 16 get m 0
299for c ulong get s 2
300omega_cg_qmma_i x 16
301put x 1 get r add c 8
302put x 2 get r 5
303put x 3 get r 6
304put x 4 get r add c 8
305put x 6 1362114610
306put x 7 get s 3
307omega_cg_qmma_emit b m x 11
308end
309omega_cg_qmma_i x 8
310put x 1 get r 4
311put x 2 get r 3
312put x 4 get r 4
313put x 6 4294967295
314omega_cg_qmma_emit b m x 0
315omega_cg_qmma_i x 28
316put x 2 get r 4
317put x 3 get r 3
318omega_cg_qmma_emit b m x 1
319omega_cg_qmma_i x 46
320put x 9 1
321put x 6 and sub get m 16 get m 0 4294967295
322omega_cg_qmma_emit b m x 8
323put m 5 1
324put m 17 sub get m 0 1
325for i ulong 4
326omega_cg_qmma_i x 0
327put x 7 15
328omega_cg_qmma_emit b m x 11
329end
330if true
331t = omega_cg_qmma_v m 1
332omega_cg_qmma_i x 8
333put x 1 t
334put x 2 get r 2
335put x 4 get r 1
336put x 6 get s 4
337omega_cg_qmma_emit b m x 0
338omega_cg_qmma_i x 9
339put x 1 get r 0
340put x 2 t
341put x 4 get r 0
342put x 6 mul get s 2 16
343omega_cg_qmma_emit b m x 0
344end
345for c ulong get s 2
346for q ulong 4
347omega_cg_qmma_i x 12
348put x 2 get r 0
349put x 3 get r add c 8
350put x 13 q
351put x 6 omega_cg_qmma_offset c q
352put x 5 0
353omega_cg_qmma_emit b m x 5
354end
355end
356end
357if eq kind 2
358omega_cg_qmma_i x 8
359put x 1 get r 4
360put x 2 get r 3
361put x 4 get r 2
362put x 6 128
363omega_cg_qmma_emit b m x 0
364for i ulong 2
365omega_cg_qmma_i x 9
366put x 1 get r i
367put x 2 get r 4
368put x 4 get r i
369put x 6 8
370if eq i 1
371put x 6 4
372end
373omega_cg_qmma_emit b m x 0
374end
375omega_cg_qmma_i x 56
376put x 1 get r 5
377put x 2 get r 0
378put x 5 0
379omega_cg_qmma_emit b m x 2
380omega_cg_qmma_i x 37
381put x 1 get r 6
382put x 2 get r 5
383put x 3 get r 5
384put x 13 1
385put x 6 1178940467
386omega_cg_qmma_emit b m x 0
387omega_cg_qmma_i x 12
388put x 2 get r 1
389put x 3 get r 6
390put x 5 0
391omega_cg_qmma_emit b m x 5
392end
393omega_cg_qmma_i x 45
394omega_cg_qmma_emit b m x 7
395omega_cg_qmma_i x 46
396n = get m 0
397put x 7 1032192
398omega_cg_qmma_pack b x n
399put m 0 add n 1
400ret 0
401end
402
403fn omega_cg_qmma_pack b edit ulong 8192 x view ulong 16 n ulong to void
404off = mul n 8
405for i ulong 6
406put b add off i get x i
407end
408put b add off 6 or get x 6 shl get x 7 32
409fl = or get x 8 or shl get x 9 1 shl get x 10 2
410for i ulong 5
411fl = or fl shl get x add i 11 add 16 mul i 8
412end
413put b add off 7 fl
414end
415
416fn cg_qmma kind ulong a ulong c ulong d ulong b edit ulong 8192 m edit ulong 512 to ulong
417s = new ulong 8 0
418put s 0 kind
419put s 1 a
420put s 2 c
421put s 3 and d 4294967295
422put s 4 shr d 32
423ret omega_cg_qmma_build s b m
424end
425