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
omega-mv / om / gpu / dsv41 / decoder / native.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note The first six entries remain the native head catalogue. Append the 28 |
| 3 | note backbone kernels in kernels.list order, followed by the 2 SM121a QMMA |
| 4 | note kernels (28 = mmaFp4, 29 = mmaFp8Block), and keep one immutable code image. |
| 5 | text dnKinds "abcdefghijklmnopqrstuvwxyzAB" |
| 6 | |
| 7 | fn dnIns lo ulong hi ulong to void |
| 8 | w = new ulong 4 0 |
| 9 | put w 0 and lo 4294967295 |
| 10 | put w 1 shr lo 32 |
| 11 | put w 2 and hi 4294967295 |
| 12 | put w 3 shr hi 32 |
| 13 | dsWrite w |
| 14 | end |
| 15 | |
| 16 | note Calibrated SM121a single-row mixed FP8xFP4 QMMA (1 warp = 8 rows, K%32==0, N%8==0). |
| 17 | fn dnEmitMmaFp4 to void |
| 18 | dnIns 0x0000df00ff017b82 0x000fe20000000800 |
| 19 | dnIns 0x00000000000c7919 0x000e2e0000000000 |
| 20 | dnIns 0x0000ea00ff107b82 0x000e620000000800 |
| 21 | dnIns 0x00007000ff0877ac 0x000ea20008000c00 |
| 22 | dnIns 0x000000ff00137202 0x000fe20000000f00 |
| 23 | dnIns 0x0000000000007919 0x000ee20000002500 |
| 24 | dnIns 0x00006b00ff0677ac 0x000f280008000a00 |
| 25 | dnIns 0x00000000000579c3 0x000e620000002600 |
| 26 | dnIns 0x000000ff00047c82 0x000fce0008000000 |
| 27 | dnIns 0x0000e600ff027b82 0x000f700000000a00 |
| 28 | dnIns 0x0000e400ff147b82 0x000f220000000a00 |
| 29 | dnIns 0x00000002ff0d7819 0x001fe2000001160c |
| 30 | dnIns 0x00000005100f7c24 0x002fe2000f8e02ff |
| 31 | dnIns 0x000000030c0c7812 0x000fc600078ec0ff |
| 32 | dnIns 0x0000000800057824 0x008fe400078e020d |
| 33 | dnIns 0x000000040c0e7824 0x000fe200078e020f |
| 34 | dnIns 0x000000ff000f7202 0x000fe20000000f00 |
| 35 | dnIns 0x0000001005077224 0x000fe200078e02ff |
| 36 | dnIns 0x00000005ff107819 0x000fc60000011610 |
| 37 | dnIns 0x000000040c077824 0x000fe200078e0207 |
| 38 | dnIns 0x000000080e0e7c35 0x004fe4000f8e0200 |
| 39 | dnIns 0x0000001005027225 0x020fe200078e0002 |
| 40 | dnIns 0x0000000000047805 0x000fe2000001ff00 |
| 41 | dnIns 0x00000001ff127819 0x000fe20000011607 |
| 42 | dnIns 0x0000000000067805 0x000fe2000001ff00 |
| 43 | dnIns 0x0000000510147c25 0x010fc6000f8e0014 |
| 44 | dnIns 0x0000000a12127c35 0x000fd0000f8e0200 |
| 45 | dnIns 0x0000000612097981 0x000ea8000c1e1500 |
| 46 | dnIns 0x0000080612177981 0x0000e8000c1e1500 |
| 47 | dnIns 0x000000060e087981 0x000f28000c1e1900 |
| 48 | dnIns 0x000010060e0a7981 0x000368000c1e1900 |
| 49 | dnIns 0x0000000614117981 0x000368000c1e1100 |
| 50 | dnIns 0x0000000602167981 0x000362000c1e1100 |
| 51 | dnIns 0x0000000104047890 0x000fe2000fffe0ff |
| 52 | dnIns 0x0000001012127835 0x001fc400078e0200 |
| 53 | dnIns 0x000000200e0e7835 0x002fe400078e0200 |
| 54 | dnIns 0x0000000114147835 0x000fe400078e0200 |
| 55 | dnIns 0x0000000410007c0c 0x000fe2000bf03070 |
| 56 | dnIns 0x0000000102027835 0x000fc600078e0200 |
| 57 | dnIns 0x0000000f090b7812 0x044fe400078ec0ff |
| 58 | dnIns 0x000000f009187812 0x000fe400078ec0ff |
| 59 | dnIns 0x0000000f17197812 0x048fe400078ec0ff |
| 60 | dnIns 0x000000f0171a7812 0x000fe200078ec0ff |
| 61 | dnIns 0x00000010180b7824 0x000fe200078e020b |
| 62 | dnIns 0x00000f0009187812 0x000fc600078ec0ff |
| 63 | dnIns 0x000000101a197824 0x000fe200078e0219 |
| 64 | dnIns 0x00000f00171a7812 0x000fe200078ec0ff |
| 65 | dnIns 0x00000100180b7824 0x000fe200078e020b |
| 66 | dnIns 0x0000f00009187812 0x000fe200078ec0ff |
| 67 | dnIns 0x0000000800097202 0x010fe40000000f00 |
| 68 | dnIns 0x000001001a197824 0x000fe200078e0219 |
| 69 | dnIns 0x0000f000171a7812 0x000fe200078ec0ff |
| 70 | dnIns 0x0000100018187824 0x000fe200078e020b |
| 71 | dnIns 0x0000000a000b7202 0x020fc60000000f00 |
| 72 | dnIns 0x000010001a197824 0x000fe400078e0219 |
| 73 | dnIns 0x0000000418187824 0x000fe400078e00ff |
| 74 | dnIns 0x0000000419197824 0x000fce00078e00ff |
| 75 | dnIns 0x716011180804747a 0x000fe2000020be04 |
| 76 | dnIns 0x0000000000007918 0x000fda0000000000 |
| 77 | dnIns 0xfffffffc007c8947 0x000fde000383ffff |
| 78 | dnIns 0x000000ff0d00720c 0x000fda0003f05070 |
| 79 | dnIns 0x000000000000094d 0x000fea0003800000 |
| 80 | dnIns 0x0000dc00ff077b82 0x000e300000000800 |
| 81 | dnIns 0x0000e800ff027b82 0x000e620000000a00 |
| 82 | dnIns 0x0000000507077c24 0x001fc8000f8e0200 |
| 83 | dnIns 0x0000000407077824 0x000fc800078e020c |
| 84 | dnIns 0x0000000207077824 0x000fc800078e00ff |
| 85 | dnIns 0x0000000407027825 0x002fca00078e0002 |
| 86 | dnIns 0x0000000402007986 0x000fe2000c101b06 |
| 87 | dnIns 0x000000000000794d 0x000fea0003800000 |
| 88 | dnIns 0xfffffffc00fc7947 0x000fc0000383ffff |
| 89 | for i ulong 9 |
| 90 | dnIns 0x0000000000007918 0x000fc00000000000 |
| 91 | end |
| 92 | end |
| 93 | |
| 94 | note Calibrated SM121a single-row FP8xFP8 QMMA with 32x32 block weight scales ([N/32, K/32]). |
| 95 | fn dnEmitMmaFp8Block to void |
| 96 | dnIns 0x0000df00ff017b82 0x000fe20000000800 |
| 97 | dnIns 0x0000000000007919 0x000e2e0000000000 |
| 98 | dnIns 0x0000ea00ff047b82 0x000e620000000800 |
| 99 | dnIns 0x00007000ff0877ac 0x000ea20008000c00 |
| 100 | dnIns 0x00000000000c7919 0x000ee20000002500 |
| 101 | dnIns 0x00006b00ff0677ac 0x000f2a0008000a00 |
| 102 | dnIns 0x00000000000579c3 0x000f620000002600 |
| 103 | dnIns 0x000000ff00047c82 0x000fce0008000000 |
| 104 | dnIns 0x0000e600ff027b82 0x000eb00000000a00 |
| 105 | dnIns 0x0000e400ff127b82 0x000f220000000a00 |
| 106 | dnIns 0x00000005ff157819 0x002fe40000011604 |
| 107 | dnIns 0x00000002ff0d7819 0x001fe20000011600 |
| 108 | dnIns 0x0000000504077c24 0x020fe2000f8e02ff |
| 109 | dnIns 0x0000000300007812 0x000fc600078ec0ff |
| 110 | dnIns 0x000000080c057824 0x008fc800078e020d |
| 111 | dnIns 0x0000000405097224 0x040fe400078e02ff |
| 112 | dnIns 0x00000005ff1a7819 0x000fcc0000011605 |
| 113 | dnIns 0x0000000400047824 0x000fe200078e0207 |
| 114 | dnIns 0x000000ff00077202 0x000fe20000000f00 |
| 115 | dnIns 0x000000151a027225 0x004fe200078e0002 |
| 116 | dnIns 0x000000ff00057202 0x000fc60000000f00 |
| 117 | dnIns 0x0000000400067824 0x000fe400078e0209 |
| 118 | dnIns 0x00000008040e7c35 0x000fe4000f8e0200 |
| 119 | dnIns 0x000000ff00047202 0x000fe20000000f00 |
| 120 | dnIns 0x0000000a06107c35 0x000fe4000f8e0200 |
| 121 | dnIns 0x000000ff00057202 0x000fe20000000f00 |
| 122 | dnIns 0x000000ff00067202 0x000fe20000000f00 |
| 123 | dnIns 0x000000ff00077202 0x000fe20000000f00 |
| 124 | dnIns 0x0000000515127c25 0x010fce000f8e0012 |
| 125 | dnIns 0x000000060e087981 0x000ea8000c1e1900 |
| 126 | dnIns 0x000010060e0a7981 0x0000e8000c1e1900 |
| 127 | dnIns 0x0000000612147981 0x000328000c1e1100 |
| 128 | dnIns 0x0000000602177981 0x000b28000c1e1100 |
| 129 | dnIns 0x0000000610187981 0x000f28000c1e1900 |
| 130 | dnIns 0x0000100610197981 0x000b22000c1e1900 |
| 131 | dnIns 0x0000000104047890 0x000fe2000fffe0ff |
| 132 | dnIns 0x000000200e0e7835 0x001fc400078e0200 |
| 133 | dnIns 0x0000000112127835 0x002fe400078e0200 |
| 134 | dnIns 0x0000000102027835 0x020fe400078e0200 |
| 135 | dnIns 0x0000000415007c0c 0x000fe2000bf03070 |
| 136 | dnIns 0x0000002010107835 0x000fe400078e0200 |
| 137 | dnIns 0x0000000800097202 0x004fe20000000f00 |
| 138 | dnIns 0x0000000a000b7202 0x008fce0000000f00 |
| 139 | dnIns 0x717014180804747a 0x010fe40000003e04 |
| 140 | dnIns 0x0000000000007918 0x000fd80000000000 |
| 141 | dnIns 0xfffffffc00bc8947 0x000fde000383ffff |
| 142 | dnIns 0x000000ff0d00720c 0x000fda0003f05070 |
| 143 | dnIns 0x000000000000094d 0x000fea0003800000 |
| 144 | dnIns 0x0000dc00ff077b82 0x000e300000000800 |
| 145 | dnIns 0x0000e800ff027b82 0x000e620000000a00 |
| 146 | dnIns 0x0000000507077c24 0x001fc8000f8e020c |
| 147 | dnIns 0x0000000407077824 0x000fc800078e0200 |
| 148 | dnIns 0x0000000207077824 0x000fc800078e00ff |
| 149 | dnIns 0x0000000407027825 0x002fca00078e0002 |
| 150 | dnIns 0x0000000402007986 0x000fe2000c101b06 |
| 151 | dnIns 0x000000000000794d 0x000fea0003800000 |
| 152 | dnIns 0xfffffffc00fc7947 0x000fc0000383ffff |
| 153 | for i ulong 7 |
| 154 | dnIns 0x0000000000007918 0x000fc00000000000 |
| 155 | end |
| 156 | end |
| 157 | |
| 158 | note Warp-parallel RMS statistic (1 warp = 32 threads, d % 32 == 0). |
| 159 | fn dnEmitRmsStatWarp to void |
| 160 | dsStart 2 |
| 161 | parameter 20 16 |
| 162 | madreg 21 15 20 Z |
| 163 | mad 23 14 1 Z |
| 164 | literal 24 32 |
| 165 | number 22 0.0f32 |
| 166 | mark = get dsPc 0 |
| 167 | iadd 25 21 23 |
| 168 | readAt 25 0 25 0 |
| 169 | fmaReg 22 25 25 22 |
| 170 | nextLoop 23 20 mark 24 |
| 171 | for stage ulong 5 |
| 172 | inst 42 26 22 Z Z shr 16 stage |
| 173 | fop 30 22 22 26 |
| 174 | end |
| 175 | fop 38 25 20 Z |
| 176 | fop 40 25 25 Z |
| 177 | number 26 1e-20f32 |
| 178 | fmaReg 22 22 25 26 |
| 179 | fop 41 22 22 Z |
| 180 | literal 27 1 |
| 181 | inst 28 Z 14 27 Z 0 |
| 182 | inst 9 16 15 Z 2 4 |
| 183 | put dsGuard 0 2 |
| 184 | inst 12 Z 16 22 Z 0 |
| 185 | end |
| 186 | |
| 187 | note Warp-parallel FP32 dense GEMV (1 warp per output row, K % 32 == 0). |
| 188 | fn dnEmitDenseWarp to void |
| 189 | dsStart 3 |
| 190 | parameter 21 24 |
| 191 | parameter 22 28 |
| 192 | madreg 23 18 21 Z |
| 193 | madreg 24 15 21 Z |
| 194 | number 25 0.0f32 |
| 195 | mad 26 14 1 Z |
| 196 | literal 27 32 |
| 197 | mark = get dsPc 0 |
| 198 | iadd 28 23 26 |
| 199 | readAt 28 0 28 0 |
| 200 | iadd 29 24 26 |
| 201 | readAt 29 2 29 0 |
| 202 | fmaReg 25 28 29 25 |
| 203 | nextLoop 26 21 mark 27 |
| 204 | for stage ulong 5 |
| 205 | inst 42 28 25 Z Z shr 16 stage |
| 206 | fop 30 25 25 28 |
| 207 | end |
| 208 | literal 27 1 |
| 209 | inst 28 Z 14 27 Z 0 |
| 210 | madreg 28 18 22 15 |
| 211 | inst 9 16 28 Z 4 4 |
| 212 | put dsGuard 0 2 |
| 213 | inst 12 Z 16 25 Z 0 |
| 214 | end |
| 215 | |
| 216 | fn dnEmit to bool |
| 217 | headEmit |
| 218 | for i ulong 28 |
| 219 | pos = and add get codePos 0 255 18446744073709551360 |
| 220 | put entry add 6 i pos |
| 221 | put codePos 0 pos |
| 222 | put dsPc 0 0 |
| 223 | if not dsKernel get dnKinds i |
| 224 | ret false |
| 225 | end |
| 226 | done |
| 227 | end |
| 228 | pos = and add get codePos 0 255 18446744073709551360 |
| 229 | put entry 34 pos |
| 230 | put codePos 0 pos |
| 231 | dnEmitMmaFp4 |
| 232 | pos = and add get codePos 0 255 18446744073709551360 |
| 233 | put entry 35 pos |
| 234 | put codePos 0 pos |
| 235 | dnEmitMmaFp8Block |
| 236 | pos = and add get codePos 0 255 18446744073709551360 |
| 237 | put entry 36 pos |
| 238 | put codePos 0 pos |
| 239 | put dsPc 0 0 |
| 240 | dnEmitRmsStatWarp |
| 241 | done |
| 242 | pos = and add get codePos 0 255 18446744073709551360 |
| 243 | put entry 37 pos |
| 244 | put codePos 0 pos |
| 245 | put dsPc 0 0 |
| 246 | dnEmitDenseWarp |
| 247 | done |
| 248 | ret eq get codeWriteFailed 0 0 |
| 249 | end |
| 250 | |
| 251 | fn dnOpen to bool |
| 252 | if not dnEmit |
| 253 | ret false |
| 254 | end |
| 255 | if not gbopen 1 |
| 256 | ret false |
| 257 | end |
| 258 | if not gbbopen |
| 259 | ret false |
| 260 | end |
| 261 | mapping = nvalloc get codePos 0 false |
| 262 | if le mapping 0 |
| 263 | ret false |
| 264 | end |
| 265 | put codeMap 0 mapping |
| 266 | ret dnEmit |
| 267 | end |
| 268 | |
| 269 | note All address derivation stays within an owned RM mapping. Its allocation |
| 270 | note size is supplied by the owner; offsets are byte offsets into that region. |
| 271 | fn dnBind mapping long allocation ulong offset ulong span ulong to bool |
| 272 | if or le mapping 0 or eq span 0 gt offset allocation |
| 273 | ret false |
| 274 | end |
| 275 | if or gt span sub allocation offset gt get bindingCount 0 14 |
| 276 | ret false |
| 277 | end |
| 278 | va = add mapaddr mapping offset |
| 279 | headArg gblo va |
| 280 | headArg gbhi va |
| 281 | ret true |
| 282 | end |
| 283 | |
| 284 | fn dnRecord kernel ulong x uint y uint z uint threads uint to bool |
| 285 | if or ge kernel 32 or eq x 0 or eq y 0 eq z 0 |
| 286 | ret false |
| 287 | end |
| 288 | if or eq threads 0 gt threads 1024 |
| 289 | ret false |
| 290 | end |
| 291 | shape = new uint 4 0 |
| 292 | put shape 0 x |
| 293 | put shape 1 y |
| 294 | put shape 2 z |
| 295 | put shape 3 threads |
| 296 | ret recordDsGrid add 6 kernel shape |
| 297 | end |