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 / graph / record.om

183 lines · 3155 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Graph constant bank codec. Input addresses are full u64; scalar cells carry raw IEEE u32 bits.
3note Kinds RES=1 SW=2 AM=3 GA=4 GT=5 XB=6 GR=7, matching codegen_dec.h.
4fn graph_wire v view ulong 16 w edit uint 32 kind uint to ulong
5if or lt kind 1 gt kind 7
6ret 0
7end
8for i ulong 32
9put w i 0
10end
11n = ulong 7
12if eq kind 1
13n = 5
14end
15if eq kind 2
16n = 2
17end
18if eq kind 3
19n = 4
20end
21if or eq kind 4 eq kind 5
22n = 3
23end
24if eq kind 6
25n = 5
26end
27for i ulong n
28put w mul i 2 uint and get v i 4294967295
29put w add mul i 2 1 uint shr get v i 32
30end
31if eq kind 1
32put w 10 uint and get v 5 4294967295
33put w 11 uint and get v 6 4294967295
34end
35if eq kind 2
36put w 4 uint and get v 2 4294967295
37end
38if eq kind 5
39put w 6 uint and get v 3 4294967295
40end
41if eq kind 6
42put w 10 uint and get v 5 4294967295
43end
44if eq kind 7
45put w 14 uint and get v 7 4294967295
46put w 15 uint and get v 8 4294967295
47end
48ret 1
49end
50
51note Launch admission and dimensions shared by every recorder. Zero dimensions are refused before multiplication.
52note q: code,gpr,threads,gx,gy,shared,nargs,peak; d: identical launch scalar projection.
53fn graph_launch q view ulong 16 d edit ulong 16 to ulong
54if or eq get q 2 0 or eq get q 3 0 eq get q 4 0
55ret 0
56end
57if gt mul get q 2 get q 1 65536
58ret 2
59end
60if ne rem get q 1 8 0
61ret 3
62end
63peak = and add get q 7 2 4294967295
64if lt get q 1 peak
65ret 3
66end
67for i ulong 16
68put d i get q i
69end
70put d 8 mul mul get q 2 get q 3 get q 4
71put d 9 20000
72put d 10 200000
73ret 1
74end
75
76note Pure offset and size operations; host shell only supplies actual buffer base and layout fields.
77fn graph_align v ulong to ulong
78ret and add v 255 18446744073709551360
79end
80fn graph_va base ulong dev ulong split ulong off ulong to ulong
81if lt off split
82ret add base off
83end
84ret add dev sub off split
85end
86fn graph_slot base ulong row ulong width ulong to ulong
87ret add base mul mul row width 4
88end
89
90note Scalar layer schedule, shared by decode, Q36 and Q38. c: model,needsnorm,attention,overlap,splitdown.
91note op: norm1 mix2 ab3 gdn4 gather5 attention6 gate7 projection8 residual9 router10 gateup11 swiglu12 down13 combine14 prefetch15.
92note p slots are fixed, not host-selected ordering. 0 means skip and 255 means end.
93fn graph_order c view ulong 16 p ulong to ulong
94model = get c 0
95if ge p 18
96ret 255
97end
98if eq p 0
99if ne get c 1 0
100ret 1
101end
102ret 0
103end
104if eq p 1
105if and ne model 0 and eq get c 2 0 ne get c 3 0
106ret 3
107end
108ret 0
109end
110if eq p 2
111ret 2
112end
113if eq p 3
114if and ne model 0 and eq get c 2 0 eq get c 3 0
115ret 3
116end
117ret 0
118end
119if eq p 4
120if and ne model 0 eq get c 2 0
121ret 4
122end
123ret 0
124end
125if eq p 5
126if and ne model 0 ne get c 2 0
127ret 5
128end
129ret 0
130end
131if eq p 6
132if or eq model 0 ne get c 2 0
133ret 6
134end
135ret 0
136end
137if eq p 7
138if and eq model 0 ne get c 5 0
139ret 15
140end
141if and ne model 0 ne get c 2 0
142ret 7
143end
144ret 0
145end
146if eq p 8
147ret 8
148end
149if eq p 9
150ret 9
151end
152if eq p 10
153if ne model 2
154ret 10
155end
156ret 0
157end
158if eq p 11
159ret 11
160end
161if eq p 12
162ret 12
163end
164if eq p 13
165ret 13
166end
167if eq p 14
168if and eq model 2 ne get c 4 0
169ret 9
170end
171ret 0
172end
173if eq p 15
174if and eq model 2 ne get c 4 0
175ret 16
176end
177ret 0
178end
179if eq p 16
180ret 14
181end
182ret 0
183end