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 / om / gpu / dsv41 / head / launch.om

174 lines · 3467 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
2note Code is generated from the same emitter as the cubins and placed at 256-byte QMD alignments.
3global codePos ulong 1
4global entry ulong 38
5global codeMap long 1
6global codeWriteFailed uint 1
7global bindings uint 16
8global bindingCount ulong 1
9global frameDirty uint 1
10fn dsWrite w view ulong 4 to void
11p = get codePos 0
12b = new uchar 16 0
13if gt get codeMap 0 0
14for i ulong 16
15put b i uchar and shr get w div i 4 mul rem i 4 8 255
16end
17if ne mapwrite get codeMap 0 p b 0 16 16
18put codeWriteFailed 0 1
19end
20end
21put codePos 0 add p 16
22end
23fn vocabularyDot to void
24note One warp per vocabulary row. Each lane accumulates 80 pairs, then the warp sums in FP32.
25dsStart 3
26mad 20 15 2560 14
27mad 21 14 1 Z
28literal 22 0
29literal 23 10
30literal 24 1
31literal 25 256
32number 26 0.0f32
33mark = get dsPc 0
34for pair ulong 8
35readAt 27 0 21 mul pair 128
36readAt 28 2 20 mul pair 128
37mad 29 27 65536 Z
38mad 30 28 65536 Z
39fmaReg 26 29 30 26
40inst 18 29 27 Z Z 0xffff0000
41inst 18 30 28 Z Z 0xffff0000
42fmaReg 26 29 30 26
43end
44iadd 20 20 25
45iadd 21 21 25
46nextLoop 22 23 mark 24
47for stage ulong 5
48inst 42 27 26 Z Z shr 16 stage
49fop 30 26 26 27
50end
51inst 28 Z 14 24 Z 0
52inst 9 16 15 Z 4 4
53put dsGuard 0 2
54inst 12 Z 16 26 Z 0
55end
56fn headRms to void
57note Sum squared BF16 hidden elements in 32 lane-local FP32 partials before reducing across the warp.
58dsStart 2
59mad 20 14 1 Z
60literal 21 0
61literal 22 20
62literal 23 1
63literal 24 256
64number 25 0.0f32
65mark = get dsPc 0
66for k ulong 8
67readAt 26 0 20 mul k 128
68fmaReg 25 26 26 25
69end
70iadd 20 20 24
71nextLoop 21 22 mark 23
72for stage ulong 5
73inst 42 26 25 Z Z shr 16 stage
74fop 30 25 25 26
75end
76number 27 0.0001953125f32
77number 28 1e-20f32
78fmaReg 25 25 27 28
79fop 41 25 25 Z
80inst 28 Z 14 23 Z 0
81put dsGuard 0 2
82inst 12 Z 2 25 Z 0
83end
84fn headEmit to void
85put codePos 0 0
86for i ulong 6
87p = mul div add get codePos 0 255 256 256
88put entry i p
89put codePos 0 p
90put dsPc 0 0
91if eq i 0
92convert true
93end
94if eq i 1
95hcPre
96end
97if eq i 2
98convert false
99end
100if eq i 3
101headRms
102end
103if eq i 4
104rmsApply
105end
106if eq i 5
107vocabularyDot
108end
109done
110end
111end
112fn headArg v uint to void
113i = get bindingCount 0
114put bindings i v
115put bindingCount 0 add i 1
116end
117fn headPtr m long to void
118a = mapaddr m
119headArg gblo a
120headArg gbhi a
121end
122fn recordHeadKernel id ulong grid uint threads uint to bool
123 shape = new uint 4 1
124 put shape 0 grid
125 put shape 3 threads
126 ret recordDsGrid id shape
127end
128fn recordDsGrid id ulong shape view uint 4 to bool
129gbqmd 1
130a = add mapaddr get codeMap 0 get entry id
131put gbq1 32 gblo shr a 4
132put gbq1 33 or uint and shr a 36 2097151 20971520
133put gbq1 59 gblo shr a 8
134put gbq1 34 or 65536 get shape 3
135put gbq1 35 or 131073 shl uint 64 8
136put gbq1 39 get shape 0
137put gbq1 40 get shape 1
138put gbq1 41 get shape 2
139put gbcb 216 get shape 3
140put gbcb 220 get shape 0
141put gbcb 221 get shape 1
142put gbcb 222 get shape 2
143cb = mapaddr get gbmem 1
144words = get bindingCount 0
145endva = add cb add 896 mul words 4
146put gbcb 212 gbhi endva
147put gbcb 213 gblo endva
148put gbused 0 0
149gbsetup
150if ne get frameDirty 0 0
151note Invalidate stale sysmem cache lines after CPU writes, before the first GPU load.
152gbmth 0 40 4
153gbemit 0
154gbemit 0
155gbemit 0
156gbemit 2281701376
157put frameDirty 0 0
158end
159gbdma cb 224
160for j ulong 224
161gbemit get gbcb j
162end
163gbdma add cb 896 uint words
164for j ulong words
165gbemit get bindings j
166end
167q = mapaddr get gbmem 2
168gbinline q false
169gbdma add q 8192 1
170gbemit 1
171gbinline add q 4096 true
172put bindingCount 0 0
173ret gbappend id get gbst 1
174end