interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / nvidia / om / components / rowpipe.om

435 lines · 11577 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Exact source: CUDApp b759afc3 src/omega_blackwell_codegen_moe2.c and moe.h.
3note Concatenate bw_alloc,bw_effect,bw_project,rowpipe. No solving or encoding here.
4note Frozen spec8:0K,1lane_bytes,2rows,3warps,4mutant MUST0,5..7reserved MUST0.
5note Unlike ignored C tuning fields this interface never silently accepts variants.
6note Returns0 unsolved IR,1 refused spec,2 emitter capacity. Outputs zero on refusal.
7note stats4=count,vregs,uvregs,sharedBytes; launch declares one CTA barrier.
8note SB_B data waits only at first takeover; SB_RD protects each load address.
9note Runtime loop consumes every issued B set before EXIT; branch/reconvergence order unchanged.
10note Private state32..41shape,42..48branchsites,49partial,50step,51row,52word,
11note 53weight,54dot/acc,55dot,56scale,57sharedoffset;10..12lowering scratch.
12note Shape admission does not solve resources: caller globally allocates with limit128.
13fn rp_check spec view ulong 8 to uint
14if or eq get spec 0 0 gt get spec 0 32768
15ret 1
16end
17if and ne get spec 1 8 ne get spec 1 16
18ret 1
19end
20if and ne get spec 2 1 and ne get spec 2 2 and ne get spec 2 4 ne get spec 2 8
21ret 1
22end
23if or eq get spec 3 0 gt get spec 3 32
24ret 1
25end
26for j ulong 4
27if ne get spec add j 4 0
28ret 1
29end
30end
31if ne rem get spec 0 mul get spec 1 32 0
32ret 1
33end
34ks = div get spec 0 mul get spec 1 32
35if or gt ks 16 gt mul mul get spec 2 ks get spec 1 128
36ret 1
37end
38if gt get spec 0 mul get spec 3 512
39ret 1
40end
41if ge add mul sub get spec 2 1 get spec 0 get spec 1 shl ulong 1 23
42ret 1
43end
44ret 0
45end
46fn rp_zero ins edit ulong 8192 m edit ulong 2048 stats edit ulong 4 to void
47for j ulong 8192
48put ins j 0
49end
50for j ulong 2048
51put m j 0
52end
53for j ulong 4
54put stats j 0
55end
56end
57fn rp_widx row ulong step ulong to ulong
58ret add ulong 64 mul add mul row 16 step 2
59end
60fn rp_regrow m edit ulong 2048 s edit ulong 64 r edit ulong 512 row ulong to void
61uv = bc_vreg s m 1 false
62put r add 32 mul row 2 uv
63uv = bc_vreg s m 1 false
64put r add 33 mul row 2 uv
65for step ulong get s 36
66idx = rp_widx row step
67uv = bc_vreg s m get s 38 false
68put r idx uv
69uv = bc_vreg s m get s 38 false
70put r add idx 1 uv
71end
72end
73fn rp_regs m edit ulong 2048 s edit ulong 64 r edit ulong 512 to void
74uv = bc_vreg s m 2 true
75for j ulong 24
76w = ulong 1
77if or lt j 3 or and ge j 14 le j 16 and ge j 18 le j 19
78w = 2
79end
80put r j bc_vreg s m w false
81end
82put r 24 bc_vreg s m 4 false
83for row ulong get s 34
84rp_regrow m s r row
85end
86for step ulong get s 36
87put r add 320 mul step 2 bc_vreg s m 1 false
88put r add 321 mul step 2 bc_vreg s m 1 false
89end
90for j ulong 7
91w = ulong 1
92if lt j 5
93w = 2
94end
95put r add j 25 bc_vreg s m w false
96end
97for j ulong 5
98put r add j 48 bc_vreg s m 1 false
99end
100for j ulong 9
101w = ulong 1
102if eq j 0
103w = 2
104end
105put r add j 352 bc_vreg s m w false
106end
107for j ulong get s 41
108put r add 384 mul j 2 bc_vreg s m 2 false
109put r add 385 mul j 2 bc_vreg s m 1 false
110end
111end
112fn rp_start ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
113bc_node s 7 0 BCNONE BCNONE BCNONE
114put s 22 856
115put s 23 1
116bc_emit ins s 4
117for j ulong 7
118op = ulong 4
119if lt j 3
120op = 5
121end
122bc_node s op get r j BCNONE BCNONE BCNONE
123put s 22 add ulong 896 mul j 8
124if ge j 3
125put s 22 add ulong 920 mul sub j 3 4
126end
127bc_emit ins s 2
128end
129for j ulong 3
130bc_node s 3 get r add j 7 BCNONE BCNONE BCNONE
131put s 22 33
132if eq j 1
133put s 22 37
134end
135if eq j 2
136put s 22 38
137end
138bc_emit ins s 2
139end
140bc_inst ins s 2 get r 12 BCNONE 1
141bc_shift ins s get r 10 get r 7 0 5
142bc_mask ins s get r 11 get r 7 0 31
143bc_imm ins s get r 13 get r 9 BCNONE 1
144bc_wide ins s get r 14 get r 13 get r 0 16
145put s 8 0
146bc_mem ins s 56 get r 15 get r 14 2
147put s 8 8
148bc_mem ins s 56 get r 16 get r 14 3
149bc_node s 8 get r 17 get r 9 get r 4 BCNONE
150bc_emit ins s 0
151bc_wide ins s get r 18 get r 17 get r 1 1
152bc_node s 8 get r 17 get r 9 get r 5 BCNONE
153bc_emit ins s 0
154bc_wide ins s get r 19 get r 17 get r 2 1
155bc_imm ins s get r 20 get r 11 BCNONE get s 33
156bc_shift ins s get r 21 get r 11 0 get s 39
157bc_imm ins s get r 21 get r 21 BCNONE 4
158bc_imm ins s get r 22 get r 8 get r 10 get s 35
159bc_imm ins s get r 23 get r 22 BCNONE 1
160end
161fn rp_clamp ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
162bc_imm ins s get r 356 get r 7 BCNONE 1
163put s 8 mul mul sub get s 41 1 32 get s 35
164put s 9 0
165bc_imad ins s 8 get r 356 get r 12 get r 356
166bc_imm ins s get r 358 get r 356 BCNONE 4294967295
167bc_imm ins s get r 358 get r 12 get r 358 sub get s 32 1
168bc_shift ins s get r 357 get r 358 0 31
169bc_imm ins s get r 358 get r 356 BCNONE 1
170put s 8 and sub ulong 0 get s 32 4294967295
171put s 9 0
172bc_imad ins s 8 get r 358 get r 12 get r 358
173bc_node s 8 get r 359 get r 357 get r 358 BCNONE
174bc_emit ins s 0
175bc_imm ins s get r 359 get r 359 get r 356 4294967295
176bc_imm ins s get r 360 get r 358 BCNONE 1
177bc_imm ins s get r 360 get r 12 get r 360 1
178bc_node s 8 get r 360 get r 357 get r 360 BCNONE
179bc_emit ins s 0
180bc_imm ins s get r 360 get r 360 get r 356 4294967295
181bc_wide ins s get r add 384 mul sub get s 41 1 2 get r 360 get r 18 4
182bc_imm ins s get r 355 get r 359 BCNONE 4
183end
184fn rp_stage ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
185put s 49 rem get s 32 mul get s 35 32
186bc_wide ins s get r 352 get r 7 get r 18 4
187bc_imm ins s get r 353 get r 7 BCNONE 4
188for j ulong get s 41
189put s 8 mul mul j 128 get s 35
190put s 9 0
191bc_imad ins s 9 get r add 384 mul j 2 get r 12 get r 352
192end
193if ne get s 49 0
194rp_clamp ins s r
195end
196for j ulong get s 41
197put s 8 0
198kind = ulong 3
199if eq j 0
200kind = 2
201end
202put s 10 get r add 385 mul j 2
203put s 11 get r add 384 mul j 2
204bc_mem ins s 11 get s 10 get s 11 kind
205end
206for j ulong get s 41
207if and ne get s 49 0 eq j sub get s 41 1
208bc_node s 50 BCNONE get r 355 get r add 385 mul j 2 BCNONE
209bc_emit ins s 5
210else
211put s 8 mul mul j 128 get s 35
212put s 9 0
213bc_imad ins s 8 get r 354 get r 12 get r 353
214bc_node s 50 BCNONE get r 354 get r add 385 mul j 2 BCNONE
215bc_emit ins s 5
216end
217end
218bc_node s 48 BCNONE BCNONE BCNONE BCNONE
219bc_emit ins s 6
220bc_imm ins s get r 31 get r 11 BCNONE mul get s 33 4
221end
222fn rp_loadrow ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
223put s 8 mul get s 51 get s 32
224put s 12 mul get s 50 32
225put s 12 mul get s 12 get s 33
226put s 8 add get s 8 get s 12
227put s 12 rp_widx get s 51 get s 50
228put s 12 get r add get s 12 1
229bc_mem ins s get s 11 get s 12 get r 25 get s 10
230put s 10 12
231end
232fn rp_issue ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
233bc_wide ins s get r 25 get r 22 get r 15 mul get s 34 get s 32
234bc_wide ins s get r 25 get r 20 get r 25 1
235bc_shift ins s get r 30 get r 22 0 get s 40
236bc_wide ins s get r 26 get r 30 get r 16 div get s 32 32
237bc_wide ins s get r 26 get r 21 get r 26 1
238put s 10 11
239put s 11 56
240if eq get s 33 16
241put s 11 57
242end
243for step ulong get s 36
244for row ulong get s 34
245put s 50 step
246put s 51 row
247rp_loadrow ins s r
248end
249end
250for step ulong get s 36
251if eq step 0
252put s 8 0
253bc_mem ins s 11 get r 321 get r 26 get s 10
254else
255put s 8 mul mul step get s 37 4
256put s 9 0
257bc_imad ins s 9 get r 27 get r 12 get r 26
258put s 8 0
259bc_mem ins s 11 get r add 321 mul step 2 get r 27 12
260end
261put s 10 12
262end
263bc_imm ins s get r 22 get r 6 get r 22 1
264end
265fn rp_takerow ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
266idx = rp_widx get s 51 get s 50
267for word ulong get s 38
268bc_node s 8 get r idx get r add idx 1 BCNONE BCNONE
269put s 22 1
270put s 23 or shl word 16 shl word 24
271bc_emit ins s get s 10
272put s 10 0
273end
274end
275fn rp_take ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
276put s 10 13
277for step ulong get s 36
278for row ulong get s 34
279put s 50 step
280put s 51 row
281rp_takerow ins s r
282end
283end
284for step ulong get s 36
285put s 10 get r add 320 mul step 2
286put s 11 get r add 321 mul step 2
287bc_imm ins s get s 10 get s 11 BCNONE 1
288end
289end
290fn rp_decode ins edit ulong 8192 s edit ulong 64 r view ulong 512 wq ulong word ulong byteidx ulong to void
291if lt byteidx 3
292put s 8 shl ulong 1 sub ulong 20 mul byteidx 8
293put s 9 word
294bc_imad ins s 8 get r 48 wq BCNONE
295else
296bc_shift ins s get r 48 wq word 4
297end
298bc_mask ins s get r 49 get r 48 0 shl ulong 127 20
299bc_mask ins s get r 50 wq word shl ulong 128 mul byteidx 8
300put s 8 1
301if lt byteidx 3
302put s 8 shl ulong 1 sub ulong 24 mul byteidx 8
303end
304put s 9 0
305bc_imad ins s 8 get r 51 get r 50 get r 49
306end
307fn rp_dotrow ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
308put s 53 get r rp_widx get s 51 get s 50
309put s 54 get r add 33 mul get s 51 2
310for byteidx ulong 4
311rp_decode ins s r get s 53 get s 52 byteidx
312put s 9 byteidx
313bc_ffma ins s get s 54 get r 51 get r 24 get s 54
314end
315end
316fn rp_step ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
317put s 57 mul get s 50 128
318put s 57 mul get s 57 get s 33
319put s 56 get r add 320 mul get s 50 2
320for row ulong get s 34
321bc_inst ins s 1 get r add 33 mul row 2 BCNONE 0
322end
323for word ulong get s 38
324put s 52 word
325bc_node s 58 get r 24 get r 31 BCNONE BCNONE
326put s 22 mul word 16
327put s 22 add get s 22 get s 57
328bc_emit ins s 2
329for row ulong get s 34
330put s 51 row
331rp_dotrow ins s r
332end
333end
334for row ulong get s 34
335put s 9 0
336put s 54 get r add 32 mul row 2
337put s 55 get r add 33 mul row 2
338bc_ffma ins s get s 54 get s 55 get s 56 get s 54
339end
340end
341fn rp_compute ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
342for row ulong get s 34
343bc_inst ins s 1 get r add 32 mul row 2 BCNONE 0
344end
345for step ulong get s 36
346put s 50 step
347rp_step ins s r
348end
349end
350fn rp_store ins edit ulong 8192 s edit ulong 64 r view ulong 512 to void
351for row ulong get s 34
352put s 54 get r add 32 mul row 2
353for j ulong 5
354bc_node s 42 get r 52 get s 54 BCNONE BCNONE
355put s 22 shr ulong 16 j
356bc_emit ins s 2
357bc_node s 30 get s 54 get s 54 get r 52 BCNONE
358bc_emit ins s 0
359end
360end
361bc_wide ins s get r 28 get r 23 get r 19 mul get s 34 4
362bc_pred ins s get r 11 get r 12
363put s 45 get s 0
364bc_node s 54 BCNONE BCNONE BCNONE BCNONE
365put s 22 2
366bc_emit ins s 9
367put s 46 bc_branch ins s add get s 0 1 true
368for row ulong get s 34
369bc_wide ins s get r 29 get r 12 get r 28 mul row 4
370bc_node s 12 BCNONE get r 29 get r add 32 mul row 2 BCNONE
371put s 21 0
372bc_emit ins s 5
373end
374put s 47 get s 0
375bc_node s 55 BCNONE BCNONE BCNONE BCNONE
376bc_emit ins s 10
377bc_patch ins get s 46 get s 47
378bc_patch ins get s 45 add get s 47 1
379end
380fn bc_rowpipe spec view ulong 8 ins edit ulong 8192 m edit ulong 2048 stats edit ulong 4 to uint
381s = new ulong 64 0
382r = new ulong 512 0
383rp_zero ins m stats
384if ne rp_check spec 0
385ret 1
386end
387for j ulong 4
388put s add j 32 get spec j
389end
390put s 36 div get spec 0 mul get spec 1 32
391put s 37 div mul get spec 1 32 128
392put s 38 div get spec 1 4
393put s 39 bc_log div ulong 128 get spec 1
394put s 40 bc_log div ulong 128 get spec 2
395put s 10 mul get spec 3 32
396put s 41 add get spec 0 get s 10
397put s 41 sub get s 41 1
398put s 41 div get s 41 get s 10
399rp_regs m s r
400rp_start ins s r
401rp_stage ins s r
402bc_pred ins s get r 22 get r 3
403put s 42 bc_branch ins s add get s 0 1 true
404rp_issue ins s r
405put s 43 get s 0
406rp_take ins s r
407bc_pred ins s get r 22 get r 3
408put s 44 bc_branch ins s add get s 0 1 true
409rp_issue ins s r
410bc_patch ins get s 44 get s 0
411rp_compute ins s r
412rp_store ins s r
413bc_imm ins s get r 23 get r 6 get r 23 1
414bc_pred ins s get r 23 get r 3
415put s 48 bc_branch ins s add get s 0 1 true
416at = bc_branch ins s get s 43 false
417bc_patch ins get s 42 get s 0
418bc_patch ins get s 48 get s 0
419bc_node s 45 BCNONE BCNONE BCNONE BCNONE
420bc_emit ins s 7
421at = bc_branch ins s get s 0 false
422bc_tail ins at
423if ne get s 3 0
424rp_zero ins m stats
425ret 2
426end
427put stats 0 get s 0
428put stats 1 get s 4
429put stats 2 get s 5
430put stats 3 mul get s 32 4
431if ne rem get s 32 mul get s 35 32 0
432put stats 3 add get stats 3 16
433end
434ret 0
435end