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 / apiviews / hostrest.om

394 lines · 6272 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note FP8/GDN host-only policy; effect acquisition remains in the C caller.
3fn ah_flag c ulong tail ulong dflt ulong to ulong
4if eq tail 0
5if eq c 48
6ret 0
7end
8if eq c 49
9ret 1
10end
11end
12ret dflt
13end
14fn ah_var c ulong tail ulong to ulong
15if and eq c 50 eq tail 0
16ret 2
17end
18ret 1
19end
20fn ah_shape k uint over uint kind uint to uint
21if ne over 0
22ret over
23end
24if eq kind 0
25if eq rem k 512 0
26ret 16
27end
28ret 8
29end
30if eq kind 1
31ret 1
32end
33ret 8
34end
35fn ah_reg threads ulong decl ulong to ulong
36if le mul threads decl 65536
37ret 1
38end
39ret 0
40end
41fn ah_group groups uint forced uint wave ulong to uint
42if and gt forced 0 le forced 256
43ret forced
44end
45if or eq wave 0 eq groups 0
46ret 6
47end
48n = div uint 48 groups
49if eq n 0
50ret 1
51end
52if lt n 6
53ret n
54end
55ret 6
56end
57fn ah_digit n uint c uint to ulong
58if or lt c 48 gt c 57
59ret 4294967296
60end
61if ge n 1000
62ret 4294967296
63end
64ret ulong add mul n 10 sub c 48
65end
66fn ah_warps k uint groups uint over uint bigk ulong variant ulong to uint
67if ne over 0
68ret over
69end
70if eq variant 2
71ret 16
72end
73if gt groups 1
74ret 32
75end
76if and and eq groups 1 gt k 4096 ne bigk 0
77ret 16
78end
79ret 8
80end
81fn ah_coal on ulong warps uint rows uint to uint
82if and ne on 0 le mul warps rows 32
83ret 1
84end
85ret 0
86end
87fn ah_depth k uint lb uint rows uint warps uint groups uint bigk ulong to ulong
88ks = div k mul uint 32 lb
89partial = false
90if gt mul mul ks rows lb 128
91if gt k 4096
92if eq groups 1
93partial = ne bigk 0
94end
95end
96end
97if partial
98full = ks
99ks = sub ks 1
100while gt ks 1
101if eq rem full ks 0
102if le mul mul ks rows lb 128
103break
104end
105end
106ks = sub ks 1
107end
108if lt ks 2
109ret 0
110end
111end
112if gt mul mul ks rows lb 128
113ret 0
114end
115if ne rem k mul uint 32 warps 0
116ret 0
117end
118if gt k mul uint 512 warps
119ret 0
120end
121if partial
122ret or ulong ks 4294967296
123end
124ret ulong ks
125end
126fn ah_refuse n uint rows uint support ulong to ulong
127if ne rem n rows 0
128ret 1
129end
130if eq support 0
131ret 1
132end
133ret 0
134end
135fn ah_grid n uint rows uint warps uint budget uint bigk ulong to uint
136rg = div n rows
137gx = div add rg sub warps 1 warps
138if ne bigk 0
139waves = div add gx 383 384
140if lt waves 2
141waves = 2
142end
143gx = div add gx sub waves 1 waves
144budget = gx
145end
146if gt gx budget
147gx = budget
148end
149if eq gx 0
150gx = 1
151end
152ret gx
153end
154fn ah_cache valid ulong equal ulong rec ulong to ulong
155if and ne valid 0 ne equal 0
156ret 1
157end
158if and ne valid 0 ne rec 0
159ret 2
160end
161ret 0
162end
163fn ah_move kind ulong dst ulong bytes ulong per ulong to ulong
164if or or or and ne kind 4 ne kind 5 eq dst 0 eq bytes 0 ne rem bytes per 0
165ret 0
166end
167if gt div bytes per 2147483647
168ret 0
169end
170ret div bytes per
171end
172fn ah_tokens layer uint layers uint t uint low uint high uint to ulong
173if or or ge layer layers lt t low gt t high
174ret 0
175end
176ret 1
177end
178fn ah_scratch rec ulong present ulong cap ulong bytes ulong to ulong
179if and ne rec 0 or eq present 0 lt cap bytes
180ret 0
181end
182ret 1
183end
184fn ah_pfgx t uint prep uint ratio uint stage uint to uint
185if eq stage 0
186ret div add t sub prep 1 prep
187end
188if eq stage 1
189ret ratio
190end
191ret t
192end
193fn ah_dcall p view ulong 16 to ulong
194a = uint get p 0
195b = uint get p 1
196c = uint get p 2
197d = uint get p 3
198e = uint get p 4
199f = get p 5
200ret ah_depth a b c d e f
201end
202fn ah_tcall p view ulong 16 to ulong
203a = uint get p 0
204b = uint get p 1
205c = uint get p 2
206d = uint get p 3
207e = uint get p 4
208ret ah_tokens a b c d e
209end
210fn ah_admit p view ulong 16 to ulong
211if eq get p 0 0
212if ne get p 1 0
213if or or eq get p 2 0 eq get p 3 0 eq get p 4 0
214ret 0
215end
216end
217ret 1
218end
219if eq get p 0 1
220if eq get p 1 0
221ret 0
222end
223if and eq get p 2 0 eq get p 3 0
224ret 0
225end
226if and and eq get p 4 0 eq get p 5 0 eq get p 6 0
227ret 0
228end
229if and eq get p 7 0 eq get p 8 0
230ret 0
231end
232ret 1
233end
234if ne get p 1 0
235if or or eq get p 2 0 eq get p 3 0 eq get p 4 0
236ret 0
237end
238else
239if or or or eq get p 5 0 eq get p 6 0 eq get p 7 0 eq get p 8 0
240ret 0
241end
242end
243ret 1
244end
245note op 25 ragged k: p0 k, p1 lane_bytes, p2 ragged allowed, p3 variant, p4 depth. 1 when the call may use a ragged-k kernel
246note (omega_blackwell_codegen_fp8_gemv_ragged_prog): variant 1, step-by-step kernel (depth 0), k a multiple of 128 and not of
247note 32 * lane_bytes. Everything else, including every k the plain kernels take, answers 0.
248fn ah_ragged p view ulong 16 to ulong
249if or eq get p 2 0 ne get p 3 1
250ret 0
251end
252if or eq get p 1 0 ne get p 4 0
253ret 0
254end
255w = mul ulong 32 get p 1
256if eq rem get p 0 w 0
257ret 0
258end
259if ne rem get p 0 128 0
260ret 0
261end
262ret 1
263end
264fn ah_extra op ulong p view ulong 16 to ulong
265if eq op 25
266ret ah_ragged p
267end
268if eq op 24
269k = uint get p 0
270lb = uint get p 1
271r = uint get p 2
272ks = div k mul uint 32 lb
273if gt mul mul ks r lb 128
274if and gt k 4096 eq get p 3 1
275ret 1
276end
277end
278ret 0
279end
280if eq op 23
281ret ah_admit p
282end
283if eq op 16
284for i ulong 8
285if ne get p i 0
286ret 0
287end
288end
289ret 1
290end
291if eq op 17
292if eq get p 0 0
293ret 0
294end
295if or eq get p 1 1 eq get p 1 get p 0
296ret 1
297end
298ret 0
299end
300if eq op 18
301if ne get p 0 0
302ret get p 1
303end
304if gt get p 2 1
305if eq get p 3 2
306ret 12
307end
308ret get p 4
309end
310ret 256
311end
312if eq op 19
313if ne get p 0 0
314ret 0
315end
316if ne get p 1 1
317ret 0
318end
319if le get p 2 4096
320ret 0
321end
322ret get p 3
323end
324if eq op 20
325if ne get p 0 1
326ret 0
327end
328if eq get p 1 0
329ret 0
330end
331if gt get p 2 get p 3
332ret 0
333end
334ret 1
335end
336if eq op 21
337if gt get p 0 get p 1
338ret 1
339end
340ret 0
341end
342ret div get p 0 get p 1
343end
344fn ah_rest op ulong p view ulong 16 to ulong
345if ge op 16
346ret ah_extra op p
347end
348if eq op 0
349ret ah_flag get p 0 get p 1 get p 2
350end
351if eq op 1
352ret ah_var get p 0 get p 1
353end
354if eq op 2
355ret ulong ah_shape uint get p 0 uint get p 1 uint get p 2
356end
357if eq op 3
358ret ah_reg get p 0 get p 1
359end
360if eq op 4
361ret ulong ah_group uint get p 0 uint get p 1 get p 2
362end
363if eq op 5
364ret ah_digit uint get p 0 uint get p 1
365end
366if eq op 6
367ret ulong ah_warps uint get p 0 uint get p 1 uint get p 2 get p 3 get p 4
368end
369if eq op 7
370ret ulong ah_coal get p 0 uint get p 1 uint get p 2
371end
372if eq op 8
373ret ah_dcall p
374end
375if eq op 9
376ret ah_refuse uint get p 0 uint get p 1 get p 2
377end
378if eq op 10
379ret ulong ah_grid uint get p 0 uint get p 1 uint get p 2 uint get p 3 get p 4
380end
381if eq op 11
382ret ah_cache get p 0 get p 1 get p 2
383end
384if eq op 12
385ret ah_move get p 0 get p 1 get p 2 get p 3
386end
387if eq op 13
388ret ah_tcall p
389end
390if eq op 14
391ret ah_scratch get p 0 get p 1 get p 2 get p 3
392end
393ret ulong ah_pfgx uint get p 0 uint get p 1 uint get p 2 uint get p 3
394end