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/tests/d8_process_tax.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 / tests / d8_process_tax.om` 1649 lines · 31277 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note tests/d8_process_tax.om -- developer bar D8, no per-process CUDA tax (docs/issues/D8-process-tax.md). 3 note Compiled by the pinned seeded omc (omega-mv `e5b32567`, sha256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`). 4 note Host forms checked with the omega lookup tool at that pin. It replaced tests/run_d8_process_tax.sh (CUDApp#366). 5 note d8_process_tax dry-run OUTDIR HELLO HELLO_CONTROL host only: no GPU, no lease; the GPU devices hidden 6 note d8_process_tax gpu OUTDIR HELLO HELLO_CONTROL GB10: one spark-window lease, three runs, judged 7 note d8_process_tax check-gpu OUTDIR judges a recorded gpu run again; opens no device 8 note d8_process_tax inside-window OUTDIR HELLO HELLO_CONTROL only under spark-window run (the lease holds the chip) 9 note An empty OUTDIR selects build/d8-process-tax-dry-run (dry-run) or build/d8-process-tax/UTC-STAMP (gpu). 10 note HELLO and HELLO_CONTROL are build/hello_gpu and build/hello_gpu_control; make builds them first. 11 note Exit: 0 PASS, 1 FAIL, 2 NOT_RUN, 90 refused (arguments, a buffer bound or a failed host call). 12 note 13 note What is measured. hello_gpu prints its own overhead line (examples/hello_gpu/hello_gpu.c, D8): resident memory 14 note (VmRSS) before the GPU opens, after it opens and with its buffers allocated, its own buffer bytes, and what the 15 note session asked the driver for. With --hold-ms it prints its pid and holds its buffers; during the hold this program 16 note reads the same process from outside: VmRSS from /proc/PID/status and, on the GPU, the memory the driver reports for 17 note the pid (nvidia-smi --query-compute-apps, a read-only ORACLE). The measured process is build/hello_gpu itself. 18 note GPU runs, all in one lease, each a separate process: 19 note main hello_gpu --hold-ms=3000 must PASS the bar 20 note n1-short hello_gpu_control --bug=short --hold-ms=3000 negative control: must FAIL B1 21 note n2-ballast hello_gpu_control --d8-ballast-mib=512 --hold-ms=3000 negative control: the open cost must show the 22 note 512 MiB held across the open, and the run must FAIL B5 23 note The D8 verdict is PASS only when main passes AND both controls are caught. 24 note Dry run (host simulator, hello_gpu --sim, the same line without the open): the same three runs, a device-hidden 25 note run of the GPU path that must stop at NOT_RUN, the hold bound (--hold-ms=60001 refused with exit 2), the ballast 26 note flag refused by the default build (exit 2), and a self-test of the GPU judge and verdict on synthetic logs 27 note (labelled synthetic; they are not measurements). The dry run says nothing about the chip. 28 note 29 note The bar, registered before any chip run (2026-11-06, on CUDApp#280 commit `074adab1`): 30 note B1 run hello_gpu exits 0 and prints "checked `1048576` of `1048576` elements: 0 wrong, 0 never written" and PASS. 31 note B2 line exactly one well-formed D8 line; its open cost and "beyond own buffers" equal the differences of the 32 note numbers it prints; own buffers 12288 KiB (sim) or 12288..12352 KiB (a, b, c plus the code buffer). 33 note B3 outside the hold line names the pid this program started, and VmRSS read from outside during the hold is within 34 note 4096 KiB of the line's "with buffers" number. 35 note B4 driver (GPU) the driver's per-process report lists the pid with a whole number of MiB. Missing is FAIL. 36 note B5 tax TAX = max(0, open cost, resident beyond own buffers) + max(0, driver MiB x 1024 - own buffers KiB) 37 note (GPU) or max(0, resident beyond own buffers) (sim), and TAX <= 262144 KiB. 38 note 262144 KiB is 256 MiB (WolframLanguageEvaluator: 256*2^10 -> 262144); the pain D8 answers is about 4.6 GB per 39 note model: N[4.6*10^9/(256*2^20)] -> 17.136, the bar is 17.1 times below it. The ballast is 512 MiB 40 note (512*2^10 -> 524288 KiB the measurement must see). 41 note 42 note Host programs this driver starts, by absolute path: /usr/bin/bwrap (hides /dev/nvidia* for the dry run when the 43 note nodes exist), /usr/bin/nice and /usr/bin/taskset (D8_CORES pin, default 16,17; D8_CORES= runs unpinned), and on the 44 note gpu path /usr/bin/env, then spark-window, nvidia-smi, git and sha256sum found on PATH. execprog starts every child 45 note with an empty environment; spark-window needs HOME and PATH, so the gpu path passes HOME, PATH, USER, LOGNAME and 46 note SPARK_WINDOW_OWNER through /usr/bin/env until omega-mv has an execprog form that takes an environment. 47 note There is no signal-handler form at the pin either: an interrupted gpu run leaves its lease to expire (20 minutes). 48 note ---- storage (the shared part, regions and helpers, is tests/d8_lib.om). Regions here: 1 message, 4 OUTDIR, 49 note 5 this program, 6 HELLO, 7 HELLO_CONTROL, 10 outside pid, 11 outside VmRSS, 12 outside driver MiB, 13 hold pid, 50 note 14 failed bars, 15 lease id, 16 cores, 17 nvidia-smi, 18 spark-window, 20 child pid digits, 24 log path, 51 note 25 outside path, 26 file content, 27 verdict or lease path, 28 rc digits, 31 cwd and sha256sum. 52 global NV long 8 53 global J long 8 54 global E ulong 1 55 global PF uchar 8 56 global DE uchar 8192 57 58 text TUse "usage: d8_process_tax dry-run OUTDIR HELLO HELLO_CONTROL | gpu OUTDIR HELLO HELLO_CONTROL | check-gpu OUTDIR\n" 59 text TNL "\n" 60 text TSp " " 61 text TCm ", " 62 text TCol ": " 63 text TQm "?" 64 text TPASS "PASS" 65 text TFAIL "FAIL" 66 text TNR "NOT_RUN" 67 text TNRc "NOT_RUN: " 68 text TMDry "dry-run" 69 text TMHid "dry-run-hidden" 70 text TMGpu "gpu" 71 text TMChk "check-gpu" 72 text TMIn "inside-window" 73 text TDDry "build/d8-process-tax-dry-run" 74 text TDGpu "build/d8-process-tax/" 75 text TLog ".log" 76 text TOut ".outside" 77 text TCmd "# command: " 78 text TUs "# utc start: " 79 text TEx "# exit: " 80 text TUe "# utc end: " 81 text THold "hold (D8): pid " 82 text TChk "checked `1048576` of `1048576` elements: 0 wrong, 0 never written" 83 text TChkP "checked " 84 text TNoChk "no check line" 85 text TOvP "overhead (D8" 86 text TNAv "not available" 87 text TReG "overhead (D8): resident # KiB before open, # KiB after open, # KiB with buffers; own buffers # KiB; session driver allocations # KiB in #; open cost $ KiB, beyond own buffers $ KiB" 88 text TReS "overhead (D8, simulator, no device opened): resident # KiB before buffers, # KiB with buffers; own buffers # KiB; beyond own buffers $ KiB" 89 text TVmP "VmRSS:" 90 text TkB " kB" 91 text TPid "pid=" 92 text TVm "vmrss_kib=" 93 text TDrv "driver_mib=" 94 text TMiss "missing" 95 text TProc "/proc/" 96 text TStat "/status" 97 text TRan "ran " 98 text TRanE ": exit " 99 text TRanV ", outside VmRSS " 100 text TRanK " KiB" 101 text TRanD ", driver " 102 text TRanM " MiB" 103 text TRunNR " run exited " 104 text TRunNR2 " without a device (NOT_RUN): " 105 text TB1ok "run: exit 0, `1048576` of `1048576` right, PASS" 106 text TB1a "run: exit " 107 text TB2a "line: " 108 text TB2b " D8 lines, " 109 text TB2c " well-formed (exactly one required)" 110 text TB3n "outside: not judged without the line" 111 text TB4n "driver: not judged without the line" 112 text TB5n "tax: not judged without the line" 113 text TB2r "line: resident " 114 text TB2own " KiB, own " 115 text TB2op " KiB, open " 116 text TB2by ", beyond own " 117 text TB2ok " KiB (sums agree)" 118 text TB2f1 "line: printed open " 119 text TB2f2 " / beyond " 120 text TB2f3 " KiB disagree with its numbers, or own " 121 text TB2f4 " KiB is off" 122 text TB3a "outside: pid " 123 text TB3b " VmRSS " 124 text TB3c " KiB during the hold, line says " 125 text TB3d " KiB (tolerance 4096)" 126 text TB3f1 "outside: hold pid '" 127 text TB3f2 "', started pid '" 128 text TB3f3 "', VmRSS '" 129 text TB3f4 "' KiB vs line " 130 text TB4a "driver: pid " 131 text TB4b " holds " 132 text TB4c " MiB by the driver's report (session asked for " 133 text TB4d " KiB)" 134 text TB4f1 "driver: no per-process report for pid " 135 text TB4f2 " ('" 136 text TB4f3 "')" 137 text TB5a "tax: not judged without the driver's report (resident part " 138 text TB5b "tax: " 139 text TB5c " KiB = resident " 140 text TB5d " + driver beyond own buffers " 141 text TB5e "; bar <= 262144 KiB" 142 text TEx1 " (" 143 text TEx2 "), expected " 144 text TEx3 " by" 145 text TEx4 ":\n" 146 text TArr " -> " 147 text TAsEx ", as expected\n" 148 text TFl " (failed:" 149 text TPar ")" 150 text TNot ": NOT the expected " 151 text TBar1 " B" 152 text TSim "sim" 153 text TGpuK "gpu" 154 text TBalS " ballast seen: beyond own buffers +" 155 text TBalS2 " KiB >= 524288 KiB\n" 156 text TBalN " ballast NOT seen: beyond own buffers '" 157 text TBalN2 "' KiB\n" 158 text TBalG " ballast seen: open cost +" 159 text TBalGN " ballast NOT seen: open cost '" 160 text TBalGN2 "' KiB < 524288 KiB, the measurement is blind\n" 161 text TMainH "main (gpu), the bar:\n" 162 text TNoMain "no main.log in " 163 text TNoMain2 ": the GPU run did not happen" 164 text TMainNR "D8 PROCESS TAX: NOT_RUN (the GPU was not available inside the window)\n" 165 text TTaxP "D8 PROCESS TAX: PASS (tax " 166 text TTaxP2 " KiB <= 262144 KiB; both negative controls caught)\n" 167 text TTaxF "D8 PROCESS TAX: FAIL (main " 168 text TTaxF2 ", tax " 169 text TTaxF3 " KiB" 170 text TTaxF4 "; " 171 text TTaxF5 " control expectation(s) not met)\n" 172 text TNMain "main" 173 text TNShort "n1-short" 174 text TNBal "n2-ballast" 175 text TSMain "sim-main" 176 text TSShort "sim-short" 177 text TSBal "sim-ballast" 178 text THid "hidden-gpu" 179 text TGood "overhead (D8): resident 2000 KiB before open, 3000 KiB after open, 15300 KiB with buffers; own buffers 12289 KiB; session driver allocations 12320 KiB in 4; open cost +1000 KiB, beyond own buffers +1011 KiB" 180 text TBadS "overhead (D8): resident 2000 KiB before open, 3000 KiB after open, 15300 KiB with buffers; own buffers 12289 KiB; session driver allocations 12320 KiB in 4; open cost +1000 KiB, beyond own buffers +11 KiB" 181 text TBall "overhead (D8): resident 2000 KiB before open, 527300 KiB after open, 539600 KiB with buffers; own buffers 12289 KiB; session driver allocations 12320 KiB in 4; open cost +525300 KiB, beyond own buffers +525311 KiB" 182 text TSyn1 "# command: synthetic judge self-test (not a measurement)\nhello_gpu: c = a + b over `1048576` floats on the GPU, built with Omega's own kernel builder\n" 183 text TSyn2 "hold (D8): pid 4242, 3000 ms with buffers allocated, for an outside reading of this process\n" 184 text TSynOk "checked `1048576` of `1048576` elements: 0 wrong, 0 never written\nPASS\n" 185 text TSynBad "checked `1048576` of `1048576` elements: 1 wrong, 1 never written\nFAIL\n" 186 text TSynO1 "pid=4242\nvmrss_kib=" 187 text TSynO2 "\ndriver_mib=" 188 text T15310 "15310" 189 text T539610 "539610" 190 text T40 "40" 191 text T5000 "5000" 192 text T0 "0" 193 text T1 "1" 194 text T2 "2" 195 text TSynG "syn-good" 196 text TSynND "syn-no-driver" 197 text TSynDT "syn-driver-tax" 198 text TSynBS "syn-bad-sum" 199 text TSynTL "syn-two-lines" 200 text TSynNL "syn-no-line" 201 text TSynE1 "syn-exit-1" 202 text TSynNDv "syn-no-device" 203 text TSynHd "GPU judge self-test on synthetic logs (not measurements):\n" 204 text TVerHd "GPU verdict self-test on a synthetic recorded run (not a measurement):\n" 205 text TSynW "/syn-window" 206 text TVer "/verdict.txt" 207 text TVerB "/verdict-blind.txt" 208 text TVGood " good run with both controls caught -> exit " 209 text TVBlind " ballast control not seen (a blind measurement) -> exit " 210 text TVNot ", NOT the expected " 211 text TDryP "D8 DRY RUN: PASS (host simulator, device-hidden refusal, hold bound, default-build ballast refusal, judge and verdict self-tests; the chip row stays NOT_RUN until gpu runs in a window)\n" 212 text TDryF "D8 DRY RUN: FAIL (" 213 text TDryF2 " expectation(s) not met)\n" 214 text TBwrap "/usr/bin/bwrap" 215 text TNice "/usr/bin/nice" 216 text TTask "/usr/bin/taskset" 217 text TEnvB "/usr/bin/env" 218 text TDevB "--dev-bind" 219 text TDev "--dev" 220 text TDevD "/dev" 221 text TProcA "--proc" 222 text TProcD "/proc" 223 text TDDash "--" 224 text TN "-n" 225 text T10 "10" 226 text TC "-c" 227 text TNoBw "bwrap is needed to hide the GPU devices for the dry run" 228 text TDevVis "GPU device nodes are visible; the dry run must not see them" 229 text TNvPre "nvidia" 230 text TCoreV "D8_CORES=" 231 text TCoreD "16,17" 232 text TSimA "--sim" 233 text TH1000 "--hold-ms=1000" 234 text TH3000 "--hold-ms=3000" 235 text TH60001 "--hold-ms=60001" 236 text TShort "--bug=short" 237 text TBal512 "--d8-ballast-mib=512" 238 text TBal64 "--d8-ballast-mib=64" 239 text TBound "hold-bound" 240 text TBGate "default-build-ballast" 241 text TGateH "hello_gpu --sim " 242 text TGateA " -> exit " 243 text TGateE ", NOT the expected 2\n" 244 text TSmiQ "--query-compute-apps=pid,used_memory" 245 text TSmiF "--format=csv,noheader,nounits" 246 text TSmiG "--query-gpu=name,driver_version" 247 text TSmiF2 "--format=csv,noheader" 248 text TSpark "spark-window" 249 text TSmi "nvidia-smi" 250 text TGit "git" 251 text TSha "sha256sum" 252 text TNoCtl "no /dev/nvidiactl here (device-hidden sandbox?)" 253 text TCtl "/dev/nvidiactl" 254 text TNoSw "spark-window is not installed: no lease, no run" 255 text TNoSmi "nvidia-smi is not installed: B4 cannot be read" 256 text TNoGit "git is not installed: env.txt cannot name the commit" 257 text TNoSha "sha256sum is not installed: env.txt cannot name the binaries" 258 text TEnvT "env.txt" 259 text TLeaseT "lease.txt" 260 text TWinT "window.log" 261 text TCapT "capture.tmp" 262 text TVerT "verdict.txt" 263 text TGHead "git HEAD: " 264 text TGStat "git status (outside evidence/): " 265 text TGStat2 " changed files\n" 266 text TShaH "hello_gpu sha256: " 267 text TShaC "hello_gpu_control sha256: " 268 text TDrvE "driver: " 269 text TKern "kernel: " 270 text TKernP "/proc/sys/kernel/osrelease" 271 text TCores "cores: " 272 text TUnpin "unpinned" 273 text TBarE "bar: tax <= 262144 KiB, outside VmRSS tolerance 4096 KiB, ballast 512 MiB, hold 3000 ms\n" 274 text TRevP "rev-parse" 275 text THEAD "HEAD" 276 text TStatus "status" 277 text TPorc "--porcelain" 278 text TDot "." 279 text TNoEv ":!evidence" 280 text TOpenR "open-request " 281 text TOpen "open" 282 text TName "d8-process-tax" 283 text TLedg "--ledger" 284 text TDRA "DRA-158" 285 text TLeas "--lease" 286 text T20 "20" 287 text TGb "--gb10" 288 text TExcl "exclusive" 289 text TQuiet "--quiet" 290 text TNone "none" 291 text TWait "--wait" 292 text TId "id" 293 text TRun "run" 294 text TClose "close" 295 text TLease "lease " 296 text TStart " start " 297 text TWrc "window run rc=" 298 text TEnd " end " 299 text TClosed "closed " 300 text TNoLease "no spark-window lease" 301 text TInNR "not inside an exclusive spark-window lease" 302 text TSwV "SPARK_WINDOW=" 303 text TLockV "AIEN_GB10_LOCK_HELD=" 304 text THomeV "HOME=" 305 text TUserV "USER=" 306 text TLognV "LOGNAME=" 307 text TOwnV "SPARK_WINDOW_OWNER=" 308 309 fn lexit r ulong to void 310 bclr r 311 p = ulong 0 312 while lt p get Ln 0 bound 999999 313 e = lend p 314 if lpre p e TEx 315 q = add p len TEx 316 ok = true 317 while lt q e bound 4096 318 c = get L q 319 if or lt c 48 gt c 57 320 ok = false 321 end 322 q = add q 1 323 end 324 if ok 325 bclr r 326 lcopy add p len TEx e r 327 end 328 end 329 p = add e 1 330 end 331 end 332 333 note the digits of "hold (D8): pid [0-9]*,..." lines into region r 334 fn lhold r ulong to void 335 bclr r 336 k = ulong 0 337 p = ulong 0 338 while lt p get Ln 0 bound 999999 339 e = lend p 340 if lpre p e THold 341 q = add p len THold 342 while lt q e bound 4096 343 c = get L q 344 if or lt c 48 gt c 57 345 break 346 end 347 q = add q 1 348 end 349 if lt q e 350 if eq get L q 44 351 if gt k 0 352 bc r 10 353 end 354 lcopy add p len THold q r 355 k = add k 1 356 end 357 end 358 end 359 p = add e 1 360 end 361 end 362 363 note line [p, e) against a template: # is [0-9]+, $ is [+-][0-9]+; the numbers go to NV 364 fn ltpl p ulong e ulong t view uchar * to bool 365 k = ulong 0 366 for i ulong len t 367 c = get t i 368 if or eq c 35 eq c 36 369 ng = false 370 if eq c 36 371 if ge p e 372 ret false 373 end 374 c = get L p 375 if eq c 45 376 ng = true 377 else 378 if ne c 43 379 ret false 380 end 381 end 382 p = add p 1 383 end 384 v = long 0 385 d = ulong 0 386 while lt p e bound 4096 387 c = get L p 388 if or lt c 48 gt c 57 389 break 390 end 391 if ge d 18 392 ret false 393 end 394 v = add mul v 10 long sub c 48 395 d = add d 1 396 p = add p 1 397 end 398 if eq d 0 399 ret false 400 end 401 if ng 402 v = neg v 403 end 404 put NV k v 405 k = add k 1 406 else 407 if ge p e 408 ret false 409 end 410 if ne get L p c 411 ret false 412 end 413 p = add p 1 414 end 415 end 416 ret eq p e 417 end 418 419 note lines matching the D8 template of kind (1 gpu, 0 sim); NV holds the last match 420 fn lcntd8 kind ulong to ulong 421 c = ulong 0 422 p = ulong 0 423 while lt p get Ln 0 bound 999999 424 e = lend p 425 if eq kind 1 426 if ltpl p e TReG 427 c = add c 1 428 end 429 else 430 if ltpl p e TReS 431 c = add c 1 432 end 433 end 434 p = add e 1 435 end 436 ret c 437 end 438 439 note ---- output rows 440 fn padto r ulong w ulong to void 441 while lt get Bn r w bound 4096 442 bc r 32 443 end 444 end 445 446 note row: bar b, the message in region 1, ok 447 fn row b ulong ok bool to void 448 bs 2 TSp 449 bt 2 TSp 450 bc 2 66 451 bu 2 b 452 padto 2 5 453 bt 2 TSp 454 bb 2 1 455 padto 2 80 456 bt 2 TSp 457 if ok 458 bt 2 TPASS 459 else 460 bt 2 TFAIL 461 bt 14 TBar1 462 bu 14 b 463 put J 7 or get J 7 long shl ulong 1 b 464 end 465 bt 2 TNL 466 bout 1 2 467 end 468 469 fn brc r ulong to void 470 if eq get Bn 28 0 471 bt r TQm 472 else 473 bb r 28 474 end 475 end 476 477 note ---- the judge. kind 1 gpu, 0 sim. J: 0 verdict (0 PASS, 1 FAIL, 2 NOT_RUN), 1 open set, 2 open, 3 beyond 478 note set, 4 beyond, 5 tax set, 6 tax, 7 failed bars (bit b). NV after B2: before, open_kib, with, own, drv_alloc. 479 fn judge12 kind ulong to bool 480 x = fload 24 481 lexit 28 482 if or bist 28 T2 gt lcnt TNR 0 0 483 bs 2 TRunNR 484 brc 2 485 bt 2 TRunNR2 486 lfirst2 TNAv TNR 2 487 bt 2 TNL 488 bout 1 2 489 put J 0 2 490 ret false 491 end 492 ok = and and bist 28 T0 gt lcnt TChk 0 0 and gt lcnt TPASS 0 0 eq lcnt TFAIL 0 0 493 if ok 494 bs 1 TB1ok 495 row 1 true 496 else 497 bs 1 TB1a 498 brc 1 499 bt 1 TCm 500 if not lfirst TChkP 1 501 bt 1 TNoChk 502 end 503 row 1 false 504 end 505 n = lcntd8 kind 506 total = lcnt TOvP 1 507 if or ne n 1 ne total 1 508 bs 1 TB2a 509 bu 1 total 510 bt 1 TB2b 511 bu 1 n 512 bt 1 TB2c 513 row 2 false 514 bs 1 TB3n 515 row 3 false 516 if eq kind 1 517 bs 1 TB4n 518 row 4 false 519 end 520 bs 1 TB5n 521 row 5 false 522 put J 0 1 523 ret false 524 end 525 ret true 526 end 527 528 fn judge2 kind ulong to void 529 before = get NV 0 530 okb = get NV 1 531 with = get NV 2 532 ownb = get NV 3 533 opc = get NV 6 534 by = get NV 7 535 if eq kind 0 536 okb = before 537 with = get NV 1 538 ownb = get NV 2 539 by = get NV 3 540 opc = long 0 541 put NV 4 0 542 end 543 put NV 1 okb 544 put NV 2 with 545 put NV 3 ownb 546 ownok = eq ownb 12288 547 if eq kind 1 548 ownok = and ge ownb 12288 le ownb 12352 549 end 550 ownok = and ownok gt before 0 551 ownok = and ownok gt with 0 552 ownok = and ownok eq opc sub okb before 553 ownok = and ownok eq by sub sub with before ownb 554 if ownok 555 bs 1 TB2r 556 bl 1 before 557 bt 1 TSl 558 bl 1 okb 559 bt 1 TSl 560 bl 1 with 561 bt 1 TB2own 562 bl 1 ownb 563 bt 1 TB2op 564 bl 1 opc 565 bt 1 TB2by 566 bl 1 by 567 bt 1 TB2ok 568 row 2 true 569 else 570 bs 1 TB2f1 571 bl 1 opc 572 bt 1 TB2f2 573 bl 1 by 574 bt 1 TB2f3 575 bl 1 ownb 576 bt 1 TB2f4 577 row 2 false 578 end 579 put J 1 1 580 put J 2 opc 581 put J 3 1 582 put J 4 by 583 end 584 585 fn judge3 to void 586 x = fload 25 587 lvals TPid 10 588 lvals TVm 11 589 lvals TDrv 12 590 x = fload 24 591 lhold 13 592 with = get NV 2 593 vm = bnum 11 594 ok = false 595 if and and gt get Bn 13 0 beq 13 10 ge vm 0 596 d = sub vm with 597 if lt d 0 598 d = neg d 599 end 600 ok = le d 4096 601 end 602 if ok 603 bs 1 TB3a 604 bb 1 10 605 bt 1 TB3b 606 bb 1 11 607 bt 1 TB3c 608 bl 1 with 609 bt 1 TB3d 610 row 3 true 611 else 612 bs 1 TB3f1 613 bb 1 13 614 bt 1 TB3f2 615 bb 1 10 616 bt 1 TB3f3 617 bb 1 11 618 bt 1 TB3f4 619 bl 1 with 620 row 3 false 621 end 622 end 623 624 fn judge45 kind ulong to void 625 opc = get J 2 626 rss = get J 4 627 if gt opc rss 628 rss = opc 629 end 630 if lt rss 0 631 rss = long 0 632 end 633 drv = bnum 12 634 dp = long 0 635 if eq kind 1 636 if ge drv 0 637 bs 1 TB4a 638 bb 1 10 639 bt 1 TB4b 640 bb 1 12 641 bt 1 TB4c 642 bl 1 get NV 4 643 bt 1 TB4d 644 row 4 true 645 dp = sub mul drv 1024 get NV 3 646 if lt dp 0 647 dp = long 0 648 end 649 else 650 bs 1 TB4f1 651 bb 1 10 652 bt 1 TB4f2 653 bb 1 12 654 bt 1 TB4f3 655 row 4 false 656 end 657 end 658 tax = add rss dp 659 put J 5 1 660 put J 6 tax 661 if and eq kind 1 lt drv 0 662 bs 1 TB5a 663 bl 1 rss 664 bt 1 TB4d 665 row 5 false 666 else 667 bs 1 TB5b 668 bl 1 tax 669 bt 1 TB5c 670 bl 1 rss 671 bt 1 TB5d 672 bl 1 dp 673 bt 1 TB5e 674 row 5 le tax 262144 675 end 676 end 677 678 fn judge kind ulong nm view uchar * to void 679 for i ulong 8 680 put J i 0 681 end 682 bclr 14 683 bpath 24 nm TLog 684 bpath 25 nm TOut 685 if not judge12 kind 686 ret 687 end 688 judge2 kind 689 judge3 690 judge45 kind 691 if eq get J 7 0 692 put J 0 0 693 else 694 put J 0 1 695 end 696 end 697 698 fn bverd r ulong v long to void 699 if eq v 0 700 bt r TPASS 701 end 702 if eq v 1 703 bt r TFAIL 704 end 705 if eq v 2 706 bt r TNR 707 end 708 end 709 710 fn bkind r ulong kind ulong to void 711 if eq kind 1 712 bt r TGpuK 713 else 714 bt r TSim 715 end 716 end 717 718 fn bbars r ulong mask long to void 719 for b ulong 6 720 if ne and mask long shl ulong 1 b 0 721 bt r TBar1 722 bu r b 723 end 724 end 725 end 726 727 note expect: want 0 PASS, 1 FAIL, 2 NOT_RUN; a FAIL expectation names the bars (bit b) that must be among the failed 728 fn expect nm view uchar * kind ulong want long mask long to void 729 bs 2 nm 730 bt 2 TEx1 731 bkind 2 kind 732 bt 2 TEx2 733 bverd 2 want 734 if ne mask 0 735 bt 2 TEx3 736 bbars 2 mask 737 end 738 bt 2 TEx4 739 bout 1 2 740 judge kind nm 741 v = get J 0 742 bs 2 TArr 743 bverd 2 v 744 if and eq v want eq and get J 7 mask mask 745 bt 2 TAsEx 746 else 747 if gt get Bn 14 0 748 bt 2 TFl 749 bb 2 14 750 bt 2 TPar 751 end 752 bt 2 TNot 753 bverd 2 want 754 if ne mask 0 755 bt 2 TEx3 756 bbars 2 mask 757 end 758 bt 2 TNL 759 put E 0 add get E 0 1 760 end 761 bout 1 2 762 end 763 764 fn notrun t view uchar * to void 765 bs 2 TNRc 766 bt 2 t 767 bt 2 TNL 768 bout 1 2 769 exit 2 770 end 771 772 note ---- check-gpu 773 fn checkgpu to int 774 bpath 24 TNMain TLog 775 if not bexists 24 776 bs 2 TNRc 777 bt 2 TNoMain 778 bb 2 4 779 bt 2 TNoMain2 780 bt 2 TNL 781 bout 1 2 782 ret 2 783 end 784 put E 0 0 785 say TMainH 786 judge 1 TNMain 787 mv = get J 0 788 tset = get J 5 789 tax = get J 6 790 bs 2 TArr 791 bverd 2 mv 792 bt 2 TNL 793 bout 1 2 794 if eq mv 2 795 say TMainNR 796 ret 2 797 end 798 expect TNShort 1 1 2 799 expect TNBal 1 1 32 800 if and eq get J 1 1 ge get J 2 524288 801 bs 2 TBalG 802 bl 2 get J 2 803 bt 2 TBalS2 804 else 805 bs 2 TBalGN 806 if eq get J 1 1 807 bl 2 get J 2 808 end 809 bt 2 TBalGN2 810 put E 0 add get E 0 1 811 end 812 bout 1 2 813 if and eq mv 0 eq get E 0 0 814 bs 2 TTaxP 815 bl 2 tax 816 bt 2 TTaxP2 817 bout 1 2 818 ret 0 819 end 820 bs 2 TTaxF 821 bverd 2 mv 822 if eq tset 1 823 bt 2 TTaxF2 824 bl 2 tax 825 bt 2 TTaxF3 826 end 827 bt 2 TTaxF4 828 bu 2 get E 0 829 bt 2 TTaxF5 830 bout 1 2 831 ret 1 832 end 833 834 note ---- measure: runs AL and reads it from outside during its hold. kind 1 gpu. Writes NAME.log and NAME.outside. 835 note The driver's report for the pid, field 2 of nvidia-smi's "pid, used_memory" rows, into region 12. 836 fn smiread pid long to void 837 bclr 12 838 x = pipefds PF 0 8 524288 839 if ne x 0 840 ret 841 end 842 rfd = int or long get PF 0 shl long get PF 1 8 843 wfd = int or long get PF 4 shl long get PF 5 8 844 alclr 845 alb 17 846 alt TSmiQ 847 alt TSmiF 848 c = spawn 2 0 wfd 849 x = fclose wfd 850 n = ulong 0 851 while lt n len L bound 999999 852 k = read rfd L n sub len L n 853 if le k 0 854 break 855 end 856 n = add n ulong k 857 end 858 x = fclose rfd 859 w = reap c 0 860 put Ln 0 n 861 bclr 20 862 bu 20 ulong pid 863 p = ulong 0 864 while lt p n bound 999999 865 e = lend p 866 q = p 867 while lt q e bound 4096 868 if eq get L q 44 869 break 870 end 871 q = add q 1 872 end 873 bclr 3 874 lcopy p q 3 875 if lt q e 876 if beq 3 20 877 q = add q 1 878 while lt q e bound 4096 879 if ne get L q 32 880 break 881 end 882 q = add q 1 883 end 884 s = q 885 while lt q e bound 4096 886 if eq get L q 44 887 break 888 end 889 q = add q 1 890 end 891 lcopy s q 12 892 ret 893 end 894 end 895 p = add e 1 896 end 897 end 898 899 note VmRSS of /proc/PID/status (sed 's/^VmRSS:[[:space:]]*\([0-9]*\) kB$/\1/p') into region 11 900 fn vmread pid long to void 901 bs 30 TProc 902 bu 30 ulong pid 903 bt 30 TStat 904 bclr 11 905 if not fload 30 906 ret 907 end 908 p = ulong 0 909 while lt p get Ln 0 bound 999999 910 e = lend p 911 if lpre p e TVmP 912 q = add p len TVmP 913 while lt q e bound 4096 914 c = get L q 915 if and ne c 32 ne c 9 916 break 917 end 918 q = add q 1 919 end 920 s = q 921 while lt q e bound 4096 922 c = get L q 923 if or lt c 48 gt c 57 924 break 925 end 926 q = add q 1 927 end 928 if leq q e TkB 929 lcopy s q 11 930 end 931 end 932 p = add e 1 933 end 934 end 935 936 fn holdseen to bool 937 x = fload 24 938 ret gt lcnt THold 1 0 939 end 940 941 fn measure nm view uchar * kind ulong to void 942 bpath 24 nm TLog 943 bpath 25 nm TOut 944 bs 26 TCmd 945 bcmd 26 946 bt 26 TNL 947 bt 26 TUs 948 bstamp 26 0 949 bt 26 TNL 950 bfile 24 26 578 951 pid = spawn 1 24 0 952 rc = neg long 1 953 for i ulong 600 954 if holdseen 955 break 956 end 957 rc = reap pid 1 958 if ge rc 0 959 break 960 end 961 x = sleepns `100000000` 962 end 963 bs 11 TMiss 964 bs 12 TMiss 965 if holdseen 966 if lt rc 0 967 rc = reap pid 1 968 end 969 end 970 if holdseen 971 if lt rc 0 972 vmread pid 973 if eq get Bn 11 0 974 bs 11 TMiss 975 end 976 if eq kind 1 977 for t ulong 3 978 smiread pid 979 if gt get Bn 12 0 980 break 981 end 982 bs 12 TMiss 983 x = sleepns `300000000` 984 end 985 end 986 end 987 end 988 if lt rc 0 989 rc = reap pid 0 990 end 991 bs 26 TEx 992 bl 26 rc 993 bt 26 TNL 994 bt 26 TUe 995 bstamp 26 0 996 bt 26 TNL 997 bfile 24 26 1089 998 bs 26 TPid 999 bl 26 pid 1000 bt 26 TNL 1001 bt 26 TVm 1002 bb 26 11 1003 bt 26 TNL 1004 bt 26 TDrv 1005 bb 26 12 1006 bt 26 TNL 1007 bfile 25 26 578 1008 bs 2 TRan 1009 bt 2 nm 1010 bt 2 TRanE 1011 bl 2 rc 1012 bt 2 TRanV 1013 bb 2 11 1014 bt 2 TRanK 1015 if eq kind 1 1016 bt 2 TRanD 1017 bb 2 12 1018 bt 2 TRanM 1019 end 1020 bt 2 TNL 1021 bout 1 2 1022 end 1023 1024 note ---- dry run 1025 note any /dev entry named nvidia* (compgen -G '/dev/nvidia*') 1026 fn devvis to bool 1027 fd = fopen TDevD 0 len TDevD 0 0 1028 if lt fd 0 1029 ret false 1030 end 1031 seen = false 1032 while true bound 4096 1033 n = getdnts int fd DE 0 len DE 1034 if le n 0 1035 break 1036 end 1037 p = ulong 0 1038 while lt p ulong n bound 8192 1039 rl = add ulong get DE add p 16 shl ulong get DE add p 17 8 1040 ok = true 1041 for i ulong len TNvPre 1042 if ne get DE add add p 19 i get TNvPre i 1043 ok = false 1044 end 1045 end 1046 if ok 1047 seen = true 1048 end 1049 if eq rl 0 1050 break 1051 end 1052 p = add p rl 1053 end 1054 end 1055 x = fclose int fd 1056 ret seen 1057 end 1058 1059 fn cores to bool 1060 if envget TCoreV 16 1061 ret gt get Bn 16 0 1062 end 1063 bs 16 TCoreD 1064 ret true 1065 end 1066 1067 fn alpin to void 1068 alt TNice 1069 alt TN 1070 alt T10 1071 if cores 1072 alt TTask 1073 alt TC 1074 alb 16 1075 end 1076 end 1077 1078 note a hello run that must refuse with exit 2 (the hold bound, the ballast flag outside the control build) 1079 fn refuse nm view uchar * arg view uchar * to void 1080 alclr 1081 alb 6 1082 alt TSimA 1083 alt arg 1084 bpath 24 nm TLog 1085 bs 26 TCmd 1086 bcmd 26 1087 bt 26 TNL 1088 bfile 24 26 578 1089 rc = runwait 1 24 1090 bs 2 nm 1091 bt 2 TCol 1092 bt 2 TGateH 1093 bt 2 arg 1094 bt 2 TGateA 1095 bl 2 rc 1096 if eq rc 2 1097 bt 2 TAsEx 1098 else 1099 bt 2 TGateE 1100 put E 0 add get E 0 1 1101 end 1102 bout 1 2 1103 end 1104 1105 note synthetic GPU logs for the judge's self-test. line 0 none, 1 good, 2 bad sum, 3 two lines, 4 ballast 1106 fn synlog p ulong line ulong bad bool rc view uchar * to void 1107 bs 26 TSyn1 1108 if eq line 1 1109 bt 26 TGood 1110 bt 26 TNL 1111 end 1112 if eq line 2 1113 bt 26 TBadS 1114 bt 26 TNL 1115 end 1116 if eq line 3 1117 bt 26 TGood 1118 bt 26 TNL 1119 bt 26 TGood 1120 bt 26 TNL 1121 end 1122 if eq line 4 1123 bt 26 TBall 1124 bt 26 TNL 1125 end 1126 bt 26 TSyn2 1127 if bad 1128 bt 26 TSynBad 1129 else 1130 bt 26 TSynOk 1131 end 1132 bt 26 TEx 1133 bt 26 rc 1134 bt 26 TNL 1135 bfile p 26 578 1136 end 1137 1138 fn synout p ulong vm view uchar * drv view uchar * to void 1139 bs 26 TSynO1 1140 bt 26 vm 1141 bt 26 TSynO2 1142 bt 26 drv 1143 bt 26 TNL 1144 bfile p 26 578 1145 end 1146 1147 note drv 0 "40", 1 missing, 2 "5000"; rc 0, 1 or 2 1148 fn syn nm view uchar * line ulong drv ulong rc ulong to void 1149 bpath 24 nm TLog 1150 if eq rc 0 1151 synlog 24 line false T0 1152 end 1153 if eq rc 1 1154 synlog 24 line false T1 1155 end 1156 if eq rc 2 1157 synlog 24 line false T2 1158 end 1159 bpath 25 nm TOut 1160 if eq drv 0 1161 synout 25 T15310 T40 1162 end 1163 if eq drv 1 1164 synout 25 T15310 TMiss 1165 end 1166 if eq drv 2 1167 synout 25 T15310 T5000 1168 end 1169 end 1170 1171 note check-gpu on OUTDIR/syn-window in a child, stdout to the verdict file; the exit code 1172 fn verdict vf view uchar * to long 1173 bclr 27 1174 bb 27 4 1175 bt 27 TSynW 1176 bt 27 vf 1177 pid = fork 1178 if lt pid 0 1179 bfail 1180 end 1181 if eq pid 0 1182 f = bopen 27 578 1183 if lt f 0 1184 exit 90 1185 end 1186 x = dupfd int f 1 0 1187 bt 4 TSynW 1188 exit checkgpu 1189 end 1190 ret reap pid 0 1191 end 1192 1193 fn vline t view uchar * rc long want long to void 1194 bs 2 t 1195 bl 2 rc 1196 if eq rc want 1197 bt 2 TAsEx 1198 else 1199 bt 2 TVNot 1200 bl 2 want 1201 bt 2 TNL 1202 put E 0 add get E 0 1 1203 end 1204 bout 1 2 1205 end 1206 1207 note path region 30 = OUTDIR/syn-window/ nm sx 1208 fn swpath nm view uchar * sx view uchar * to void 1209 bclr 30 1210 bb 30 4 1211 bt 30 TSynW 1212 bt 30 TSl 1213 bt 30 nm 1214 bt 30 sx 1215 end 1216 1217 fn selftest to void 1218 say TSynHd 1219 syn TSynG 1 0 0 1220 syn TSynND 1 1 0 1221 syn TSynDT 1 2 0 1222 syn TSynBS 2 0 0 1223 syn TSynTL 3 0 0 1224 syn TSynNL 0 0 0 1225 syn TSynE1 1 0 1 1226 syn TSynNDv 0 1 2 1227 expect TSynG 1 0 0 1228 expect TSynND 1 1 48 1229 expect TSynDT 1 1 32 1230 expect TSynBS 1 1 4 1231 expect TSynTL 1 1 4 1232 expect TSynNL 1 1 4 1233 expect TSynE1 1 1 2 1234 expect TSynNDv 1 2 0 1235 say TVerHd 1236 bclr 30 1237 bb 30 4 1238 bt 30 TSynW 1239 x = makedir B mul ulong 30 4096 get Bn 30 493 1240 swpath TNMain TLog 1241 synlog 30 1 false T0 1242 swpath TNMain TOut 1243 synout 30 T15310 T40 1244 swpath TNShort TOut 1245 synout 30 T15310 T40 1246 swpath TNShort TLog 1247 synlog 30 1 true T1 1248 swpath TNBal TLog 1249 synlog 30 4 false T0 1250 swpath TNBal TOut 1251 synout 30 T539610 T40 1252 vline TVGood verdict TVer 0 1253 swpath TNBal TLog 1254 synlog 30 1 false T0 1255 swpath TNBal TOut 1256 synout 30 T15310 T40 1257 vline TVBlind verdict TVerB 1 1258 end 1259 1260 fn dryrun hidden bool to int 1261 if not hidden 1262 if devvis 1263 if ne faccess TBwrap 0 len TBwrap 1 0 1264 notrun TNoBw 1265 end 1266 alclr 1267 alpin 1268 alt TBwrap 1269 alt TDevB 1270 alt TSl 1271 alt TSl 1272 alt TDev 1273 alt TDevD 1274 alt TProcA 1275 alt TProcD 1276 alt TDDash 1277 alb 5 1278 alt TMHid 1279 alb 4 1280 alb 6 1281 alb 7 1282 put AL 0 uchar get AP 1 1283 put AL 1 0 1284 x = execprog AL 0 get AP 0 1285 bfail 1286 end 1287 end 1288 if devvis 1289 notrun TDevVis 1290 end 1291 mkdirp 4 1292 alclr 1293 alb 6 1294 alt TSimA 1295 alt TH1000 1296 measure TSMain 0 1297 alclr 1298 alb 7 1299 alt TSimA 1300 alt TShort 1301 alt TH1000 1302 measure TSShort 0 1303 alclr 1304 alb 7 1305 alt TSimA 1306 alt TBal512 1307 alt TH1000 1308 measure TSBal 0 1309 alclr 1310 alb 6 1311 alt TH1000 1312 measure THid 1 1313 put E 0 0 1314 expect TSMain 0 0 0 1315 expect TSShort 0 1 2 1316 expect TSBal 0 1 32 1317 if and eq get J 3 1 ge get J 4 524288 1318 bs 2 TBalS 1319 bl 2 get J 4 1320 bt 2 TBalS2 1321 else 1322 bs 2 TBalN 1323 if eq get J 3 1 1324 bl 2 get J 4 1325 end 1326 bt 2 TBalN2 1327 put E 0 add get E 0 1 1328 end 1329 bout 1 2 1330 expect THid 1 2 0 1331 refuse TBound TH60001 1332 refuse TBGate TBal64 1333 selftest 1334 if eq get E 0 0 1335 say TDryP 1336 ret 0 1337 end 1338 bs 2 TDryF 1339 bu 2 get E 0 1340 bt 2 TDryF2 1341 bout 1 2 1342 ret 1 1343 end 1344 1345 note ---- inside the window and the gpu run 1346 fn inside to int 1347 if not envget TSwV 3 1348 notrun TInNR 1349 end 1350 if eq get Bn 3 0 1351 notrun TInNR 1352 end 1353 if not envget TLockV 3 1354 notrun TInNR 1355 end 1356 if not bist 3 T1 1357 notrun TInNR 1358 end 1359 alclr 1360 alb 6 1361 alt TH3000 1362 measure TNMain 1 1363 alclr 1364 alb 7 1365 alt TShort 1366 alt TH3000 1367 measure TNShort 1 1368 alclr 1369 alb 7 1370 alt TBal512 1371 alt TH3000 1372 measure TNBal 1 1373 ret 0 1374 end 1375 1376 fn alenv to void 1377 alclr 1378 alt TEnvB 1379 envkv THomeV 1380 envkv TPathV 1381 envkv TUserV 1382 envkv TLognV 1383 envkv TOwnV 1384 alb 18 1385 end 1386 1387 note runs AL with stdout and stderr to region 29's file; region 3 gets the output without trailing newlines 1388 fn shafield r ulong to void 1389 for i ulong get Bn 3 1390 c = get B add mul ulong 3 4096 i 1391 if eq c 32 1392 break 1393 end 1394 bc r c 1395 end 1396 bt r TNL 1397 end 1398 1399 note env.txt: the commit, the binaries, the driver, the kernel, the pin and the bar. git and sha256sum are in 19/31. 1400 fn envtxt to void 1401 bpath1 29 TCapT 1402 bs 26 TGHead 1403 alclr 1404 alb 19 1405 alt TRevP 1406 alt THEAD 1407 x = capture 1408 bb 26 3 1409 bt 26 TNL 1410 bt 26 TGStat 1411 alclr 1412 alb 19 1413 alt TStatus 1414 alt TPorc 1415 alt TDDash 1416 alt TDot 1417 alt TNoEv 1418 x = capture 1419 c = ulong 0 1420 if gt get Bn 3 0 1421 c = ulong 1 1422 end 1423 for i ulong get Bn 3 1424 if eq get B add mul ulong 3 4096 i 10 1425 c = add c 1 1426 end 1427 end 1428 bu 26 c 1429 bt 26 TGStat2 1430 bt 26 TShaH 1431 alclr 1432 alb 31 1433 alb 6 1434 x = capture 1435 shafield 26 1436 bt 26 TShaC 1437 alclr 1438 alb 31 1439 alb 7 1440 x = capture 1441 shafield 26 1442 bt 26 TDrvE 1443 alclr 1444 alb 17 1445 alt TSmiG 1446 alt TSmiF2 1447 x = capture 1448 bb 26 3 1449 bt 26 TNL 1450 bt 26 TKern 1451 bs 30 TKernP 1452 if fload 30 1453 n = get Ln 0 1454 while gt n 0 bound 4096 1455 if ne get L sub n 1 10 1456 break 1457 end 1458 n = sub n 1 1459 end 1460 lcopy 0 n 26 1461 end 1462 bt 26 TNL 1463 bt 26 TCores 1464 if cores 1465 bb 26 16 1466 else 1467 bt 26 TUnpin 1468 end 1469 bt 26 TNL 1470 bt 26 TBarE 1471 bpath1 30 TEnvT 1472 bfile 30 26 578 1473 end 1474 1475 fn lnote p ulong t view uchar * t2 view uchar * to void 1476 bs 26 t 1477 bb 26 15 1478 bt 26 t2 1479 bstamp 26 1 1480 bt 26 TNL 1481 bfile p 26 1089 1482 end 1483 1484 fn gpurun to int 1485 if not bexists 30 1486 notrun TNoCtl 1487 end 1488 if not which TSpark 1489 notrun TNoSw 1490 end 1491 bclr 18 1492 bb 18 19 1493 if not which TSmi 1494 notrun TNoSmi 1495 end 1496 bclr 17 1497 bb 17 19 1498 if not which TSha 1499 notrun TNoSha 1500 end 1501 bclr 31 1502 bb 31 19 1503 if not which TGit 1504 notrun TNoGit 1505 end 1506 mkdirp 4 1507 envtxt 1508 bpath1 27 TLeaseT 1509 bs 26 TOpenR 1510 bstamp 26 1 1511 bt 26 TNL 1512 bfile 27 26 578 1513 alenv 1514 alt TOpen 1515 alt TName 1516 alt TLedg 1517 alt TDRA 1518 alt TLeas 1519 alt T20 1520 alt TGb 1521 alt TExcl 1522 alt TQuiet 1523 alt TNone 1524 alt TWait 1525 rc = runwait 1 27 1526 bpath1 29 TCapT 1527 alenv 1528 alt TId 1529 rc = capture 1530 bclr 15 1531 if eq rc 0 1532 bb 15 3 1533 end 1534 if eq get Bn 15 0 1535 catfile 27 1536 notrun TNoLease 1537 end 1538 lnote 27 TLease TStart 1539 bpath1 29 TWinT 1540 alenv 1541 alt TRun 1542 alpin 1543 alb 5 1544 alt TMIn 1545 alb 4 1546 alb 6 1547 alb 7 1548 bclr 3 1549 bfile 29 3 578 1550 pid = spawn 1 29 0 1551 t0 = monons 1552 rc = neg long 1 1553 while lt rc 0 bound 999999 1554 rc = reap pid 1 1555 if lt rc 0 1556 if gt sub monons t0 `1080000000000` 1557 x = killpid int pid 15 1558 rc = reap pid 0 1559 rc = long 124 1560 else 1561 x = sleepns `100000000` 1562 end 1563 end 1564 end 1565 bs 26 TWrc 1566 bl 26 rc 1567 bt 26 TEnd 1568 bstamp 26 1 1569 bt 26 TNL 1570 bfile 27 26 1089 1571 alenv 1572 alt TClose 1573 alb 15 1574 rc = runwait 1 27 1575 bs 3 TClosed 1576 lnote 27 TClosed TSp 1577 catfile 29 1578 bpath1 27 TVerT 1579 pid = fork 1580 if lt pid 0 1581 bfail 1582 end 1583 if eq pid 0 1584 f = bopen 27 578 1585 if lt f 0 1586 exit 90 1587 end 1588 x = dupfd int f 1 0 1589 exit checkgpu 1590 end 1591 v = reap pid 0 1592 catfile 27 1593 ret int v 1594 end 1595 1596 fn main to int 1597 c = argcnt 1598 if lt c 3 1599 r = write 2 TUse 0 len TUse 1600 ret 2 1601 end 1602 barg 0 5 1603 barg 1 3 1604 barg 2 4 1605 if ne get B mul ulong 5 4096 47 1606 k = cwd B mul ulong 31 4096 4095 1607 if le k 0 1608 bfail 1609 end 1610 put Bn 31 sub ulong k 1 1611 bt 31 TSl 1612 bb 31 5 1613 bclr 5 1614 bb 5 31 1615 end 1616 if ge c 5 1617 barg 3 6 1618 barg 4 7 1619 end 1620 if bist 3 TMChk 1621 ret checkgpu 1622 end 1623 if lt c 5 1624 r = write 2 TUse 0 len TUse 1625 ret 2 1626 end 1627 if bist 3 TMDry 1628 if eq get Bn 4 0 1629 bs 4 TDDry 1630 end 1631 ret dryrun false 1632 end 1633 if bist 3 TMHid 1634 ret dryrun true 1635 end 1636 if bist 3 TMIn 1637 ret inside 1638 end 1639 if bist 3 TMGpu 1640 if eq get Bn 4 0 1641 bs 4 TDGpu 1642 bstamp 4 2 1643 end 1644 bs 30 TCtl 1645 ret gpurun 1646 end 1647 r = write 2 TUse 0 len TUse 1648 ret 2 1649 end