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 / bw_effect.om

207 lines · 4269 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Concatenate after bw_alloc.om. No second IR: st16..23 is one existing8cell instruction.
3note st0 count,1pending,2held,3error,4nv,5nu; st8..15 temporary component args.
4fn bc_node s edit ulong 64 op ulong d ulong a ulong b ulong c ulong to void
5put s 16 op
6put s 17 d
7put s 18 a
8put s 19 b
9put s 20 c
10put s 21 BCNONE
11put s 22 0
12put s 23 0
13end
14fn bc_vreg s edit ulong 64 m edit ulong 2048 width ulong uniform bool to ulong
15k = ulong 4
16base = ulong 0
17cap = ulong 256
18if uniform
19k = 5
20base = 256
21cap = 32
22end
23v = get s k
24if ge v cap
25put s 3 1
26ret BCNONE
27end
28put s k add v 1
29put m add base v width
30ret v
31end
32fn bc_control stall ulong wb ulong rbar ulong wait ulong yield bool to ulong
33v = or or shl stall 9 shl wb 14 or shl rbar 17 shl wait 20
34if yield
35v = or v 8192
36end
37ret v
38end
39fn bc_append ins edit ulong 8192 s edit ulong 64 to void
40for k ulong 8
41put ins add mul get s 0 8 k get s add k 16
42end
43put s 0 add get s 0 1
44end
45fn bc_emit ins edit ulong 8192 s edit ulong 64 kind ulong to void
46if ge get s 0 1024
47put s 3 1
48ret
49end
50wait = get s 1
51stall = ulong 6
52wb = ulong 7
53rbar = ulong 7
54yld = false
55next = ulong 0
56if eq kind 1
57stall = 14
58end
59if or eq kind 2 eq kind 3
60stall = 4
61wb = 0
62rbar = 1
63yld = true
64next = 3
65if eq kind 3
66wait = and wait 2
67end
68end
69if eq kind 4
70stall = 4
71wb = 2
72yld = true
73next = 4
74end
75if eq kind 5
76stall = 4
77rbar = 1
78yld = true
79next = 2
80end
81if or eq kind 7 eq kind 8
82stall = 5
83if ne and get s 23 2 0
84next = wait
85end
86end
87if eq kind 9
88stall = 1
89yld = true
90end
91if eq kind 10
92stall = 5
93yld = true
94end
95note kind11/12 SB_B prefetch,13 first takeover; pending never carries SB_B.
96if or eq kind 11 eq kind 12
97stall = 4
98wb = 3
99rbar = 1
100yld = true
101next = 2
102put s 2 or get s 2 8
103if eq kind 12
104wait = and wait 2
105end
106end
107if eq kind 13
108if eq and get s 2 8 0
109put s 3 1
110ret
111end
112wait = or wait 8
113put s 2 xor get s 2 8
114end
115if gt kind 13
116put s 3 1
117ret
118end
119stall = bc_control stall wb rbar wait yld
120put s 22 or and get s 22 4294967295 shl stall 32
121put s 1 next
122bc_append ins s
123end
124fn bc_inst ins edit ulong 8192 s edit ulong 64 op ulong d ulong a ulong imm ulong to void
125bc_node s op d a BCNONE BCNONE
126put s 22 imm
127bc_emit ins s 0
128end
129fn bc_imad ins edit ulong 8192 s edit ulong 64 op ulong d ulong a ulong c ulong to void
130bc_node s op d a BCNONE c
131put s 22 get s 8
132put s 23 shl get s 9 24
133bc_emit ins s 0
134end
135fn bc_mem ins edit ulong 8192 s edit ulong 64 op ulong d ulong a ulong kind ulong to void
136bc_node s op d a BCNONE BCNONE
137put s 21 0
138put s 22 get s 8
139bc_emit ins s kind
140end
141fn bc_ffma ins edit ulong 8192 s edit ulong 64 d ulong a ulong b ulong c ulong to void
142bc_node s 33 d a b c
143put s 23 shl get s 9 32
144bc_emit ins s 0
145end
146fn bc_pred ins edit ulong 8192 s edit ulong 64 a ulong b ulong to void
147bc_node s 28 BCNONE a b BCNONE
148bc_emit ins s 1
149end
150fn bc_branch ins edit ulong 8192 s edit ulong 64 target ulong ispred bool to ulong
151at = get s 0
152bc_node s 46 BCNONE BCNONE BCNONE BCNONE
153put s 22 and sub target at 4294967295
154if ispred
155put s 23 2
156end
157bc_emit ins s 8
158ret at
159end
160fn bc_patch ins edit ulong 8192 at ulong target ulong to void
161note A refused emission can leave branchsite=count=1024; never patch an unallocated slot.
162if ge at 1024
163ret
164end
165k = add mul at 8 6
166put ins k or shl shr get ins k 32 32 and sub target at 4294967295
167end
168fn bc_tail ins edit ulong 8192 at ulong to void
169if ge at 1024
170ret
171end
172put ins add mul at 8 6 shl ulong 1032192 32
173end
174note Typed HMMA component: BF16 A quad,B pair,C/D quads; no raw solved bytes.
175note Component includes existing hmma_wait15+nop14 spacing before any external reader.
176fn bc_mma ins edit ulong 8192 s edit ulong 64 m view ulong 2048 args view ulong 4 to uint
177for j ulong 4
178if ge get args j 256
179ret 1
180end
181end
182if or ne get m get args 0 4 ne get m get args 1 4
183ret 1
184end
185if or ne get m get args 2 2 ne get m get args 3 4
186ret 1
187end
188if gt get s 0 1021
189ret 1
190end
191bc_node s 16 get args 0 get args 1 get args 2 get args 3
192put s 22 shl bc_control 8 7 7 get s 1 false 32
193put s 1 0
194if ge get s 0 1024
195ret 1
196end
197for j ulong 8
198put ins add mul get s 0 8 j get s add j 16
199end
200put s 0 add get s 0 1
201for k ulong 2
202bc_node s 0 BCNONE BCNONE BCNONE BCNONE
203bc_emit ins s 0
204put ins add mul sub get s 0 1 8 6 shl bc_control sub ulong 15 k 7 7 0 false 32
205end
206ret 0
207end