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 / components / bw_project.om

304 lines · 7729 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Port of existing nondeep OmegaFp8GemvSpec sched0 coal0 at b759afc3.
3note spec8:K,laneBytes,rows,warps,load-order component(0X-first/1W-first),reserved0.
4note Mutants are never accepted production specs. No solved bytes or second IR.
5fn bc_log v ulong to ulong
6for i ulong 32
7if eq shl ulong 1 i v
8ret i
9end
10end
11ret BCNONE
12end
13fn bc_imm ins edit ulong 8192 s edit ulong 64 d ulong a ulong c ulong imm ulong to void
14put s 8 imm
15put s 9 0
16bc_imad ins s 8 d a c
17end
18fn bc_wide ins edit ulong 8192 s edit ulong 64 d ulong a ulong c ulong imm ulong to void
19put s 8 imm
20put s 9 0
21bc_imad ins s 9 d a c
22end
23fn bc_shift ins edit ulong 8192 s edit ulong 64 d ulong a ulong subreg ulong amount ulong to void
24bc_node s 17 d a BCNONE BCNONE
25put s 22 amount
26put s 23 shl subreg 24
27bc_emit ins s 0
28end
29fn bc_mask ins edit ulong 8192 s edit ulong 64 d ulong a ulong subreg ulong mask ulong to void
30bc_node s 18 d a BCNONE BCNONE
31put s 22 mask
32put s 23 shl subreg 24
33bc_emit ins s 0
34end
35fn bc_initregs m edit ulong 2048 s edit ulong 64 r edit ulong 64 to void
36uv = bc_vreg s m 2 true
37for k ulong 31
38width = ulong 1
39if or lt k 3 and ge k 14 le k 16
40width = 2
41end
42if or and ge k 18 le k 20 and ge k 24 le k 28
43width = 2
44end
45put r k bc_vreg s m width false
46end
47for row ulong get s 34
48put r add 32 mul row 2 bc_vreg s m 1 false
49put r add 33 mul row 2 bc_vreg s m div get s 33 4 false
50end
51for word ulong get s 38
52put r add word 48 bc_vreg s m 4 false
53end
54put r 52 bc_vreg s m 1 false
55put r 53 bc_vreg s m 2 false
56for k ulong 6
57put r add k 54 bc_vreg s m 1 false
58end
59end
60fn bc_prologue ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
61bc_node s 7 0 BCNONE BCNONE BCNONE
62put s 22 856
63put s 23 1
64bc_emit ins s 4
65for k ulong 7
66op = ulong 4
67if lt k 3
68op = 5
69end
70bc_node s op get r k BCNONE BCNONE BCNONE
71put s 22 add ulong 896 mul k 8
72if ge k 3
73put s 22 add ulong 920 mul sub k 3 4
74end
75bc_emit ins s 2
76end
77for k ulong 3
78bc_node s 3 get r add k 7 BCNONE BCNONE BCNONE
79put s 22 33
80if eq k 1
81put s 22 37
82end
83if eq k 2
84put s 22 38
85end
86bc_emit ins s 2
87end
88bc_inst ins s 2 get r 12 BCNONE 1
89bc_shift ins s get r 10 get r 7 0 5
90bc_mask ins s get r 11 get r 7 0 31
91bc_imm ins s get r 13 get r 9 BCNONE 1
92bc_wide ins s get r 14 get r 13 get r 0 16
93put s 8 0
94bc_mem ins s 56 get r 15 get r 14 2
95put s 8 8
96bc_mem ins s 56 get r 16 get r 14 3
97bc_node s 8 get r 17 get r 9 get r 4 BCNONE
98bc_emit ins s 0
99bc_wide ins s get r 18 get r 17 get r 1 1
100bc_node s 8 get r 17 get r 9 get r 5 BCNONE
101bc_emit ins s 0
102bc_wide ins s get r 19 get r 17 get r 2 1
103bc_wide ins s get r 20 get r 11 get r 18 mul get s 33 4
104bc_imm ins s get r 21 get r 11 BCNONE get s 33
105bc_shift ins s get r 22 get r 11 0 get s 39
106bc_imm ins s get r 22 get r 22 BCNONE 4
107bc_imm ins s get r 23 get r 8 get r 10 get s 35
108end
109fn bc_decode ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
110wq = get s 11
111word = get s 12
112byteidx = get s 13
113if lt byteidx 3
114put s 8 shl ulong 1 sub ulong 20 mul byteidx 8
115put s 9 word
116bc_imad ins s 8 get r 55 wq BCNONE
117else
118bc_shift ins s get r 55 wq word 4
119end
120bc_mask ins s get r 56 get r 55 0 shl ulong 127 20
121bc_mask ins s get r 57 wq word shl ulong 128 mul byteidx 8
122put s 8 1
123if lt byteidx 3
124put s 8 shl ulong 1 sub ulong 24 mul byteidx 8
125end
126put s 9 0
127bc_imad ins s 8 get r 58 get r 57 get r 56
128end
129fn bc_xloads ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
130for q ulong get s 38
131put s 8 mul q 16
132bc_mem ins s 57 get r add q 48 get r 26 get s 10
133put s 10 3
134end
135end
136fn bc_loads ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
137put s 10 2
138if eq get s 36 0
139bc_xloads ins s r
140end
141bc_wide ins s get r 53 get r 12 get r 25 0
142for row ulong get s 34
143put s 8 mul row get s 32
144op = ulong 56
145if eq get s 33 16
146op = 57
147end
148dst = get r add 33 mul row 2
149bc_mem ins s op dst get r 24 get s 10
150put s 10 3
151end
152put s 8 0
153bc_mem ins s 11 get r 52 get r 53 3
154if eq get s 36 1
155bc_xloads ins s r
156end
157end
158fn bc_dotword ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
159for byteidx ulong 4
160put s 13 byteidx
161bc_decode ins s r
162put s 9 byteidx
163bc_ffma ins s get r 54 get r 58 get r add get s 12 48 get r 54
164end
165end
166fn bc_accum ins edit ulong 8192 s edit ulong 64 r view ulong 64 row ulong to void
167put s 9 0
168acc = get r add 32 mul row 2
169bc_ffma ins s acc get r 54 get r 52 acc
170end
171fn bc_dot ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
172for row ulong get s 34
173bc_inst ins s 1 get r 54 BCNONE 0
174put s 11 get r add 33 mul row 2
175for word ulong get s 38
176put s 12 word
177bc_dotword ins s r
178end
179bc_accum ins s r row
180end
181end
182fn bc_reduce ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
183for row ulong get s 34
184acc = get r add 32 mul row 2
185for q ulong 5
186bc_node s 42 get r 59 acc BCNONE BCNONE
187put s 22 shr ulong 16 q
188bc_emit ins s 2
189bc_node s 30 acc acc get r 59 BCNONE
190bc_emit ins s 0
191end
192end
193end
194fn bc_epilogue ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
195bc_reduce ins s r
196bc_wide ins s get r 27 get r 23 get r 19 mul get s 34 4
197bc_pred ins s get r 11 get r 12
198put s 13 get s 0
199bc_node s 54 BCNONE BCNONE BCNONE BCNONE
200put s 22 2
201bc_emit ins s 9
202put s 14 bc_branch ins s add get s 0 1 true
203for row ulong get s 34
204bc_wide ins s get r 28 get r 12 get r 27 mul row 4
205bc_node s 12 BCNONE get r 28 get r add 32 mul row 2 BCNONE
206put s 21 0
207bc_emit ins s 5
208end
209put s 15 get s 0
210bc_node s 55 BCNONE BCNONE BCNONE BCNONE
211bc_emit ins s 10
212bc_patch ins get s 14 get s 15
213bc_patch ins get s 13 add get s 15 1
214end
215fn bc_prcheck spec view ulong 8 to uint
216if or eq get spec 0 0 gt get spec 0 32768
217ret 1
218end
219if and ne get spec 1 8 ne get spec 1 16
220ret 1
221end
222if and ne get spec 2 1 and ne get spec 2 2 and ne get spec 2 4 ne get spec 2 8
223ret 1
224end
225if or eq get spec 3 0 gt get spec 3 32
226ret 1
227end
228if ne rem get spec 0 mul get spec 1 32 0
229ret 1
230end
231if gt get spec 4 1
232ret 1
233end
234for k ulong 3
235if ne get spec add k 5 0
236ret 1
237end
238end
239ret 0
240end
241fn bc_prbody ins edit ulong 8192 s edit ulong 64 r view ulong 64 to void
242bc_prologue ins s r
243put s 41 get s 0
244bc_pred ins s get r 23 get r 3
245put s 42 bc_branch ins s add get s 0 1 true
246bc_wide ins s get r 24 get r 23 get r 15 mul get s 34 get s 32
247bc_wide ins s get r 24 get r 21 get r 24 1
248bc_shift ins s get r 29 get r 23 0 get s 40
249bc_wide ins s get r 25 get r 29 get r 16 div get s 32 32
250bc_wide ins s get r 25 get r 22 get r 25 1
251bc_wide ins s get r 26 get r 12 get r 20 0
252for row ulong get s 34
253bc_inst ins s 1 get r add 32 mul row 2 BCNONE 0
254end
255bc_inst ins s 2 get r 30 BCNONE get s 37
256put s 43 get s 0
257bc_loads ins s r
258bc_dot ins s r
259bc_wide ins s get r 24 get r 12 get r 24 mul get s 33 32
260bc_wide ins s get r 26 get r 12 get r 26 mul get s 33 128
261bc_wide ins s get r 25 get r 12 get r 25 get s 33
262bc_imm ins s get r 30 get r 12 get r 30 4294967295
263bc_pred ins s get r 30 get r 12
264at = bc_branch ins s get s 43 true
265bc_epilogue ins s r
266bc_imm ins s get r 23 get r 6 get r 23 1
267at = bc_branch ins s get s 41 false
268bc_patch ins get s 42 get s 0
269bc_node s 45 BCNONE BCNONE BCNONE BCNONE
270bc_emit ins s 7
271at = bc_branch ins s get s 0 false
272note Historical tail BRA has exact fixed control independent of scheduler pending.
273bc_tail ins at
274end
275fn bc_project spec view ulong 8 ins edit ulong 8192 m edit ulong 2048 stats edit ulong 4 to uint
276if ne bc_prcheck spec 0
277ret 1
278end
279s = new ulong 64 0
280r = new ulong 64 0
281for k ulong 2048
282put m k 0
283end
284for k ulong 8192
285put ins k 0
286end
287for k ulong 5
288put s add k 32 get spec k
289end
290put s 37 div get spec 0 mul get spec 1 32
291put s 38 div get spec 1 4
292put s 39 bc_log div ulong 128 get spec 1
293put s 40 bc_log div ulong 128 get spec 2
294bc_initregs m s r
295bc_prbody ins s r
296if ne get s 3 0
297ret 2
298end
299put stats 0 get s 0
300put stats 1 get s 4
301put stats 2 get s 5
302put stats 3 0
303ret 0
304end