omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / gpu / amd / bench / barrier / gate.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Persistent-kernel barrier micro-benchmark. Compiled after gpu/amd/gfx942/exec/fma.om, |
| 3 | note under target x86linux and om2, so the host can exec llvm-mc. fpfma is the GEMV |
| 4 | note reduction. This program does not submit an AQL packet and does not reset a GPU. |
| 5 | note See README.md. hardware timings are NOT_RUN on every host, including one with a card. |
| 6 | |
| 7 | global xin ulong 16 |
| 8 | global row ulong 16 |
| 9 | global yout ulong 16 |
| 10 | global ref ulong 16 |
| 11 | global wt ulong 4 |
| 12 | global gw ulong 16 |
| 13 | global sc ulong 4 |
| 14 | global samp ulong 8000 |
| 15 | global sampn ulong 1 |
| 16 | global rec ulong 1 |
| 17 | global cold ulong 1 |
| 18 | global sense ulong 1 |
| 19 | global arrived ulong 1 |
| 20 | global clock ulong 1 |
| 21 | global deadline ulong 1 |
| 22 | global ob uchar 256 |
| 23 | global on ulong 1 |
| 24 | global filebuf uchar 8192 |
| 25 | global filen ulong 1 |
| 26 | global ix ulong 1 |
| 27 | global exp uchar 256 |
| 28 | global explen ulong 32 |
| 29 | global expn ulong 1 |
| 30 | global eoff ulong 1 |
| 31 | global live uchar 256 |
| 32 | global livelen ulong 32 |
| 33 | global liven ulong 1 |
| 34 | global loff ulong 1 |
| 35 | global pathb uchar 160 |
| 36 | global pathn ulong 1 |
| 37 | global kbuf uchar 128 |
| 38 | global kn ulong 1 |
| 39 | global dv ulong 12 |
| 40 | global dgot ulong 1 |
| 41 | global saw ulong 1 |
| 42 | global pkt uchar 64 |
| 43 | global av uchar 1024 |
| 44 | global avp ulong 1 |
| 45 | global avn ulong 1 |
| 46 | global avl ulong 1 |
| 47 | global stbuf uchar 4 |
| 48 | global pre uchar 96 |
| 49 | global pren ulong 1 |
| 50 | global miss long 1 |
| 51 | |
| 52 | text sp " " |
| 53 | text comma "," |
| 54 | text tpass "PASS " |
| 55 | text tfail "FAIL " |
| 56 | text tmodel "source=model" |
| 57 | text tnotrun "NOT_RUN" |
| 58 | text tabsent "device=absent" |
| 59 | text tpresent "device=present" |
| 60 | text tnosys " reason=no-sysfs errno=" |
| 61 | text tnofx " reason=no-gfx942" |
| 62 | text thw "hardware=NOT_RUN reason=no-submit" |
| 63 | text tsum "OMEGA-GPU-AMD-BARRIER PASS llvm-mc=PASS hardware=NOT_RUN" |
| 64 | text tsumf "OMEGA-GPU-AMD-BARRIER FAIL" |
| 65 | text mcbin "/usr/bin/llvm-mc-18" |
| 66 | text mctri "-triple=amdgcn" |
| 67 | text mccpu "-mcpu=gfx942" |
| 68 | text mcenc "-show-encoding" |
| 69 | text mcseq "gpu/amd/bench/barrier/seq.s" |
| 70 | text mcgold "gpu/amd/bench/barrier/seq.enc" |
| 71 | text mcout "/tmp/omega-barrier-mc.out" |
| 72 | text enckey "encoding: [" |
| 73 | text kfdpre "/sys/class/kfd/kfd/topology/nodes/" |
| 74 | text propsuf "/properties" |
| 75 | text osrel "/proc/sys/kernel/osrelease" |
| 76 | text rocm1 "/opt/rocm/.info/version" |
| 77 | text rocm2 "/opt/rocm/.info/version-dev" |
| 78 | text kgfx "gfx_target_version" |
| 79 | text ksimd "simd_count" |
| 80 | text kspc "simd_per_cu" |
| 81 | text kwave "max_waves_per_simd" |
| 82 | text kxcc "num_xcc" |
| 83 | text klds "lds_size_in_kb" |
| 84 | text kfw "fw_version" |
| 85 | text kclk "max_engine_clk_fcompute" |
| 86 | text kdrm "drm_render_minor" |
| 87 | text knum "numeric " |
| 88 | text kocc "occupancy " |
| 89 | text kaql "aql " |
| 90 | text kwatch "watchdog " |
| 91 | text kstat "stats " |
| 92 | text kmc "llvm-mc=" |
| 93 | text kform "cold_formula " |
| 94 | text kkern "kernel=" |
| 95 | text twmed "warm_median=" |
| 96 | text twcen "warm_central=" |
| 97 | text twp "warm_p99=" |
| 98 | text twx "warm_max=" |
| 99 | text twsp "warm_spread=" |
| 100 | text tcmed "cold_median=" |
| 101 | text tccen "cold_central=" |
| 102 | text tcp "cold_p99=" |
| 103 | text tcx "cold_max=" |
| 104 | text tcsp "cold_spread=" |
| 105 | text tenc "PASS encodings=" |
| 106 | text tdiff " diff_wbl2=1 diff_inv=1 diff_nt=1 diff_sc1=1 diff_ticket=2" |
| 107 | text trocm "rocm=" |
| 108 | text tformv "xcc=8 l2_per_xcc=4194304 mall=268435456 bytes=603979776" |
| 109 | text tfw "firmware=" |
| 110 | text tclk "clocks=" |
| 111 | text tcold "cold_bytes=" |
| 112 | text tgfx " gfx=" |
| 113 | text tnode " node=" |
| 114 | text tcu " cu=" |
| 115 | text tno "REFUSED" |
| 116 | text tsimd " simd_count=" |
| 117 | text tspc " simd_per_cu=" |
| 118 | text twaves " max_waves=" |
| 119 | text txcc " num_xcc=" |
| 120 | text tgrid "plan_grid=" |
| 121 | text tgpc " groups_per_cu=" |
| 122 | text tres " resident=" |
| 123 | text tfit " fit=" |
| 124 | text tyes "yes" |
| 125 | text tabort "abort" |
| 126 | text tfwv "kfd_fw_version=" |
| 127 | text tclkv "kfd_max_engine_clk_fcompute=" |
| 128 | text tcur "current_clock=" |
| 129 | text tflush " source=formula flush=NOT_RUN" |
| 130 | text tldsk " lds_kb=" |
| 131 | text ktop "topology " |
| 132 | text taqp "armA_packets=" |
| 133 | text tbqp " armB_packets=" |
| 134 | text tsuma " agent_sum=" |
| 135 | text tsums " system_sum=" |
| 136 | |
| 137 | fn oreset to void |
| 138 | put on 0 0 |
| 139 | end |
| 140 | |
| 141 | fn obyte c ulong to void |
| 142 | n = get on 0 |
| 143 | if ge n 255 |
| 144 | ret |
| 145 | end |
| 146 | put ob n uchar and c 255 |
| 147 | put on 0 add n 1 |
| 148 | end |
| 149 | |
| 150 | fn ostr t view uchar * to void |
| 151 | n = len t |
| 152 | for i ulong n bound 80 |
| 153 | obyte ulong get t i |
| 154 | end |
| 155 | end |
| 156 | |
| 157 | fn odig v ulong to void |
| 158 | q = div v 10 |
| 159 | if ne q 0 |
| 160 | odig q |
| 161 | end |
| 162 | obyte add 48 sub v mul q 10 |
| 163 | end |
| 164 | |
| 165 | fn onl to void |
| 166 | obyte 10 |
| 167 | n = get on 0 |
| 168 | r = write 1 ob 0 n |
| 169 | if ne r long n |
| 170 | exit 74 |
| 171 | end |
| 172 | put on 0 0 |
| 173 | end |
| 174 | |
| 175 | fn fail m view uchar * c int to void |
| 176 | oreset |
| 177 | ostr tfail |
| 178 | ostr m |
| 179 | onl |
| 180 | oreset |
| 181 | ostr tsumf |
| 182 | onl |
| 183 | exit c |
| 184 | end |
| 185 | |
| 186 | fn ok m view uchar * to void |
| 187 | oreset |
| 188 | ostr tpass |
| 189 | ostr m |
| 190 | onl |
| 191 | end |
| 192 | |
| 193 | fn fdiv a ulong b ulong to ulong |
| 194 | ret ulong bitcast uint div bitcast f32 uint a bitcast f32 uint b |
| 195 | end |
| 196 | |
| 197 | fn fmul a ulong b ulong to ulong |
| 198 | ret ulong bitcast uint mul bitcast f32 uint a bitcast f32 uint b |
| 199 | end |
| 200 | |
| 201 | fn fsq a ulong to ulong |
| 202 | ret ulong bitcast uint fsqrt bitcast f32 uint a |
| 203 | end |
| 204 | |
| 205 | fn fp8bits a ulong to ulong |
| 206 | v = and a 255 |
| 207 | if eq v 128 |
| 208 | ret 0x7fc00000 |
| 209 | end |
| 210 | m = and v 127 |
| 211 | if eq m 0 |
| 212 | ret 0 |
| 213 | end |
| 214 | e = shr m 3 |
| 215 | f = and m 7 |
| 216 | if eq e 0 |
| 217 | e = ulong 120 |
| 218 | while lt f 8 bound 3 |
| 219 | f = shl f 1 |
| 220 | e = sub e 1 |
| 221 | end |
| 222 | else |
| 223 | e = add e 119 |
| 224 | end |
| 225 | ret or shl and v 128 24 or shl e 23 shl and f 7 20 |
| 226 | end |
| 227 | |
| 228 | fn loadfix to void |
| 229 | for k ulong 4 bound 4 |
| 230 | put wt k 0x3f800000 |
| 231 | put sc k 0x3f800000 |
| 232 | end |
| 233 | for i ulong 16 bound 16 |
| 234 | put gw i 64 |
| 235 | end |
| 236 | end |
| 237 | |
| 238 | fn loadin v ulong to void |
| 239 | for i ulong 16 bound 16 |
| 240 | put xin i v |
| 241 | end |
| 242 | end |
| 243 | |
| 244 | fn fillnan to void |
| 245 | for i ulong 16 bound 16 |
| 246 | put row i 0x7fc00000 |
| 247 | end |
| 248 | end |
| 249 | |
| 250 | fn copyxy to void |
| 251 | for i ulong 16 bound 16 |
| 252 | put xin i get yout i |
| 253 | end |
| 254 | end |
| 255 | |
| 256 | fn record cost ulong to void |
| 257 | n = get sampn 0 |
| 258 | if ge n 8000 |
| 259 | fail kstat 4 |
| 260 | end |
| 261 | put samp n cost |
| 262 | put sampn 0 add n 1 |
| 263 | end |
| 264 | |
| 265 | fn rms g ulong to void |
| 266 | base = mul g 4 |
| 267 | ss = ulong 0 |
| 268 | for k ulong 4 bound 4 |
| 269 | x = get xin add base k |
| 270 | ss = fpfma x x ss |
| 271 | end |
| 272 | mean = fdiv ss 0x40800000 |
| 273 | inv = fdiv 0x3f800000 fsq mean |
| 274 | for k ulong 4 bound 4 |
| 275 | x = get xin add base k |
| 276 | y = fmul x inv |
| 277 | y = fmul y get wt k |
| 278 | put row add base k y |
| 279 | end |
| 280 | end |
| 281 | |
| 282 | fn gemv g ulong to void |
| 283 | for m ulong 4 bound 4 |
| 284 | acc = ulong 0 |
| 285 | for k ulong 4 bound 4 |
| 286 | w = fp8bits get gw add mul m 4 k |
| 287 | x = get row mul k 4 |
| 288 | acc = fpfma w x acc |
| 289 | end |
| 290 | y = fmul acc get sc m |
| 291 | put yout add mul g 4 m y |
| 292 | end |
| 293 | end |
| 294 | |
| 295 | fn note_barrier to void |
| 296 | if eq get rec 0 0 |
| 297 | ret |
| 298 | end |
| 299 | for g ulong 4 bound 4 |
| 300 | cost = sub 3 g |
| 301 | if ne get cold 0 0 |
| 302 | cost = add cost 1000 |
| 303 | end |
| 304 | record cost |
| 305 | end |
| 306 | end |
| 307 | |
| 308 | fn phased n ulong to void |
| 309 | loadin 0x3f800000 |
| 310 | fillnan |
| 311 | for t ulong n bound 1000 |
| 312 | for g ulong 4 bound 4 |
| 313 | rms g |
| 314 | end |
| 315 | note_barrier |
| 316 | for g ulong 4 bound 4 |
| 317 | gemv g |
| 318 | end |
| 319 | note_barrier |
| 320 | copyxy |
| 321 | end |
| 322 | end |
| 323 | |
| 324 | fn mutant n ulong to void |
| 325 | loadin 0x3f800000 |
| 326 | fillnan |
| 327 | for t ulong n bound 1000 |
| 328 | for g ulong 4 bound 4 |
| 329 | rms g |
| 330 | gemv g |
| 331 | end |
| 332 | copyxy |
| 333 | end |
| 334 | end |
| 335 | |
| 336 | fn expect to bool |
| 337 | for i ulong 16 bound 16 |
| 338 | if ne get row i 0x3f800000 |
| 339 | ret false |
| 340 | end |
| 341 | if ne get yout i 0x40800000 |
| 342 | ret false |
| 343 | end |
| 344 | end |
| 345 | ret true |
| 346 | end |
| 347 | |
| 348 | fn saveref to void |
| 349 | for i ulong 16 bound 16 |
| 350 | put ref i get yout i |
| 351 | end |
| 352 | end |
| 353 | |
| 354 | fn matchref to bool |
| 355 | for i ulong 16 bound 16 |
| 356 | if ne get yout i get ref i |
| 357 | ret false |
| 358 | end |
| 359 | end |
| 360 | ret true |
| 361 | end |
| 362 | |
| 363 | fn nanout to bool |
| 364 | for i ulong 16 bound 16 |
| 365 | if eq get yout i 0x7fc00000 |
| 366 | ret true |
| 367 | end |
| 368 | end |
| 369 | ret false |
| 370 | end |
| 371 | |
| 372 | fn numeric to void |
| 373 | loadfix |
| 374 | put rec 0 0 |
| 375 | phased 1 |
| 376 | if not expect |
| 377 | fail knum 11 |
| 378 | end |
| 379 | phased 1000 |
| 380 | if not expect |
| 381 | fail knum 12 |
| 382 | end |
| 383 | saveref |
| 384 | phased 1000 |
| 385 | if not matchref |
| 386 | fail knum 13 |
| 387 | end |
| 388 | phased 1000 |
| 389 | if not matchref |
| 390 | fail knum 14 |
| 391 | end |
| 392 | mutant 1 |
| 393 | if matchref |
| 394 | fail knum 15 |
| 395 | end |
| 396 | if not nanout |
| 397 | fail knum 16 |
| 398 | end |
| 399 | ok knum |
| 400 | end |
| 401 | |
| 402 | fn align8 n ulong to ulong |
| 403 | if eq and n 7 0 |
| 404 | ret n |
| 405 | end |
| 406 | ret and add n ulong 7 xor ulong 7 18446744073709551615 |
| 407 | end |
| 408 | |
| 409 | fn waves_vgpr n ulong to ulong |
| 410 | if lt n 8 |
| 411 | ret 8 |
| 412 | end |
| 413 | r = align8 n |
| 414 | w = div 512 r |
| 415 | if eq w 0 |
| 416 | w = ulong 1 |
| 417 | end |
| 418 | if gt w 8 |
| 419 | w = ulong 8 |
| 420 | end |
| 421 | ret w |
| 422 | end |
| 423 | |
| 424 | fn sgpr_max w ulong to ulong |
| 425 | m = div 800 w |
| 426 | m = and m xor ulong 15 18446744073709551615 |
| 427 | if gt m 102 |
| 428 | m = ulong 102 |
| 429 | end |
| 430 | ret m |
| 431 | end |
| 432 | |
| 433 | fn waves_sgpr n ulong to ulong |
| 434 | if eq n 0 |
| 435 | ret 8 |
| 436 | end |
| 437 | w = ulong 8 |
| 438 | while true bound 8 |
| 439 | if ge sgpr_max w n |
| 440 | ret w |
| 441 | end |
| 442 | if eq w 1 |
| 443 | ret 0 |
| 444 | end |
| 445 | w = sub w 1 |
| 446 | end |
| 447 | ret 0 |
| 448 | end |
| 449 | |
| 450 | fn groups vgpr ulong sgpr ulong lds ulong wgsz ulong cap ulong simd ulong to ulong |
| 451 | wv = waves_vgpr vgpr |
| 452 | ws = waves_sgpr sgpr |
| 453 | we = wv |
| 454 | if lt ws we |
| 455 | we = ws |
| 456 | end |
| 457 | if lt cap we |
| 458 | we = cap |
| 459 | end |
| 460 | if eq we 0 |
| 461 | ret 0 |
| 462 | end |
| 463 | if eq simd 0 |
| 464 | ret 0 |
| 465 | end |
| 466 | cuw = mul we simd |
| 467 | if eq wgsz 0 |
| 468 | ret 0 |
| 469 | end |
| 470 | wpg = div add wgsz 63 64 |
| 471 | g = div cuw wpg |
| 472 | if gt wpg 1 |
| 473 | if gt g 16 |
| 474 | g = ulong 16 |
| 475 | end |
| 476 | end |
| 477 | if ne lds 0 |
| 478 | lg = div 65536 lds |
| 479 | if lt lg g |
| 480 | g = lg |
| 481 | end |
| 482 | end |
| 483 | ret g |
| 484 | end |
| 485 | |
| 486 | fn cu_of simds ulong per ulong to ulong |
| 487 | if eq per 0 |
| 488 | ret 0 |
| 489 | end |
| 490 | q = div simds per |
| 491 | if ne mul q per simds |
| 492 | ret 0 |
| 493 | end |
| 494 | ret q |
| 495 | end |
| 496 | |
| 497 | fn fit grid ulong res ulong to bool |
| 498 | if eq res 0 |
| 499 | ret false |
| 500 | end |
| 501 | ret le grid res |
| 502 | end |
| 503 | |
| 504 | fn occupancy to void |
| 505 | g = groups 32 32 0 64 8 4 |
| 506 | if ne g 32 |
| 507 | fail kocc 21 |
| 508 | end |
| 509 | if not fit 4 mul g 1 |
| 510 | fail kocc 22 |
| 511 | end |
| 512 | if fit 33 mul g 1 |
| 513 | fail kocc 23 |
| 514 | end |
| 515 | g = groups 512 32 0 64 8 4 |
| 516 | if ne g 4 |
| 517 | fail kocc 24 |
| 518 | end |
| 519 | if not fit 4 g |
| 520 | fail kocc 25 |
| 521 | end |
| 522 | if fit 5 g |
| 523 | fail kocc 26 |
| 524 | end |
| 525 | g = groups 32 32 32768 64 8 4 |
| 526 | if ne g 2 |
| 527 | fail kocc 27 |
| 528 | end |
| 529 | g = groups 32 103 0 64 8 4 |
| 530 | if ne g 0 |
| 531 | fail kocc 28 |
| 532 | end |
| 533 | if ne cu_of 8 4 2 |
| 534 | fail kocc 29 |
| 535 | end |
| 536 | if ne cu_of 10 4 0 |
| 537 | fail kocc 30 |
| 538 | end |
| 539 | g = groups 32 32 0 128 8 4 |
| 540 | if ne g 16 |
| 541 | fail kocc 31 |
| 542 | end |
| 543 | ok kocc |
| 544 | end |
| 545 | |
| 546 | fn hdr b ulong acq ulong rel ulong to ulong |
| 547 | h = ulong 2 |
| 548 | h = or h shl b 8 |
| 549 | h = or h shl acq 9 |
| 550 | h = or h shl rel 11 |
| 551 | ret h |
| 552 | end |
| 553 | |
| 554 | fn put16 off ulong v ulong to void |
| 555 | put pkt off uchar and v 255 |
| 556 | put pkt add off 1 uchar and shr v 8 255 |
| 557 | end |
| 558 | |
| 559 | fn put32 off ulong v ulong to void |
| 560 | put16 off v |
| 561 | put16 add off 2 shr v 16 |
| 562 | end |
| 563 | |
| 564 | fn buildpkt b ulong acq ulong rel ulong gx ulong to void |
| 565 | put16 0 hdr b acq rel |
| 566 | put16 2 1 |
| 567 | put16 4 64 |
| 568 | put16 6 1 |
| 569 | put16 8 1 |
| 570 | put16 10 0 |
| 571 | put32 12 gx |
| 572 | put32 16 1 |
| 573 | put32 20 1 |
| 574 | end |
| 575 | |
| 576 | fn pktsum acq ulong rel ulong to ulong |
| 577 | h = hdr 1 acq rel |
| 578 | s = ulong 0 |
| 579 | for i ulong 2000 bound 2000 |
| 580 | s = add s h |
| 581 | end |
| 582 | ret s |
| 583 | end |
| 584 | |
| 585 | fn aql to void |
| 586 | buildpkt 1 1 1 4 |
| 587 | if ne get pkt 0 2 |
| 588 | fail kaql 41 |
| 589 | end |
| 590 | if ne get pkt 1 11 |
| 591 | fail kaql 42 |
| 592 | end |
| 593 | if ne get pkt 4 64 |
| 594 | fail kaql 43 |
| 595 | end |
| 596 | if ne get pkt 12 4 |
| 597 | fail kaql 44 |
| 598 | end |
| 599 | ha = hdr 1 1 1 |
| 600 | hs = hdr 1 2 2 |
| 601 | if ne pktsum 1 1 mul 2000 ha |
| 602 | fail kaql 45 |
| 603 | end |
| 604 | if ne pktsum 2 2 mul 2000 hs |
| 605 | fail kaql 46 |
| 606 | end |
| 607 | if eq ha hs |
| 608 | fail kaql 47 |
| 609 | end |
| 610 | if ne and ha 256 256 |
| 611 | fail kaql 48 |
| 612 | end |
| 613 | hz = hdr 0 1 1 |
| 614 | if eq hz ha |
| 615 | fail kaql 49 |
| 616 | end |
| 617 | buildpkt 1 2 2 4 |
| 618 | if ne get pkt 1 21 |
| 619 | fail kaql 50 |
| 620 | end |
| 621 | sa = pktsum 1 1 |
| 622 | sb = pktsum 2 2 |
| 623 | oreset |
| 624 | ostr tpass |
| 625 | ostr kaql |
| 626 | ostr taqp |
| 627 | odig 2000 |
| 628 | ostr tbqp |
| 629 | odig 1 |
| 630 | ostr tsuma |
| 631 | odig sa |
| 632 | ostr tsums |
| 633 | odig sb |
| 634 | onl |
| 635 | end |
| 636 | |
| 637 | fn pass n ulong to int |
| 638 | local = xor get sense 0 1 |
| 639 | put arrived 0 0 |
| 640 | for g ulong n bound 4 |
| 641 | put clock 0 add get clock 0 1 |
| 642 | if gt get clock 0 get deadline 0 |
| 643 | ret 2 |
| 644 | end |
| 645 | t = get arrived 0 |
| 646 | put arrived 0 add t 1 |
| 647 | if eq t 3 |
| 648 | put arrived 0 0 |
| 649 | put sense 0 local |
| 650 | end |
| 651 | end |
| 652 | if eq n 4 |
| 653 | ret 0 |
| 654 | end |
| 655 | spins = ulong 0 |
| 656 | while lt spins 16 bound 16 |
| 657 | put clock 0 add get clock 0 1 |
| 658 | if gt get clock 0 get deadline 0 |
| 659 | ret 2 |
| 660 | end |
| 661 | spins = add spins 1 |
| 662 | end |
| 663 | ret 3 |
| 664 | end |
| 665 | |
| 666 | fn watchdog to void |
| 667 | put sense 0 0 |
| 668 | put clock 0 0 |
| 669 | put deadline 0 100 |
| 670 | if ne pass 4 0 |
| 671 | fail kwatch 61 |
| 672 | end |
| 673 | if ne get sense 0 1 |
| 674 | fail kwatch 62 |
| 675 | end |
| 676 | if ne get arrived 0 0 |
| 677 | fail kwatch 63 |
| 678 | end |
| 679 | if ne pass 4 0 |
| 680 | fail kwatch 64 |
| 681 | end |
| 682 | if ne get sense 0 0 |
| 683 | fail kwatch 65 |
| 684 | end |
| 685 | put clock 0 0 |
| 686 | put deadline 0 3 |
| 687 | if ne pass 3 2 |
| 688 | fail kwatch 66 |
| 689 | end |
| 690 | put clock 0 0 |
| 691 | put sense 0 0 |
| 692 | put deadline 0 1000 |
| 693 | if ne pass 3 3 |
| 694 | fail kwatch 67 |
| 695 | end |
| 696 | ok kwatch |
| 697 | end |
| 698 | |
| 699 | fn isort n ulong to void |
| 700 | for i ulong n bound 8192 |
| 701 | if eq i 0 |
| 702 | continue |
| 703 | end |
| 704 | v = get samp i |
| 705 | j = i |
| 706 | while true bound 8192 |
| 707 | if eq j 0 |
| 708 | break |
| 709 | end |
| 710 | p = sub j 1 |
| 711 | u = get samp p |
| 712 | if le u v |
| 713 | break |
| 714 | end |
| 715 | put samp j u |
| 716 | j = p |
| 717 | end |
| 718 | put samp j v |
| 719 | end |
| 720 | end |
| 721 | |
| 722 | fn median n ulong to ulong |
| 723 | if eq and n 1 1 |
| 724 | ret get samp div n 2 |
| 725 | end |
| 726 | a = get samp sub div n 2 1 |
| 727 | b = get samp div n 2 |
| 728 | ret div add a b 2 |
| 729 | end |
| 730 | |
| 731 | fn p99 n ulong to ulong |
| 732 | rank = div add mul n 99 99 100 |
| 733 | if eq rank 0 |
| 734 | rank = ulong 1 |
| 735 | end |
| 736 | ret get samp sub rank 1 |
| 737 | end |
| 738 | |
| 739 | fn putpair a ulong b ulong to void |
| 740 | odig a |
| 741 | ostr comma |
| 742 | odig b |
| 743 | end |
| 744 | |
| 745 | fn stats_unit to void |
| 746 | put samp 0 5 |
| 747 | put samp 1 1 |
| 748 | put samp 2 4 |
| 749 | put samp 3 2 |
| 750 | put samp 4 3 |
| 751 | isort 5 |
| 752 | if ne median 5 3 |
| 753 | fail kstat 71 |
| 754 | end |
| 755 | if ne p99 5 5 |
| 756 | fail kstat 72 |
| 757 | end |
| 758 | if ne get samp 4 5 |
| 759 | fail kstat 73 |
| 760 | end |
| 761 | put samp 0 10 |
| 762 | put samp 1 20 |
| 763 | isort 2 |
| 764 | if ne median 2 15 |
| 765 | fail kstat 74 |
| 766 | end |
| 767 | if ne p99 2 20 |
| 768 | fail kstat 75 |
| 769 | end |
| 770 | put samp 0 7 |
| 771 | isort 1 |
| 772 | if ne median 1 7 |
| 773 | fail kstat 76 |
| 774 | end |
| 775 | if ne p99 1 7 |
| 776 | fail kstat 77 |
| 777 | end |
| 778 | end |
| 779 | |
| 780 | fn fill_model to void |
| 781 | put sampn 0 0 |
| 782 | put rec 0 1 |
| 783 | phased 1000 |
| 784 | put rec 0 0 |
| 785 | if ne get sampn 0 8000 |
| 786 | fail kstat 78 |
| 787 | end |
| 788 | isort 8000 |
| 789 | end |
| 790 | |
| 791 | fn stats to void |
| 792 | stats_unit |
| 793 | put cold 0 0 |
| 794 | fill_model |
| 795 | wm = median 8000 |
| 796 | wp = p99 8000 |
| 797 | wx = get samp 7999 |
| 798 | w0 = get samp 0 |
| 799 | wa = get samp 3999 |
| 800 | wb = get samp 4000 |
| 801 | if ne wm 1 |
| 802 | fail kstat 79 |
| 803 | end |
| 804 | if ne wp 3 |
| 805 | fail kstat 80 |
| 806 | end |
| 807 | if ne wx 3 |
| 808 | fail kstat 81 |
| 809 | end |
| 810 | put cold 0 1 |
| 811 | fill_model |
| 812 | cm = median 8000 |
| 813 | cp = p99 8000 |
| 814 | cx = get samp 7999 |
| 815 | c0 = get samp 0 |
| 816 | ca = get samp 3999 |
| 817 | cb = get samp 4000 |
| 818 | if ne cm 1001 |
| 819 | fail kstat 82 |
| 820 | end |
| 821 | if ne cp 1003 |
| 822 | fail kstat 83 |
| 823 | end |
| 824 | if ne cx 1003 |
| 825 | fail kstat 84 |
| 826 | end |
| 827 | oreset |
| 828 | ostr tpass |
| 829 | ostr kstat |
| 830 | ostr tmodel |
| 831 | ostr sp |
| 832 | ostr twmed |
| 833 | odig wm |
| 834 | ostr sp |
| 835 | ostr twcen |
| 836 | putpair wa wb |
| 837 | ostr sp |
| 838 | ostr twp |
| 839 | odig wp |
| 840 | ostr sp |
| 841 | ostr twx |
| 842 | odig wx |
| 843 | ostr sp |
| 844 | ostr twsp |
| 845 | odig sub wx w0 |
| 846 | ostr sp |
| 847 | ostr tcmed |
| 848 | odig cm |
| 849 | ostr sp |
| 850 | ostr tccen |
| 851 | putpair ca cb |
| 852 | ostr sp |
| 853 | ostr tcp |
| 854 | odig cp |
| 855 | ostr sp |
| 856 | ostr tcx |
| 857 | odig cx |
| 858 | ostr sp |
| 859 | ostr tcsp |
| 860 | odig sub cx c0 |
| 861 | onl |
| 862 | end |
| 863 | |
| 864 | fn peekc to ulong |
| 865 | if ge get ix 0 get filen 0 |
| 866 | ret 0 |
| 867 | end |
| 868 | ret ulong get filebuf get ix 0 |
| 869 | end |
| 870 | |
| 871 | fn hexval c ulong to ulong |
| 872 | if and ge c 48 le c 57 |
| 873 | ret sub c 48 |
| 874 | end |
| 875 | if and ge c 97 le c 102 |
| 876 | ret sub c 87 |
| 877 | end |
| 878 | if and ge c 65 le c 70 |
| 879 | ret sub c 55 |
| 880 | end |
| 881 | ret 99 |
| 882 | end |
| 883 | |
| 884 | fn skip to void |
| 885 | while true bound 65536 |
| 886 | if ge get ix 0 get filen 0 |
| 887 | ret |
| 888 | end |
| 889 | c = peekc |
| 890 | if eq c 35 |
| 891 | while true bound 512 |
| 892 | if ge get ix 0 get filen 0 |
| 893 | ret |
| 894 | end |
| 895 | c = peekc |
| 896 | put ix 0 add get ix 0 1 |
| 897 | if eq c 10 |
| 898 | break |
| 899 | end |
| 900 | end |
| 901 | continue |
| 902 | end |
| 903 | if gt c 32 |
| 904 | ret |
| 905 | end |
| 906 | put ix 0 add get ix 0 1 |
| 907 | end |
| 908 | end |
| 909 | |
| 910 | fn dec to ulong |
| 911 | skip |
| 912 | v = ulong 0 |
| 913 | any = ulong 0 |
| 914 | while true bound 8 |
| 915 | c = peekc |
| 916 | if or lt c 48 gt c 57 |
| 917 | break |
| 918 | end |
| 919 | any = ulong 1 |
| 920 | v = add mul v 10 sub c 48 |
| 921 | put ix 0 add get ix 0 1 |
| 922 | end |
| 923 | if eq any 0 |
| 924 | ret 100 |
| 925 | end |
| 926 | ret v |
| 927 | end |
| 928 | |
| 929 | fn hex2 to ulong |
| 930 | skip |
| 931 | hi = hexval peekc |
| 932 | put ix 0 add get ix 0 1 |
| 933 | lo = hexval peekc |
| 934 | put ix 0 add get ix 0 1 |
| 935 | if or eq hi 99 eq lo 99 |
| 936 | ret 256 |
| 937 | end |
| 938 | ret add mul hi 16 lo |
| 939 | end |
| 940 | |
| 941 | fn slurp to long |
| 942 | fd = fopen pathb 0 get pathn 0 0 0 |
| 943 | if lt fd 0 |
| 944 | ret fd |
| 945 | end |
| 946 | off = ulong 0 |
| 947 | while lt off 8192 bound 8192 |
| 948 | r = read int fd filebuf off 1024 |
| 949 | if lt r 0 |
| 950 | c = fclose int fd |
| 951 | ret r |
| 952 | end |
| 953 | if eq r 0 |
| 954 | break |
| 955 | end |
| 956 | off = add off ulong r |
| 957 | if ge off 8192 |
| 958 | c = fclose int fd |
| 959 | ret -22 |
| 960 | end |
| 961 | end |
| 962 | c = fclose int fd |
| 963 | put filen 0 off |
| 964 | ret 0 |
| 965 | end |
| 966 | |
| 967 | fn loadgold to void |
| 968 | pathset mcgold |
| 969 | r = slurp |
| 970 | if ne r 0 |
| 971 | fail kmc 91 |
| 972 | end |
| 973 | put ix 0 0 |
| 974 | put expn 0 0 |
| 975 | put eoff 0 0 |
| 976 | while lt get ix 0 get filen 0 bound 64 |
| 977 | skip |
| 978 | if ge get ix 0 get filen 0 |
| 979 | break |
| 980 | end |
| 981 | n = dec |
| 982 | if or eq n 0 gt n 8 |
| 983 | fail kmc 92 |
| 984 | end |
| 985 | k = get expn 0 |
| 986 | if ge k 32 |
| 987 | fail kmc 93 |
| 988 | end |
| 989 | put explen k n |
| 990 | for i ulong n bound 8 |
| 991 | b = hex2 |
| 992 | if ge b 256 |
| 993 | fail kmc 94 |
| 994 | end |
| 995 | p = get eoff 0 |
| 996 | if ge p 256 |
| 997 | fail kmc 95 |
| 998 | end |
| 999 | put exp p uchar b |
| 1000 | put eoff 0 add p 1 |
| 1001 | end |
| 1002 | put expn 0 add k 1 |
| 1003 | end |
| 1004 | if ne get expn 0 27 |
| 1005 | fail kmc 96 |
| 1006 | end |
| 1007 | end |
| 1008 | |
| 1009 | fn areset to void |
| 1010 | put avn 0 0 |
| 1011 | put avp 0 2 |
| 1012 | put av 0 0 |
| 1013 | put av 1 0 |
| 1014 | end |
| 1015 | |
| 1016 | fn afix to void |
| 1017 | p = get avp 0 |
| 1018 | q = get avl 0 |
| 1019 | m = sub sub p q 2 |
| 1020 | put av q uchar and m 255 |
| 1021 | put av add q 1 uchar shr m 8 |
| 1022 | end |
| 1023 | |
| 1024 | fn anew to void |
| 1025 | p = get avp 0 |
| 1026 | put avl 0 p |
| 1027 | put avp 0 add p 2 |
| 1028 | afix |
| 1029 | c = add get avn 0 1 |
| 1030 | put avn 0 c |
| 1031 | put av 0 uchar and c 255 |
| 1032 | put av 1 uchar shr c 8 |
| 1033 | end |
| 1034 | |
| 1035 | fn amore t view uchar * to void |
| 1036 | p = get avp 0 |
| 1037 | n = len t |
| 1038 | for i ulong n bound 80 |
| 1039 | put av add p i get t i |
| 1040 | end |
| 1041 | put avp 0 add p n |
| 1042 | afix |
| 1043 | end |
| 1044 | |
| 1045 | fn aadd t view uchar * to void |
| 1046 | anew |
| 1047 | amore t |
| 1048 | end |
| 1049 | |
| 1050 | fn findkey to bool |
| 1051 | k = len enckey |
| 1052 | while true bound 65536 |
| 1053 | if gt add get ix 0 k get filen 0 |
| 1054 | ret false |
| 1055 | end |
| 1056 | good = true |
| 1057 | for i ulong k bound 16 |
| 1058 | if ne get filebuf add get ix 0 i get enckey i |
| 1059 | good = false |
| 1060 | break |
| 1061 | end |
| 1062 | end |
| 1063 | if good |
| 1064 | put ix 0 add get ix 0 k |
| 1065 | ret true |
| 1066 | end |
| 1067 | put ix 0 add get ix 0 1 |
| 1068 | end |
| 1069 | ret false |
| 1070 | end |
| 1071 | |
| 1072 | fn parsebyte to ulong |
| 1073 | while true bound 16 |
| 1074 | if ge get ix 0 get filen 0 |
| 1075 | ret 257 |
| 1076 | end |
| 1077 | c = peekc |
| 1078 | if eq c 93 |
| 1079 | ret 256 |
| 1080 | end |
| 1081 | if eq c 120 |
| 1082 | break |
| 1083 | end |
| 1084 | put ix 0 add get ix 0 1 |
| 1085 | end |
| 1086 | put ix 0 add get ix 0 1 |
| 1087 | hi = hexval peekc |
| 1088 | put ix 0 add get ix 0 1 |
| 1089 | lo = hexval peekc |
| 1090 | put ix 0 add get ix 0 1 |
| 1091 | if or eq hi 99 eq lo 99 |
| 1092 | ret 258 |
| 1093 | end |
| 1094 | ret add mul hi 16 lo |
| 1095 | end |
| 1096 | |
| 1097 | fn parselive to void |
| 1098 | put ix 0 0 |
| 1099 | put liven 0 0 |
| 1100 | put loff 0 0 |
| 1101 | while true bound 64 |
| 1102 | if not findkey |
| 1103 | break |
| 1104 | end |
| 1105 | k = get liven 0 |
| 1106 | n = ulong 0 |
| 1107 | while true bound 16 |
| 1108 | b = parsebyte |
| 1109 | if eq b 256 |
| 1110 | break |
| 1111 | end |
| 1112 | if ge b 256 |
| 1113 | fail kmc 97 |
| 1114 | end |
| 1115 | p = get loff 0 |
| 1116 | put live p uchar b |
| 1117 | put loff 0 add p 1 |
| 1118 | n = add n 1 |
| 1119 | end |
| 1120 | put livelen k n |
| 1121 | put liven 0 add k 1 |
| 1122 | end |
| 1123 | end |
| 1124 | |
| 1125 | fn same to bool |
| 1126 | if ne get expn 0 get liven 0 |
| 1127 | ret false |
| 1128 | end |
| 1129 | for i ulong get expn 0 bound 32 |
| 1130 | if ne get explen i get livelen i |
| 1131 | ret false |
| 1132 | end |
| 1133 | end |
| 1134 | nb = get eoff 0 |
| 1135 | if ne nb get loff 0 |
| 1136 | ret false |
| 1137 | end |
| 1138 | for i ulong nb bound 256 |
| 1139 | if ne get exp i get live i |
| 1140 | ret false |
| 1141 | end |
| 1142 | end |
| 1143 | ret true |
| 1144 | end |
| 1145 | |
| 1146 | fn ioff ins ulong to ulong |
| 1147 | o = ulong 0 |
| 1148 | for i ulong ins bound 32 |
| 1149 | o = add o get explen i |
| 1150 | end |
| 1151 | ret o |
| 1152 | end |
| 1153 | |
| 1154 | fn diffbits a ulong b ulong to ulong |
| 1155 | na = get explen a |
| 1156 | if ne na get explen b |
| 1157 | ret 99 |
| 1158 | end |
| 1159 | pa = ioff a |
| 1160 | pb = ioff b |
| 1161 | d = ulong 0 |
| 1162 | for i ulong na bound 8 |
| 1163 | x = xor get live add pa i get live add pb i |
| 1164 | while ne x 0 bound 8 |
| 1165 | if ne and x 1 0 |
| 1166 | d = add d 1 |
| 1167 | end |
| 1168 | x = shr x 1 |
| 1169 | end |
| 1170 | end |
| 1171 | ret d |
| 1172 | end |
| 1173 | |
| 1174 | fn mcrun to int |
| 1175 | areset |
| 1176 | aadd mcbin |
| 1177 | aadd mctri |
| 1178 | aadd mccpu |
| 1179 | aadd mcenc |
| 1180 | aadd mcseq |
| 1181 | fd = fopen mcout 0 len mcout 577 448 |
| 1182 | if lt fd 0 |
| 1183 | ret 1 |
| 1184 | end |
| 1185 | pid = fork |
| 1186 | if lt pid 0 |
| 1187 | c = fclose int fd |
| 1188 | ret 2 |
| 1189 | end |
| 1190 | if eq pid 0 |
| 1191 | r = dupfd int fd 1 0 |
| 1192 | r = execprog av 0 get avp 0 |
| 1193 | exit 98 |
| 1194 | end |
| 1195 | c = fclose int fd |
| 1196 | w = waitpid int pid stbuf 0 4 0 |
| 1197 | if ne w pid |
| 1198 | ret 3 |
| 1199 | end |
| 1200 | if ne and get stbuf 0 127 0 |
| 1201 | ret 4 |
| 1202 | end |
| 1203 | if ne get stbuf 1 0 |
| 1204 | ret 5 |
| 1205 | end |
| 1206 | ret 0 |
| 1207 | end |
| 1208 | |
| 1209 | fn llvm to void |
| 1210 | probe = fopen mcbin 0 len mcbin 0 0 |
| 1211 | if lt probe 0 |
| 1212 | fail kmc 101 |
| 1213 | end |
| 1214 | c = fclose int probe |
| 1215 | loadgold |
| 1216 | e = mcrun |
| 1217 | if ne e 0 |
| 1218 | fail kmc 102 |
| 1219 | end |
| 1220 | pathset mcout |
| 1221 | r = slurp |
| 1222 | if ne r 0 |
| 1223 | fail kmc 103 |
| 1224 | end |
| 1225 | parselive |
| 1226 | if not same |
| 1227 | fail kmc 104 |
| 1228 | end |
| 1229 | if ne diffbits 0 3 1 |
| 1230 | fail kmc 105 |
| 1231 | end |
| 1232 | if ne diffbits 8 11 1 |
| 1233 | fail kmc 106 |
| 1234 | end |
| 1235 | if ne diffbits 12 13 1 |
| 1236 | fail kmc 107 |
| 1237 | end |
| 1238 | if ne diffbits 12 14 1 |
| 1239 | fail kmc 108 |
| 1240 | end |
| 1241 | if ne diffbits 13 15 1 |
| 1242 | fail kmc 109 |
| 1243 | end |
| 1244 | if ne diffbits 2 12 2 |
| 1245 | fail kmc 110 |
| 1246 | end |
| 1247 | if eq diffbits 16 17 0 |
| 1248 | fail kmc 111 |
| 1249 | end |
| 1250 | oreset |
| 1251 | ostr tpass |
| 1252 | ostr kmc |
| 1253 | ostr tenc |
| 1254 | odig get expn 0 |
| 1255 | ostr tdiff |
| 1256 | onl |
| 1257 | end |
| 1258 | |
| 1259 | fn pathset t view uchar * to void |
| 1260 | n = len t |
| 1261 | for i ulong n bound 80 |
| 1262 | put pathb i get t i |
| 1263 | end |
| 1264 | put pathn 0 n |
| 1265 | end |
| 1266 | |
| 1267 | fn pathadd t view uchar * to void |
| 1268 | p = get pathn 0 |
| 1269 | n = len t |
| 1270 | for i ulong n bound 40 |
| 1271 | put pathb add p i get t i |
| 1272 | end |
| 1273 | put pathn 0 add p n |
| 1274 | end |
| 1275 | |
| 1276 | fn pathnum v ulong to void |
| 1277 | if eq v 0 |
| 1278 | p = get pathn 0 |
| 1279 | put pathb p 48 |
| 1280 | put pathn 0 add p 1 |
| 1281 | ret |
| 1282 | end |
| 1283 | n = ulong 0 |
| 1284 | x = v |
| 1285 | while ne x 0 bound 16 |
| 1286 | q = div x 10 |
| 1287 | put kbuf n uchar add 48 sub x mul q 10 |
| 1288 | n = add n 1 |
| 1289 | x = q |
| 1290 | end |
| 1291 | while ne n 0 bound 16 |
| 1292 | n = sub n 1 |
| 1293 | p = get pathn 0 |
| 1294 | put pathb p get kbuf n |
| 1295 | put pathn 0 add p 1 |
| 1296 | end |
| 1297 | end |
| 1298 | |
| 1299 | fn line_match pos ulong key view uchar * to bool |
| 1300 | n = len key |
| 1301 | if gt add pos n get filen 0 |
| 1302 | ret false |
| 1303 | end |
| 1304 | for i ulong n bound 40 |
| 1305 | if ne get filebuf add pos i get key i |
| 1306 | ret false |
| 1307 | end |
| 1308 | end |
| 1309 | if ne get filebuf add pos n 32 |
| 1310 | ret false |
| 1311 | end |
| 1312 | ret true |
| 1313 | end |
| 1314 | |
| 1315 | fn parsenum pos ulong to ulong |
| 1316 | while and lt pos get filen 0 eq get filebuf pos 32 bound 8 |
| 1317 | pos = add pos 1 |
| 1318 | end |
| 1319 | v = ulong 0 |
| 1320 | while lt pos get filen 0 bound 24 |
| 1321 | c = ulong get filebuf pos |
| 1322 | if or lt c 48 gt c 57 |
| 1323 | break |
| 1324 | end |
| 1325 | v = add mul v 10 sub c 48 |
| 1326 | pos = add pos 1 |
| 1327 | end |
| 1328 | ret v |
| 1329 | end |
| 1330 | |
| 1331 | fn take pos ulong slot ulong key view uchar * to void |
| 1332 | if not line_match pos key |
| 1333 | ret |
| 1334 | end |
| 1335 | put dv slot parsenum add pos add len key 1 |
| 1336 | put dgot 0 or get dgot 0 shl ulong 1 slot |
| 1337 | end |
| 1338 | |
| 1339 | fn parseprops to void |
| 1340 | put dgot 0 0 |
| 1341 | pos = ulong 0 |
| 1342 | while lt pos get filen 0 bound 8192 |
| 1343 | take pos 0 kgfx |
| 1344 | take pos 1 ksimd |
| 1345 | take pos 2 kspc |
| 1346 | take pos 3 kwave |
| 1347 | take pos 4 kxcc |
| 1348 | take pos 5 klds |
| 1349 | take pos 6 kfw |
| 1350 | take pos 7 kclk |
| 1351 | take pos 8 kdrm |
| 1352 | while and lt pos get filen 0 ne get filebuf pos 10 bound 4096 |
| 1353 | pos = add pos 1 |
| 1354 | end |
| 1355 | if lt pos get filen 0 |
| 1356 | pos = add pos 1 |
| 1357 | end |
| 1358 | end |
| 1359 | end |
| 1360 | |
| 1361 | fn hasbit b ulong to bool |
| 1362 | ret ne and get dgot 0 shl ulong 1 b 0 |
| 1363 | end |
| 1364 | |
| 1365 | fn kernel_line to void |
| 1366 | pathset osrel |
| 1367 | r = slurp |
| 1368 | oreset |
| 1369 | ostr kkern |
| 1370 | if ne r 0 |
| 1371 | ostr tnotrun |
| 1372 | onl |
| 1373 | ret |
| 1374 | end |
| 1375 | n = get filen 0 |
| 1376 | if and gt n 0 eq ulong get filebuf sub n 1 10 |
| 1377 | n = sub n 1 |
| 1378 | end |
| 1379 | for i ulong n bound 128 |
| 1380 | obyte ulong get filebuf i |
| 1381 | end |
| 1382 | onl |
| 1383 | end |
| 1384 | |
| 1385 | fn rocm_line to void |
| 1386 | pathset rocm1 |
| 1387 | r = slurp |
| 1388 | if ne r 0 |
| 1389 | pathset rocm2 |
| 1390 | r = slurp |
| 1391 | end |
| 1392 | oreset |
| 1393 | ostr trocm |
| 1394 | if ne r 0 |
| 1395 | ostr tnotrun |
| 1396 | onl |
| 1397 | ret |
| 1398 | end |
| 1399 | n = get filen 0 |
| 1400 | for i ulong n bound 128 |
| 1401 | c = ulong get filebuf i |
| 1402 | if eq c 10 |
| 1403 | break |
| 1404 | end |
| 1405 | obyte c |
| 1406 | end |
| 1407 | onl |
| 1408 | end |
| 1409 | |
| 1410 | fn cold_formula xcc ulong to ulong |
| 1411 | ret mul 2 add mul xcc 4194304 268435456 |
| 1412 | end |
| 1413 | |
| 1414 | fn formula to void |
| 1415 | if ne cold_formula 8 603979776 |
| 1416 | fail kform 121 |
| 1417 | end |
| 1418 | oreset |
| 1419 | ostr tpass |
| 1420 | ostr kform |
| 1421 | ostr tformv |
| 1422 | onl |
| 1423 | end |
| 1424 | |
| 1425 | fn copypre to void |
| 1426 | n = len kfdpre |
| 1427 | for i ulong n bound 80 |
| 1428 | put pre i uchar get kfdpre i |
| 1429 | end |
| 1430 | put pren 0 n |
| 1431 | end |
| 1432 | |
| 1433 | fn loadpre to void |
| 1434 | if le argcnt 1 |
| 1435 | copypre |
| 1436 | ret |
| 1437 | end |
| 1438 | n = argread 1 pre 0 80 |
| 1439 | if or lt n 0 eq n 0 |
| 1440 | fail ktop 131 |
| 1441 | end |
| 1442 | put pren 0 ulong n |
| 1443 | end |
| 1444 | |
| 1445 | fn pathpre to void |
| 1446 | n = get pren 0 |
| 1447 | for i ulong n bound 80 |
| 1448 | put pathb i get pre i |
| 1449 | end |
| 1450 | put pathn 0 n |
| 1451 | end |
| 1452 | |
| 1453 | fn device to void |
| 1454 | put saw 0 0 |
| 1455 | put miss 0 0 |
| 1456 | hit = ulong 0 |
| 1457 | node = ulong 0 |
| 1458 | for n ulong 8 bound 8 |
| 1459 | pathpre |
| 1460 | pathnum n |
| 1461 | pathadd propsuf |
| 1462 | fd = fopen pathb 0 get pathn 0 0 0 |
| 1463 | if lt fd 0 |
| 1464 | if eq get miss 0 0 |
| 1465 | put miss 0 fd |
| 1466 | end |
| 1467 | continue |
| 1468 | end |
| 1469 | c = fclose int fd |
| 1470 | r = slurp |
| 1471 | if ne r 0 |
| 1472 | continue |
| 1473 | end |
| 1474 | put saw 0 1 |
| 1475 | parseprops |
| 1476 | if not hasbit 0 |
| 1477 | continue |
| 1478 | end |
| 1479 | if ne get dv 0 90402 |
| 1480 | continue |
| 1481 | end |
| 1482 | hit = ulong 1 |
| 1483 | node = n |
| 1484 | break |
| 1485 | end |
| 1486 | oreset |
| 1487 | if eq hit 0 |
| 1488 | ostr tabsent |
| 1489 | if eq get saw 0 0 |
| 1490 | ostr tnosys |
| 1491 | odig ulong sub long 0 get miss 0 |
| 1492 | else |
| 1493 | ostr tnofx |
| 1494 | end |
| 1495 | onl |
| 1496 | ostr thw |
| 1497 | onl |
| 1498 | ostr tfw |
| 1499 | ostr tnotrun |
| 1500 | onl |
| 1501 | ostr tclk |
| 1502 | ostr tnotrun |
| 1503 | onl |
| 1504 | ostr tcold |
| 1505 | ostr tnotrun |
| 1506 | onl |
| 1507 | ret |
| 1508 | end |
| 1509 | simds = get dv 1 |
| 1510 | per = get dv 2 |
| 1511 | cu = cu_of simds per |
| 1512 | cap = get dv 3 |
| 1513 | if gt cap 8 |
| 1514 | cap = ulong 8 |
| 1515 | end |
| 1516 | g = ulong 0 |
| 1517 | if and ne cu 0 ne cap 0 |
| 1518 | g = groups 32 32 0 64 cap per |
| 1519 | end |
| 1520 | res = mul g cu |
| 1521 | oreset |
| 1522 | ostr tpresent |
| 1523 | ostr tgfx |
| 1524 | odig get dv 0 |
| 1525 | ostr tnode |
| 1526 | odig node |
| 1527 | ostr tcu |
| 1528 | if eq cu 0 |
| 1529 | ostr tno |
| 1530 | else |
| 1531 | odig cu |
| 1532 | end |
| 1533 | ostr tsimd |
| 1534 | odig simds |
| 1535 | ostr tspc |
| 1536 | odig per |
| 1537 | ostr twaves |
| 1538 | odig get dv 3 |
| 1539 | ostr txcc |
| 1540 | odig get dv 4 |
| 1541 | ostr tldsk |
| 1542 | if hasbit 5 |
| 1543 | odig get dv 5 |
| 1544 | else |
| 1545 | ostr tnotrun |
| 1546 | end |
| 1547 | onl |
| 1548 | ostr tgrid |
| 1549 | if eq cu 0 |
| 1550 | ostr tno |
| 1551 | else |
| 1552 | odig cu |
| 1553 | end |
| 1554 | ostr tgpc |
| 1555 | odig g |
| 1556 | ostr tres |
| 1557 | odig res |
| 1558 | ostr tfit |
| 1559 | if fit cu res |
| 1560 | ostr tyes |
| 1561 | else |
| 1562 | ostr tabort |
| 1563 | end |
| 1564 | onl |
| 1565 | ostr tfwv |
| 1566 | if hasbit 6 |
| 1567 | odig get dv 6 |
| 1568 | else |
| 1569 | ostr tnotrun |
| 1570 | end |
| 1571 | onl |
| 1572 | ostr tclkv |
| 1573 | if hasbit 7 |
| 1574 | odig get dv 7 |
| 1575 | else |
| 1576 | ostr tnotrun |
| 1577 | end |
| 1578 | onl |
| 1579 | ostr tcur |
| 1580 | ostr tnotrun |
| 1581 | onl |
| 1582 | ostr tcold |
| 1583 | if and hasbit 4 ne get dv 4 0 |
| 1584 | odig cold_formula get dv 4 |
| 1585 | ostr tflush |
| 1586 | else |
| 1587 | ostr tnotrun |
| 1588 | end |
| 1589 | onl |
| 1590 | ostr thw |
| 1591 | onl |
| 1592 | end |
| 1593 | |
| 1594 | fn main to int |
| 1595 | loadpre |
| 1596 | numeric |
| 1597 | occupancy |
| 1598 | aql |
| 1599 | watchdog |
| 1600 | stats |
| 1601 | llvm |
| 1602 | formula |
| 1603 | kernel_line |
| 1604 | rocm_line |
| 1605 | device |
| 1606 | oreset |
| 1607 | ostr tsum |
| 1608 | onl |
| 1609 | ret 0 |
| 1610 | end |