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/benchmarks-mv/blob/main/native/queueflow/kflow.om # benchmarks-mv Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS. 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 `benchmarks-mv / native / queueflow / kflow.om` 824 lines ยท 11994 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note kflow.om (DRA-190): flow bookkeeping of a Hermes kanban board export (export-kanban.sh). 3 note Compiler: the omc named in omc.pin (gate.sh checks it). The held-out run's compiler is in 4 note evidence/heldout/IDENTITY.txt, which records this file before later header edits. 5 note kflow TASKS RUNS EVENTS TX CAP 6 note TX: the export time (epoch s; a run with no end is counted as running until TX). CAP: the 7 note dispatcher's max_in_progress. Prints KQ lines of integers only; ratios and thresholds are 8 note evaluated outside (Wolfram, PREREG.md section 6). Exit 0 ok, 2 usage, 3 I/O or malformed 9 note input, 4 more than 4096 rows in a file. 10 note Checks (PREREG.md section 5): conservation of the open-task node (created minus closed events 11 note against the task table), of the running node (run starts minus run ends against tasks in 12 note status running), and the slot bound (concurrent runs never above CAP). 13 om2 14 15 const MAXN ulong 4096 16 17 global arg uchar 1024 18 global buf uchar `1048576` 19 global ob uchar 8192 20 global st ulong 16 21 global num uchar 24 22 global row long 16 23 global ti long 4096 24 global tc long 4096 25 global ts long 4096 26 global tp long 4096 27 global td long 4096 28 global ri long 4096 29 global rs long 4096 30 global re long 4096 31 global ro long 4096 32 global ei long 4096 33 global et long 4096 34 global ek long 4096 35 global cnt long 4096 36 global fl long 4096 37 global wk long 4096 38 global wv long 4096 39 global gv long 32 40 41 text t_usage "usage: kflow TASKS RUNS EVENTS TX CAP\n" 42 text t_ioerr "KQ error io\n" 43 text t_bad "KQ error malformed\n" 44 text t_big "KQ error rows > 4096\n" 45 text t_nl "\n" 46 text t_tr "KQ trace tasks=" 47 text t_runs " runs=" 48 text t_evs " events=" 49 text t_tx " tx=" 50 text t_cap " cap=" 51 text t_sys "KQ sys created=" 52 text t_clo " closed=" 53 text t_oev " open_events=" 54 text t_otb " open_table=" 55 text t_mis " mismatch=" 56 text t_run "KQ run starts=" 57 text t_ends " ends=" 58 text t_rr " running_runs=" 59 text t_rt " running_table=" 60 text t_conc "KQ conc max=" 61 text t_over " overcap_s=" 62 text t_rty "KQ retry extra=" 63 text t_multi " tasks_multi=" 64 text t_badr " bad=" 65 text t_acc "KQ acc done=" 66 text t_dcomp " done_completed_run=" 67 text t_lat "KQ lat n=" 68 text t_sum " sum=" 69 text t_p95 " p95=" 70 text t_max " max=" 71 text t_fst "KQ first n=" 72 text t_util "KQ util busy=" 73 text t_h " h=" 74 text t_pool "KQ pool p=" 75 text t_pbusy " busy=" 76 text t_puni " union=" 77 text t_pmax " maxc=" 78 text t_arm "KQ arm=Cr dropped=" 79 text t_dacc " dropped_completed=" 80 81 fn pr t view uchar * to void 82 w = write 1 t 0 len t 83 end 84 85 fn argn i ulong to ulong 86 if ge i ulong argcnt 87 ret 0 88 end 89 n = argread i arg 0 len arg 90 if le n 0 91 ret 0 92 end 93 ret ulong n 94 end 95 96 fn oreset to void 97 put st 2 0 98 end 99 100 fn obyte b uchar to void 101 p = get st 2 102 if lt p 8192 103 put ob p b 104 put st 2 add p 1 105 end 106 end 107 108 fn otext t view uchar * to void 109 for i ulong len t 110 obyte get t i 111 end 112 end 113 114 fn onum v ulong to void 115 k = ulong 0 116 x = v 117 while true bound 21 118 put num k uchar add rem x 10 48 119 k = add k 1 120 x = div x 10 121 if eq x 0 122 break 123 end 124 end 125 for i ulong k 126 obyte get num sub sub k 1 i 127 end 128 end 129 130 fn osnum v long to void 131 if lt v 0 132 obyte 45 133 onum ulong neg v 134 ret 135 end 136 onum ulong v 137 end 138 139 fn oflush to void 140 w = write 1 ob 0 get st 2 141 put st 2 0 142 end 143 144 fn lmax a long b long to long 145 if gt a b 146 ret a 147 end 148 ret b 149 end 150 151 fn lmin a long b long to long 152 if lt a b 153 ret a 154 end 155 ret b 156 end 157 158 fn slurp i ulong to long 159 n = argn i 160 if eq n 0 161 ret -1 162 end 163 if ge n 1023 164 ret -1 165 end 166 fd = int fopen arg 0 n 0 0 167 if lt fd 0 168 ret -1 169 end 170 tot = ulong 0 171 while true bound 999999 172 if ge tot len buf 173 c = fclose fd 174 ret -1 175 end 176 k = read fd buf tot sub len buf tot 177 if lt k 0 178 c2 = fclose fd 179 ret -1 180 end 181 if eq k 0 182 break 183 end 184 tot = add tot ulong k 185 end 186 c3 = fclose fd 187 ret long tot 188 end 189 190 fn pfield p ulong e ulong to long 191 i = p 192 s = long 1 193 if lt i e 194 if eq get buf i 45 195 s = long -1 196 i = add i 1 197 end 198 end 199 v = long 0 200 nd = ulong 0 201 while true bound 32 202 if ge i e 203 break 204 end 205 b = get buf i 206 if or lt b 48 gt b 57 207 break 208 end 209 if gt nd 17 210 put st 5 1 211 break 212 end 213 v = add mul v 10 long sub b 48 214 nd = add nd 1 215 i = add i 1 216 end 217 if eq nd 0 218 put st 5 1 219 end 220 put st 4 i 221 ret mul s v 222 end 223 224 note Parse buf[0, e) as rows of nc tab-separated integers into row and then the table selected by 225 note which (0 tasks, 1 runs, 2 events). Returns the row count, -1 malformed, -2 too many rows. 226 fn parse e ulong nc ulong which ulong to long 227 p = ulong 0 228 r = ulong 0 229 while true bound 999999 230 if ge p e 231 break 232 end 233 if ge r MAXN 234 ret -2 235 end 236 put st 5 0 237 for c ulong nc 238 v = pfield p e 239 put row c v 240 q = get st 4 241 if lt add c 1 nc 242 if ge q e 243 put st 5 1 244 else 245 if ne get buf q 9 246 put st 5 1 247 end 248 end 249 end 250 p = add q 1 251 end 252 if ne get st 5 0 253 ret -1 254 end 255 q2 = sub p 1 256 if lt q2 e 257 if ne get buf q2 10 258 ret -1 259 end 260 end 261 store which r 262 r = add r 1 263 end 264 ret long r 265 end 266 267 fn store which ulong r ulong to void 268 if eq which 0 269 put ti r get row 0 270 put tc r get row 1 271 put ts r get row 2 272 put tp r get row 3 273 put td r get row 4 274 end 275 if eq which 1 276 put ri r get row 0 277 put rs r get row 1 278 put re r get row 2 279 put ro r get row 3 280 end 281 if eq which 2 282 put ei r get row 0 283 put et r get row 1 284 put ek r get row 2 285 end 286 end 287 288 fn load i ulong nc ulong which ulong to long 289 sz = slurp i 290 if lt sz 0 291 ret -3 292 end 293 ret parse ulong sz nc which 294 end 295 296 note End of run i: its end, or TX when it has none. 297 fn rend i ulong tx long to long 298 e = get re i 299 if eq e 0 300 ret tx 301 end 302 ret e 303 end 304 305 fn sortwk n ulong to void 306 for i ulong n 307 j = i 308 while gt j 0 bound 4096 309 x = get wk j 310 y = get wk sub j 1 311 if ge x y 312 break 313 end 314 put wk j y 315 put wk sub j 1 x 316 j = sub j 1 317 end 318 end 319 end 320 321 note Open-task conservation. A task is closed when it has a completed or archived event. 322 fn sysline nt ulong nev ulong to void 323 for i ulong nt 324 put fl i 0 325 put cnt i 0 326 end 327 for j ulong nev 328 k = get ek j 329 x = ulong sub get ei j 1 330 if lt x nt 331 if eq k 1 332 put cnt x 1 333 end 334 if gt k 1 335 put fl x 1 336 end 337 end 338 end 339 cr = long 0 340 cl = long 0 341 ot = long 0 342 for i ulong nt 343 cr = add cr get cnt i 344 cl = add cl get fl i 345 s = get ts i 346 if ne s 6 347 if ne s 7 348 ot = add ot 1 349 end 350 end 351 end 352 oreset 353 otext t_sys 354 osnum cr 355 otext t_clo 356 osnum cl 357 otext t_oev 358 osnum sub cr cl 359 otext t_otb 360 osnum ot 361 otext t_mis 362 osnum sub sub cr cl ot 363 otext t_nl 364 oflush 365 end 366 367 fn runline nt ulong nr ulong to void 368 en = long 0 369 for i ulong nr 370 if gt get re i 0 371 en = add en 1 372 end 373 end 374 rt = long 0 375 for i ulong nt 376 if eq get ts i 3 377 rt = add rt 1 378 end 379 end 380 oreset 381 otext t_run 382 onum nr 383 otext t_ends 384 osnum en 385 otext t_rr 386 osnum sub long nr en 387 otext t_rt 388 osnum rt 389 otext t_mis 390 osnum sub sub long nr en rt 391 otext t_nl 392 oflush 393 end 394 395 note Concurrent runs at time t (runs with start <= t < end). 396 fn concat t long nr ulong tx long to long 397 c = long 0 398 for j ulong nr 399 if le get rs j t 400 if lt t rend j tx 401 c = add c 1 402 end 403 end 404 end 405 ret c 406 end 407 408 note Max concurrency (it is reached at a run start) and the seconds with more than cap runs: 409 note between consecutive sorted boundary times the count is constant. 410 fn concline nr ulong tx long cap long to void 411 mx = long 0 412 for i ulong nr 413 c = concat get rs i nr tx 414 if gt c mx 415 mx = c 416 end 417 end 418 m = ulong 0 419 for i ulong nr 420 put wk m get rs i 421 m = add m 1 422 put wk m rend i tx 423 m = add m 1 424 end 425 sortwk m 426 ov = long 0 427 for k ulong m 428 if gt k 0 429 a = get wk sub k 1 430 b = get wk k 431 if lt a b 432 if gt concat a nr tx cap 433 ov = add ov sub b a 434 end 435 end 436 end 437 end 438 oreset 439 otext t_conc 440 osnum mx 441 otext t_over 442 osnum ov 443 otext t_nl 444 oflush 445 end 446 447 fn rtyline nt ulong nr ulong to void 448 for i ulong nt 449 put cnt i 0 450 end 451 bad = long 0 452 for j ulong nr 453 x = ulong sub get ri j 1 454 if lt x nt 455 put cnt x add get cnt x 1 456 end 457 o = get ro j 458 if ge o 3 459 if le o 7 460 bad = add bad 1 461 end 462 end 463 end 464 ex = long 0 465 mu = long 0 466 for i ulong nt 467 c = get cnt i 468 if gt c 1 469 ex = add ex sub c 1 470 mu = add mu 1 471 end 472 end 473 oreset 474 otext t_rty 475 osnum ex 476 otext t_multi 477 osnum mu 478 otext t_badr 479 osnum bad 480 otext t_nl 481 oflush 482 end 483 484 fn accline nt ulong nr ulong to void 485 for i ulong nt 486 put fl i 0 487 end 488 for j ulong nr 489 if eq get ro j 1 490 x = ulong sub get ri j 1 491 if lt x nt 492 put fl x 1 493 end 494 end 495 end 496 dn = long 0 497 dc = long 0 498 for i ulong nt 499 if eq get ts i 6 500 dn = add dn 1 501 dc = add dc get fl i 502 end 503 end 504 oreset 505 otext t_acc 506 osnum dn 507 otext t_dcomp 508 osnum dc 509 otext t_nl 510 oflush 511 end 512 513 note Prints n, sum, nearest-rank p95 and max of wk[0, n) after a label. 514 fn statline t view uchar * n ulong s long to void 515 sortwk n 516 oreset 517 otext t 518 onum n 519 otext t_sum 520 osnum s 521 if gt n 0 522 rk = div add mul n 95 99 100 523 otext t_p95 524 osnum get wk sub rk 1 525 otext t_max 526 osnum get wk sub n 1 527 end 528 otext t_nl 529 oflush 530 end 531 532 note Created-to-completed latency of done tasks. 533 fn latline nt ulong to void 534 n = ulong 0 535 s = long 0 536 for i ulong nt 537 if eq get ts i 6 538 if gt get td i 0 539 w = sub get td i get tc i 540 put wk n w 541 s = add s w 542 n = add n 1 543 end 544 end 545 end 546 statline t_lat n s 547 end 548 549 note Created-to-first-run-start of tasks that have a run (includes dependency waits). 550 fn fstline nt ulong nr ulong to void 551 for i ulong nt 552 put wv i -1 553 end 554 for j ulong nr 555 x = ulong sub get ri j 1 556 if lt x nt 557 if eq get wv x -1 558 put wv x get rs j 559 end 560 end 561 end 562 n = ulong 0 563 s = long 0 564 for i ulong nt 565 if ge get wv i 0 566 w = sub get wv i get tc i 567 put wk n w 568 s = add s w 569 n = add n 1 570 end 571 end 572 statline t_fst n s 573 end 574 575 fn utilline nt ulong nr ulong tx long to void 576 b = long 0 577 for j ulong nr 578 b = add b sub rend j tx get rs j 579 end 580 mn = long `9223372036854775807` 581 for i ulong nt 582 mn = lmin mn get tc i 583 end 584 oreset 585 otext t_util 586 osnum b 587 otext t_h 588 osnum sub tx mn 589 otext t_nl 590 oflush 591 end 592 593 note Pool p: busy seconds of its runs, the length of the union of their intervals and the maximum 594 note number of its runs at one time. busy minus union is the integral of (c - 1) over the time c >= 1 595 note runs are active; it is not the slot time shared with another run (RESULTS deviation 5). 596 fn poolof j ulong nt ulong to long 597 x = ulong sub get ri j 1 598 if lt x nt 599 ret get tp x 600 end 601 ret -1 602 end 603 604 fn poolmax p long nr ulong nt ulong tx long to long 605 mx = long 0 606 for i ulong nr 607 if eq poolof i nt p 608 t = get rs i 609 c = long 0 610 for j ulong nr 611 if eq poolof j nt p 612 if le get rs j t 613 if lt t rend j tx 614 c = add c 1 615 end 616 end 617 end 618 end 619 mx = lmax mx c 620 end 621 end 622 ret mx 623 end 624 625 fn poolline p long nr ulong nt ulong tx long to void 626 n = ulong 0 627 b = long 0 628 for j ulong nr 629 if eq poolof j nt p 630 put wk n get rs j 631 put wv n rend j tx 632 b = add b sub rend j tx get rs j 633 n = add n 1 634 end 635 end 636 psort n 637 u = long 0 638 cs = long 0 639 ce = long 0 640 for k ulong n 641 s = get wk k 642 e = get wv k 643 if eq k 0 644 cs = s 645 ce = e 646 else 647 if gt s ce 648 u = add u sub ce cs 649 cs = s 650 ce = e 651 else 652 ce = lmax ce e 653 end 654 end 655 end 656 if gt n 0 657 u = add u sub ce cs 658 end 659 oreset 660 otext t_pool 661 osnum p 662 otext t_runs 663 onum n 664 otext t_pbusy 665 osnum b 666 otext t_puni 667 osnum u 668 otext t_pmax 669 osnum poolmax p nr nt tx 670 otext t_nl 671 oflush 672 end 673 674 note Insertion sort of (wk, wv) pairs by wk. 675 fn psort n ulong to void 676 for i ulong n 677 j = i 678 while gt j 0 bound 4096 679 x = get wk j 680 y = get wk sub j 1 681 if ge x y 682 break 683 end 684 xv = get wv j 685 put wk j y 686 put wv j get wv sub j 1 687 put wk sub j 1 x 688 put wv sub j 1 xv 689 j = sub j 1 690 end 691 end 692 end 693 694 note Bounded retry R = 1: runs after the second run of a task are dropped. 695 fn armline nt ulong nr ulong to void 696 for i ulong nt 697 put cnt i 0 698 end 699 dr = long 0 700 dc = long 0 701 for j ulong nr 702 x = ulong sub get ri j 1 703 if lt x nt 704 put cnt x add get cnt x 1 705 if gt get cnt x 2 706 dr = add dr 1 707 if eq get ro j 1 708 dc = add dc 1 709 end 710 end 711 end 712 end 713 oreset 714 otext t_arm 715 osnum dr 716 otext t_dacc 717 osnum dc 718 otext t_nl 719 oflush 720 end 721 722 fn argnum i ulong to long 723 n = argn i 724 if eq n 0 725 ret -1 726 end 727 for k ulong n 728 put buf k get arg k 729 end 730 put st 5 0 731 v = pfield 0 n 732 if ne get st 5 0 733 ret -1 734 end 735 if ne get st 4 n 736 ret -1 737 end 738 ret v 739 end 740 741 fn main to int 742 if ne argcnt 6 743 pr t_usage 744 ret 2 745 end 746 tx = argnum 4 747 cap = argnum 5 748 if lt tx 0 749 pr t_usage 750 ret 2 751 end 752 if lt cap 1 753 pr t_usage 754 ret 2 755 end 756 a = load 1 5 0 757 b = load 2 4 1 758 c = load 3 3 2 759 if eq a -3 760 pr t_ioerr 761 ret 3 762 end 763 if eq b -3 764 pr t_ioerr 765 ret 3 766 end 767 if eq c -3 768 pr t_ioerr 769 ret 3 770 end 771 if eq a -2 772 pr t_big 773 ret 4 774 end 775 if eq b -2 776 pr t_big 777 ret 4 778 end 779 if eq c -2 780 pr t_big 781 ret 4 782 end 783 if lt a 0 784 pr t_bad 785 ret 3 786 end 787 if lt b 0 788 pr t_bad 789 ret 3 790 end 791 if lt c 0 792 pr t_bad 793 ret 3 794 end 795 nt = ulong a 796 nr = ulong b 797 nev = ulong c 798 oreset 799 otext t_tr 800 onum nt 801 otext t_runs 802 onum nr 803 otext t_evs 804 onum nev 805 otext t_tx 806 osnum tx 807 otext t_cap 808 osnum cap 809 otext t_nl 810 oflush 811 sysline nt nev 812 runline nt nr 813 concline nr tx cap 814 rtyline nt nr 815 accline nt nr 816 latline nt 817 fstline nt nr 818 utilline nt nr tx 819 for p ulong 5 820 poolline long p nr nt tx 821 end 822 armline nt nr 823 ret 0 824 end