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/cache/templates.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 / cache / templates.om` 537 lines · 10660 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Private retained-snapshot consistency checker, NOT artifact admission authority. 3 note Existing successful admission supplies bytes/name/actualid; selected immutable bundle supplies launch/expectedid. 4 note Concatenate digest.om and Composer realize.om dependencies before this unit. 5 note Function image has no text globals; prefix words reuse cubin_elf.om Wolfram-filed constants. 6 fn kt_range n ulong off ulong count ulong to bool 7 if gt off n 8 ret false 9 end 10 ret le count sub n off 11 end 12 fn kt_u b view uchar 32768 off ulong count ulong to ulong 13 v = ulong 0 14 for j ulong count 15 v = or v shl ulong get b add off j mul j 8 16 end 17 ret v 18 end 19 fn kt_obs b view uchar 2048 off ulong count ulong to ulong 20 v = ulong 0 21 for j ulong count 22 v = or v shl ulong get b add off j mul j 8 23 end 24 ret v 25 end 26 fn kt_plen kind ulong to ulong 27 if eq kind 0 28 ret 9 29 end 30 if eq kind 1 31 ret 6 32 end 33 ret 14 34 end 35 fn kt_pbyte word ulong i ulong to uchar 36 ret uchar and shr word mul i 8 255 37 end 38 fn kt_pref kind ulong i ulong to uchar 39 if eq kind 0 40 if lt i 8 41 ret kt_pbyte `8027224783864622638` i 42 end 43 ret 46 44 end 45 if eq kind 1 46 ret kt_pbyte `51077770998830` i 47 end 48 if lt i 8 49 ret kt_pbyte `8317708033571843630` i 50 end 51 ret kt_pbyte `50785646698868` sub i 8 52 end 53 note ctx12: filelen shoff shcount stroff strlen infohdr infooff infolen symoff symlen symcount reserved. 54 fn kt_named b view uchar 32768 ctx view ulong 12 off ulong obs view uchar 2048 count ulong kind ulong to bool 55 pn = kt_plen kind 56 if not kt_range get ctx 4 off add add pn count 1 57 ret false 58 end 59 base = add get ctx 3 off 60 for j ulong pn 61 if ne get b add base j kt_pref kind j 62 ret false 63 end 64 end 65 base = add base pn 66 for j ulong count 67 if ne get b add base j get obs add 896 j 68 ret false 69 end 70 end 71 ret eq get b add base count 0 72 end 73 fn kt_elf b view uchar 32768 n ulong obs view uchar 2048 count ulong ctx edit ulong 12 to int 74 if or lt n 64 gt n 32768 75 ret -21 76 end 77 if ne get b 0 127 78 ret -21 79 end 80 for j ulong 3 81 if ne get b add j 1 kt_pbyte `4684026196722992511` add j 1 82 ret -21 83 end 84 end 85 if or ne get b 4 2 or ne get b 5 1 ne get b 6 1 86 ret -21 87 end 88 if or ne kt_u b 16 2 2 ne kt_u b 18 2 190 89 ret -21 90 end 91 if or ne kt_u b 20 4 1 or ne kt_u b 52 2 64 ne kt_u b 58 2 64 92 ret -21 93 end 94 put ctx 0 n 95 put ctx 1 kt_u b 40 8 96 put ctx 2 kt_u b 60 2 97 if or eq get ctx 2 0 gt get ctx 2 512 98 ret -21 99 end 100 if not kt_range n get ctx 1 mul get ctx 2 64 101 ret -21 102 end 103 si = kt_u b 62 2 104 if or eq si 0 ge si get ctx 2 105 ret -21 106 end 107 sh = add get ctx 1 mul si 64 108 if ne kt_u b add sh 4 4 3 109 ret -21 110 end 111 put ctx 3 kt_u b add sh 24 8 112 put ctx 4 kt_u b add sh 32 8 113 if not kt_range n get ctx 3 get ctx 4 114 ret -21 115 end 116 for i ulong get ctx 2 117 sh = add get ctx 1 mul i 64 118 si = kt_u b sh 4 119 if ge si get ctx 4 120 ret -21 121 end 122 if kt_named b ctx si obs count 0 123 if ne get ctx 5 0 124 ret -22 125 end 126 put ctx 5 sh 127 end 128 end 129 if eq get ctx 5 0 130 ret -22 131 end 132 sh = get ctx 5 133 if ne kt_u b add sh 4 4 shl ulong 7 28 134 ret -22 135 end 136 put ctx 6 kt_u b add sh 24 8 137 put ctx 7 kt_u b add sh 32 8 138 if not kt_range n get ctx 6 get ctx 7 139 ret -22 140 end 141 ret 0 142 end 143 fn kt_assoc b view uchar 32768 ctx edit ulong 12 obs view uchar 2048 count ulong to int 144 sh = get ctx 5 145 ti = kt_u b add sh 44 4 146 si = kt_u b add sh 40 4 147 if or eq ti 0 ge ti get ctx 2 148 ret -22 149 end 150 if or eq si 0 ge si get ctx 2 151 ret -22 152 end 153 sh = add get ctx 1 mul ti 64 154 if ne kt_u b add sh 4 4 1 155 ret -22 156 end 157 if not kt_named b ctx kt_u b sh 4 obs count 1 158 ret -22 159 end 160 if not kt_range get ctx 0 kt_u b add sh 24 8 kt_u b add sh 32 8 161 ret -22 162 end 163 sh = add get ctx 1 mul si 64 164 if or ne kt_u b add sh 4 4 2 ne kt_u b add sh 56 8 24 165 ret -22 166 end 167 put ctx 8 kt_u b add sh 24 8 168 put ctx 9 kt_u b add sh 32 8 169 if ne rem get ctx 9 24 0 170 ret -22 171 end 172 if not kt_range get ctx 0 get ctx 8 get ctx 9 173 ret -22 174 end 175 put ctx 10 div get ctx 9 24 176 ret 0 177 end 178 fn kt_symbol b view uchar 32768 ctx view ulong 12 obs view uchar 2048 count ulong index ulong need ulong to bool 179 if ge index get ctx 10 180 ret false 181 end 182 p = add get ctx 8 mul index 24 183 if ne and get b add p 4 15 3 184 ret false 185 end 186 si = kt_u b add p 6 2 187 if or eq si 0 ge si get ctx 2 188 ret false 189 end 190 p = add get ctx 1 mul si 64 191 if ne kt_u b add p 4 4 1 192 ret false 193 end 194 if not kt_named b ctx kt_u b p 4 obs count 2 195 ret false 196 end 197 if lt kt_u b add p 32 8 need 198 ret false 199 end 200 ret kt_range get ctx 0 kt_u b add p 24 8 kt_u b add p 32 8 201 end 202 note ABI numeric encodings come unchanged from om/cubin/cubin_elf.om wpar/wtail. 203 fn kt_prefix b view uchar 32768 ctx view ulong 12 launch view uchar 4096 span edit ulong 4 to int 204 p = get ctx 6 205 lim = add p get ctx 7 206 if not kt_range lim p 8 207 ret -23 208 end 209 if or ne kt_u b p 2 14084 ne kt_u b add p 2 2 4 210 ret -23 211 end 212 if ne kt_u b add p 4 4 130 213 ret -23 214 end 215 put span 0 p 216 p = add p 8 217 ord = ulong 0 218 last = ulong 0 219 while lt p lim bound 33 220 if not kt_range lim p 4 221 ret -23 222 end 223 if ne kt_u b p 2 5892 224 break 225 end 226 if or ge ord 32 not kt_range lim p 16 227 ret -23 228 end 229 if or ne kt_u b add p 2 2 12 ne kt_u b add p 4 4 0 230 ret -23 231 end 232 v = kt_u b add p 8 4 233 if ne and v 65535 ord 234 ret -23 235 end 236 v = shr v 16 237 if or lt v last ge v mul compose_word launch 12 4 238 ret -23 239 end 240 last = add v 1 241 v = kt_u b add p 12 4 242 if not or eq v `1175552` eq v `2225408` 243 ret -23 244 end 245 if eq v `2225408` 246 if ne rem sub last 1 8 0 247 ret -23 248 end 249 last = add last 7 250 end 251 ord = add ord 1 252 p = add p 16 253 end 254 if not kt_range lim p 20 255 ret -23 256 end 257 if or ne kt_u b p 2 6403 ne kt_u b add p 4 2 2564 258 ret -23 259 end 260 if ne kt_u b add p 6 2 8 261 ret -23 262 end 263 v = kt_u b add p 2 2 264 if or gt v mul compose_word launch 12 4 lt v last 265 ret -23 266 end 267 if ne kt_u b add p 12 4 or compose_word launch 11 shl v 16 268 ret -23 269 end 270 put span 2 kt_u b add p 8 4 271 put span 3 add compose_word launch 11 v 272 p = add p 16 273 put span 1 sub p get span 0 274 if gt get span 1 4096 275 ret -23 276 end 277 ret 0 278 end 279 fn kt_banklink b view uchar 32768 ctx view ulong 12 obs view uchar 2048 count ulong span view ulong 4 to int 280 if not kt_symbol b ctx obs count get span 2 get span 3 281 ret -23 282 end 283 ret 0 284 end 285 fn kt_abiid attr ulong to bool 286 ret or eq attr 55 or eq attr 23 or eq attr 25 or eq attr 10 eq attr 80 287 end 288 fn kt_tail b view uchar 32768 ctx view ulong 12 launch view uchar 4096 span view ulong 4 to int 289 p = add get span 0 get span 1 290 lim = add get ctx 6 get ctx 7 291 if or ne kt_u b p 2 20483 ne kt_u b add p 2 2 0 292 ret -23 293 end 294 p = add p 4 295 ord = ulong 0 296 while lt p lim bound 8192 297 if not kt_range lim p 4 298 ret -23 299 end 300 v = kt_u b p 2 301 if kt_abiid shr v 8 302 ret -23 303 end 304 if eq v 6915 305 if or ne ord 0 ne kt_u b add p 2 2 compose_word launch 8 306 ret -23 307 end 308 ord = 1 309 end 310 v = and v 255 311 if eq v 4 312 v = add 4 kt_u b add p 2 2 313 else 314 if not or eq v 2 eq v 3 315 ret -23 316 end 317 v = 4 318 end 319 if not kt_range lim p v 320 ret -23 321 end 322 p = add p v 323 end 324 if ne ord 1 325 ret -23 326 end 327 ret 0 328 end 329 fn kt_hex c uchar to int 330 if and ge c 48 le c 57 331 ret sub int c 48 332 end 333 if and ge c 97 le c 102 334 ret add sub int c 97 10 335 end 336 ret -1 337 end 338 fn kt_shape launch view uchar 4096 obs view uchar 2048 sizes view ulong 8 to int 339 if or eq get sizes 0 0 gt get sizes 0 32768 340 ret -20 341 end 342 if or eq get sizes 1 0 gt get sizes 1 128 343 ret -20 344 end 345 if or eq get sizes 2 0 gt get sizes 2 63 346 ret -20 347 end 348 for i ulong 5 349 if ne get sizes add i 3 0 350 ret -20 351 end 352 end 353 if ne get sizes 1 mul compose_word launch 12 4 354 ret -20 355 end 356 if or ne compose_word launch 0 1 ne compose_word launch 11 896 357 ret -20 358 end 359 if or ne compose_word launch 13 1 ne compose_word launch 14 1 360 ret -20 361 end 362 for i ulong 3880 363 note Canonical launch tail begins at27 words, including reserved words27..31. 364 if ne get launch add 216 i 0 365 ret -20 366 end 367 end 368 for i ulong 128 369 if and ge i get sizes 1 ne get obs add 768 i 0 370 ret -20 371 end 372 end 373 for i ulong 64 374 if lt i get sizes 2 375 if eq get obs add 896 i 0 376 ret -20 377 end 378 else 379 if ne get obs add 896 i 0 380 ret -20 381 end 382 end 383 end 384 for i ulong 32 385 if ne get obs add 992 i 0 386 ret -20 387 end 388 hi = kt_hex get obs add 1024 mul i 2 389 lo = kt_hex get obs add 1025 mul i 2 390 if or lt hi 0 lt lo 0 391 ret -24 392 end 393 if ne get obs add 960 i uchar or shl hi 4 lo 394 ret -24 395 end 396 end 397 for i ulong 960 398 if ne get obs add 1088 i 0 399 ret -20 400 end 401 end 402 ret 0 403 end 404 fn kt_qcheck launch view uchar 4096 obs view uchar 2048 to int 405 for i ulong 3 406 if ne kt_obs obs add 384 mul add 39 i 4 4 compose_word launch add 1 i 407 ret -25 408 end 409 end 410 if or eq compose_word launch 1 0 or eq compose_word launch 2 0 ne compose_word launch 3 1 411 ret -25 412 end 413 if or eq compose_word launch 4 0 or gt compose_word launch 4 65535 ne compose_word launch 5 1 414 ret -25 415 end 416 if ne compose_word launch 6 1 417 ret -25 418 end 419 v = compose_word launch 4 420 v = or v shl compose_word launch 5 16 421 if ne kt_obs obs add ulong 384 mul ulong 34 4 4 v 422 ret -25 423 end 424 v = kt_obs obs add ulong 384 mul ulong 35 4 4 425 if ne and v 255 compose_word launch 6 426 ret -25 427 end 428 gpr = compose_word launch 8 429 if lt gpr 16 430 gpr = 16 431 end 432 if or gt gpr 511 ne and shr v 8 511 gpr 433 ret -25 434 end 435 v = compose_word launch 7 436 if gt v `4294967295` 437 ret -25 438 end 439 if eq v 0 440 v = 8 441 else 442 v = div add v 127 128 443 end 444 if gt v 2047 445 ret -25 446 end 447 if ne and kt_obs obs add ulong 384 mul ulong 36 4 4 2047 v 448 ret -25 449 end 450 ret 0 451 end 452 fn kt_equal launch view uchar 4096 hash view uchar 32 slot ulong to bool 453 for i ulong 32 454 if ne get launch add mul slot 8 i get hash i 455 ret false 456 end 457 end 458 ret true 459 end 460 fn kt_hashinfo launch view uchar 4096 cubin view uchar 32768 span view ulong 4 to bool 461 buf = new uchar 4096 0 462 hash = new uchar 32 0 463 for i ulong get span 1 464 put buf i get cubin add get span 0 i 465 end 466 if ne kc_sha buf get span 1 hash 0 467 ret false 468 end 469 ret kt_equal launch hash 15 470 end 471 fn kt_obshash launch view uchar 4096 obs view uchar 2048 off ulong count ulong slot ulong to bool 472 buf = new uchar 4096 0 473 hash = new uchar 32 0 474 for i ulong count 475 put buf i get obs add off i 476 end 477 if ne kc_sha buf count hash 0 478 ret false 479 end 480 ret kt_equal launch hash slot 481 end 482 fn kt_hashes launch view uchar 4096 cubin view uchar 32768 obs view uchar 2048 sizes view ulong 8 span view ulong 4 to int 483 if not kt_hashinfo launch cubin span 484 ret -26 485 end 486 if not kt_obshash launch obs 768 get sizes 1 19 487 ret -27 488 end 489 if not kt_obshash launch obs 0 768 23 490 ret -28 491 end 492 ret 0 493 end 494 fn kt_tailzero cubin view uchar 32768 n ulong to bool 495 for i ulong sub 32768 n 496 if ne get cubin add n i 0 497 ret false 498 end 499 end 500 ret true 501 end 502 fn native_templates launch view uchar 4096 cubin view uchar 32768 observed view uchar 2048 sizes view ulong 8 to long 503 ctx = new ulong 12 0 504 span = new ulong 4 0 505 rc = kt_shape launch observed sizes 506 if ne rc 0 507 ret long rc 508 end 509 if not kt_tailzero cubin get sizes 0 510 ret -20 511 end 512 rc = kt_elf cubin get sizes 0 observed get sizes 2 ctx 513 if ne rc 0 514 ret long rc 515 end 516 rc = kt_assoc cubin ctx observed get sizes 2 517 if ne rc 0 518 ret long rc 519 end 520 rc = kt_prefix cubin ctx launch span 521 if ne rc 0 522 ret long rc 523 end 524 rc = kt_banklink cubin ctx observed get sizes 2 span 525 if ne rc 0 526 ret long rc 527 end 528 rc = kt_tail cubin ctx launch span 529 if ne rc 0 530 ret long rc 531 end 532 rc = kt_qcheck launch observed 533 if ne rc 0 534 ret long rc 535 end 536 ret long kt_hashes launch cubin observed sizes span 537 end