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/mathlibs/host.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 / mathlibs / host.om` 871 lines · 15463 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Host policy of omega_gpu_mathlibs_api.c at `3d28358d4881`; no device or host effects. 3 note Descriptor protocol is private, see evidence/mathlibs-host-`20261106`/README.md. 4 note Unsigned operations intentionally retain the C oracle's modulo arithmetic. 5 6 fn mh_time sec ulong ns ulong to ulong 7 ret add mul sec `1000000000` ns 8 end 9 fn mh_sub a ulong b ulong to ulong 10 ret sub a b 11 end 12 fn mh_mul a ulong b ulong to ulong 13 ret mul a b 14 end 15 fn mh_add a ulong b ulong to ulong 16 ret add a b 17 end 18 fn mh_min a ulong b ulong to ulong 19 if lt a b 20 ret a 21 end 22 ret b 23 end 24 fn mh_bit v bool to ulong 25 if v 26 ret 1 27 end 28 ret 0 29 end 30 fn mh_overlap a ulong na ulong b ulong nb ulong to ulong 31 note Difference comparisons avoid pointer arithmetic outside objects and address wrap. 32 if le a b 33 ret mh_bit lt sub b a na 34 end 35 ret mh_bit lt sub a b nb 36 end 37 fn mh_rng kind ulong ns ulong per ulong lim ulong to ulong 38 if or gt kind lim or eq ns 0 eq per 0 39 ret 1 40 end 41 if or gt ns 131072 gt mul ns per `268435456` 42 ret 2 43 end 44 ret 0 45 end 46 fn mh_rngval kind ulong ns ulong per ulong q ulong to ulong 47 if eq q 0 48 ret mul ns per 49 end 50 if eq q 1 51 if eq kind 0 52 ret 8 53 end 54 ret 4 55 end 56 if eq q 2 57 ret div add ns 127 128 58 end 59 ret 0 60 end 61 fn mh_seed seed ulong stream ulong i ulong to ulong 62 ret add add seed stream mul add i 1 `11400714819323198485` 63 end 64 fn mh_phil dist ulong ns ulong per ulong off ulong q ulong to ulong 65 if eq q 0 66 if or eq dist 2 eq dist 3 67 ret mul mul ns per 2 68 end 69 ret mul ns per 70 end 71 if eq q 1 72 ret rem off 4 73 end 74 if eq q 2 75 ret div off 4 76 end 77 g = ulong 4 78 if eq dist 3 79 g = 2 80 end 81 r = rem per g 82 if eq q 3 83 ret add div per g mh_bit ne r 0 84 end 85 if eq q 4 86 if ne r 0 87 ret and sub r g `4294967295` 88 end 89 ret 0 90 end 91 if eq q 5 92 if or eq dist 2 eq dist 3 93 ret 2 94 end 95 ret 1 96 end 97 ret div add ns 127 128 98 end 99 fn mh_lg n ulong lo ulong hi ulong to ulong 100 if or lt n lo or gt n hi ne and n sub n 1 0 101 ret `4294967295` 102 end 103 k = ulong 0 104 while lt shl ulong 1 k n bound 32 105 k = add k 1 106 end 107 ret k 108 end 109 fn mh_chunk total ulong first ulong width ulong outw ulong q ulong to ulong 110 ctas = div add total sub width 1 width 111 grid = mh_min sub ctas first 1024 112 if eq q 0 113 ret grid 114 end 115 if eq q 1 116 ret mul first width 117 end 118 ret mul outw mh_min mul grid width sub total mul first width 119 end 120 fn mh_fill old ulong idx ulong to ulong 121 bit = shl ulong 1 and idx 7 122 if ne and old bit 0 123 ret add old 256 124 end 125 ret or old bit 126 end 127 fn mh_poison a ulong b ulong wide ulong dual ulong to ulong 128 if ne dual 0 129 ret mh_bit and eq a `4290436013` eq b `12245933` 130 end 131 if ne wide 0 132 ret mh_bit eq a `18427282365706066861` 133 end 134 ret mh_bit eq a `4290436013` 135 end 136 137 note Layout entries are base, batch stride, and three axis strides. 138 fn mh_index l view ulong 8 e view ulong 4 rank ulong idx ulong to ulong 139 v = get l 0 140 x = idx 141 i = rank 142 while gt i 0 bound 3 143 i = sub i 1 144 v = add v mul rem x get e i get l add i 2 145 x = div x get e i 146 end 147 ret and add v mul x get l 1 `4294967295` 148 end 149 150 note Legacy walk admission: p mode, rank, batch, inverse, dims[3]. o rc,lgs,bytes[3]. 151 fn mh_walk p view ulong 8 o edit ulong 8 to ulong 152 mode = get p 0 153 rank = get p 1 154 sum = ulong 0 155 lgs = ulong 0 156 if or eq get p 2 0 gt get p 3 1 157 ret 1 158 end 159 if eq mode 0 160 if or lt rank 1 gt rank 3 161 ret 1 162 end 163 for i ulong rank 164 k = mh_lg get p add i 4 4 2048 165 if eq k `4294967295` 166 ret 1 167 end 168 lgs = or lgs shl k mul i 4 169 sum = add sum k 170 end 171 else 172 if or gt mode 2 or ne rank 1 ne get p 3 0 173 ret 1 174 end 175 sum = mh_lg get p 4 8 4096 176 if eq sum `4294967295` 177 ret 1 178 end 179 lgs = sum 180 end 181 if gt sum 27 182 ret 2 183 end 184 elems = shl get p 2 sum 185 if gt elems `134217728` 186 ret 2 187 end 188 put o 0 lgs 189 put o 4 or mode shl rank 4 190 put o 1 mul elems 8 191 put o 2 mul elems 8 192 put o 3 mul elems 8 193 half = add div shl ulong 1 sum 2 1 194 if eq mode 1 195 put o 1 mul elems 4 196 put o 2 mul mul half 8 get p 2 197 put o 3 mul elems 4 198 end 199 if eq mode 2 200 put o 1 mul mul half 8 get p 2 201 put o 2 mul elems 4 202 put o 3 mul elems 4 203 end 204 ret 0 205 end 206 fn mh_walkfft o edit ulong 16 cursor ulong rows ulong to ulong 207 n = shl ulong 1 get o 1 208 si = n 209 so = n 210 if eq get o 0 4 211 si = add div n 2 get o 2 212 so = sub add div n 2 1 get o 2 213 end 214 put o 5 mul mul cursor si 8 215 put o 6 mul mul cursor so 8 216 put o 7 div n 4 217 put o 8 mh_min sub rows cursor 1024 218 put o 9 0 219 if eq get o 0 1 220 put o 9 mul n 8 221 end 222 put o 12 n 223 put o 13 get o 2 224 put o 14 mul mul so 2 get o 8 225 put o 15 rows 226 ret 0 227 end 228 note One decoded legacy step; q is a row/CTA cursor, o matches private launch fields. 229 fn mh_walkstep step ulong batch ulong cursor ulong o edit ulong 16 to ulong 230 for i ulong 5 231 put o i and shr step mul i 8 255 232 end 233 kind = get o 0 234 a = get o 1 235 b = get o 2 236 if or gt get o 3 2 gt get o 4 2 237 ret 3 238 end 239 rows = shl batch and shr step 40 255 240 if or eq kind 1 eq kind 4 241 ret mh_walkfft o cursor rows 242 end 243 if eq kind 5 244 total = shl rows add a b 245 put o 7 256 246 put o 8 mh_chunk total cursor 256 2 0 247 put o 10 total 248 put o 11 mul cursor 256 249 put o 14 mh_chunk total cursor 256 2 2 250 put o 15 div add total 255 256 251 ret 0 252 end 253 ret 3 254 end 255 256 note s is a private planner state, o holds at most 204 records of 40 cells. 257 note Emit unchunked descriptors; mh_chunk expands them without allocating a large Omega stack. 258 fn mh_emit s edit ulong 256 o edit ulong 8192 to void 259 at = add 32 mul get s 1 40 260 if gt at 8152 261 put s 0 3 262 ret 263 end 264 for i ulong 40 265 put o add at i 0 266 end 267 put o at get s 188 268 put o add at 1 get s 189 269 put o add at 2 get s 190 270 put o add at 3 get s 191 271 put o add at 4 get s 192 272 put o add at 5 get s 193 273 put o add at 6 get s 194 274 for i ulong 3 275 v = get s add 180 i 276 if and ne get s 25 0 eq v 1 277 v = 0 278 end 279 put o add add at 7 i v 280 put o add add at 10 i get s add 184 i 281 end 282 for i ulong 18 283 put o add add at 13 i get s add 160 i 284 end 285 put s 1 add get s 1 1 286 end 287 fn mh_table s edit ulong 256 o edit ulong 8192 kind ulong n ulong dir ulong to ulong 288 for i ulong get s 144 289 at = add 80 mul i 4 290 if eq get s at kind 291 if eq get s add at 1 n 292 if eq get s add at 2 dir 293 ret get s add at 3 294 end 295 end 296 end 297 end 298 if ge get s 144 16 299 put s 0 3 300 ret 0 301 end 302 at = add 80 mul get s 144 4 303 off = mul get s 2 8 304 put s at kind 305 put s add at 1 n 306 put s add at 2 dir 307 put s add at 3 off 308 put s 144 add get s 144 1 309 put s 188 kind 310 put s 189 n 311 put s 190 dir 312 put s 191 0 313 put s 192 0 314 put s 193 off 315 put s 194 0 316 mh_emit s o 317 put s 2 add get s 2 n 318 ret off 319 end 320 fn mh_magic n ulong to ulong 321 ret mh_min div ulong `4294967296` n `4294967295` 322 end 323 fn mh_dense s edit ulong 256 dst ulong perm ulong ext ulong to void 324 for i ulong 5 325 put s add dst i 0 326 end 327 p = ulong 1 328 i = get s 16 329 while gt i 0 bound 3 330 i = sub i 1 331 ax = get s add perm i 332 put s add add dst 2 ax p 333 p = and mul p get s add ext ax `4294967295` 334 end 335 put s add dst 1 p 336 end 337 fn mh_copy s edit ulong 256 o edit ulong 8192 mode ulong src ulong dst ulong to void 338 for i ulong 18 339 put s add 160 i 0 340 end 341 total = get s 17 342 for k ulong 3 343 e = ulong 1 344 if lt k get s 16 345 ax = get s add 41 sub sub get s 16 1 k 346 e = get s add 38 ax 347 put s add 170 k get s add 60 ax 348 put s add 175 k get s add 65 ax 349 end 350 if eq e 0 351 ret 352 end 353 total = mul total e 354 put s add 162 mul k 2 e 355 put s add 163 mul k 2 mh_magic e 356 end 357 put s 168 get s 58 358 put s 169 get s 59 359 put s 173 get s 63 360 put s 174 get s 64 361 put s 180 src 362 put s 181 dst 363 put s 182 0 364 for i ulong 3 365 put s add 184 i 0 366 end 367 put s 188 9 368 put s 189 mode 369 put s 190 0 370 put s 191 2 371 put s 192 18 372 put s 193 total 373 put s 194 2 374 if eq mode 2 375 put s 194 1 376 end 377 mh_emit s o 378 end 379 note Factor order matches mathlibs_ir.om fpl/fpr at the pinned base. 380 fn mh_factor s edit ulong 256 n ulong to void 381 x = n 382 cnt = ulong 0 383 for j ulong 5 384 r = ulong 4 385 if eq j 1 386 r = 2 387 end 388 if eq j 2 389 r = 3 390 end 391 if eq j 3 392 r = 5 393 end 394 if eq j 4 395 r = 7 396 end 397 while eq rem x r 0 bound 12 398 put s add 203 cnt r 399 cnt = add cnt 1 400 x = div x r 401 end 402 end 403 put s 200 n 404 put s 201 0 405 if ne x 1 406 M = ulong 1 407 while lt M sub mul n 2 1 bound 13 408 M = mul M 2 409 end 410 put s 200 M 411 put s 201 1 412 cnt = 0 413 x = M 414 while eq rem x 4 0 bound 7 415 put s add 203 cnt 4 416 cnt = add cnt 1 417 x = div x 4 418 end 419 if eq x 2 420 put s add 203 cnt 2 421 cnt = add cnt 1 422 end 423 end 424 put s 202 cnt 425 end 426 note Stockham configuration: s219 dir,220 src,221 alt,222 final (UINT32_MAX for none),223 table offset. 427 fn mh_zero s edit ulong 256 to void 428 for i ulong 18 429 put s add 160 i 0 430 end 431 end 432 fn mh_stock s edit ulong 256 o edit ulong 8192 n ulong rows ulong to ulong 433 cur = get s 220 434 ns = ulong 1 435 for i ulong get s 202 436 r = get s add 203 i 437 nr = div n r 438 dst = get s 220 439 if eq cur dst 440 dst = get s 221 441 end 442 if eq add i 1 get s 202 443 if ne get s 222 `4294967295` 444 dst = get s 222 445 end 446 end 447 mh_zero s 448 put s 162 nr 449 put s 163 mh_magic nr 450 put s 164 ns 451 put s 165 mh_magic ns 452 put s 166 div n mul ns r 453 put s 167 n 454 put s 180 cur 455 put s 181 dst 456 put s 182 7 457 put s 184 0 458 put s 185 0 459 put s 186 get s 223 460 put s 188 7 461 put s 189 r 462 put s 190 get s 219 463 put s 191 3 464 put s 192 8 465 put s 193 mul rows nr 466 put s 194 mul r 2 467 mh_emit s o 468 cur = dst 469 ns = mul ns r 470 end 471 ret cur 472 end 473 fn mh_blue s edit ulong 256 o edit ulong 8192 variant ulong src ulong dst ulong total ulong to void 474 for i ulong 18 475 put s add 160 i 0 476 end 477 put s 162 get s 230 478 put s 180 src 479 put s 181 dst 480 put s 182 7 481 put s 184 0 482 put s 185 0 483 put s 186 get s 233 484 if eq variant 1 485 put s 182 6 486 put s 186 0 487 end 488 if eq variant 3 489 put s 184 get s 233 490 end 491 put s 188 8 492 put s 189 variant 493 put s 190 get s 234 494 put s 191 3 495 put s 192 3 496 put s 193 total 497 put s 194 2 498 mh_emit s o 499 end 500 fn mh_axis s edit ulong 256 o edit ulong 8192 n ulong rows ulong to void 501 mh_factor s n 502 M = get s 200 503 if eq get s 201 0 504 tw = mh_table s o 10 n get s 19 505 put s 219 get s 19 506 put s 220 get s 26 507 put s 221 sub 5 get s 26 508 put s 222 `4294967295` 509 put s 223 tw 510 put s 26 mh_stock s o n rows 511 ret 512 end 513 if gt mul rows M `268435456` 514 put s 0 2 515 ret 516 end 517 if gt mul mul rows M 8 get s 3 518 put s 3 mul mul rows M 8 519 end 520 if gt mul M 8 get s 4 521 put s 4 mul M 8 522 end 523 put s 230 n 524 put s 233 mh_table s o 11 n get s 19 525 put s 231 mh_table s o 10 M 0 526 put s 232 mh_table s o 10 M 1 527 put s 234 mh_lg M 1 8192 528 mh_blue s o 3 7 4 M 529 put s 219 0 530 put s 220 4 531 put s 221 5 532 put s 222 6 533 put s 223 get s 231 534 x = mh_stock s o M 1 535 mh_blue s o 0 get s 26 4 mul rows M 536 put s 220 4 537 put s 221 5 538 put s 222 `4294967295` 539 x = mh_stock s o M rows 540 mh_blue s o 1 x x mul rows M 541 put s 219 1 542 put s 220 x 543 put s 221 sub 9 x 544 put s 223 get s 232 545 y = mh_stock s o M rows 546 mh_blue s o 2 y get s 26 mul rows M 547 end 548 fn mh_rows s view ulong 256 ax ulong to ulong 549 rows = get s 17 550 for i ulong get s 16 551 if ne i ax 552 rows = mul rows get s add 38 i 553 end 554 end 555 ret rows 556 end 557 note A side reads p embed/stride/dist and emits its layout and addressed extent in s. 558 fn mh_sideini p view ulong 32 s edit ulong 256 outside ulong to void 559 emb = ulong 9 560 ext = ulong 32 561 put s 241 48 562 put s 243 get p 12 563 put s 244 get p 13 564 put s 245 0 565 if and eq get s 18 1 ne get p 4 0 566 put s 245 mul get s 22 2 567 end 568 if ne outside 0 569 emb = 14 570 ext = 35 571 put s 241 53 572 put s 243 get p 17 573 put s 244 get p 18 574 put s 245 0 575 if and eq get s 18 2 ne get p 4 0 576 put s 245 mul get s 22 2 577 end 578 end 579 put s 242 ext 580 for i ulong get s 16 581 put s add 246 i get p add emb i 582 if ne get s 24 0 583 put s add 246 i get s add ext i 584 end 585 end 586 end 587 fn mh_side p view ulong 32 s edit ulong 256 outside ulong to ulong 588 mh_sideini p s outside 589 if ne get s 24 0 590 if ne get s 245 0 591 put s add 246 get s 20 get s 245 592 end 593 put s 243 1 594 prod = ulong 1 595 for i ulong get s 16 596 prod = mul prod get s add 246 i 597 end 598 if ge prod `4294967296` 599 ret 2 600 end 601 put s 244 prod 602 else 603 if eq get s 243 0 604 ret 1 605 end 606 for i ulong get s 20 607 ax = add i 1 608 if lt get s add 246 ax get s add get s 242 ax 609 ret 1 610 end 611 end 612 end 613 dst = get s 241 614 put s dst 0 615 put s add dst 1 get s 244 616 hi = mul get s 244 sub get s 17 1 617 pos = get s 243 618 if gt hi `268435455` 619 ret 2 620 end 621 i = get s 16 622 while gt i 0 bound 3 623 i = sub i 1 624 if ge pos `4294967296` 625 ret 2 626 end 627 put s add add dst 2 i pos 628 hi = add hi mul sub get s add get s 242 i 1 pos 629 pos = mul pos get s add 246 i 630 end 631 if or ge hi `4294967296` gt add hi 1 `268435456` 632 ret 2 633 end 634 put s add 68 outside add hi 1 635 ret 0 636 end 637 fn mh_admit p view ulong 32 s edit ulong 256 to ulong 638 r = get p 0 639 if or lt r 1 or gt r 3 or eq get p 1 0 gt get p 2 2 640 ret 1 641 end 642 if eq get p 2 0 643 if gt get p 3 1 644 ret 1 645 end 646 else 647 if ne get p 3 0 648 ret 1 649 end 650 end 651 put s 16 r 652 put s 17 get p 1 653 put s 18 get p 2 654 put s 19 get p 3 655 if eq get p 2 2 656 put s 19 1 657 end 658 put s 20 sub r 1 659 put s 21 get p add 6 sub r 1 660 put s 22 add div get s 21 2 1 661 put s 25 get p 5 662 put s 26 2 663 P = ulong 1 664 ib = true 665 ob = true 666 for i ulong r 667 n = get p add 6 i 668 if or lt n 2 gt n 4096 669 ret 1 670 end 671 P = mul P n 672 ib = and ib eq get p add 9 i 0 673 ob = and ob eq get p add 14 i 0 674 put s add 32 i n 675 put s add 35 i n 676 put s add 38 i n 677 put s add 41 i i 678 end 679 if ne ib ob 680 ret 1 681 end 682 put s 24 mh_bit ib 683 put s 23 P 684 if gt P div `134217728` get s 17 685 ret 2 686 end 687 if eq get s 18 1 688 put s add 35 get s 20 get s 22 689 end 690 if eq get s 18 2 691 put s add 32 get s 20 get s 22 692 put s add 38 get s 20 get s 22 693 for k ulong r 694 v = get s 20 695 if gt k 0 696 v = sub k 1 697 end 698 put s add 41 k v 699 end 700 end 701 rc = mh_side p s 0 702 if ne rc 0 703 ret rc 704 end 705 ret mh_side p s 1 706 end 707 fn mh_rot s edit ulong 256 to void 708 v = get s add 41 get s 20 709 i = get s 20 710 while gt i 0 bound 2 711 put s add 41 i get s add 40 i 712 i = sub i 1 713 end 714 put s 41 v 715 end 716 fn mh_lcopy s edit ulong 256 dst ulong src ulong to void 717 for i ulong 5 718 put s add dst i get s add src i 719 end 720 end 721 fn mh_finish s edit ulong 256 o edit ulong 8192 to void 722 ib = mul get s 68 8 723 ob = mul get s 69 8 724 if eq get s 18 1 725 ib = mul get s 68 4 726 end 727 if eq get s 18 2 728 ob = mul get s 69 4 729 end 730 put o 5 ib 731 put o 6 ob 732 if ne get s 25 0 733 if gt ob ib 734 put o 5 ob 735 end 736 put o 6 0 737 end 738 put o 7 mul mul get s 23 get s 17 8 739 put o 8 get o 7 740 put o 9 get s 3 741 put o 10 get s 3 742 put o 11 get s 4 743 put o 12 mul get s 2 8 744 put o 13 get s 16 745 put o 14 get s 17 746 put o 15 2 747 if eq get s 18 2 748 put o 15 1 749 end 750 put o 16 get s 69 751 put o 17 get s 24 752 for i ulong 3 753 put o add 18 i get s add 35 i 754 end 755 for i ulong 5 756 put o add 21 i get s add 53 i 757 end 758 end 759 fn mh_many p view ulong 32 o edit ulong 8192 to ulong 760 s = new ulong 256 0 761 rc = mh_admit p s 762 if ne rc 0 763 ret rc 764 end 765 mh_dense s 63 41 38 766 mh_lcopy s 58 48 767 mode = ulong 0 768 if eq get s 18 1 769 mode = 1 770 end 771 mh_copy s o mode 0 2 772 mh_lcopy s 58 63 773 nax = get s 16 774 if eq get s 18 2 775 nax = sub nax 1 776 end 777 for t ulong nax 778 ax = get s add 41 get s 20 779 mh_axis s o get p add 6 ax mh_rows s ax 780 if ne get s 0 0 781 ret get s 0 782 end 783 if and eq get s 18 1 eq ax get s 20 784 put s add 38 get s 20 get s 22 785 end 786 if and eq add t 1 nax ne get s 18 2 787 break 788 end 789 mh_rot s 790 mh_dense s 63 41 38 791 mh_copy s o 0 get s 26 sub 5 get s 26 792 mh_lcopy s 58 63 793 put s 26 sub 5 get s 26 794 end 795 if eq get s 18 2 796 put s add 38 get s 20 get s 21 797 mh_dense s 63 41 38 798 put s add 38 get s 20 get s 22 799 mh_copy s o 0 get s 26 sub 5 get s 26 800 if gt get s 21 get s 22 801 put s 58 sub get s 21 get s 22 802 put s add 60 get s 20 `4294967295` 803 put s 63 get s 22 804 put s add 38 get s 20 sub get s 21 get s 22 805 mh_copy s o 3 get s 26 sub 5 get s 26 806 end 807 put s 63 0 808 mh_lcopy s 58 63 809 put s 26 sub 5 get s 26 810 put s add 38 get s 20 get s 21 811 mh_axis s o get s 21 mh_rows s get s 20 812 end 813 for i ulong get s 16 814 put s add 41 i i 815 end 816 mh_lcopy s 63 53 817 mode = 0 818 if eq get s 18 2 819 mode = 2 820 end 821 mh_copy s o mode get s 26 1 822 mh_finish s o 823 put o 0 get s 1 824 ret get s 0 825 end 826 827 fn mh_div a ulong b ulong to ulong 828 ret div a b 829 end 830 fn mh_eachcnt e view ulong 4 rank ulong batch ulong to ulong 831 n = batch 832 for i ulong rank 833 n = mul n get e i 834 end 835 ret n 836 end 837 fn mh_basic rank ulong in ulong out ulong dims ulong to ulong 838 if or eq in 0 or eq out 0 or eq in out or eq dims 0 or lt rank 1 gt rank 3 839 ret 1 840 end 841 ret 0 842 end 843 fn mh_fft in ulong out ulong n ulong batch ulong inv ulong o edit ulong 8 to ulong 844 k = mh_lg n 4 2048 845 if and eq k `4294967295` and ge n 2 le n 4096 846 ret 4 847 end 848 if or eq k `4294967295` eq batch 0 849 ret 1 850 end 851 if or eq in 0 eq out 0 852 ret 1 853 end 854 if gt inv 1 855 ret 1 856 end 857 floats = mul mul n batch 2 858 if gt floats `268435456` 859 ret 2 860 end 861 bytes = mul floats 4 862 if ne mh_overlap in bytes out bytes 0 863 ret 1 864 end 865 put o 0 k 866 put o 1 floats 867 put o 2 bytes 868 put o 3 mul n 8 869 put o 4 div n 4 870 ret 0 871 end