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/omega-mv/blob/main/tools/dagsim/dagsim_cli.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tools / dagsim / dagsim_cli.om` 1012 lines ยท 21019 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note tools/dagsim/dagsim_cli.om -- Pure seeded OM-2 CLI for the offline resource-DAG evaluator (omega-mv#583). 3 note Composed after tools/dagsim/dagsim.om: 4 note cat tools/dagsim/dagsim.om tools/dagsim/dagsim_cli.om | seed/out/omc > dagsim 5 6 global cli_arg uchar 4096 7 global cli_cmd uchar 32 8 global cli_cmd_len ulong 1 9 global cli_files uchar 16384 10 global cli_flens ulong 64 11 global cli_nfiles ulong 1 12 global cli_changed uchar 256 13 global cli_changed_len ulong 1 14 global cli_asof long 1 15 global cli_has_model ulong 1 16 17 global cli_nom_sc ulong 8192 18 global cli_nom_rsn uchar 256 19 global cli_nom_rsn_len ulong 1 20 21 note Pareto row tables (up to 64 rows) 22 global pr_status ulong 64 23 global pr_t ulong 64 24 global pr_lo ulong 64 25 global pr_hi ulong 64 26 global pr_peak ulong 64 27 global pr_e ulong 64 28 global pr_emeas ulong 64 29 global pr_esyn ulong 64 30 global pr_front ulong 64 31 global pr_rsn uchar 16384 32 global pr_rsn_len ulong 64 33 34 note Sensitivity tables (up to 32 resources) 35 global sn_cf ulong 32 36 global sn_width ulong 32 37 global sn_score ulong 32 38 global sn_idx ulong 32 39 40 text cli_usage "usage: dagsim eval FILE | pareto FILE... | diff BASE TRANSFORMED [--asof YYYY-MM-DD] [--model BLOB] [--changed a,b]\n" 41 text cli_need_asof "dagsim: --asof YYYY-MM-DD is required so the run is reproducible (calibration validity is checked against it)\n" 42 text cli_bad_asof "bad --asof\n" 43 text cli_keval "eval" 44 text cli_kpareto "pareto" 45 text cli_kdiff "diff" 46 text cli_fasof "--asof" 47 text cli_fmodel "--model" 48 text cli_fchanged "--changed" 49 50 text cj_perr1 "{\"schema\": \"oev1\", \"tool\": \"dagsim\", \"file\": " 51 text cj_perr2 ", \"status\": \"PARSE_ERROR\", \"reason\": " 52 text cj_perr3 "}\n" 53 54 text cj_h1 "{\n \"schema\": \"oev1\", \"tool\": \"dagsim\", \"file\": " 55 text cj_h2 ",\n \"machine\": " 56 text cj_h3 ", \"build_sha\": " 57 text cj_h4 ",\n \"calibration\": {\"id\": " 58 text cj_h5 ", \"taken_day\": " 59 text cj_h6 ", \"valid_days\": " 60 text cj_h7 ", \"load1\": " 61 text cj_h8 ", \"src\": " 62 text cj_h9 "},\n \"asof_day\": " 63 text cj_h10 ",\n \"status\": " 64 text cj_h11 ", \"reason\": " 65 text cj_h12 ",\n \"provenance\": [" 66 text cj_h13 "], \"synthetic\": " 67 text cj_h14 ", \"offline\": true, \"gpu_executed\": false" 68 text cj_end_ref "\n}\n" 69 70 text cj_mk1 ",\n \"makespan_ns\": {\"nominal\": " 71 text cj_mk2 ", \"lo\": " 72 text cj_mk3 ", \"hi\": " 73 text cj_mk4 ", \"interval_known\": " 74 text cj_true "true" 75 text cj_false "false" 76 text cj_null "null" 77 text cj_comma ", " 78 text cj_colon ": " 79 text cj_rbrace "}" 80 81 text cj_bd1 "},\n \"bounds_ns\": {\"critical_path\": " 82 text cj_bd2 ", \"max\": " 83 text cj_bd3 ", \"resources\": {" 84 text cj_bd4 "}, \"makespan_ge_bounds\": " 85 86 text cj_ops1 "},\n \"ops\": [" 87 text cj_op_a "\n {\"id\": " 88 text cj_op_a2 ",\n {\"id\": " 89 text cj_op_s ", \"start_ns\": " 90 text cj_op_e ", \"end_ns\": " 91 text cj_op_f ", \"floor_ns\": " 92 text cj_op_c ", \"contention_ns\": " 93 text cj_op_p ", \"prov\": " 94 text cj_op_r ", \"src\": " 95 96 text cj_cp1 "\n ],\n \"critical_path\": [" 97 text cj_pk1 "],\n \"peak_live_bytes\": {" 98 text cj_pk2 ": {\"bytes\": " 99 text cj_pk3 ", \"at_ns\": " 100 text cj_pk4 ", \"cap\": " 101 102 text cj_at1 "},\n \"attribution_ns\": {" 103 text cj_en1 "},\n \"energy\": {\"status\": " 104 text cj_en2 ", \"joules\": " 105 text cj_en3 ", \"instrument\": " 106 text cj_en4 ", \"boundary\": " 107 text cj_en5 ", \"ranking_valid\": " 108 109 text cj_co1 "},\n \"conservation\": {\"n_ops\": " 110 text cj_co2 ", \"total_bytes\": " 111 text cj_co3 ", \"total_busy_ns\": " 112 text cj_co4 ", \"total_launch_ns\": " 113 text cj_co5 ", \"instrument_overhead_ns\": null}" 114 115 text cj_sn1 ",\n \"sensitivities\": [" 116 text cj_sn_a "\n {\"resource\": " 117 text cj_sn_a2 ",\n {\"resource\": " 118 text cj_sn_k ", \"kind\": " 119 text cj_sn_m ", \"makespan_if_doubled_ns\": " 120 text cj_sn_d ", \"delta_ns\": " 121 text cj_sn_w ", \"interval_width_frac\": " 122 text cj_sn_s ", \"decision_score\": " 123 text cj_sn_n ", \"next_experiment\": " 124 125 text cj_tail1 "\n ],\n \"unresolved_residual_ns\": " 126 text cj_tail2 ",\n \"note\": \"loaded-box calibration (load1 above); bounds are floors, not predictions; no performance claim from this simulation alone\"\n}\n" 127 128 text cj_df1 "{\"tool\": \"dagsim diff\", \"baseline\": " 129 text cj_df2 ", \"transformed\": " 130 text cj_df3 ", \"status\": " 131 text cj_df4 ", \"reason\": " 132 text cj_df5 ", \"kept\": " 133 text cj_df6 ", \"added\": " 134 text cj_df7 ", \"removed\": " 135 text cj_df8 ", \"double_counted\": " 136 text cj_df9 ", \"required_removed\": " 137 text cj_df10 ", \"removed_ns\": {" 138 text cj_df11 "}, \"changed\": " 139 text cj_df12 "}\n" 140 141 text cp_hdr1 "# dagsim pareto: objectives = seconds, peak bytes" 142 text cp_hdr_j ", joules" 143 text cp_hdr2 ". Energy " 144 text cp_hdr_em "measured on every row and part of the dominance test" 145 text cp_hdr_en "not measured on every row: shown, never ranked" 146 text cp_hdr3 ".\n# file status seconds lo_s hi_s peak_bytes energy front\n" 147 text cp_yes "yes" 148 text cp_no "no" 149 text cp_ref "refused" 150 text cp_unm "UNMEASURED" 151 text cp_syn "syn " 152 text cp_j " J" 153 text cp_dash "-" 154 text cp_cmt " # " 155 156 fn cli_arg_eq s view uchar * n ulong to bool 157 if ne n len s 158 ret false 159 end 160 for i ulong n bound 4096 161 if ne get cli_arg i get s i 162 ret false 163 end 164 end 165 ret true 166 end 167 168 fn cli_cmd_eq s view uchar * to bool 169 n = get cli_cmd_len 0 170 if ne n len s 171 ret false 172 end 173 for i ulong n bound 32 174 if ne get cli_cmd i get s i 175 ret false 176 end 177 end 178 ret true 179 end 180 181 fn cli_out_fmt_name mode ulong idx ulong to void 182 fa = new ulong 16 0 183 sn = new uchar 256 0 184 put fa 0 idx 185 n = dag_fmt mode edit fa edit sn 186 ds_out_jstr_buf view sn n 187 end 188 189 fn cli_out_next_exp rk ulong prov ulong to void 190 fa = new ulong 16 0 191 sn = new uchar 256 0 192 put fa 0 rk 193 put fa 1 prov 194 nl = dag_fmt 12 edit fa edit sn 195 ds_out_jstr_buf view sn nl 196 end 197 198 fn cli_out_energy_status em ulong es ulong to void 199 fa = new ulong 16 0 200 sn = new uchar 256 0 201 put fa 0 em 202 put fa 1 es 203 nl = dag_fmt 10 edit fa edit sn 204 ds_out_jstr_buf view sn nl 205 end 206 207 fn cli_out_nom_rsn_jstr to void 208 esc = new uchar 6 0 209 ds_out_ch uchar 34 210 n = get cli_nom_rsn_len 0 211 for i ulong n bound 256 212 k = dag_jstr get cli_nom_rsn i edit esc 213 for j ulong k bound 6 214 ds_out_ch get esc j 215 end 216 end 217 ds_out_ch uchar 34 218 end 219 220 fn cli_out_changed_jstr to void 221 esc = new uchar 6 0 222 ds_out_ch uchar 34 223 n = get cli_changed_len 0 224 for i ulong n bound 256 225 k = dag_jstr get cli_changed i edit esc 226 for j ulong k bound 6 227 ds_out_ch get esc j 228 end 229 end 230 ds_out_ch uchar 34 231 end 232 233 fn cli_out_file_jstr fi ulong to void 234 fl = get cli_flens fi 235 fb = mul fi 256 236 esc = new uchar 6 0 237 ds_out_ch uchar 34 238 for i ulong fl bound 256 239 k = dag_jstr get cli_files add fb i edit esc 240 for j ulong k bound 6 241 ds_out_ch get esc j 242 end 243 end 244 ds_out_ch uchar 34 245 end 246 247 fn cli_out_pad count ulong to void 248 for i ulong count bound 64 249 ds_out_ch uchar 32 250 end 251 end 252 253 fn cli_emit_ops to void 254 ds_out_text cj_ops1 255 n_ops = get ds_pm 12 256 for i ulong n_ops bound 256 257 if eq i 0 258 ds_out_text cj_op_a 259 else 260 ds_out_text cj_op_a2 261 end 262 sp = add 448 mul i 26 263 ds_out_jstr_slice_txt 0 get ds_pm sp get ds_pm add sp 1 264 ds_out_text cj_op_s 265 ds_out_jnum bitcast f64 get cli_nom_sc add 4512 i 266 ds_out_text cj_op_e 267 ds_out_jnum bitcast f64 get cli_nom_sc add 4768 i 268 ds_out_text cj_op_f 269 ds_out_jnum bitcast f64 get cli_nom_sc add 5280 i 270 ds_out_text cj_op_c 271 ds_out_jnum bitcast f64 get cli_nom_sc add 5536 i 272 ds_out_text cj_op_p 273 kind = get ds_pm add sp 2 274 hast = get ds_pm add sp 8 275 pv = get ds_pm add sp 7 276 if and eq kind 3 eq hast 0 277 pv = ulong 2 278 end 279 cli_out_fmt_name 1 pv 280 ds_out_text cj_op_r 281 ds_out_jstr_slice_txt 0 get ds_pm add sp 17 get ds_pm add sp 18 282 ds_out_text cj_rbrace 283 ds_out_flush 1 284 end 285 end 286 287 fn cli_sens_width sp ulong to f64 288 rk = get ds_pm add sp 2 289 capv = bitcast f64 get ds_pm add sp 4 290 w = f64 0.0f64 291 if and eq rk 2 gt capv 0.0f64 292 w = div sub bitcast f64 get ds_pm add sp 6 bitcast f64 get ds_pm add sp 5 capv 293 end 294 if eq get ds_pm add sp 7 4 295 w = f64 1.0f64 296 end 297 ret w 298 end 299 300 fn cli_sens_compute n_res ulong mk f64 asof long hasm ulong qbits ulong to void 301 for i ulong n_res bound 32 302 cf = ds_counterfactual_idx long i asof hasm qbits 303 put sn_cf i bitcast ulong cf 304 w = cli_sens_width add 64 mul i 12 305 put sn_width i bitcast ulong w 306 sc = f64 0.0f64 307 if ge cf 0.0f64 308 wf = w 309 if le wf 0.0f64 310 wf = f64 0.05f64 311 end 312 sc = mul fabs sub mk cf wf 313 end 314 put sn_score i bitcast ulong sc 315 put sn_idx i i 316 end 317 end 318 319 fn cli_sens_sort n_res ulong to void 320 for a ulong n_res bound 32 321 if gt a 0 322 k = get sn_idx a 323 b = a 324 while gt b 0 bound 32 325 prev = get sn_idx sub b 1 326 if not lt bitcast f64 get sn_score prev bitcast f64 get sn_score k 327 break 328 end 329 put sn_idx b prev 330 b = sub b 1 331 end 332 put sn_idx b k 333 end 334 end 335 end 336 337 fn cli_emit_sens_one a ulong mk f64 to void 338 i = get sn_idx a 339 sp = add 64 mul i 12 340 if eq a 0 341 ds_out_text cj_sn_a 342 else 343 ds_out_text cj_sn_a2 344 end 345 ds_out_jstr_slice_txt 0 get ds_pm sp get ds_pm add sp 1 346 ds_out_text cj_sn_k 347 cli_out_fmt_name 3 get ds_pm add sp 2 348 cf = bitcast f64 get sn_cf i 349 ds_out_text cj_sn_m 350 if ge cf 0.0f64 351 ds_out_jnum cf 352 else 353 ds_out_text cj_null 354 end 355 ds_out_text cj_sn_d 356 if ge cf 0.0f64 357 ds_out_jnum sub mk cf 358 else 359 ds_out_text cj_null 360 end 361 ds_out_text cj_sn_w 362 ds_out_jnum bitcast f64 get sn_width i 363 ds_out_text cj_sn_s 364 ds_out_jnum bitcast f64 get sn_score i 365 ds_out_text cj_sn_n 366 cli_out_next_exp get ds_pm add sp 2 get ds_pm add sp 7 367 ds_out_text cj_rbrace 368 ds_out_flush 1 369 end 370 371 fn cli_emit_sens n_res ulong mk f64 asof long hasm ulong qbits ulong to void 372 cli_sens_compute n_res mk asof hasm qbits 373 cli_sens_sort n_res 374 ds_out_text cj_sn1 375 for a ulong n_res bound 32 376 cli_emit_sens_one a mk 377 end 378 end 379 380 fn cli_emit_eval_hdr fi ulong st ulong to void 381 ds_out_text cj_h1 382 cli_out_file_jstr fi 383 ds_out_text cj_h2 384 ds_out_jstr_slice_txt 0 get ds_pm 17 get ds_pm 18 385 ds_out_text cj_h3 386 ds_out_jstr_slice_txt 0 get ds_pm 23 get ds_pm 24 387 ds_out_text cj_h4 388 if ne get ds_pm 3 0 389 ds_out_jstr_slice_txt 0 get ds_pm 27 get ds_pm 28 390 else 391 ds_out_ch uchar 34 392 ds_out_ch uchar 34 393 end 394 ds_out_text cj_h5 395 ds_out_i64 dr_i get ds_pm 4 396 ds_out_text cj_h6 397 ds_out_i64 dr_i get ds_pm 5 398 ds_out_text cj_h7 399 ds_out_jnum bitcast f64 get ds_pm 6 400 ds_out_text cj_h8 401 ds_out_jstr_slice_txt 0 get ds_pm 29 get ds_pm 30 402 ds_out_text cj_h9 403 ds_out_i64 get cli_asof 0 404 ds_out_text cj_h10 405 cli_out_fmt_name 0 st 406 ds_out_text cj_h11 407 cli_out_nom_rsn_jstr 408 ds_out_text cj_h12 409 pmask = get cli_nom_sc 11 410 first = ulong 1 411 for p ulong 5 412 if ne and pmask shl ulong 1 p 0 413 if eq first 0 414 ds_out_text cj_comma 415 end 416 first = ulong 0 417 cli_out_fmt_name 1 p 418 end 419 end 420 ds_out_text cj_h13 421 ds_out_u64 get cli_nom_sc 26 422 ds_out_text cj_h14 423 end 424 425 fn cli_emit_bounds mk f64 lo f64 hi f64 to void 426 ds_out_text cj_mk1 427 ds_out_jnum mk 428 ds_out_text cj_mk2 429 ds_out_jnum lo 430 ds_out_text cj_mk3 431 ds_out_jnum hi 432 ds_out_text cj_mk4 433 if and gt lo 0.0f64 gt hi 0.0f64 434 ds_out_text cj_true 435 else 436 ds_out_text cj_false 437 end 438 ds_out_text cj_bd1 439 ds_out_jnum bitcast f64 get cli_nom_sc 20 440 ds_out_text cj_bd2 441 bnd = bitcast f64 get cli_nom_sc 19 442 ds_out_jnum bnd 443 ds_out_text cj_bd3 444 n_res = get ds_pm 11 445 for i ulong n_res bound 32 446 if gt i 0 447 ds_out_text cj_comma 448 end 449 sp = add 64 mul i 12 450 ds_out_jstr_slice_txt 0 get ds_pm sp get ds_pm add sp 1 451 ds_out_text cj_colon 452 ds_out_jnum bitcast f64 get cli_nom_sc add 5792 i 453 end 454 ds_out_text cj_bd4 455 if ge add mk 0.`000001f64` bnd 456 ds_out_text cj_true 457 else 458 ds_out_text cj_false 459 end 460 ds_out_flush 1 461 end 462 463 fn cli_emit_cp_peak to void 464 ds_out_text cj_cp1 465 nc = get cli_nom_sc 21 466 for i ulong nc bound 256 467 if gt i 0 468 ds_out_text cj_comma 469 end 470 oi = get cli_nom_sc add 6080 i 471 sp = add 448 mul oi 26 472 ds_out_jstr_slice_txt 0 get ds_pm sp get ds_pm add sp 1 473 end 474 ds_out_text cj_pk1 475 n_res = get ds_pm 11 476 first = ulong 1 477 for i ulong n_res bound 32 478 sp = add 64 mul i 12 479 if eq get ds_pm add sp 2 3 480 if eq first 0 481 ds_out_text cj_comma 482 end 483 first = ulong 0 484 ds_out_jstr_slice_txt 0 get ds_pm sp get ds_pm add sp 1 485 ds_out_text cj_pk2 486 ds_out_jnum bitcast f64 get cli_nom_sc add 6344 i 487 ds_out_text cj_pk3 488 ds_out_jnum bitcast f64 get cli_nom_sc add 6376 i 489 ds_out_text cj_pk4 490 ds_out_jnum bitcast f64 get ds_pm add sp 4 491 ds_out_text cj_rbrace 492 end 493 end 494 ds_out_flush 1 495 end 496 497 fn cli_emit_attr_energy_cons to void 498 ds_out_text cj_at1 499 for i ulong 7 500 if gt i 0 501 ds_out_text cj_comma 502 end 503 cli_out_fmt_name 4 i 504 ds_out_text cj_colon 505 ds_out_jnum bitcast f64 get cli_nom_sc add 5824 i 506 end 507 ds_out_text cj_en1 508 em = get cli_nom_sc 22 509 es = get cli_nom_sc 23 510 cli_out_energy_status em es 511 ds_out_text cj_en2 512 if or ne em 0 ne es 0 513 ds_out_jnum bitcast f64 get cli_nom_sc 24 514 else 515 ds_out_text cj_null 516 end 517 ds_out_text cj_en3 518 ds_out_jstr_slice_txt 0 get ds_pm 33 get ds_pm 34 519 ds_out_text cj_en4 520 ds_out_jstr_slice_txt 0 get ds_pm 35 get ds_pm 36 521 ds_out_text cj_en5 522 if ne em 0 523 ds_out_text cj_true 524 else 525 ds_out_text cj_false 526 end 527 ds_out_text cj_co1 528 ds_out_u64 get ds_pm 12 529 ds_out_text cj_co2 530 ds_out_jnum bitcast f64 get cli_nom_sc 15 531 ds_out_text cj_co3 532 ds_out_jnum bitcast f64 get cli_nom_sc 16 533 ds_out_text cj_co4 534 ds_out_jnum bitcast f64 get cli_nom_sc 17 535 ds_out_text cj_co5 536 ds_out_flush 1 537 end 538 539 fn cli_emit_eval_body lo f64 hi f64 to void 540 mk = bitcast f64 get cli_nom_sc 3 541 cli_emit_bounds mk lo hi 542 cli_emit_ops 543 cli_emit_cp_peak 544 cli_emit_attr_energy_cons 545 cli_emit_sens get ds_pm 11 mk get cli_asof 0 get cli_has_model 0 bitcast ulong 0.9f64 546 ds_out_text cj_tail1 547 ds_out_jnum bitcast f64 get cli_nom_sc 5830 548 ds_out_text cj_tail2 549 ds_out_flush 1 550 end 551 552 fn cli_cmd_eval to int 553 flen = get cli_flens 0 554 pbuf = new uchar 256 0 555 for i ulong flen bound 256 556 put pbuf i get cli_files i 557 end 558 prc = ds_read_file_side 0 view pbuf flen 559 ds_out_reset 560 if ne prc 0 561 ds_out_text cj_perr1 562 cli_out_file_jstr 0 563 ds_out_text cj_perr2 564 ds_out_jstr_err 565 ds_out_text cj_perr3 566 ds_out_flush 1 567 ret 1 568 end 569 asof = get cli_asof 0 570 hasm = get cli_has_model 0 571 qbits = bitcast ulong 0.9f64 572 rc = ds_eval_current 0 asof hasm qbits 573 for i ulong 8192 574 put cli_nom_sc i get ds_sc i 575 end 576 rlen = get ds_reason_len 0 577 put cli_nom_rsn_len 0 rlen 578 for i ulong rlen bound 256 579 put cli_nom_rsn i get ds_reason i 580 end 581 cli_emit_eval_hdr 0 rc 582 if ne rc 0 583 ds_out_text cj_end_ref 584 ds_out_flush 1 585 ret 1 586 end 587 lo = f64 0.0f64 588 hi = f64 0.0f64 589 rc_lo = ds_eval_current 1 asof hasm qbits 590 if eq rc_lo 0 591 lo = bitcast f64 get ds_sc 3 592 end 593 rc_hi = ds_eval_current -1 asof hasm qbits 594 if eq rc_hi 0 595 hi = bitcast f64 get ds_sc 3 596 end 597 cli_emit_eval_body lo hi 598 ret 0 599 end 600 601 fn cli_pareto_load k ulong to ulong 602 fl = get cli_flens k 603 fb = mul k 256 604 pbuf = new uchar 256 0 605 for i ulong fl bound 256 606 put pbuf i get cli_files add fb i 607 end 608 prc = ds_read_file_side 0 view pbuf fl 609 if ne prc 0 610 put pr_status k 9 611 rl = ulong 0 612 while lt rl 255 bound 256 613 c = get ds_err rl 614 if eq c 0 615 break 616 end 617 put pr_rsn add fb rl c 618 rl = add rl 1 619 end 620 put pr_rsn_len k rl 621 ret 1 622 end 623 ret 0 624 end 625 626 fn cli_pareto_max_peak to f64 627 peak = f64 0.0f64 628 n_res = get ds_pm 11 629 for i ulong n_res bound 32 630 sp = add 64 mul i 12 631 if eq get ds_pm add sp 2 3 632 pv = bitcast f64 get ds_sc add 6344 i 633 if gt pv peak 634 peak = pv 635 end 636 end 637 end 638 ret peak 639 end 640 641 fn cli_pareto_eval_one k ulong to ulong 642 if ne cli_pareto_load k 0 643 ret 0 644 end 645 asof = get cli_asof 0 646 hasm = get cli_has_model 0 647 qbits = bitcast ulong 0.9f64 648 rc = ds_eval_current 0 asof hasm qbits 649 put pr_status k rc 650 fb = mul k 256 651 rl = get ds_reason_len 0 652 put pr_rsn_len k rl 653 for i ulong rl bound 256 654 put pr_rsn add fb i get ds_reason i 655 end 656 if ne rc 0 657 ret 0 658 end 659 put pr_t k get ds_sc 3 660 put pr_peak k bitcast ulong cli_pareto_max_peak 661 put pr_e k get ds_sc 24 662 put pr_emeas k get ds_sc 22 663 put pr_esyn k get ds_sc 23 664 rc_lo = ds_eval_current 1 asof hasm qbits 665 if eq rc_lo 0 666 put pr_lo k get ds_sc 3 667 else 668 put pr_lo k 0 669 end 670 rc_hi = ds_eval_current -1 asof hasm qbits 671 if eq rc_hi 0 672 put pr_hi k get ds_sc 3 673 else 674 put pr_hi k 0 675 end 676 if eq get pr_emeas k 0 677 ret 0 678 end 679 ret 1 680 end 681 682 fn cli_pareto_dom a ulong b ulong all_e ulong to bool 683 ta = bitcast f64 get pr_t a 684 tb = bitcast f64 get pr_t b 685 pa = bitcast f64 get pr_peak a 686 pb = bitcast f64 get pr_peak b 687 leq = and le tb ta le pb pa 688 str = or lt tb ta lt pb pa 689 if ne all_e 0 690 ea = bitcast f64 get pr_e a 691 eb = bitcast f64 get pr_e b 692 leq = and leq le eb ea 693 str = or str lt eb ea 694 end 695 ret and leq str 696 end 697 698 fn cli_pareto_print_row k ulong to void 699 fa = new ulong 16 0 700 sn = new uchar 256 0 701 ds_out_ch uchar 32 702 ds_out_ch uchar 32 703 fl = get cli_flens k 704 fb = mul k 256 705 for i ulong fl bound 256 706 ds_out_ch get cli_files add fb i 707 end 708 if lt fl 36 709 cli_out_pad sub 36 fl 710 end 711 ds_out_ch uchar 32 712 st = get pr_status k 713 put fa 0 st 714 sl = dag_fmt 0 edit fa edit sn 715 for i ulong sl bound 64 716 ds_out_ch get sn i 717 end 718 if lt sl 24 719 cli_out_pad sub 24 sl 720 end 721 ds_out_ch uchar 32 722 if eq st 0 723 ds_out_fixed mul bitcast f64 get pr_t k 1.0e-9f64 6 724 ds_out_ch uchar 32 725 ds_out_fixed mul bitcast f64 get pr_lo k 1.0e-9f64 6 726 ds_out_ch uchar 32 727 ds_out_fixed mul bitcast f64 get pr_hi k 1.0e-9f64 6 728 ds_out_ch uchar 32 729 ds_out_fixed bitcast f64 get pr_peak k 0 730 ds_out_ch uchar 32 731 if ne get pr_emeas k 0 732 ds_out_fixed bitcast f64 get pr_e k 3 733 ds_out_text cp_j 734 else 735 if ne get pr_esyn k 0 736 ds_out_text cp_syn 737 ds_out_fixed bitcast f64 get pr_e k 3 738 ds_out_text cp_j 739 else 740 ds_out_text cp_unm 741 end 742 end 743 ds_out_ch uchar 32 744 if ne get pr_front k 0 745 ds_out_text cp_yes 746 else 747 ds_out_text cp_no 748 end 749 else 750 ds_out_text cp_dash 751 ds_out_ch uchar 32 752 ds_out_text cp_dash 753 ds_out_ch uchar 32 754 ds_out_text cp_dash 755 ds_out_ch uchar 32 756 ds_out_text cp_dash 757 ds_out_ch uchar 32 758 ds_out_text cp_dash 759 ds_out_ch uchar 32 760 ds_out_text cp_ref 761 ds_out_text cp_cmt 762 rl = get pr_rsn_len k 763 for i ulong rl bound 256 764 ds_out_ch get pr_rsn add fb i 765 end 766 end 767 ds_out_ch uchar 10 768 ds_out_flush 1 769 end 770 771 fn cli_cmd_pareto to int 772 nf = get cli_nfiles 0 773 all_e = ulong 1 774 for k ulong nf bound 64 775 ok_e = cli_pareto_eval_one k 776 if eq ok_e 0 777 all_e = ulong 0 778 end 779 end 780 for a ulong nf bound 64 781 if eq get pr_status a 0 782 put pr_front a 1 783 for b ulong nf bound 64 784 if and ne a b eq get pr_status b 0 785 if cli_pareto_dom a b all_e 786 put pr_front a 0 787 break 788 end 789 end 790 end 791 end 792 end 793 ds_out_reset 794 ds_out_text cp_hdr1 795 if ne all_e 0 796 ds_out_text cp_hdr_j 797 end 798 ds_out_text cp_hdr2 799 if ne all_e 0 800 ds_out_text cp_hdr_em 801 else 802 ds_out_text cp_hdr_en 803 end 804 ds_out_text cp_hdr3 805 ds_out_flush 1 806 for k ulong nf bound 64 807 cli_pareto_print_row k 808 end 809 ret 0 810 end 811 812 fn cli_cmd_diff to int 813 f0 = new uchar 256 0 814 f1 = new uchar 256 0 815 cb = new uchar 256 0 816 l0 = get cli_flens 0 817 l1 = get cli_flens 1 818 for i ulong l0 bound 256 819 put f0 i get cli_files i 820 end 821 for i ulong l1 bound 256 822 put f1 i get cli_files add 256 i 823 end 824 if ne ds_read_file_side 0 view f0 l0 0 825 ds_out_reset 826 ds_out_jstr_err 827 ds_out_ch uchar 10 828 ds_out_flush 2 829 ret 1 830 end 831 if ne ds_read_file_side 1 view f1 l1 0 832 ds_out_reset 833 ds_out_jstr_err 834 ds_out_ch uchar 10 835 ds_out_flush 2 836 ret 1 837 end 838 ds_pack_side 0 839 ds_pack_side 1 840 clen = get cli_changed_len 0 841 if gt clen 0 842 for i ulong clen bound 256 843 put cb i get cli_changed i 844 end 845 ds_mark_changed view cb clen 846 end 847 for i ulong 64 848 put ds_ra i 0 849 end 850 rc = ds_run_diff 851 ds_out_reset 852 ds_out_text cj_df1 853 cli_out_file_jstr 0 854 ds_out_text cj_df2 855 cli_out_file_jstr 1 856 ds_out_text cj_df3 857 cli_out_fmt_name 0 rc 858 ds_out_text cj_df4 859 ds_out_ch uchar 34 860 ds_out_ch uchar 34 861 ds_out_text cj_df5 862 ds_out_u64 get ds_ra 11 863 ds_out_text cj_df6 864 ds_out_u64 get ds_ra 10 865 ds_out_text cj_df7 866 ds_out_u64 get ds_ra 12 867 ds_out_text cj_df8 868 ds_out_u64 get ds_ra 13 869 ds_out_text cj_df9 870 ds_out_u64 get ds_ra 14 871 ds_out_text cj_df10 872 for i ulong 7 873 if gt i 0 874 ds_out_text cj_comma 875 end 876 cli_out_fmt_name 2 add i 1 877 ds_out_text cj_colon 878 ds_out_jnum bitcast f64 get ds_ra add 33 i 879 end 880 ds_out_text cj_df11 881 cli_out_changed_jstr 882 ds_out_text cj_df12 883 ds_out_flush 1 884 if eq rc 0 885 ret 0 886 end 887 ret 1 888 end 889 890 fn cli_parse_asof_arg n2 ulong to long 891 dbuf = new uchar 256 0 892 lim = n2 893 if gt lim 255 894 lim = ulong 255 895 end 896 for k ulong lim bound 256 897 put dbuf k get cli_arg k 898 end 899 ret ds_day_from_slice view dbuf lim 900 end 901 902 fn cli_parse_args ac ulong to int 903 i = ulong 2 904 while lt i ac bound 256 905 n = argread i cli_arg 0 4096 906 if lt n 0 907 ret 2 908 end 909 un = ulong n 910 if cli_arg_eq cli_fasof un 911 if ge add i 1 ac 912 ret 2 913 end 914 i = add i 1 915 n2 = argread i cli_arg 0 4096 916 if le n2 0 917 ret 2 918 end 919 d = cli_parse_asof_arg ulong n2 920 if lt d 0 921 w = write 2 cli_bad_asof 0 len cli_bad_asof 922 ret 2 923 end 924 put cli_asof 0 d 925 i = add i 1 926 continue 927 end 928 if cli_arg_eq cli_fchanged un 929 if ge add i 1 ac 930 ret 2 931 end 932 i = add i 1 933 n2 = argread i cli_arg 0 4096 934 if lt n2 0 935 ret 2 936 end 937 lim = ulong n2 938 if gt lim 255 939 lim = ulong 255 940 end 941 for k ulong lim bound 256 942 put cli_changed k get cli_arg k 943 end 944 put cli_changed_len 0 lim 945 i = add i 1 946 continue 947 end 948 if cli_arg_eq cli_fmodel un 949 if ge add i 1 ac 950 ret 2 951 end 952 i = add i 2 953 continue 954 end 955 nf = get cli_nfiles 0 956 if lt nf 64 957 lim = un 958 if gt lim 255 959 lim = ulong 255 960 end 961 fb = mul nf 256 962 for k ulong lim bound 256 963 put cli_files add fb k get cli_arg k 964 end 965 put cli_flens nf lim 966 put cli_nfiles 0 add nf 1 967 end 968 i = add i 1 969 end 970 ret 0 971 end 972 973 fn main to int 974 ac = argcnt 975 if lt ac 3 976 w = write 2 cli_usage 0 len cli_usage 977 ret 2 978 end 979 n1 = argread 1 cli_arg 0 4096 980 if le n1 0 981 w = write 2 cli_usage 0 len cli_usage 982 ret 2 983 end 984 cl = ulong n1 985 if gt cl 31 986 cl = ulong 31 987 end 988 for i ulong cl bound 32 989 put cli_cmd i get cli_arg i 990 end 991 put cli_cmd_len 0 cl 992 prc = cli_parse_args ulong ac 993 if ne prc 0 994 ret prc 995 end 996 if eq get cli_asof 0 0 997 w = write 2 cli_need_asof 0 len cli_need_asof 998 ret 2 999 end 1000 nf = get cli_nfiles 0 1001 if and cli_cmd_eq cli_keval eq nf 1 1002 ret cli_cmd_eval 1003 end 1004 if and cli_cmd_eq cli_kpareto ge nf 1 1005 ret cli_cmd_pareto 1006 end 1007 if and cli_cmd_eq cli_kdiff eq nf 2 1008 ret cli_cmd_diff 1009 end 1010 w = write 2 cli_usage 0 len cli_usage 1011 ret 2 1012 end