Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/om/components/realize.om # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / om / components / realize.om` 355 lines · 6865 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note CUDApp157 canonical realization v1. Concatenate after quant.om. 3 note Wire is 1152 used bytes in uchar4096; trailing bytes MUST zero. 4 note 64 LE64 metadata, eight SHA256 digests, exact QuantSchema384. 5 note Digests semantic/compiler/encoder/spec/unsolvedIR/code/launch/lineage. 6 note A nonzero digest is not evidence: caller must hash actual bytes and qualify. 7 fn compose_word b view uchar 4096 k ulong to ulong 8 v = ulong 0 9 for j ulong 8 10 v = or v shl ulong get b add mul k 8 j mul j 8 11 end 12 ret v 13 end 14 fn compose_put b edit uchar 4096 k ulong v ulong to void 15 for j ulong 8 16 put b add mul k 8 j uchar and shr v mul j 8 255 17 end 18 end 19 fn compose_digest b view uchar 4096 slot ulong h view uchar 32 to bool 20 if ge slot 8 21 ret false 22 end 23 for j ulong 32 24 if ne get b add add 512 mul slot 32 j get h j 25 ret false 26 end 27 end 28 ret true 29 end 30 fn compose_codeid b view uchar 4096 h view uchar 32 to bool 31 ret compose_digest b 5 h 32 end 33 fn compose_launchid b view uchar 4096 h view uchar 32 to bool 34 ret compose_digest b 6 h 35 end 36 note Family3 structural subset mirrors sg_valid, not artifact qualification. 37 fn compose_staged b view uchar 4096 to uint 38 mt = compose_word b 14 39 tk = compose_word b 16 40 w = compose_word b 17 41 if and ne mt 1 and ne mt 2 and ne mt 4 ne mt 8 42 ret 2 43 end 44 if ne compose_word b 15 1 45 ret 2 46 end 47 if and ne tk 256 ne tk 512 48 ret 2 49 end 50 if or eq w 0 gt w 32 51 ret 3 52 end 53 if ne and w sub w 1 0 54 ret 3 55 end 56 lb = div tk 32 57 if ne rem mul mt lb w 0 58 ret 2 59 end 60 if gt div mul mt lb w 8 61 ret 2 62 end 63 if or gt compose_word b 6 16384 ne rem compose_word b 6 tk 0 64 ret 2 65 end 66 ks = div compose_word b 6 tk 67 if and ne rem ks 2 0 gt ks 3 68 ret 2 69 end 70 u = ks 71 if eq rem ks 2 0 72 u = 2 73 end 74 note Word18 is emitted K-step unroll U for family3, not buffer depth. 75 if ne compose_word b 18 u 76 ret 2 77 end 78 required = mul mul mt 128 lb 79 if or lt compose_word b 21 required ne rem compose_word b 21 128 0 80 ret 3 81 end 82 note Keep the existing launch declaration granularity; peak+2 needs actual out8. 83 if or lt compose_word b 22 16 ne rem compose_word b 22 8 0 84 ret 3 85 end 86 if or ne compose_word b 23 6 ne compose_word b 24 1 87 ret 3 88 end 89 if or gt compose_word b 26 `4294967295` gt compose_word b 27 `4294967295` 90 ret 3 91 end 92 if or ne compose_word b 28 1 gt mul compose_word b 26 w `4294967295` 93 ret 3 94 end 95 note This FFMA family has seven non-MMA component declarations; IDs remain opaque. 96 if or ne compose_word b 29 7 ne compose_word b 32 0 97 ret 2 98 end 99 for k ulong 8 100 if ne k 2 101 if eq compose_word b add k 30 0 102 ret 2 103 end 104 end 105 end 106 ret 0 107 end 108 fn compose_check b view uchar 4096 n ulong to uint 109 d = new ulong 48 0 110 q = new uchar 384 0 111 if ne n 1152 112 ret 1 113 end 114 if or ne compose_word b 0 1 ne compose_word b 1 1152 115 ret 1 116 end 117 if ne compose_word b 2 121 118 ret 2 119 end 120 note v1 no optional feature bits: SM121 warp instruction path only, no TMA/TMEM. 121 if ne compose_word b 3 0 122 ret 2 123 end 124 for k ulong 3 125 v = compose_word b add k 4 126 if or eq v 0 gt v `16777216` 127 ret 3 128 end 129 end 130 note type tags1F32 2BF16 3E4M3 4E5M2. This bounded realization uses folded E4M3. 131 if or ne compose_word b 7 1 ne compose_word b 8 3 132 ret 2 133 end 134 if or ne compose_word b 9 1 ne compose_word b 10 1 135 ret 2 136 end 137 if or ne compose_word b 11 1 ne compose_word b 12 0 138 ret 2 139 end 140 note alias0 means disjoint input weights scales output. Admission must prove addresses. 141 if ne compose_word b 13 0 142 ret 2 143 end 144 for k ulong 6 145 if eq compose_word b add k 14 0 146 ret 3 147 end 148 end 149 if gt compose_word b 17 32 150 ret 3 151 end 152 if gt compose_word b 18 16 153 ret 3 154 end 155 if gt compose_word b 19 3 156 ret 2 157 end 158 if gt compose_word b 20 127 159 ret 2 160 end 161 if gt compose_word b 21 16384 162 ret 3 163 end 164 if or lt compose_word b 22 3 gt compose_word b 22 246 165 ret 3 166 end 167 if or lt compose_word b 23 4 gt compose_word b 23 32 168 ret 3 169 end 170 if gt compose_word b 24 16 171 ret 3 172 end 173 if ne compose_word b 25 mul compose_word b 17 32 174 ret 3 175 end 176 if gt mul compose_word b 25 compose_word b 22 65536 177 ret 3 178 end 179 for k ulong 3 180 if eq compose_word b add k 26 0 181 ret 3 182 end 183 end 184 cnt = ulong 0 185 for k ulong 8 186 if ne compose_word b add k 30 0 187 cnt = add cnt 1 188 end 189 end 190 if or eq cnt 0 ne cnt compose_word b 29 191 ret 1 192 end 193 for k ulong 26 194 if ne compose_word b add k 38 0 195 ret 1 196 end 197 end 198 for k ulong 8 199 nz = uchar 0 200 for j ulong 32 201 nz = or nz get b add add 512 mul k 32 j 202 end 203 if eq nz 0 204 ret 1 205 end 206 end 207 for j ulong 384 208 put q j get b add j 768 209 end 210 rc = quant_read q d 211 if ne rc 0 212 ret 4 213 end 214 rc = quant_check d 215 if ne rc 0 216 ret 4 217 end 218 if eq compose_word b 19 3 219 rc = compose_staged b 220 if ne rc 0 221 ret rc 222 end 223 end 224 note Quant descriptor describes a load-time chunk, NOT necessarily entire MNK. 225 if or ne get d 1 2 ne get d 24 3 226 ret 2 227 end 228 if or ne get d 40 1 ne get d 32 0 229 ret 2 230 end 231 for j ulong 2944 232 if ne get b add j 1152 0 233 ret 1 234 end 235 end 236 ret 0 237 end 238 fn compose_match a view uchar 4096 b view uchar 4096 to bool 239 if ne compose_check a 1152 0 240 ret false 241 end 242 if ne compose_check b 1152 0 243 ret false 244 end 245 for k ulong 12 246 if ne compose_word a add k 2 compose_word b add k 2 247 ret false 248 end 249 end 250 note semantic and pinned tool identities only; qualification remains candidate-specific. 251 for j ulong 128 252 if ne get a add j 512 get b add j 512 253 ret false 254 end 255 end 256 for j ulong 384 257 if ne get a add j 768 get b add j 768 258 ret false 259 end 260 end 261 ret true 262 end 263 note launch template is32 LE64 words: v1,gridXYZ,blockXYZ,shared,gpr,ugpr,barriers, 264 note cbankOffset,argWords,paramABI,relocationPolicy;15..18parameterABI SHA256 limbs, 265 note 19..22constantbank SHA256 limbs,23..26zeroVA QMD templates SHA256 limbs;27..31zero. 266 note Address-free templates only; blockY=blockZ=1; args remain immutable artifact data. 267 fn compose_launch b view uchar 4096 l view ulong 32 to uint 268 if ne compose_check b 1152 0 269 ret 1 270 end 271 if or ne get l 0 1 ne get l 4 compose_word b 25 272 ret 1 273 end 274 if or ne get l 5 1 ne get l 6 1 275 ret 1 276 end 277 for j ulong 3 278 if ne get l add j 1 compose_word b add j 26 279 ret 1 280 end 281 end 282 for j ulong 4 283 if ne get l add j 7 compose_word b add j 21 284 ret 1 285 end 286 end 287 if or eq get l 11 0 gt get l 12 32 288 ret 1 289 end 290 if or eq get l 12 0 ne get l 13 1 291 ret 1 292 end 293 if ne get l 14 1 294 ret 1 295 end 296 if eq compose_word b 19 3 297 if ne get l 11 896 298 ret 1 299 end 300 if and ne get l 12 8 ne get l 12 12 301 ret 1 302 end 303 if and eq get l 12 12 gt compose_word b 14 4 304 ret 1 305 end 306 end 307 for k ulong 3 308 v = ulong 0 309 for j ulong 4 310 v = or v get l add add 15 mul k 4 j 311 end 312 if eq v 0 313 ret 1 314 end 315 end 316 for j ulong 5 317 if ne get l add j 27 0 318 ret 1 319 end 320 end 321 ret 0 322 end 323 fn compose_launchread b view uchar 4096 wire view uchar 4096 n ulong to uint 324 l = new ulong 32 0 325 if ne n 256 326 ret 1 327 end 328 for k ulong 32 329 put l k compose_word wire k 330 end 331 for j ulong 3840 332 if ne get wire add j 256 0 333 ret 1 334 end 335 end 336 ret compose_launch b l 337 end 338 fn compose_launchwrite l view ulong 32 wire edit uchar 4096 to void 339 for j ulong 4096 340 put wire j 0 341 end 342 for k ulong 32 343 compose_put wire k get l k 344 end 345 end 346 fn compose_quant b view uchar 4096 q edit uchar 384 to void 347 for j ulong 384 348 put q j get b add j 768 349 end 350 end 351 fn compose_setquant b edit uchar 4096 q view uchar 384 to void 352 for j ulong 384 353 put b add j 768 get q j 354 end 355 end