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 / tools / r15_reduce.om
| 1 | om2 |
| 2 | note SPDX-License-Identifier: Apache-2.0 |
| 3 | note Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 4 | note |
| 5 | note tools/r15_reduce.om -- R15 performance proof reducer in pure seeded OM-2. |
| 6 | note Replaces tools/r15_reduce.c (spec/r15-performance-proof.md sections 10-12). |
| 7 | |
| 8 | const R15_MAXF ulong 4096 |
| 9 | const R15_MAXT ulong 512 |
| 10 | const R15_MAXL1 ulong 256 |
| 11 | const R15_L1_BLKS ulong 8192 |
| 12 | const R15_L1_BSZ ulong 1024 |
| 13 | const R15_SORT_CAP ulong 262144 |
| 14 | const R15_MAXL2 ulong 64 |
| 15 | const R15_L2_CAP ulong 65536 |
| 16 | const R15_MAXBAR ulong 4096 |
| 17 | const R15_MAXW ulong 64 |
| 18 | const R15_MAXTEL ulong 65536 |
| 19 | const R15_MAXHB ulong 65536 |
| 20 | const R15_MAXJN ulong 32768 |
| 21 | const R15_JSTR_CAP ulong 131072 |
| 22 | const R15_LINE_CAP ulong 524288 |
| 23 | const R15_RESAMP ulong 10000 |
| 24 | |
| 25 | const JT_NULL ulong 0 |
| 26 | const JT_BOOL ulong 1 |
| 27 | const JT_NUM ulong 2 |
| 28 | const JT_STR ulong 3 |
| 29 | const JT_ARR ulong 4 |
| 30 | const JT_OBJ ulong 5 |
| 31 | |
| 32 | const W_IDLE ulong 0 |
| 33 | const W_BEFORE ulong 1 |
| 34 | const W_AFTER ulong 2 |
| 35 | const W_SPAN ulong 3 |
| 36 | const W_N ulong 4 |
| 37 | |
| 38 | const C_ADAPT ulong 0 |
| 39 | const C_COST ulong 1 |
| 40 | const C_BEFORE ulong 2 |
| 41 | const C_AFTER ulong 3 |
| 42 | const C_SPAN ulong 4 |
| 43 | const C_N ulong 5 |
| 44 | |
| 45 | note ---- Messages & punctuation ---- |
| 46 | text t_usg "usage: r15_reduce <raw-dir> <summary.json>\n" |
| 47 | text t_nosums "no SHA256SUMS in " |
| 48 | text t_hbad "hash mismatch: " |
| 49 | text t_unlisted "not in SHA256SUMS: " |
| 50 | text t_unread "unreadable: " |
| 51 | text t_notjson ": not JSON\n" |
| 52 | text t_toomany_t "too many trials\n" |
| 53 | text t_toomany_l1 "too many L1 sets\n" |
| 54 | text t_toomany_l2 "too many L2 runs\n" |
| 55 | text t_sums_name "SHA256SUMS" |
| 56 | text t_jsonl ".jsonl" |
| 57 | text t_nl "\n" |
| 58 | text t_col ":" |
| 59 | text t_true "true" |
| 60 | text t_false "false" |
| 61 | text t_null "null" |
| 62 | text t_nan "nan" |
| 63 | text t_inf "inf" |
| 64 | text t_ninf "-inf" |
| 65 | text t_pass "PASS" |
| 66 | text t_fail "FAIL" |
| 67 | text t_all_gates "all gates: " |
| 68 | |
| 69 | note ---- Configs & Window names ---- |
| 70 | text t_cfg0 "RES-4" |
| 71 | text t_cfg1 "RES-1" |
| 72 | text t_cfg2 "SEQ" |
| 73 | text t_cfg3 "RES-1-NODIGEST" |
| 74 | text t_nodig "NODIGEST" |
| 75 | |
| 76 | text t_w_idle "IDLE" |
| 77 | text t_w_before "BEFORE" |
| 78 | text t_w_after "AFTER" |
| 79 | text t_w_span "ADAPT_AFTER" |
| 80 | text t_cw_adapt "ADAPT" |
| 81 | text t_cw_cost "ADAPT_COST" |
| 82 | text t_w_timing "W_TIMING" |
| 83 | text t_w_timing_on "W_TIMING_ON" |
| 84 | |
| 85 | note ---- JSON input keys ---- |
| 86 | text t_k_kind "kind" |
| 87 | text t_k_level "level" |
| 88 | text t_k_config "config" |
| 89 | text t_k_round "round" |
| 90 | text t_k_trial "trial" |
| 91 | text t_k_l2 "l2" |
| 92 | text t_k_start "start" |
| 93 | text t_k_end "end" |
| 94 | text t_k_silicon "silicon" |
| 95 | text t_k_exit "exit" |
| 96 | text t_k_episode "episode" |
| 97 | text t_k_adapt "adapt" |
| 98 | text t_k_residency "residency" |
| 99 | text t_k_observers "observers" |
| 100 | text t_k_result "result" |
| 101 | text t_k_complete "complete" |
| 102 | text t_k_window "window" |
| 103 | text t_k_cwindow "cwindow" |
| 104 | text t_k_telemetry "telemetry" |
| 105 | text t_k_e "e" |
| 106 | text t_k_t_ns "t_ns" |
| 107 | text t_k_energy_uj "energy_uj" |
| 108 | text t_k_spbm_ok "spbm_ok" |
| 109 | text t_k_overflow "overflow" |
| 110 | text t_k_e0 "e0" |
| 111 | text t_k_e1 "e1" |
| 112 | text t_k_nvml_ok "nvml_ok" |
| 113 | text t_k_nvml_mj "nvml_mj" |
| 114 | text t_k_l1 "l1" |
| 115 | text t_k_l1_g "l1_g" |
| 116 | text t_k_l1_bf "l1_b_failed" |
| 117 | text t_k_tstat "timing_status" |
| 118 | text t_k_ok "ok" |
| 119 | text t_k_fsamp "failed_samples" |
| 120 | text t_k_v "v" |
| 121 | text t_k_measure "measure" |
| 122 | text t_k_field "field" |
| 123 | text t_k_param "param" |
| 124 | text t_k_enter "enter" |
| 125 | text t_k_begin "begin" |
| 126 | text t_k_flip "flip" |
| 127 | text t_k_receipt "receipt" |
| 128 | text t_k_pcb "production_commits_barrier" |
| 129 | text t_k_prc "promote_rc" |
| 130 | text t_k_b_enter "barrier_enter" |
| 131 | text t_k_b_begin "barrier_begin" |
| 132 | text t_k_b_flip "barrier_flip" |
| 133 | text t_k_b_receipt "barrier_receipt" |
| 134 | text t_k_b_commits "barrier_production_commits" |
| 135 | text t_k_b_res "barrier_result" |
| 136 | text t_k_l2_claim "l2_claim" |
| 137 | text t_k_in_t "input_t" |
| 138 | text t_k_ss_t "seat_start_t" |
| 139 | text t_k_sc_t "seat_commit_t" |
| 140 | text t_k_ds_t "dependent_start_t" |
| 141 | text t_k_cpick "chip_pick" |
| 142 | text t_k_cdone "chip_done" |
| 143 | text t_k_ops "ops" |
| 144 | text t_k_wall_ns "wall_ns" |
| 145 | text t_k_stats "stats" |
| 146 | text t_k_gsb "gen_store_bytes" |
| 147 | text t_k_cuser "cpu_user_ns" |
| 148 | text t_k_csys "cpu_sys_ns" |
| 149 | text t_k_pmu "pmu" |
| 150 | text t_k_mux "multiplexed" |
| 151 | text t_k_sum "sum" |
| 152 | text t_k_sampler "sampler" |
| 153 | text t_k_intervals "intervals" |
| 154 | text t_k_slot_sum "slot_sum" |
| 155 | text t_k_slot_max "slot_max" |
| 156 | text t_k_claims_max "claims_max" |
| 157 | text t_k_total "total" |
| 158 | text t_k_seat_live "seat_live" |
| 159 | text t_k_diag "diag" |
| 160 | text t_k_dead_runs "dead_runs" |
| 161 | text t_k_dead_long "dead_longest" |
| 162 | text t_k_dead_end "dead_at_end" |
| 163 | text t_k_late_2ms "late_2ms" |
| 164 | text t_k_late_10ms "late_10ms" |
| 165 | text t_k_max_gap "max_gap_ns" |
| 166 | text t_k_stale_max "stale_max_ns" |
| 167 | text t_k_fdead_t "first_dead_t" |
| 168 | text t_k_t_first "t_first" |
| 169 | |
| 170 | text t_k_wrong "wrong" |
| 171 | text t_k_illegal "illegal" |
| 172 | text t_k_cver "crumbs_verified" |
| 173 | text t_k_covf "crumb_overflow" |
| 174 | text t_k_gstat "goal_status" |
| 175 | text t_k_gbefore "gen_before" |
| 176 | text t_k_gafter "gen_after" |
| 177 | text t_k_unprom "unpromoted_use" |
| 178 | text t_k_aegisw "aegis_woken" |
| 179 | text t_k_rootw "root_woken" |
| 180 | text t_k_losttr "lost_triggers" |
| 181 | text t_k_inforce "inforce_id" |
| 182 | |
| 183 | text t_k_goal_t "goal_t" |
| 184 | text t_k_met_t "met_t" |
| 185 | text t_k_plan_t "plan_t" |
| 186 | text t_k_select_t "select_t" |
| 187 | text t_k_evid_t "evidence_t" |
| 188 | text t_k_claim_t "claim_t" |
| 189 | text t_k_inforce_t "inforce_t" |
| 190 | text t_k_cand_t "candidate_t" |
| 191 | text t_k_ref_ps "reference_ps" |
| 192 | text t_k_sel_ps "selected_ps" |
| 193 | |
| 194 | text t_k_t0 "t0" |
| 195 | text t_k_t1 "t1" |
| 196 | text t_k_scomm "serve_commits" |
| 197 | text t_k_acost "adapt_cost_ns" |
| 198 | text t_k_conseq "consequential" |
| 199 | text t_k_replays "replays" |
| 200 | text t_k_acts "activations" |
| 201 | text t_k_kinds "kinds" |
| 202 | text t_k_inval "invalidated" |
| 203 | text t_k_blkauth "blocked_authority" |
| 204 | text t_k_rej "rejected" |
| 205 | text t_k_failed "failed" |
| 206 | text t_k_noop "noop" |
| 207 | text t_k_quar "quarantine" |
| 208 | text t_k_commit "commit" |
| 209 | text t_k_latency "latency" |
| 210 | text t_k_b "b" |
| 211 | |
| 212 | text t_st_0 "snapshot_bytes" |
| 213 | text t_st_1 "stage_bytes" |
| 214 | text t_st_2 "crumb_bytes" |
| 215 | text t_st_3 "proj_bytes" |
| 216 | text t_st_4 "c2g_write_bytes" |
| 217 | text t_st_5 "c2g_read_bytes" |
| 218 | text t_st_6 "g2c_write_bytes" |
| 219 | text t_st_7 "g2c_read_bytes" |
| 220 | text t_st_8 "window_move_bytes" |
| 221 | text t_st_9 "setup_copy_bytes" |
| 222 | text t_st_seqp "seq_polls" |
| 223 | text t_st_wakes "wakes" |
| 224 | text t_st_grt "gpu_results_taken" |
| 225 | text t_st_rc "resident_claims" |
| 226 | text t_st_ghw "gpu_host_waits" |
| 227 | text t_st_gpe "gpu_polls_empty" |
| 228 | |
| 229 | text t_pm_0 "cpu_cycles" |
| 230 | text t_pm_1 "inst_retired" |
| 231 | text t_pm_2 "ll_cache_miss_rd" |
| 232 | text t_pm_3 "bus_access" |
| 233 | text t_pm_4 "l2d_cache_refill" |
| 234 | text t_pm_5 "mem_access" |
| 235 | |
| 236 | note ---- JSON output keys & strings ---- |
| 237 | text t_o_schema "schema" |
| 238 | text t_o_schema_v "AIEN_RX_R15_SUMMARY_V1" |
| 239 | text t_o_rdig "raw_digest_sha256_of_SHA256SUMS" |
| 240 | text t_o_boot "bootstrap" |
| 241 | text t_o_boot_v "percentile, 10000 resamples, splitmix64 seed 0x15 per comparison" |
| 242 | text t_o_files "files" |
| 243 | text t_o_name "name" |
| 244 | text t_o_sha256 "sha256" |
| 245 | text t_o_trials "trials" |
| 246 | text t_o_file "file" |
| 247 | text t_o_correct "correct" |
| 248 | text t_o_why "why" |
| 249 | text t_o_bops "before_ops_per_s" |
| 250 | text t_o_adops "adapt_ops_per_s" |
| 251 | text t_o_afops "after_ops_per_s" |
| 252 | text t_o_idlew "idle_power_w" |
| 253 | text t_o_ean "energy_uj_per_op_after_net" |
| 254 | text t_o_eag "energy_uj_per_op_after_gross" |
| 255 | text t_o_ebn "energy_uj_per_op_before_net" |
| 256 | text t_o_nvml "gpu_domain_nvml_mj_after" |
| 257 | text t_o_epw "episode_wall_ns" |
| 258 | text t_o_epe "episode_energy_uj" |
| 259 | text t_o_cog "cognition_ns" |
| 260 | text t_o_srch "search_ns" |
| 261 | text t_o_gexp "gpu_experiment_ns" |
| 262 | text t_o_prom "promotion_ns" |
| 263 | text t_o_gain "gain_ns_per_op" |
| 264 | text t_o_xops "crossover_ops" |
| 265 | text t_o_xs "crossover_s" |
| 266 | text t_o_wamp "wake_amplification" |
| 267 | text t_o_cps "commits_per_stimulus" |
| 268 | text t_o_wps "wasted_per_stimulus" |
| 269 | text t_o_ira "invalidation_rate_adapt" |
| 270 | text t_o_cra "conflict_rate_adapt" |
| 271 | text t_o_apo "after_per_op" |
| 272 | text t_o_cpuns "cpu_ns" |
| 273 | text t_o_dram "dram_read_bytes_ll_miss_x64" |
| 274 | text t_o_bus "bus_bytes_bus_access_x64" |
| 275 | text t_o_r5m "r5_slots_mean" |
| 276 | text t_o_r5p "r5_slots_peak" |
| 277 | text t_o_rcp "resident_claims_peak" |
| 278 | text t_o_gres "gpu_residency" |
| 279 | |
| 280 | text t_o_cmps "comparisons" |
| 281 | text t_o_c_a1s "after_throughput_RES-1_over_SEQ" |
| 282 | text t_o_c_a4s "after_throughput_RES-4_over_SEQ" |
| 283 | text t_o_c_a41 "after_throughput_RES-4_over_RES-1" |
| 284 | text t_o_c_b1s "before_throughput_RES-1_over_SEQ" |
| 285 | text t_o_c_ad4s "adapt_rate_RES-4_over_SEQ" |
| 286 | text t_o_c_ad1s "adapt_rate_RES-1_over_SEQ" |
| 287 | text t_o_c_nd "after_throughput_RES-1_over_NODIGEST" |
| 288 | text t_o_c_en "energy_per_op_after_RES-1_over_SEQ" |
| 289 | text t_o_c_wa "wasted_per_stimulus_RES-1_over_SEQ" |
| 290 | text t_o_mrat "median_ratio" |
| 291 | text t_o_cilo "ci95_lo" |
| 292 | text t_o_cihi "ci95_hi" |
| 293 | text t_o_pairs "pairs" |
| 294 | text t_o_pexcl "pairs_excluded" |
| 295 | |
| 296 | text t_o_metrics "metrics" |
| 297 | text t_o_m1 "m1_semantic_ops_per_s" |
| 298 | text t_o_bmed "before_median" |
| 299 | text t_o_admed "adapt_median" |
| 300 | text t_o_afmed "after_median" |
| 301 | text t_o_m2 "m2_activation_latency_ns" |
| 302 | text t_o_l1ar "L1A_RES-1" |
| 303 | text t_o_l1as "L1A_SEQ" |
| 304 | text t_o_tc_p "trial_crumbs_" |
| 305 | text t_o_m3 "m3_propagation_ns" |
| 306 | text t_o_fan_p "fanout_" |
| 307 | text t_o_wwall "wave_wall" |
| 308 | text t_o_wcpu "wave_cpu" |
| 309 | text t_o_wp50 "wall_per_dependent_p50" |
| 310 | text t_o_cp50 "cpu_per_dependent_p50" |
| 311 | text t_o_ffan "failed_fanouts" |
| 312 | text t_o_m4 "m4_scheduler_ns" |
| 313 | text t_o_m5 "m5_aegis_fast_path_ns" |
| 314 | text t_o_vchk "validate_per_check_RES-1" |
| 315 | text t_o_awgr "activation_with_grant_RES-1" |
| 316 | text t_o_awgs "activation_with_grant_SEQ" |
| 317 | text t_o_m6 "m6_generation_barrier" |
| 318 | text t_o_latns "latency_ns" |
| 319 | text t_o_bars "barriers" |
| 320 | text t_o_barf "barriers_failed" |
| 321 | text t_o_fpc "fraction_with_production_commits" |
| 322 | text t_o_bycfg "by_configuration" |
| 323 | text t_o_wpc "with_production_commits" |
| 324 | text t_o_frac "fraction" |
| 325 | text t_o_m7 "m7_copied_bytes_per_op_after" |
| 326 | text t_o_ctb "chip_transferred_bytes" |
| 327 | text t_o_ctb_v "derived: claims x 128 B descriptor read + results x 128 B written + per-claim window/heartbeat bytes (see receipt)" |
| 328 | text t_o_m8 "m8_cpu_gpu" |
| 329 | text t_o_runs "runs" |
| 330 | text t_o_runsf "runs_failed" |
| 331 | text t_o_smed "syncs_per_gpu_result_median" |
| 332 | text t_o_sdef "sync_definition" |
| 333 | text t_o_sdef_v "synchronization events per result (spec amendment A1): claim notices + completion notices taken + seat fences (1 per result) + host blocking waits; empty completion polls excluded" |
| 334 | text t_o_hspin "host_spin_empty_polls_per_gpu_result_median" |
| 335 | text t_o_hsdef "host_spin_definition" |
| 336 | text t_o_hsdef_v "reported, not gated (amendment A1): host completion polls that found nothing, per GPU result" |
| 337 | text t_o_enq "enqueue_ns" |
| 338 | text t_o_gexec "gpu_exec_ns_chip_clock" |
| 339 | text t_o_cpub "completion_publication_ns" |
| 340 | text t_o_dwake "dependent_wake_ns" |
| 341 | text t_o_e2e "end_to_end_ns" |
| 342 | text t_o_m9 "m9_memory_traffic_per_op_after" |
| 343 | text t_o_wused "windows_used" |
| 344 | text t_o_wmux "windows_multiplexed_excluded" |
| 345 | text t_o_deriv "derivation" |
| 346 | text t_o_deriv_v "DRAM read bytes = ll_cache_miss_rd x 64 B; bus bytes = bus_access x 64 B; raw sum over both CPU PMUs, never scaled" |
| 347 | text t_o_m10 "m10_gpu_residency" |
| 348 | text t_o_mfl "min_fraction_live" |
| 349 | text t_o_sproc "silicon_processes" |
| 350 | text t_o_wpd "worst_process_diagnostic" |
| 351 | text t_o_proc "process" |
| 352 | text t_o_lsamp "lost_samples" |
| 353 | text t_o_class "class" |
| 354 | text t_o_noloss "no_loss" |
| 355 | text t_o_unmeas "UNMEASURED" |
| 356 | text t_o_unmeas_w "raw evidence has no sampler diag fields; starvation, residency loss and stale reads are not distinguishable" |
| 357 | text t_o_stop "seat_stopped_long_run" |
| 358 | text t_o_scat "scattered_not_live" |
| 359 | text t_o_slobs "sampler_late_observed" |
| 360 | text t_o_fdead_a "first_dead_after_ns" |
| 361 | text t_o_m11 "m11_resources_after" |
| 362 | text t_o_pcbm "process_cpus_busy_median" |
| 363 | text t_o_r5mm "r5_slots_mean_median" |
| 364 | text t_o_pthr "per_thread" |
| 365 | text t_o_pthr_v "per-thread CPU ticks are in each window's threads0/threads1 in the raw records" |
| 366 | text t_o_m1215 "m12_13_14_15_reactions" |
| 367 | text t_o_wpsm "wasted_per_stimulus_median" |
| 368 | text t_o_iram "invalidation_rate_adapt_median" |
| 369 | text t_o_cram "conflict_rate_adapt_median" |
| 370 | text t_o_wampm "wake_amplification_median" |
| 371 | text t_o_m16 "m16_causal_trace_overhead" |
| 372 | text t_o_cprm "cycles_per_op_ratio_median" |
| 373 | text t_o_m17 "m17_energy" |
| 374 | text t_o_pnet "pkg_uj_per_op_after_net_median" |
| 375 | text t_o_pgrs "pkg_uj_per_op_after_gross_median" |
| 376 | text t_o_pepi "pkg_uj_per_episode_median" |
| 377 | text t_o_nvmed "gpu_domain_nvml_mj_per_op_after_median" |
| 378 | text t_o_wins "windows" |
| 379 | text t_o_unc "uncertainty" |
| 380 | text t_o_unc_v "1 mJ resolution; +-1 sample period (100 ms) of power at each window edge; accumulator vs power discrepancy up to 0.5 W; no external meter calibration (spec ยง17)" |
| 381 | text t_o_instov "instrumentation_overhead" |
| 382 | |
| 383 | text t_o_n "n" |
| 384 | text t_o_p50 "p50" |
| 385 | text t_o_p90 "p90" |
| 386 | text t_o_p95 "p95" |
| 387 | text t_o_p99 "p99" |
| 388 | text t_o_p999 "p99_9" |
| 389 | text t_o_max "max" |
| 390 | |
| 391 | text t_o_gates "gates" |
| 392 | text t_o_id "id" |
| 393 | text t_o_crit "criterion" |
| 394 | text t_o_thr "threshold" |
| 395 | text t_o_val "value" |
| 396 | text t_o_outc "outcome" |
| 397 | text t_o_note "note" |
| 398 | text t_o_inps "inputs_seen" |
| 399 | text t_o_l1p "l1_processes" |
| 400 | text t_o_l1pf "l1_processes_failed" |
| 401 | text t_o_l1tb "l1_timing_buffers_truncated" |
| 402 | text t_o_l2p "l2_processes" |
| 403 | text t_o_agp "all_gates_pass" |
| 404 | |
| 405 | note ---- L1 measure & field names ---- |
| 406 | text t_l1m_A "A" |
| 407 | text t_l1m_B "B" |
| 408 | text t_l1m_E "E" |
| 409 | text t_l1m_Ea "E_activation" |
| 410 | text t_l1m_Cu "C_uncontended" |
| 411 | text t_l1m_Cb "C_blocked" |
| 412 | text t_l1m_Cp "C_priority" |
| 413 | text t_l1f_lat "latency_ns" |
| 414 | text t_l1f_ww "wave_wall_ns" |
| 415 | text t_l1f_wc "wave_cpu_ns" |
| 416 | text t_l1f_sc "sched_cpu_ns" |
| 417 | text t_l1f_sw "sched_wall_ns" |
| 418 | text t_l1f_rr "ready_to_run_ns" |
| 419 | text t_l1f_dr "demand_to_ready_ns" |
| 420 | text t_l1f_b100 "batch100_ns" |
| 421 | text t_l1f_rtv "run_to_visible_ns" |
| 422 | |
| 423 | note ---- Trial failure reasons ---- |
| 424 | text t_w_nocomp "trial did not complete (exit " |
| 425 | text t_w_noep "no episode record" |
| 426 | text t_w_wrong "wrong results " |
| 427 | text t_w_illeg "illegal transitions" |
| 428 | text t_w_crumbs "crumbs do not verify" |
| 429 | text t_w_covf "crumb log overflowed" |
| 430 | text t_w_goal "goal not MET (status " |
| 431 | text t_w_gen "generation did not advance exactly once" |
| 432 | text t_w_unp "a realization not in force was used" |
| 433 | text t_w_woken "AEGIS/root woken during the episode" |
| 434 | text t_w_lost "lost triggers" |
| 435 | |
| 436 | note ---- Gate strings ---- |
| 437 | text t_gid_0 "G1" |
| 438 | text t_gid_1 "G2" |
| 439 | text t_gid_2 "G3" |
| 440 | text t_gid_3 "G4" |
| 441 | text t_gid_4 "G5" |
| 442 | text t_gid_5 "G6" |
| 443 | text t_gid_6 "G7" |
| 444 | text t_gid_7 "G8" |
| 445 | text t_gid_8 "G9" |
| 446 | text t_gid_9 "G10" |
| 447 | text t_gid_10 "G11" |
| 448 | text t_gid_11 "G12" |
| 449 | text t_gid_12 "G13" |
| 450 | text t_gid_13 "G14" |
| 451 | text t_gid_14 "G15" |
| 452 | text t_gid_15 "G16" |
| 453 | |
| 454 | text t_gw_0 "correctness in every trial" |
| 455 | text t_gw_1 "AFTER throughput RES-1/SEQ" |
| 456 | text t_gw_2 "ADAPT rate RES-4/SEQ" |
| 457 | text t_gw_3 "RES-4 ADAPT rate / BEFORE rate" |
| 458 | text t_gw_4 "L1-A activation latency RES-1" |
| 459 | text t_gw_5 "L1-E AEGIS fast path" |
| 460 | text t_gw_6 "generation barrier" |
| 461 | text t_gw_7 "AFTER throughput RES-1/NODIGEST" |
| 462 | text t_gw_8 "energy per op AFTER RES-1/SEQ (package, net)" |
| 463 | text t_gw_9 "CPU-GPU synchronization events per GPU result (amendment A1)" |
| 464 | text t_gw_10 "adaptation crossover RES-4" |
| 465 | text t_gw_11 "wake amplification RES-4 vs SEQ" |
| 466 | text t_gw_12 "wasted reactions RES-1/SEQ" |
| 467 | text t_gw_13 "conflict rate RES-4 ADAPT" |
| 468 | text t_gw_14 "GPU residency" |
| 469 | text t_gw_15 "metrics 1-17 present, reduced from raw" |
| 470 | |
| 471 | text t_gt_0 "all correct" |
| 472 | text t_gt_1 "median >= 0.90 and CI lo >= 0.85" |
| 473 | text t_gt_2 "CI lo > 1.0" |
| 474 | text t_gt_3 "median >= 0.50" |
| 475 | text t_gt_4 "p50 <= 50 us and p99 <= 221 us" |
| 476 | text t_gt_5 "p50 <= 1 us and p99 <= 5 us" |
| 477 | text t_gt_6 "commits during >= 90% of barriers; p99 <= 500 ms" |
| 478 | text t_gt_7 "median >= 0.50" |
| 479 | text t_gt_8 "median <= 1.15 and CI hi <= 1.25" |
| 480 | text t_gt_9 "RES-1 <= SEQ" |
| 481 | text t_gt_10 "median <= 10,000,000 ops" |
| 482 | text t_gt_11 "RES-4 <= SEQ" |
| 483 | text t_gt_12 "median ratio <= 1.10" |
| 484 | text t_gt_13 "median <= 25%" |
| 485 | text t_gt_14 ">= 99% of samples live" |
| 486 | text t_gt_15 "all present" |
| 487 | |
| 488 | text t_gn_rnd " round " |
| 489 | text t_gn_f12 "fewer than 12 trials of a configuration" |
| 490 | text t_gn_semi "; " |
| 491 | text t_gn_vp10 " valid pairs (need >= 10)" |
| 492 | text t_gn_vp " valid pairs" |
| 493 | text t_gn_p50 "p50 " |
| 494 | text t_gn_p99 " ns, p99 " |
| 495 | text t_gn_nsn " ns, n " |
| 496 | text t_gn_pchk " ns per check (batch mean)" |
| 497 | text t_gn_bars " barriers, " |
| 498 | text t_gn_bfail " failed, p99 " |
| 499 | text t_gn_ns " ns" |
| 500 | text t_gn_g10a "RES-1 " |
| 501 | text t_gn_g10b ", SEQ " |
| 502 | text t_gn_g10c " sync events per result (host spin, not gated: RES-1 " |
| 503 | text t_gn_g10d " empty polls per result)" |
| 504 | text t_gn_g12a "RES-4 " |
| 505 | text t_gn_g12b " per consequential stimulus" |
| 506 | text t_gn_g15a " silicon processes (trials + L2); " |
| 507 | text t_gn_g15b " silicon trials" |
| 508 | text t_gn_miss "missing " |
| 509 | text t_l2_pref "l2-" |
| 510 | |
| 511 | note ---- Globals: CLI, I/O, String Builder, SHA-256 ---- |
| 512 | global g_dir uchar 1024 |
| 513 | global g_dirlen ulong 1 |
| 514 | global g_outpath uchar 1024 |
| 515 | global g_outlen ulong 1 |
| 516 | global g_path uchar 2048 |
| 517 | global g_dent uchar 16384 |
| 518 | global g_iobuf uchar 65536 |
| 519 | global g_rbuf uchar 65536 |
| 520 | global g_rpos ulong 1 |
| 521 | global g_rlen ulong 1 |
| 522 | global g_reof ulong 1 |
| 523 | |
| 524 | global g_obuf uchar 16384 |
| 525 | global g_olen ulong 1 |
| 526 | global g_ofd long 1 |
| 527 | global g_ebuf uchar 4096 |
| 528 | global g_elen ulong 1 |
| 529 | global g_fstack ulong 32 |
| 530 | global g_fdepth ulong 1 |
| 531 | global g_numbuf uchar 128 |
| 532 | |
| 533 | global g_sbuf uchar 512 |
| 534 | global g_slen ulong 1 |
| 535 | global g_kbuf uchar 128 |
| 536 | global g_klen ulong 1 |
| 537 | |
| 538 | global g_shk uint 72 |
| 539 | global g_shh uint 8 |
| 540 | global g_shw uint 64 |
| 541 | global g_shv uint 8 |
| 542 | global g_shb uchar 64 |
| 543 | global g_shm ulong 2 |
| 544 | global g_hextmp uchar 64 |
| 545 | global g_sums_hex uchar 64 |
| 546 | |
| 547 | note ---- Globals: Files from SHA256SUMS ---- |
| 548 | global g_nfiles ulong 1 |
| 549 | global g_fname uchar 1048576 |
| 550 | global g_flen ulong 4096 |
| 551 | global g_fhash uchar 262144 |
| 552 | global g_ford ulong 4096 |
| 553 | |
| 554 | note ---- Globals: Per-line JSON DOM pool ---- |
| 555 | global g_jbuf uchar 524288 |
| 556 | global g_jlen ulong 1 |
| 557 | global g_jpos ulong 1 |
| 558 | global g_jn_n ulong 1 |
| 559 | global g_jn_t ulong 32768 |
| 560 | global g_jn_d f64 32768 |
| 561 | global g_jn_u ulong 32768 |
| 562 | global g_jn_iu ulong 32768 |
| 563 | global g_jn_so ulong 32768 |
| 564 | global g_jn_sl ulong 32768 |
| 565 | global g_jn_ko ulong 32768 |
| 566 | global g_jn_kl ulong 32768 |
| 567 | global g_jn_fc ulong 32768 |
| 568 | global g_jn_lc ulong 32768 |
| 569 | global g_jn_nx ulong 32768 |
| 570 | global g_jn_cnt ulong 32768 |
| 571 | global g_jstr uchar 131072 |
| 572 | global g_jslen ulong 1 |
| 573 | global g_tmpu ulong 8 |
| 574 | |
| 575 | note ---- Globals: Trials (up to 512) ---- |
| 576 | global g_nt ulong 1 |
| 577 | global g_t_file uchar 131072 |
| 578 | global g_t_cfg uchar 12288 |
| 579 | global g_t_rnd long 512 |
| 580 | global g_t_sil ulong 512 |
| 581 | global g_t_exit long 512 |
| 582 | global g_t_comp ulong 512 |
| 583 | global g_t_has_ep ulong 512 |
| 584 | global g_t_ep_u ulong 5632 |
| 585 | global g_t_ep_cv long 512 |
| 586 | global g_t_ep_inf ulong 2048 |
| 587 | global g_t_ad_u ulong 1536 |
| 588 | global g_t_ad_d f64 4096 |
| 589 | |
| 590 | note Residency totals: 0..511 = trials, 512..575 = L2 runs |
| 591 | global g_res_has ulong 576 |
| 592 | global g_res_hdg ulong 576 |
| 593 | global g_res_d f64 1152 |
| 594 | global g_res_u ulong 6912 |
| 595 | |
| 596 | note Windows: 512 * 4 = 2048 slots |
| 597 | global g_w_has ulong 2048 |
| 598 | global g_w_d f64 59392 |
| 599 | global g_w_pmu ulong 4096 |
| 600 | |
| 601 | note CWindows: 512 * 5 = 2560 slots |
| 602 | global g_cw_has ulong 2560 |
| 603 | global g_cw_hk ulong 2560 |
| 604 | global g_cw_d f64 35840 |
| 605 | |
| 606 | note C_SPAN histogram buckets pool |
| 607 | global g_t_hboff ulong 512 |
| 608 | global g_t_hbcnt ulong 512 |
| 609 | global g_hb_n ulong 1 |
| 610 | global g_hb_lo ulong 65536 |
| 611 | global g_hb_cnt ulong 65536 |
| 612 | |
| 613 | note Telemetry pool |
| 614 | global g_t_toff ulong 512 |
| 615 | global g_t_tcnt ulong 512 |
| 616 | global g_tel_n ulong 1 |
| 617 | global g_tel_t ulong 65536 |
| 618 | global g_tel_pkg ulong 65536 |
| 619 | global g_tel_ok ulong 65536 |
| 620 | |
| 621 | note ---- Globals: L1 sets ---- |
| 622 | global g_nl1 ulong 1 |
| 623 | global g_l1_key uchar 24576 |
| 624 | global g_l1_hd ulong 256 |
| 625 | global g_l1_tl ulong 256 |
| 626 | global g_l1_cnt ulong 256 |
| 627 | global g_l1_nb ulong 1 |
| 628 | global g_l1_bnx ulong 8192 |
| 629 | global g_l1_bln ulong 8192 |
| 630 | global g_l1_val ulong 8388608 |
| 631 | global g_l1_st ulong 4 |
| 632 | |
| 633 | note ---- Globals: Barriers ---- |
| 634 | global g_nbar ulong 1 |
| 635 | global g_bar_cfg uchar 98304 |
| 636 | global g_bar_u ulong 20480 |
| 637 | global g_bar_rc long 4096 |
| 638 | global g_bar_tr ulong 4096 |
| 639 | |
| 640 | note ---- Globals: L2 runs ---- |
| 641 | global g_nl2 ulong 1 |
| 642 | global g_l2_cfg uchar 1536 |
| 643 | global g_l2_exit long 64 |
| 644 | global g_l2_sil ulong 64 |
| 645 | global g_l2_wd f64 256 |
| 646 | global g_l2_off ulong 320 |
| 647 | global g_l2_cnt ulong 320 |
| 648 | global g_l2_tot ulong 5 |
| 649 | global g_l2_e2e ulong 65536 |
| 650 | global g_l2_gpu ulong 65536 |
| 651 | global g_l2_enq ulong 65536 |
| 652 | global g_l2_pub ulong 65536 |
| 653 | global g_l2_dep ulong 65536 |
| 654 | |
| 655 | note ---- Globals: W_TIMING runs ---- |
| 656 | global g_nw ulong 1 |
| 657 | global g_wr_cfg uchar 1536 |
| 658 | global g_wr_tim ulong 64 |
| 659 | global g_wr_thr f64 64 |
| 660 | |
| 661 | note ---- Globals: Scratch for sorting, stats, bootstrap, gates ---- |
| 662 | global g_sort_u ulong 262144 |
| 663 | global g_hs_lo ulong 65536 |
| 664 | global g_hs_cnt ulong 65536 |
| 665 | global g_vd f64 512 |
| 666 | global g_vd2 f64 512 |
| 667 | global g_boot f64 10000 |
| 668 | global g_bsamp f64 512 |
| 669 | global g_rng ulong 1 |
| 670 | global g_pct ulong 7 |
| 671 | global g_cmp_d f64 27 |
| 672 | global g_cmp_u ulong 18 |
| 673 | global g_have ulong 18 |
| 674 | global g_gt_val f64 16 |
| 675 | global g_gt_pass ulong 16 |
| 676 | global g_gt_note uchar 3200 |
| 677 | global g_gt_nlen ulong 16 |
| 678 | global g_g1_why uchar 256 |
| 679 | global g_g1_wlen ulong 1 |
| 680 | global g_wname uchar 300 |
| 681 | global g_wnlen ulong 1 |
| 682 | global g_sync_m f64 2 |
| 683 | global g_spin_m f64 2 |
| 684 | global g_a_res ulong 7 |
| 685 | global g_e_res ulong 7 |
| 686 | global g_bp ulong 7 |
| 687 | global g_bar_st ulong 3 |
| 688 | global g_res_st ulong 3 |
| 689 | global g_res_min f64 1 |
| 690 | global g_tr_st ulong 3 |
| 691 | |
| 692 | note ---- Low-level I/O: ch 0=file(g_ofd), 1=stderr(2), 2=g_sbuf ---- |
| 693 | fn io_flush ch ulong to void |
| 694 | if eq ch 0 |
| 695 | n = get g_olen 0 |
| 696 | fd = get g_ofd 0 |
| 697 | if gt n 0 |
| 698 | if ge fd 0 |
| 699 | _w = write int fd g_obuf 0 n |
| 700 | put g_olen 0 0 |
| 701 | end |
| 702 | end |
| 703 | ret |
| 704 | end |
| 705 | if eq ch 1 |
| 706 | n = get g_elen 0 |
| 707 | if gt n 0 |
| 708 | _w = write 2 g_ebuf 0 n |
| 709 | put g_elen 0 0 |
| 710 | end |
| 711 | end |
| 712 | end |
| 713 | |
| 714 | fn io_putc ch ulong b uchar to void |
| 715 | if eq ch 0 |
| 716 | n = get g_olen 0 |
| 717 | if ge n 16384 |
| 718 | io_flush 0 |
| 719 | n = 0 |
| 720 | end |
| 721 | put g_obuf n b |
| 722 | put g_olen 0 add n 1 |
| 723 | ret |
| 724 | end |
| 725 | if eq ch 1 |
| 726 | n = get g_elen 0 |
| 727 | if ge n 4096 |
| 728 | io_flush 1 |
| 729 | n = 0 |
| 730 | end |
| 731 | put g_ebuf n b |
| 732 | put g_elen 0 add n 1 |
| 733 | ret |
| 734 | end |
| 735 | n = get g_slen 0 |
| 736 | if lt n 511 |
| 737 | put g_sbuf n b |
| 738 | put g_slen 0 add n 1 |
| 739 | end |
| 740 | end |
| 741 | |
| 742 | fn io_puts ch ulong s view uchar * to void |
| 743 | n = len s |
| 744 | for i ulong n |
| 745 | io_putc ch get s i |
| 746 | end |
| 747 | end |
| 748 | |
| 749 | fn io_put_u64 ch ulong v ulong to void |
| 750 | if eq v 0 |
| 751 | io_putc ch uchar 48 |
| 752 | ret |
| 753 | end |
| 754 | n = ulong 0 |
| 755 | x = v |
| 756 | while gt x 0 |
| 757 | put g_numbuf n uchar add 48 rem x 10 |
| 758 | x = div x 10 |
| 759 | n = add n 1 |
| 760 | end |
| 761 | i = n |
| 762 | while gt i 0 |
| 763 | i = sub i 1 |
| 764 | io_putc ch get g_numbuf i |
| 765 | end |
| 766 | end |
| 767 | |
| 768 | fn io_put_i64 ch ulong v long to void |
| 769 | if lt v 0 |
| 770 | io_putc ch uchar 45 |
| 771 | uv = sub ulong 0 bitcast ulong v |
| 772 | io_put_u64 ch uv |
| 773 | ret |
| 774 | end |
| 775 | io_put_u64 ch ulong v |
| 776 | end |
| 777 | |
| 778 | fn is_nan x f64 to bool |
| 779 | ret ne x x |
| 780 | end |
| 781 | |
| 782 | fn is_inf x f64 to bool |
| 783 | if ne x x |
| 784 | ret false |
| 785 | end |
| 786 | ret ne sub x x f64 0.0 |
| 787 | end |
| 788 | |
| 789 | fn r15_fabs x f64 to f64 |
| 790 | if lt x f64 0.0 |
| 791 | ret sub f64 0.0 x |
| 792 | end |
| 793 | ret x |
| 794 | end |
| 795 | |
| 796 | fn r15_nan to f64 |
| 797 | ret div f64 0.0 f64 0.0 |
| 798 | end |
| 799 | |
| 800 | fn b2u b bool to ulong |
| 801 | if b |
| 802 | ret 1 |
| 803 | end |
| 804 | ret 0 |
| 805 | end |
| 806 | |
| 807 | fn ceil_u p f64 n ulong to ulong |
| 808 | x = mul p f64 n |
| 809 | if le x f64 0.0 |
| 810 | ret 0 |
| 811 | end |
| 812 | i = ulong x |
| 813 | if lt f64 i x |
| 814 | i = add i 1 |
| 815 | end |
| 816 | ret i |
| 817 | end |
| 818 | |
| 819 | fn io_put_fix_frac ch ulong fr ulong sc ulong to void |
| 820 | io_putc ch uchar 46 |
| 821 | d = div sc 10 |
| 822 | while gt d 0 |
| 823 | dig = rem div fr d 10 |
| 824 | io_putc ch uchar add 48 dig |
| 825 | d = div d 10 |
| 826 | end |
| 827 | end |
| 828 | |
| 829 | fn io_put_fix ch ulong x f64 dp ulong to void |
| 830 | if is_nan x |
| 831 | io_puts ch t_nan |
| 832 | ret |
| 833 | end |
| 834 | if is_inf x |
| 835 | if lt x f64 0.0 |
| 836 | io_puts ch t_ninf |
| 837 | else |
| 838 | io_puts ch t_inf |
| 839 | end |
| 840 | ret |
| 841 | end |
| 842 | ax = x |
| 843 | if lt ax f64 0.0 |
| 844 | io_putc ch uchar 45 |
| 845 | ax = sub f64 0.0 ax |
| 846 | end |
| 847 | sc = ulong 1 |
| 848 | for i ulong dp |
| 849 | sc = mul sc 10 |
| 850 | end |
| 851 | scaled = ulong add mul ax f64 sc f64 0.5 |
| 852 | io_put_u64 ch div scaled sc |
| 853 | if gt dp 0 |
| 854 | io_put_fix_frac ch rem scaled sc sc |
| 855 | end |
| 856 | end |
| 857 | |
| 858 | fn io_put_g9_emit ch ulong exp long last ulong to void |
| 859 | if and ge exp -4 lt exp 9 |
| 860 | if lt exp 0 |
| 861 | io_putc ch uchar 48 |
| 862 | io_putc ch uchar 46 |
| 863 | zs = ulong sub -1 exp |
| 864 | for i ulong zs |
| 865 | io_putc ch uchar 48 |
| 866 | end |
| 867 | for i ulong last |
| 868 | io_putc ch get g_numbuf i |
| 869 | end |
| 870 | else |
| 871 | ip = add ulong exp 1 |
| 872 | for i ulong ip |
| 873 | if lt i last |
| 874 | io_putc ch get g_numbuf i |
| 875 | else |
| 876 | io_putc ch uchar 48 |
| 877 | end |
| 878 | end |
| 879 | if gt last ip |
| 880 | io_putc ch uchar 46 |
| 881 | i = ip |
| 882 | while lt i last |
| 883 | io_putc ch get g_numbuf i |
| 884 | i = add i 1 |
| 885 | end |
| 886 | end |
| 887 | end |
| 888 | else |
| 889 | io_putc ch get g_numbuf 0 |
| 890 | if gt last 1 |
| 891 | io_putc ch uchar 46 |
| 892 | i = ulong 1 |
| 893 | while lt i last |
| 894 | io_putc ch get g_numbuf i |
| 895 | i = add i 1 |
| 896 | end |
| 897 | end |
| 898 | io_putc ch uchar 101 |
| 899 | if lt exp 0 |
| 900 | io_putc ch uchar 45 |
| 901 | ae = ulong sub 0 exp |
| 902 | if lt ae 10 |
| 903 | io_putc ch uchar 48 |
| 904 | end |
| 905 | io_put_u64 ch ae |
| 906 | else |
| 907 | io_putc ch uchar 43 |
| 908 | ae = ulong exp |
| 909 | if lt ae 10 |
| 910 | io_putc ch uchar 48 |
| 911 | end |
| 912 | io_put_u64 ch ae |
| 913 | end |
| 914 | end |
| 915 | end |
| 916 | |
| 917 | fn round_even x f64 to ulong |
| 918 | d = ulong x |
| 919 | fr = sub x f64 d |
| 920 | if gt fr f64 0.5 |
| 921 | ret add d 1 |
| 922 | end |
| 923 | if eq fr f64 0.5 |
| 924 | if eq rem d 2 1 |
| 925 | ret add d 1 |
| 926 | end |
| 927 | end |
| 928 | ret d |
| 929 | end |
| 930 | |
| 931 | fn io_put_g9 ch ulong x f64 to void |
| 932 | if or is_nan x is_inf x |
| 933 | io_puts ch t_null |
| 934 | ret |
| 935 | end |
| 936 | ax = r15_fabs x |
| 937 | if lt ax f64 9000000000000000.0 |
| 938 | if eq f64 long x x |
| 939 | io_put_i64 ch long x |
| 940 | ret |
| 941 | end |
| 942 | end |
| 943 | if lt x f64 0.0 |
| 944 | io_putc ch uchar 45 |
| 945 | end |
| 946 | if eq ax f64 0.0 |
| 947 | io_putc ch uchar 48 |
| 948 | ret |
| 949 | end |
| 950 | exp = long 0 |
| 951 | m = ax |
| 952 | while ge m f64 10.0 |
| 953 | m = div m f64 10.0 |
| 954 | exp = add exp 1 |
| 955 | end |
| 956 | while lt m f64 1.0 |
| 957 | m = mul m f64 10.0 |
| 958 | exp = sub exp 1 |
| 959 | end |
| 960 | digs = round_even mul m f64 100000000.0 |
| 961 | if ge digs 1000000000 |
| 962 | digs = div digs 10 |
| 963 | exp = add exp 1 |
| 964 | end |
| 965 | for i ulong 9 |
| 966 | put g_numbuf sub 8 i uchar add 48 rem digs 10 |
| 967 | digs = div digs 10 |
| 968 | end |
| 969 | last = ulong 9 |
| 970 | while gt last 1 |
| 971 | if ne get g_numbuf sub last 1 uchar 48 |
| 972 | break |
| 973 | end |
| 974 | last = sub last 1 |
| 975 | end |
| 976 | io_put_g9_emit ch exp last |
| 977 | end |
| 978 | |
| 979 | note ---- Table byte reader: 0=g_t_file, 1=g_t_cfg, 2=g_fname, 3=g_fhash, 4=g_sbuf, 5=g_g1_why, 6=g_wname, 7=g_gt_note, 8=g_bar_cfg, 9=g_l2_cfg, 10=g_wr_cfg, 11=g_sums_hex, 12=g_kbuf ---- |
| 980 | fn tb_get tbl ulong idx ulong to uchar |
| 981 | if eq tbl 0 |
| 982 | ret get g_t_file idx |
| 983 | end |
| 984 | if eq tbl 1 |
| 985 | ret get g_t_cfg idx |
| 986 | end |
| 987 | if eq tbl 2 |
| 988 | ret get g_fname idx |
| 989 | end |
| 990 | if eq tbl 3 |
| 991 | ret get g_fhash idx |
| 992 | end |
| 993 | if eq tbl 4 |
| 994 | ret get g_sbuf idx |
| 995 | end |
| 996 | if eq tbl 5 |
| 997 | ret get g_g1_why idx |
| 998 | end |
| 999 | if eq tbl 6 |
| 1000 | ret get g_wname idx |
| 1001 | end |
| 1002 | if eq tbl 7 |
| 1003 | ret get g_gt_note idx |
| 1004 | end |
| 1005 | if eq tbl 8 |
| 1006 | ret get g_bar_cfg idx |
| 1007 | end |
| 1008 | if eq tbl 9 |
| 1009 | ret get g_l2_cfg idx |
| 1010 | end |
| 1011 | if eq tbl 10 |
| 1012 | ret get g_wr_cfg idx |
| 1013 | end |
| 1014 | if eq tbl 11 |
| 1015 | ret get g_sums_hex idx |
| 1016 | end |
| 1017 | ret get g_kbuf idx |
| 1018 | end |
| 1019 | |
| 1020 | fn io_put_cs ch ulong tbl ulong off ulong cap ulong to void |
| 1021 | for i ulong cap |
| 1022 | c = tb_get tbl add off i |
| 1023 | if eq c 0 |
| 1024 | ret |
| 1025 | end |
| 1026 | io_putc ch c |
| 1027 | end |
| 1028 | end |
| 1029 | |
| 1030 | fn io_put_mem ch ulong tbl ulong off ulong n ulong to void |
| 1031 | for i ulong n |
| 1032 | io_putc ch tb_get tbl add off i |
| 1033 | end |
| 1034 | end |
| 1035 | |
| 1036 | fn cs_eq_t tbl ulong off ulong cap ulong s view uchar * to bool |
| 1037 | n = len s |
| 1038 | for i ulong cap |
| 1039 | c = tb_get tbl add off i |
| 1040 | if eq c 0 |
| 1041 | ret eq i n |
| 1042 | end |
| 1043 | if ge i n |
| 1044 | ret false |
| 1045 | end |
| 1046 | if ne c get s i |
| 1047 | ret false |
| 1048 | end |
| 1049 | end |
| 1050 | ret eq cap n |
| 1051 | end |
| 1052 | |
| 1053 | fn cs_has_sub tbl ulong off ulong cap ulong s view uchar * to bool |
| 1054 | m = len s |
| 1055 | if eq m 0 |
| 1056 | ret true |
| 1057 | end |
| 1058 | n = ulong 0 |
| 1059 | while lt n cap |
| 1060 | if eq tb_get tbl add off n 0 |
| 1061 | break |
| 1062 | end |
| 1063 | n = add n 1 |
| 1064 | end |
| 1065 | if lt n m |
| 1066 | ret false |
| 1067 | end |
| 1068 | lim = add sub n m 1 |
| 1069 | for i ulong lim |
| 1070 | ok = true |
| 1071 | for j ulong m |
| 1072 | if ne tb_get tbl add off add i j get s j |
| 1073 | ok = false |
| 1074 | end |
| 1075 | end |
| 1076 | if ok |
| 1077 | ret true |
| 1078 | end |
| 1079 | end |
| 1080 | ret false |
| 1081 | end |
| 1082 | |
| 1083 | fn cs_starts tbl ulong off ulong cap ulong s view uchar * to bool |
| 1084 | m = len s |
| 1085 | if gt m cap |
| 1086 | ret false |
| 1087 | end |
| 1088 | for i ulong m |
| 1089 | c = tb_get tbl add off i |
| 1090 | if ne c get s i |
| 1091 | ret false |
| 1092 | end |
| 1093 | end |
| 1094 | ret true |
| 1095 | end |
| 1096 | |
| 1097 | note ---- JSON writer (channel 0) ---- |
| 1098 | fn o_sep to void |
| 1099 | d = get g_fdepth 0 |
| 1100 | if eq get g_fstack d 0 |
| 1101 | io_putc 0 uchar 44 |
| 1102 | end |
| 1103 | put g_fstack d 0 |
| 1104 | end |
| 1105 | |
| 1106 | fn o_key k view uchar * to void |
| 1107 | o_sep |
| 1108 | if gt len k 0 |
| 1109 | io_putc 0 uchar 34 |
| 1110 | io_puts 0 k |
| 1111 | io_putc 0 uchar 34 |
| 1112 | io_putc 0 uchar 58 |
| 1113 | end |
| 1114 | end |
| 1115 | |
| 1116 | fn o_key_kbuf to void |
| 1117 | o_sep |
| 1118 | io_putc 0 uchar 34 |
| 1119 | io_put_mem 0 12 0 get g_klen 0 |
| 1120 | io_putc 0 uchar 34 |
| 1121 | io_putc 0 uchar 58 |
| 1122 | end |
| 1123 | |
| 1124 | fn o_open k view uchar * c uchar to void |
| 1125 | o_key k |
| 1126 | io_putc 0 c |
| 1127 | d = add get g_fdepth 0 1 |
| 1128 | put g_fdepth 0 d |
| 1129 | put g_fstack d 1 |
| 1130 | end |
| 1131 | |
| 1132 | fn o_open_kbuf c uchar to void |
| 1133 | o_key_kbuf |
| 1134 | io_putc 0 c |
| 1135 | d = add get g_fdepth 0 1 |
| 1136 | put g_fdepth 0 d |
| 1137 | put g_fstack d 1 |
| 1138 | end |
| 1139 | |
| 1140 | fn o_open_anon c uchar to void |
| 1141 | o_sep |
| 1142 | io_putc 0 c |
| 1143 | d = add get g_fdepth 0 1 |
| 1144 | put g_fdepth 0 d |
| 1145 | put g_fstack d 1 |
| 1146 | end |
| 1147 | |
| 1148 | fn o_close c uchar to void |
| 1149 | io_putc 0 c |
| 1150 | put g_fdepth 0 sub get g_fdepth 0 1 |
| 1151 | end |
| 1152 | |
| 1153 | fn o_num k view uchar * x f64 to void |
| 1154 | o_key k |
| 1155 | io_put_g9 0 x |
| 1156 | end |
| 1157 | |
| 1158 | fn o_u k view uchar * x ulong to void |
| 1159 | o_key k |
| 1160 | io_put_u64 0 x |
| 1161 | end |
| 1162 | |
| 1163 | fn o_str k view uchar * s view uchar * to void |
| 1164 | o_key k |
| 1165 | io_putc 0 uchar 34 |
| 1166 | io_puts 0 s |
| 1167 | io_putc 0 uchar 34 |
| 1168 | end |
| 1169 | |
| 1170 | fn o_str_cs k view uchar * tbl ulong off ulong cap ulong to void |
| 1171 | o_key k |
| 1172 | io_putc 0 uchar 34 |
| 1173 | io_put_cs 0 tbl off cap |
| 1174 | io_putc 0 uchar 34 |
| 1175 | end |
| 1176 | |
| 1177 | fn o_str_mem k view uchar * tbl ulong off ulong n ulong to void |
| 1178 | o_key k |
| 1179 | io_putc 0 uchar 34 |
| 1180 | io_put_mem 0 tbl off n |
| 1181 | io_putc 0 uchar 34 |
| 1182 | end |
| 1183 | |
| 1184 | fn o_bool k view uchar * b bool to void |
| 1185 | o_key k |
| 1186 | if b |
| 1187 | io_puts 0 t_true |
| 1188 | else |
| 1189 | io_puts 0 t_false |
| 1190 | end |
| 1191 | end |
| 1192 | |
| 1193 | note ---- FIPS 180-4 SHA-256 ---- |
| 1194 | fn sh_init_tbl to void |
| 1195 | if ne get g_shk 0 0 |
| 1196 | ret |
| 1197 | end |
| 1198 | put g_shk 0 1116352408 |
| 1199 | put g_shk 1 1899447441 |
| 1200 | put g_shk 2 3049323471 |
| 1201 | put g_shk 3 3921009573 |
| 1202 | put g_shk 4 961987163 |
| 1203 | put g_shk 5 1508970993 |
| 1204 | put g_shk 6 2453635748 |
| 1205 | put g_shk 7 2870763221 |
| 1206 | put g_shk 8 3624381080 |
| 1207 | put g_shk 9 310598401 |
| 1208 | put g_shk 10 607225278 |
| 1209 | put g_shk 11 1426881987 |
| 1210 | put g_shk 12 1925078388 |
| 1211 | put g_shk 13 2162078206 |
| 1212 | put g_shk 14 2614888103 |
| 1213 | put g_shk 15 3248222580 |
| 1214 | put g_shk 16 3835390401 |
| 1215 | put g_shk 17 4022224774 |
| 1216 | put g_shk 18 264347078 |
| 1217 | put g_shk 19 604807628 |
| 1218 | put g_shk 20 770255983 |
| 1219 | put g_shk 21 1249150122 |
| 1220 | put g_shk 22 1555081692 |
| 1221 | put g_shk 23 1996064986 |
| 1222 | put g_shk 24 2554220882 |
| 1223 | put g_shk 25 2821834349 |
| 1224 | put g_shk 26 2952996808 |
| 1225 | put g_shk 27 3210313671 |
| 1226 | put g_shk 28 3336571891 |
| 1227 | put g_shk 29 3584528711 |
| 1228 | put g_shk 30 113926993 |
| 1229 | put g_shk 31 338241895 |
| 1230 | put g_shk 32 666307205 |
| 1231 | put g_shk 33 773529912 |
| 1232 | put g_shk 34 1294757372 |
| 1233 | put g_shk 35 1396182291 |
| 1234 | put g_shk 36 1695183700 |
| 1235 | put g_shk 37 1986661051 |
| 1236 | put g_shk 38 2177026350 |
| 1237 | put g_shk 39 2456956037 |
| 1238 | put g_shk 40 2730485921 |
| 1239 | put g_shk 41 2820302411 |
| 1240 | put g_shk 42 3259730800 |
| 1241 | put g_shk 43 3345764771 |
| 1242 | put g_shk 44 3516065817 |
| 1243 | put g_shk 45 3600352804 |
| 1244 | put g_shk 46 4094571909 |
| 1245 | put g_shk 47 275423344 |
| 1246 | put g_shk 48 430227734 |
| 1247 | put g_shk 49 506948616 |
| 1248 | put g_shk 50 659060556 |
| 1249 | put g_shk 51 883997877 |
| 1250 | put g_shk 52 958139571 |
| 1251 | put g_shk 53 1322822218 |
| 1252 | put g_shk 54 1537002063 |
| 1253 | put g_shk 55 1747873779 |
| 1254 | put g_shk 56 1955562222 |
| 1255 | put g_shk 57 2024104815 |
| 1256 | put g_shk 58 2227730452 |
| 1257 | put g_shk 59 2361852424 |
| 1258 | put g_shk 60 2428436474 |
| 1259 | put g_shk 61 2756734187 |
| 1260 | put g_shk 62 3204031479 |
| 1261 | put g_shk 63 3329325298 |
| 1262 | put g_shk 64 1779033703 |
| 1263 | put g_shk 65 3144134277 |
| 1264 | put g_shk 66 1013904242 |
| 1265 | put g_shk 67 2773480762 |
| 1266 | put g_shk 68 1359893119 |
| 1267 | put g_shk 69 2600822924 |
| 1268 | put g_shk 70 528734635 |
| 1269 | put g_shk 71 1541459225 |
| 1270 | end |
| 1271 | |
| 1272 | fn sh_load_w to void |
| 1273 | for i ulong 16 |
| 1274 | b0 = shl uint get g_shb mul i 4 uint 24 |
| 1275 | b1 = shl uint get g_shb add mul i 4 1 uint 16 |
| 1276 | b2 = shl uint get g_shb add mul i 4 2 uint 8 |
| 1277 | b3 = uint get g_shb add mul i 4 3 |
| 1278 | put g_shw i or or b0 b1 or b2 b3 |
| 1279 | end |
| 1280 | i = ulong 16 |
| 1281 | while lt i 64 |
| 1282 | x = get g_shw sub i 15 |
| 1283 | s0 = xor xor rotr x uint 7 rotr x uint 18 shr x uint 3 |
| 1284 | y = get g_shw sub i 2 |
| 1285 | s1 = xor xor rotr y uint 17 rotr y uint 19 shr y uint 10 |
| 1286 | put g_shw i add add get g_shw sub i 16 s0 add get g_shw sub i 7 s1 |
| 1287 | i = add i 1 |
| 1288 | end |
| 1289 | end |
| 1290 | |
| 1291 | fn sh_round j ulong to void |
| 1292 | e = get g_shv 4 |
| 1293 | t1 = xor xor rotr e uint 6 rotr e uint 11 rotr e uint 25 |
| 1294 | t1 = add t1 get g_shv 7 |
| 1295 | t1 = add t1 xor and e get g_shv 5 and not e get g_shv 6 |
| 1296 | t1 = add add t1 get g_shk j get g_shw j |
| 1297 | a = get g_shv 0 |
| 1298 | t2 = xor xor rotr a uint 2 rotr a uint 13 rotr a uint 22 |
| 1299 | b = get g_shv 1 |
| 1300 | c = get g_shv 2 |
| 1301 | t2 = add t2 xor xor and a b and a c and b c |
| 1302 | put g_shv 7 get g_shv 6 |
| 1303 | put g_shv 6 get g_shv 5 |
| 1304 | put g_shv 5 e |
| 1305 | put g_shv 4 add get g_shv 3 t1 |
| 1306 | put g_shv 3 c |
| 1307 | put g_shv 2 b |
| 1308 | put g_shv 1 a |
| 1309 | put g_shv 0 add t1 t2 |
| 1310 | end |
| 1311 | |
| 1312 | fn sh_block to void |
| 1313 | sh_load_w |
| 1314 | for j ulong 8 |
| 1315 | put g_shv j get g_shh j |
| 1316 | end |
| 1317 | for j ulong 64 |
| 1318 | sh_round j |
| 1319 | end |
| 1320 | for j ulong 8 |
| 1321 | put g_shh j add get g_shh j get g_shv j |
| 1322 | end |
| 1323 | end |
| 1324 | |
| 1325 | fn sh_init to void |
| 1326 | sh_init_tbl |
| 1327 | for i ulong 8 |
| 1328 | put g_shh i get g_shk add i 64 |
| 1329 | end |
| 1330 | put g_shm 0 0 |
| 1331 | put g_shm 1 0 |
| 1332 | end |
| 1333 | |
| 1334 | fn sh_byte b uchar to void |
| 1335 | bl = get g_shm 0 |
| 1336 | put g_shb bl b |
| 1337 | bl = add bl 1 |
| 1338 | put g_shm 1 add get g_shm 1 1 |
| 1339 | if eq bl 64 |
| 1340 | sh_block |
| 1341 | bl = 0 |
| 1342 | end |
| 1343 | put g_shm 0 bl |
| 1344 | end |
| 1345 | |
| 1346 | fn sh_final_hex to void |
| 1347 | tot = get g_shm 1 |
| 1348 | bits = mul tot 8 |
| 1349 | sh_byte uchar 128 |
| 1350 | while ne get g_shm 0 56 |
| 1351 | sh_byte uchar 0 |
| 1352 | end |
| 1353 | for i ulong 8 |
| 1354 | sh = mul sub 7 i 8 |
| 1355 | sh_byte uchar and shr bits sh 255 |
| 1356 | end |
| 1357 | for i ulong 8 |
| 1358 | w = get g_shh i |
| 1359 | for k ulong 8 |
| 1360 | sh = mul sub 7 k 4 |
| 1361 | d = ulong and shr w uint sh uint 15 |
| 1362 | c = add 48 d |
| 1363 | if ge d 10 |
| 1364 | c = add 87 d |
| 1365 | end |
| 1366 | put g_hextmp add mul i 8 k uchar c |
| 1367 | end |
| 1368 | end |
| 1369 | end |
| 1370 | |
| 1371 | fn hash_path plen ulong to long |
| 1372 | fd = fopen g_path 0 plen 0 0 |
| 1373 | if lt fd 0 |
| 1374 | ret -1 |
| 1375 | end |
| 1376 | sh_init |
| 1377 | while true bound 100000 |
| 1378 | rd = read int fd g_iobuf 0 65536 |
| 1379 | if lt rd 0 |
| 1380 | _fc = fclose int fd |
| 1381 | ret -1 |
| 1382 | end |
| 1383 | if eq rd 0 |
| 1384 | break |
| 1385 | end |
| 1386 | n = ulong rd |
| 1387 | for i ulong n |
| 1388 | sh_byte get g_iobuf i |
| 1389 | end |
| 1390 | end |
| 1391 | _fc = fclose int fd |
| 1392 | sh_final_hex |
| 1393 | ret 0 |
| 1394 | end |
| 1395 | |
| 1396 | note ---- Streaming line reader ---- |
| 1397 | fn rl_init to void |
| 1398 | put g_rpos 0 0 |
| 1399 | put g_rlen 0 0 |
| 1400 | put g_reof 0 0 |
| 1401 | end |
| 1402 | |
| 1403 | fn rl_next fd int to long |
| 1404 | n = ulong 0 |
| 1405 | while true bound 600000 |
| 1406 | p = get g_rpos 0 |
| 1407 | l = get g_rlen 0 |
| 1408 | if ge p l |
| 1409 | if ne get g_reof 0 0 |
| 1410 | break |
| 1411 | end |
| 1412 | rd = read fd g_rbuf 0 65536 |
| 1413 | if le rd 0 |
| 1414 | put g_reof 0 1 |
| 1415 | break |
| 1416 | end |
| 1417 | put g_rpos 0 0 |
| 1418 | put g_rlen 0 ulong rd |
| 1419 | p = 0 |
| 1420 | l = ulong rd |
| 1421 | end |
| 1422 | c = get g_rbuf p |
| 1423 | put g_rpos 0 add p 1 |
| 1424 | if eq c uchar 10 |
| 1425 | put g_jbuf n uchar 0 |
| 1426 | put g_jlen 0 n |
| 1427 | ret 1 |
| 1428 | end |
| 1429 | if lt n sub R15_LINE_CAP 1 |
| 1430 | put g_jbuf n c |
| 1431 | n = add n 1 |
| 1432 | end |
| 1433 | end |
| 1434 | if eq n 0 |
| 1435 | ret 0 |
| 1436 | end |
| 1437 | put g_jbuf n uchar 0 |
| 1438 | put g_jlen 0 n |
| 1439 | ret 1 |
| 1440 | end |
| 1441 | |
| 1442 | note ---- Per-line JSON parser ---- |
| 1443 | fn jp_ws to void |
| 1444 | n = get g_jlen 0 |
| 1445 | p = get g_jpos 0 |
| 1446 | while lt p n |
| 1447 | c = get g_jbuf p |
| 1448 | if or eq c 32 or eq c 9 or eq c 10 eq c 13 |
| 1449 | p = add p 1 |
| 1450 | else |
| 1451 | put g_jpos 0 p |
| 1452 | ret |
| 1453 | end |
| 1454 | end |
| 1455 | put g_jpos 0 p |
| 1456 | end |
| 1457 | |
| 1458 | fn jp_new t ulong to long |
| 1459 | idx = get g_jn_n 0 |
| 1460 | if ge idx R15_MAXJN |
| 1461 | ret -1 |
| 1462 | end |
| 1463 | put g_jn_n 0 add idx 1 |
| 1464 | put g_jn_t idx t |
| 1465 | put g_jn_d idx f64 0.0 |
| 1466 | put g_jn_u idx 0 |
| 1467 | put g_jn_iu idx 0 |
| 1468 | put g_jn_so idx 0 |
| 1469 | put g_jn_sl idx 0 |
| 1470 | put g_jn_ko idx 0 |
| 1471 | put g_jn_kl idx 0 |
| 1472 | put g_jn_fc idx 0 |
| 1473 | put g_jn_lc idx 0 |
| 1474 | put g_jn_nx idx 0 |
| 1475 | put g_jn_cnt idx 0 |
| 1476 | ret long idx |
| 1477 | end |
| 1478 | |
| 1479 | fn jp_str_raw to long |
| 1480 | n = get g_jlen 0 |
| 1481 | p = get g_jpos 0 |
| 1482 | if ge p n |
| 1483 | ret -1 |
| 1484 | end |
| 1485 | if ne get g_jbuf p uchar 34 |
| 1486 | ret -1 |
| 1487 | end |
| 1488 | p = add p 1 |
| 1489 | so = get g_jslen 0 |
| 1490 | sl = ulong 0 |
| 1491 | while lt p n |
| 1492 | c = get g_jbuf p |
| 1493 | if eq c uchar 34 |
| 1494 | put g_jpos 0 add p 1 |
| 1495 | put g_jslen 0 add so sl |
| 1496 | put g_tmpu 0 so |
| 1497 | put g_tmpu 1 sl |
| 1498 | ret 0 |
| 1499 | end |
| 1500 | p = add p 1 |
| 1501 | if eq c uchar 92 |
| 1502 | if lt p n |
| 1503 | c = get g_jbuf p |
| 1504 | p = add p 1 |
| 1505 | end |
| 1506 | end |
| 1507 | if lt add so sl R15_JSTR_CAP |
| 1508 | put g_jstr add so sl c |
| 1509 | sl = add sl 1 |
| 1510 | end |
| 1511 | end |
| 1512 | ret -1 |
| 1513 | end |
| 1514 | |
| 1515 | fn jp_match s view uchar * to bool |
| 1516 | n = get g_jlen 0 |
| 1517 | p = get g_jpos 0 |
| 1518 | m = len s |
| 1519 | if gt add p m n |
| 1520 | ret false |
| 1521 | end |
| 1522 | for i ulong m |
| 1523 | if ne get g_jbuf add p i get s i |
| 1524 | ret false |
| 1525 | end |
| 1526 | end |
| 1527 | put g_jpos 0 add p m |
| 1528 | ret true |
| 1529 | end |
| 1530 | |
| 1531 | fn jp_is_dig p ulong n ulong to bool |
| 1532 | if ge p n |
| 1533 | ret false |
| 1534 | end |
| 1535 | c = get g_jbuf p |
| 1536 | ret and ge c uchar 48 le c uchar 57 |
| 1537 | end |
| 1538 | |
| 1539 | fn jp_parse_exp fl f64 to f64 |
| 1540 | n = get g_jlen 0 |
| 1541 | p = get g_jpos 0 |
| 1542 | eneg = false |
| 1543 | if lt p n |
| 1544 | ec = get g_jbuf p |
| 1545 | if eq ec uchar 45 |
| 1546 | eneg = true |
| 1547 | p = add p 1 |
| 1548 | else |
| 1549 | if eq ec uchar 43 |
| 1550 | p = add p 1 |
| 1551 | end |
| 1552 | end |
| 1553 | end |
| 1554 | ev = ulong 0 |
| 1555 | while jp_is_dig p n |
| 1556 | ev = add mul ev 10 ulong sub get g_jbuf p uchar 48 |
| 1557 | p = add p 1 |
| 1558 | end |
| 1559 | put g_jpos 0 p |
| 1560 | res = fl |
| 1561 | for i ulong ev |
| 1562 | if eneg |
| 1563 | res = div res f64 10.0 |
| 1564 | else |
| 1565 | res = mul res f64 10.0 |
| 1566 | end |
| 1567 | end |
| 1568 | ret res |
| 1569 | end |
| 1570 | |
| 1571 | fn jp_parse_frac fl f64 to f64 |
| 1572 | n = get g_jlen 0 |
| 1573 | p = get g_jpos 0 |
| 1574 | sc = f64 0.1 |
| 1575 | res = fl |
| 1576 | while jp_is_dig p n |
| 1577 | d = ulong sub get g_jbuf p uchar 48 |
| 1578 | res = add res mul f64 d sc |
| 1579 | sc = mul sc f64 0.1 |
| 1580 | p = add p 1 |
| 1581 | end |
| 1582 | put g_jpos 0 p |
| 1583 | ret res |
| 1584 | end |
| 1585 | |
| 1586 | fn jp_parse_num to long |
| 1587 | n = get g_jlen 0 |
| 1588 | p = get g_jpos 0 |
| 1589 | if ge p n |
| 1590 | ret -1 |
| 1591 | end |
| 1592 | negv = false |
| 1593 | if eq get g_jbuf p uchar 45 |
| 1594 | negv = true |
| 1595 | p = add p 1 |
| 1596 | end |
| 1597 | if not jp_is_dig p n |
| 1598 | ret -1 |
| 1599 | end |
| 1600 | u = ulong 0 |
| 1601 | fl = f64 0.0 |
| 1602 | is_u = not negv |
| 1603 | while jp_is_dig p n |
| 1604 | d = ulong sub get g_jbuf p uchar 48 |
| 1605 | if or gt u 1844674407370955161 and eq u 1844674407370955161 gt d 5 |
| 1606 | is_u = false |
| 1607 | else |
| 1608 | u = add mul u 10 d |
| 1609 | end |
| 1610 | fl = add mul fl f64 10.0 f64 d |
| 1611 | p = add p 1 |
| 1612 | end |
| 1613 | put g_jpos 0 p |
| 1614 | if lt p n |
| 1615 | if eq get g_jbuf p uchar 46 |
| 1616 | is_u = false |
| 1617 | put g_jpos 0 add p 1 |
| 1618 | fl = jp_parse_frac fl |
| 1619 | p = get g_jpos 0 |
| 1620 | end |
| 1621 | end |
| 1622 | if lt p n |
| 1623 | ec = get g_jbuf p |
| 1624 | if or eq ec uchar 101 eq ec uchar 69 |
| 1625 | is_u = false |
| 1626 | put g_jpos 0 add p 1 |
| 1627 | fl = jp_parse_exp fl |
| 1628 | end |
| 1629 | end |
| 1630 | nd = jp_new JT_NUM |
| 1631 | if lt nd 0 |
| 1632 | ret -1 |
| 1633 | end |
| 1634 | ni = ulong nd |
| 1635 | if is_u |
| 1636 | put g_jn_u ni u |
| 1637 | put g_jn_iu ni 1 |
| 1638 | put g_jn_d ni f64 u |
| 1639 | else |
| 1640 | if negv |
| 1641 | fl = sub f64 0.0 fl |
| 1642 | end |
| 1643 | put g_jn_d ni fl |
| 1644 | end |
| 1645 | ret nd |
| 1646 | end |
| 1647 | |
| 1648 | fn jp_push par ulong ch ulong to void |
| 1649 | fc = get g_jn_fc par |
| 1650 | if eq fc 0 |
| 1651 | put g_jn_fc par ch |
| 1652 | put g_jn_lc par ch |
| 1653 | else |
| 1654 | lc = get g_jn_lc par |
| 1655 | put g_jn_nx lc ch |
| 1656 | put g_jn_lc par ch |
| 1657 | end |
| 1658 | put g_jn_cnt par add get g_jn_cnt par 1 |
| 1659 | end |
| 1660 | |
| 1661 | fn jp_parse to long |
| 1662 | jp_ws |
| 1663 | n = get g_jlen 0 |
| 1664 | p = get g_jpos 0 |
| 1665 | if ge p n |
| 1666 | ret -1 |
| 1667 | end |
| 1668 | c = get g_jbuf p |
| 1669 | if eq c uchar 123 |
| 1670 | put g_jpos 0 add p 1 |
| 1671 | nd = jp_new JT_OBJ |
| 1672 | if lt nd 0 |
| 1673 | ret -1 |
| 1674 | end |
| 1675 | obj = ulong nd |
| 1676 | jp_ws |
| 1677 | p2 = get g_jpos 0 |
| 1678 | if lt p2 n |
| 1679 | if eq get g_jbuf p2 uchar 125 |
| 1680 | put g_jpos 0 add p2 1 |
| 1681 | ret nd |
| 1682 | end |
| 1683 | end |
| 1684 | while true |
| 1685 | jp_ws |
| 1686 | if lt jp_str_raw 0 |
| 1687 | ret -1 |
| 1688 | end |
| 1689 | ko = get g_tmpu 0 |
| 1690 | kl = get g_tmpu 1 |
| 1691 | jp_ws |
| 1692 | p3 = get g_jpos 0 |
| 1693 | if ge p3 n |
| 1694 | ret -1 |
| 1695 | end |
| 1696 | if ne get g_jbuf p3 uchar 58 |
| 1697 | ret -1 |
| 1698 | end |
| 1699 | put g_jpos 0 add p3 1 |
| 1700 | val = jp_parse |
| 1701 | if lt val 0 |
| 1702 | ret -1 |
| 1703 | end |
| 1704 | vi = ulong val |
| 1705 | put g_jn_ko vi ko |
| 1706 | put g_jn_kl vi kl |
| 1707 | jp_push obj vi |
| 1708 | jp_ws |
| 1709 | p4 = get g_jpos 0 |
| 1710 | if ge p4 n |
| 1711 | ret -1 |
| 1712 | end |
| 1713 | c4 = get g_jbuf p4 |
| 1714 | if eq c4 uchar 44 |
| 1715 | put g_jpos 0 add p4 1 |
| 1716 | else |
| 1717 | if eq c4 uchar 125 |
| 1718 | put g_jpos 0 add p4 1 |
| 1719 | ret nd |
| 1720 | else |
| 1721 | ret -1 |
| 1722 | end |
| 1723 | end |
| 1724 | end |
| 1725 | end |
| 1726 | if eq c uchar 91 |
| 1727 | put g_jpos 0 add p 1 |
| 1728 | nd = jp_new JT_ARR |
| 1729 | if lt nd 0 |
| 1730 | ret -1 |
| 1731 | end |
| 1732 | arr = ulong nd |
| 1733 | jp_ws |
| 1734 | p2 = get g_jpos 0 |
| 1735 | if lt p2 n |
| 1736 | if eq get g_jbuf p2 uchar 93 |
| 1737 | put g_jpos 0 add p2 1 |
| 1738 | ret nd |
| 1739 | end |
| 1740 | end |
| 1741 | while true |
| 1742 | val = jp_parse |
| 1743 | if lt val 0 |
| 1744 | ret -1 |
| 1745 | end |
| 1746 | jp_push arr ulong val |
| 1747 | jp_ws |
| 1748 | p4 = get g_jpos 0 |
| 1749 | if ge p4 n |
| 1750 | ret -1 |
| 1751 | end |
| 1752 | c4 = get g_jbuf p4 |
| 1753 | if eq c4 uchar 44 |
| 1754 | put g_jpos 0 add p4 1 |
| 1755 | else |
| 1756 | if eq c4 uchar 93 |
| 1757 | put g_jpos 0 add p4 1 |
| 1758 | ret nd |
| 1759 | else |
| 1760 | ret -1 |
| 1761 | end |
| 1762 | end |
| 1763 | end |
| 1764 | end |
| 1765 | if eq c uchar 34 |
| 1766 | if lt jp_str_raw 0 |
| 1767 | ret -1 |
| 1768 | end |
| 1769 | nd = jp_new JT_STR |
| 1770 | if lt nd 0 |
| 1771 | ret -1 |
| 1772 | end |
| 1773 | put g_jn_so ulong nd get g_tmpu 0 |
| 1774 | put g_jn_sl ulong nd get g_tmpu 1 |
| 1775 | ret nd |
| 1776 | end |
| 1777 | if jp_match t_true |
| 1778 | nd = jp_new JT_BOOL |
| 1779 | if ge nd 0 |
| 1780 | put g_jn_d ulong nd f64 1.0 |
| 1781 | end |
| 1782 | ret nd |
| 1783 | end |
| 1784 | if jp_match t_false |
| 1785 | ret jp_new JT_BOOL |
| 1786 | end |
| 1787 | if jp_match t_null |
| 1788 | ret jp_new JT_NULL |
| 1789 | end |
| 1790 | ret jp_parse_num |
| 1791 | end |
| 1792 | |
| 1793 | fn jget o long k view uchar * to long |
| 1794 | if lt o 0 |
| 1795 | ret -1 |
| 1796 | end |
| 1797 | if ne get g_jn_t ulong o JT_OBJ |
| 1798 | ret -1 |
| 1799 | end |
| 1800 | kl = len k |
| 1801 | cur = get g_jn_fc ulong o |
| 1802 | while gt cur 0 |
| 1803 | if eq get g_jn_kl cur kl |
| 1804 | ko = get g_jn_ko cur |
| 1805 | ok = true |
| 1806 | for i ulong kl |
| 1807 | if ne get g_jstr add ko i get k i |
| 1808 | ok = false |
| 1809 | end |
| 1810 | end |
| 1811 | if ok |
| 1812 | ret long cur |
| 1813 | end |
| 1814 | end |
| 1815 | cur = get g_jn_nx cur |
| 1816 | end |
| 1817 | ret -1 |
| 1818 | end |
| 1819 | |
| 1820 | fn jarr_at a long idx ulong to long |
| 1821 | if lt a 0 |
| 1822 | ret -1 |
| 1823 | end |
| 1824 | if ne get g_jn_t ulong a JT_ARR |
| 1825 | ret -1 |
| 1826 | end |
| 1827 | if ge idx get g_jn_cnt ulong a |
| 1828 | ret -1 |
| 1829 | end |
| 1830 | cur = get g_jn_fc ulong a |
| 1831 | for i ulong idx |
| 1832 | cur = get g_jn_nx cur |
| 1833 | end |
| 1834 | ret long cur |
| 1835 | end |
| 1836 | |
| 1837 | fn jd o long k view uchar * to f64 |
| 1838 | v = jget o k |
| 1839 | if lt v 0 |
| 1840 | ret r15_nan |
| 1841 | end |
| 1842 | if ne get g_jn_t ulong v JT_NUM |
| 1843 | ret r15_nan |
| 1844 | end |
| 1845 | ret get g_jn_d ulong v |
| 1846 | end |
| 1847 | |
| 1848 | fn ju o long k view uchar * to ulong |
| 1849 | v = jget o k |
| 1850 | if lt v 0 |
| 1851 | ret 0 |
| 1852 | end |
| 1853 | vi = ulong v |
| 1854 | if ne get g_jn_t vi JT_NUM |
| 1855 | ret 0 |
| 1856 | end |
| 1857 | if ne get g_jn_iu vi 0 |
| 1858 | ret get g_jn_u vi |
| 1859 | end |
| 1860 | d = get g_jn_d vi |
| 1861 | if lt d f64 0.0 |
| 1862 | ret 0 |
| 1863 | end |
| 1864 | ret ulong d |
| 1865 | end |
| 1866 | |
| 1867 | fn jau a long idx ulong to ulong |
| 1868 | v = jarr_at a idx |
| 1869 | if lt v 0 |
| 1870 | ret 0 |
| 1871 | end |
| 1872 | ret get g_jn_u ulong v |
| 1873 | end |
| 1874 | |
| 1875 | fn jstr_eq o long k view uchar * s view uchar * to bool |
| 1876 | v = jget o k |
| 1877 | if lt v 0 |
| 1878 | ret eq len s 0 |
| 1879 | end |
| 1880 | vi = ulong v |
| 1881 | if ne get g_jn_t vi JT_STR |
| 1882 | ret eq len s 0 |
| 1883 | end |
| 1884 | sl = get g_jn_sl vi |
| 1885 | if ne sl len s |
| 1886 | ret false |
| 1887 | end |
| 1888 | so = get g_jn_so vi |
| 1889 | for i ulong sl |
| 1890 | if ne get g_jstr add so i get s i |
| 1891 | ret false |
| 1892 | end |
| 1893 | end |
| 1894 | ret true |
| 1895 | end |
| 1896 | |
| 1897 | fn jstr_starts o long k view uchar * s view uchar * to bool |
| 1898 | v = jget o k |
| 1899 | if lt v 0 |
| 1900 | ret eq len s 0 |
| 1901 | end |
| 1902 | vi = ulong v |
| 1903 | if ne get g_jn_t vi JT_STR |
| 1904 | ret eq len s 0 |
| 1905 | end |
| 1906 | if lt get g_jn_sl vi len s |
| 1907 | ret false |
| 1908 | end |
| 1909 | so = get g_jn_so vi |
| 1910 | for i ulong len s |
| 1911 | if ne get g_jstr add so i get s i |
| 1912 | ret false |
| 1913 | end |
| 1914 | end |
| 1915 | ret true |
| 1916 | end |
| 1917 | |
| 1918 | fn jcopy_cfg o long k view uchar * dst ulong off ulong to void |
| 1919 | v = jget o k |
| 1920 | so = ulong 0 |
| 1921 | sl = ulong 0 |
| 1922 | if ge v 0 |
| 1923 | vi = ulong v |
| 1924 | if eq get g_jn_t vi JT_STR |
| 1925 | so = get g_jn_so vi |
| 1926 | sl = get g_jn_sl vi |
| 1927 | end |
| 1928 | end |
| 1929 | lim = ulong 23 |
| 1930 | if lt sl lim |
| 1931 | lim = sl |
| 1932 | end |
| 1933 | for i ulong 24 |
| 1934 | c = uchar 0 |
| 1935 | if lt i lim |
| 1936 | c = get g_jstr add so i |
| 1937 | end |
| 1938 | if eq dst 0 |
| 1939 | put g_t_cfg add off i c |
| 1940 | else |
| 1941 | if eq dst 1 |
| 1942 | put g_l2_cfg add off i c |
| 1943 | else |
| 1944 | if eq dst 2 |
| 1945 | put g_bar_cfg add off i c |
| 1946 | else |
| 1947 | put g_wr_cfg add off i c |
| 1948 | end |
| 1949 | end |
| 1950 | end |
| 1951 | end |
| 1952 | end |
| 1953 | |
| 1954 | note ---- Sorting & Statistics ---- |
| 1955 | fn sift_u start ulong endi ulong to void |
| 1956 | r = start |
| 1957 | while le add mul r 2 1 endi |
| 1958 | ch = add mul r 2 1 |
| 1959 | sw = r |
| 1960 | if lt get g_sort_u sw get g_sort_u ch |
| 1961 | sw = ch |
| 1962 | end |
| 1963 | if le add ch 1 endi |
| 1964 | c2 = add ch 1 |
| 1965 | if lt get g_sort_u sw get g_sort_u c2 |
| 1966 | sw = c2 |
| 1967 | end |
| 1968 | end |
| 1969 | if eq sw r |
| 1970 | ret |
| 1971 | end |
| 1972 | tmp = get g_sort_u r |
| 1973 | put g_sort_u r get g_sort_u sw |
| 1974 | put g_sort_u sw tmp |
| 1975 | r = sw |
| 1976 | end |
| 1977 | end |
| 1978 | |
| 1979 | fn sort_u n ulong to void |
| 1980 | if le n 1 |
| 1981 | ret |
| 1982 | end |
| 1983 | i = div n 2 |
| 1984 | while gt i 0 |
| 1985 | i = sub i 1 |
| 1986 | sift_u i sub n 1 |
| 1987 | end |
| 1988 | ei = sub n 1 |
| 1989 | while gt ei 0 |
| 1990 | tmp = get g_sort_u ei |
| 1991 | put g_sort_u ei get g_sort_u 0 |
| 1992 | put g_sort_u 0 tmp |
| 1993 | ei = sub ei 1 |
| 1994 | sift_u 0 ei |
| 1995 | end |
| 1996 | end |
| 1997 | |
| 1998 | fn sift_hs start ulong endi ulong to void |
| 1999 | r = start |
| 2000 | while le add mul r 2 1 endi |
| 2001 | ch = add mul r 2 1 |
| 2002 | sw = r |
| 2003 | if lt get g_hs_lo sw get g_hs_lo ch |
| 2004 | sw = ch |
| 2005 | end |
| 2006 | if le add ch 1 endi |
| 2007 | c2 = add ch 1 |
| 2008 | if lt get g_hs_lo sw get g_hs_lo c2 |
| 2009 | sw = c2 |
| 2010 | end |
| 2011 | end |
| 2012 | if eq sw r |
| 2013 | ret |
| 2014 | end |
| 2015 | tl = get g_hs_lo r |
| 2016 | put g_hs_lo r get g_hs_lo sw |
| 2017 | put g_hs_lo sw tl |
| 2018 | tc = get g_hs_cnt r |
| 2019 | put g_hs_cnt r get g_hs_cnt sw |
| 2020 | put g_hs_cnt sw tc |
| 2021 | r = sw |
| 2022 | end |
| 2023 | end |
| 2024 | |
| 2025 | fn sort_hs n ulong to void |
| 2026 | if le n 1 |
| 2027 | ret |
| 2028 | end |
| 2029 | i = div n 2 |
| 2030 | while gt i 0 |
| 2031 | i = sub i 1 |
| 2032 | sift_hs i sub n 1 |
| 2033 | end |
| 2034 | ei = sub n 1 |
| 2035 | while gt ei 0 |
| 2036 | tl = get g_hs_lo ei |
| 2037 | put g_hs_lo ei get g_hs_lo 0 |
| 2038 | put g_hs_lo 0 tl |
| 2039 | tc = get g_hs_cnt ei |
| 2040 | put g_hs_cnt ei get g_hs_cnt 0 |
| 2041 | put g_hs_cnt 0 tc |
| 2042 | ei = sub ei 1 |
| 2043 | sift_hs 0 ei |
| 2044 | end |
| 2045 | end |
| 2046 | |
| 2047 | fn sift_boot start ulong endi ulong to void |
| 2048 | r = start |
| 2049 | while le add mul r 2 1 endi |
| 2050 | ch = add mul r 2 1 |
| 2051 | sw = r |
| 2052 | if lt get g_boot sw get g_boot ch |
| 2053 | sw = ch |
| 2054 | end |
| 2055 | if le add ch 1 endi |
| 2056 | c2 = add ch 1 |
| 2057 | if lt get g_boot sw get g_boot c2 |
| 2058 | sw = c2 |
| 2059 | end |
| 2060 | end |
| 2061 | if eq sw r |
| 2062 | ret |
| 2063 | end |
| 2064 | tmp = get g_boot r |
| 2065 | put g_boot r get g_boot sw |
| 2066 | put g_boot sw tmp |
| 2067 | r = sw |
| 2068 | end |
| 2069 | end |
| 2070 | |
| 2071 | fn sort_boot n ulong to void |
| 2072 | if le n 1 |
| 2073 | ret |
| 2074 | end |
| 2075 | i = div n 2 |
| 2076 | while gt i 0 |
| 2077 | i = sub i 1 |
| 2078 | sift_boot i sub n 1 |
| 2079 | end |
| 2080 | ei = sub n 1 |
| 2081 | while gt ei 0 |
| 2082 | tmp = get g_boot ei |
| 2083 | put g_boot ei get g_boot 0 |
| 2084 | put g_boot 0 tmp |
| 2085 | ei = sub ei 1 |
| 2086 | sift_boot 0 ei |
| 2087 | end |
| 2088 | end |
| 2089 | |
| 2090 | fn median_bsamp n ulong to f64 |
| 2091 | if eq n 0 |
| 2092 | ret r15_nan |
| 2093 | end |
| 2094 | i = ulong 1 |
| 2095 | while lt i n |
| 2096 | v = get g_bsamp i |
| 2097 | j = i |
| 2098 | while gt j 0 |
| 2099 | pv = get g_bsamp sub j 1 |
| 2100 | if le pv v |
| 2101 | break |
| 2102 | end |
| 2103 | put g_bsamp j pv |
| 2104 | j = sub j 1 |
| 2105 | end |
| 2106 | put g_bsamp j v |
| 2107 | i = add i 1 |
| 2108 | end |
| 2109 | if eq rem n 2 1 |
| 2110 | ret get g_bsamp div n 2 |
| 2111 | end |
| 2112 | h = div n 2 |
| 2113 | ret div add get g_bsamp sub h 1 get g_bsamp h f64 2.0 |
| 2114 | end |
| 2115 | |
| 2116 | fn median_vd n ulong which ulong to f64 |
| 2117 | if eq n 0 |
| 2118 | ret r15_nan |
| 2119 | end |
| 2120 | for i ulong n |
| 2121 | if eq which 0 |
| 2122 | put g_bsamp i get g_vd i |
| 2123 | else |
| 2124 | put g_bsamp i get g_vd2 i |
| 2125 | end |
| 2126 | end |
| 2127 | ret median_bsamp n |
| 2128 | end |
| 2129 | |
| 2130 | fn splitmix to ulong |
| 2131 | z = add get g_rng 0 ulong 0x9e3779b97f4a7c15 |
| 2132 | put g_rng 0 z |
| 2133 | z = mul xor z shr z 30 ulong 0xbf58476d1ce4e5b9 |
| 2134 | z = mul xor z shr z 27 ulong 0x94d049bb133111eb |
| 2135 | ret xor z shr z 31 |
| 2136 | end |
| 2137 | |
| 2138 | fn boot_ci_vd n ulong slot ulong to void |
| 2139 | bo = mul slot 3 |
| 2140 | put g_cmp_d add bo 1 r15_nan |
| 2141 | put g_cmp_d add bo 2 r15_nan |
| 2142 | if lt n 2 |
| 2143 | ret |
| 2144 | end |
| 2145 | put g_rng 0 21 |
| 2146 | for b ulong R15_RESAMP |
| 2147 | for i ulong n |
| 2148 | idx = rem splitmix n |
| 2149 | put g_bsamp i get g_vd idx |
| 2150 | end |
| 2151 | put g_boot b median_bsamp n |
| 2152 | end |
| 2153 | sort_boot R15_RESAMP |
| 2154 | put g_cmp_d add bo 1 get g_boot 249 |
| 2155 | put g_cmp_d add bo 2 get g_boot 9749 |
| 2156 | end |
| 2157 | |
| 2158 | fn pct_u_at n ulong p f64 to ulong |
| 2159 | if eq n 0 |
| 2160 | ret 0 |
| 2161 | end |
| 2162 | r = ceil_u p n |
| 2163 | if lt r 1 |
| 2164 | r = 1 |
| 2165 | end |
| 2166 | if gt r n |
| 2167 | r = n |
| 2168 | end |
| 2169 | ret get g_sort_u sub r 1 |
| 2170 | end |
| 2171 | |
| 2172 | fn pct_of_sortu n ulong to void |
| 2173 | for i ulong 7 |
| 2174 | put g_pct i 0 |
| 2175 | end |
| 2176 | if eq n 0 |
| 2177 | ret |
| 2178 | end |
| 2179 | sort_u n |
| 2180 | put g_pct 0 n |
| 2181 | put g_pct 1 pct_u_at n f64 0.50 |
| 2182 | put g_pct 2 pct_u_at n f64 0.90 |
| 2183 | put g_pct 3 pct_u_at n f64 0.95 |
| 2184 | put g_pct 4 pct_u_at n f64 0.99 |
| 2185 | put g_pct 5 pct_u_at n f64 0.999 |
| 2186 | put g_pct 6 get g_sort_u sub n 1 |
| 2187 | end |
| 2188 | |
| 2189 | fn o_pct k view uchar * to void |
| 2190 | o_open k uchar 123 |
| 2191 | o_u t_o_n get g_pct 0 |
| 2192 | o_u t_o_p50 get g_pct 1 |
| 2193 | o_u t_o_p90 get g_pct 2 |
| 2194 | o_u t_o_p95 get g_pct 3 |
| 2195 | o_u t_o_p99 get g_pct 4 |
| 2196 | o_u t_o_p999 get g_pct 5 |
| 2197 | o_u t_o_max get g_pct 6 |
| 2198 | o_close uchar 125 |
| 2199 | end |
| 2200 | |
| 2201 | fn o_pct_kbuf to void |
| 2202 | o_open_kbuf uchar 123 |
| 2203 | o_u t_o_n get g_pct 0 |
| 2204 | o_u t_o_p50 get g_pct 1 |
| 2205 | o_u t_o_p90 get g_pct 2 |
| 2206 | o_u t_o_p95 get g_pct 3 |
| 2207 | o_u t_o_p99 get g_pct 4 |
| 2208 | o_u t_o_p999 get g_pct 5 |
| 2209 | o_u t_o_max get g_pct 6 |
| 2210 | o_close uchar 125 |
| 2211 | end |
| 2212 | |
| 2213 | note ---- L1 set storage (chunked blocks of 1024 ulongs) ---- |
| 2214 | fn sb_reset to void |
| 2215 | put g_slen 0 0 |
| 2216 | end |
| 2217 | |
| 2218 | fn sb_put_jstr o long k view uchar * to void |
| 2219 | v = jget o k |
| 2220 | if lt v 0 |
| 2221 | ret |
| 2222 | end |
| 2223 | vi = ulong v |
| 2224 | if ne get g_jn_t vi JT_STR |
| 2225 | ret |
| 2226 | end |
| 2227 | so = get g_jn_so vi |
| 2228 | sl = get g_jn_sl vi |
| 2229 | for i ulong sl |
| 2230 | io_putc 2 get g_jstr add so i |
| 2231 | end |
| 2232 | end |
| 2233 | |
| 2234 | fn l1_key_eq idx ulong to bool |
| 2235 | ko = mul idx 96 |
| 2236 | sl = get g_slen 0 |
| 2237 | if ge sl 95 |
| 2238 | sl = 95 |
| 2239 | end |
| 2240 | for i ulong sl |
| 2241 | if ne get g_l1_key add ko i get g_sbuf i |
| 2242 | ret false |
| 2243 | end |
| 2244 | end |
| 2245 | ret eq get g_l1_key add ko sl uchar 0 |
| 2246 | end |
| 2247 | |
| 2248 | fn l1_find to long |
| 2249 | nl = get g_nl1 0 |
| 2250 | for i ulong nl |
| 2251 | if l1_key_eq i |
| 2252 | ret long i |
| 2253 | end |
| 2254 | end |
| 2255 | ret -1 |
| 2256 | end |
| 2257 | |
| 2258 | fn l1_find_or_add to ulong |
| 2259 | f = l1_find |
| 2260 | if ge f 0 |
| 2261 | ret ulong f |
| 2262 | end |
| 2263 | nl = get g_nl1 0 |
| 2264 | if ge nl R15_MAXL1 |
| 2265 | io_puts 1 t_toomany_l1 |
| 2266 | io_flush 1 |
| 2267 | exit 3 |
| 2268 | end |
| 2269 | ko = mul nl 96 |
| 2270 | sl = get g_slen 0 |
| 2271 | if ge sl 95 |
| 2272 | sl = 95 |
| 2273 | end |
| 2274 | for i ulong 96 |
| 2275 | c = uchar 0 |
| 2276 | if lt i sl |
| 2277 | c = get g_sbuf i |
| 2278 | end |
| 2279 | put g_l1_key add ko i c |
| 2280 | end |
| 2281 | put g_l1_hd nl 0 |
| 2282 | put g_l1_tl nl 0 |
| 2283 | put g_l1_cnt nl 0 |
| 2284 | put g_nl1 0 add nl 1 |
| 2285 | ret nl |
| 2286 | end |
| 2287 | |
| 2288 | fn l1_push sid ulong v ulong to void |
| 2289 | tl = get g_l1_tl sid |
| 2290 | need = eq tl 0 |
| 2291 | if not need |
| 2292 | if ge get g_l1_bln tl R15_L1_BSZ |
| 2293 | need = true |
| 2294 | end |
| 2295 | end |
| 2296 | if need |
| 2297 | nb = get g_l1_nb 0 |
| 2298 | if ge nb R15_L1_BLKS |
| 2299 | exit 3 |
| 2300 | end |
| 2301 | put g_l1_nb 0 add nb 1 |
| 2302 | put g_l1_bnx nb 0 |
| 2303 | put g_l1_bln nb 0 |
| 2304 | if eq tl 0 |
| 2305 | put g_l1_hd sid nb |
| 2306 | else |
| 2307 | put g_l1_bnx tl nb |
| 2308 | end |
| 2309 | put g_l1_tl sid nb |
| 2310 | tl = nb |
| 2311 | end |
| 2312 | bl = get g_l1_bln tl |
| 2313 | put g_l1_val add mul tl R15_L1_BSZ bl v |
| 2314 | put g_l1_bln tl add bl 1 |
| 2315 | put g_l1_cnt sid add get g_l1_cnt sid 1 |
| 2316 | end |
| 2317 | |
| 2318 | fn l1_load_sortu sid ulong div100 bool to ulong |
| 2319 | n = ulong 0 |
| 2320 | blk = get g_l1_hd sid |
| 2321 | while gt blk 0 |
| 2322 | bl = get g_l1_bln blk |
| 2323 | bo = mul blk R15_L1_BSZ |
| 2324 | for i ulong bl |
| 2325 | if lt n R15_SORT_CAP |
| 2326 | v = get g_l1_val add bo i |
| 2327 | if div100 |
| 2328 | v = div v 100 |
| 2329 | end |
| 2330 | put g_sort_u n v |
| 2331 | n = add n 1 |
| 2332 | end |
| 2333 | end |
| 2334 | blk = get g_l1_bnx blk |
| 2335 | end |
| 2336 | ret n |
| 2337 | end |
| 2338 | |
| 2339 | fn l1_pct_run div100 bool to void |
| 2340 | idx = l1_find |
| 2341 | if lt idx 0 |
| 2342 | pct_of_sortu 0 |
| 2343 | ret |
| 2344 | end |
| 2345 | n = l1_load_sortu ulong idx div100 |
| 2346 | pct_of_sortu n |
| 2347 | end |
| 2348 | |
| 2349 | fn l1_pct_key m view uchar * f view uchar * param ulong ci ulong to void |
| 2350 | sb_reset |
| 2351 | io_puts 2 m |
| 2352 | io_putc 2 uchar 124 |
| 2353 | io_puts 2 f |
| 2354 | io_putc 2 uchar 124 |
| 2355 | io_put_u64 2 param |
| 2356 | io_putc 2 uchar 124 |
| 2357 | if eq ci 0 |
| 2358 | io_puts 2 t_cfg0 |
| 2359 | else |
| 2360 | if eq ci 1 |
| 2361 | io_puts 2 t_cfg1 |
| 2362 | else |
| 2363 | if eq ci 2 |
| 2364 | io_puts 2 t_cfg2 |
| 2365 | else |
| 2366 | io_puts 2 t_cfg3 |
| 2367 | end |
| 2368 | end |
| 2369 | end |
| 2370 | l1_pct_run false |
| 2371 | end |
| 2372 | |
| 2373 | fn l1_pct_key_d100 m view uchar * f view uchar * param ulong ci ulong to void |
| 2374 | sb_reset |
| 2375 | io_puts 2 m |
| 2376 | io_putc 2 uchar 124 |
| 2377 | io_puts 2 f |
| 2378 | io_putc 2 uchar 124 |
| 2379 | io_put_u64 2 param |
| 2380 | io_putc 2 uchar 124 |
| 2381 | if eq ci 0 |
| 2382 | io_puts 2 t_cfg0 |
| 2383 | else |
| 2384 | if eq ci 1 |
| 2385 | io_puts 2 t_cfg1 |
| 2386 | else |
| 2387 | if eq ci 2 |
| 2388 | io_puts 2 t_cfg2 |
| 2389 | else |
| 2390 | io_puts 2 t_cfg3 |
| 2391 | end |
| 2392 | end |
| 2393 | end |
| 2394 | l1_pct_run true |
| 2395 | end |
| 2396 | |
| 2397 | note ---- Barriers ---- |
| 2398 | fn add_barrier cfg_tbl ulong cfg_off ulong en ulong be ulong fl ulong re ulong to void |
| 2399 | nb = get g_nbar 0 |
| 2400 | if ge nb R15_MAXBAR |
| 2401 | ret |
| 2402 | end |
| 2403 | bo = mul nb 24 |
| 2404 | for i ulong 24 |
| 2405 | put g_bar_cfg add bo i tb_get cfg_tbl add cfg_off i |
| 2406 | end |
| 2407 | uo = mul nb 5 |
| 2408 | put g_bar_u uo en |
| 2409 | put g_bar_u add uo 1 be |
| 2410 | put g_bar_u add uo 2 fl |
| 2411 | put g_bar_u add uo 3 re |
| 2412 | put g_bar_u add uo 4 0 |
| 2413 | put g_bar_rc nb 0 |
| 2414 | put g_bar_tr nb 0 |
| 2415 | put g_nbar 0 add nb 1 |
| 2416 | end |
| 2417 | |
| 2418 | fn finish_barrier commits ulong rc long tr ulong to void |
| 2419 | nb = get g_nbar 0 |
| 2420 | if eq nb 0 |
| 2421 | ret |
| 2422 | end |
| 2423 | idx = sub nb 1 |
| 2424 | put g_bar_u add mul idx 5 4 commits |
| 2425 | put g_bar_rc idx rc |
| 2426 | put g_bar_tr idx tr |
| 2427 | end |
| 2428 | |
| 2429 | note ---- Energy & JSON Record Extractors ---- |
| 2430 | fn energy_ok e long to bool |
| 2431 | if lt e 0 |
| 2432 | ret false |
| 2433 | end |
| 2434 | d = jd e t_k_spbm_ok |
| 2435 | if eq long d 0 |
| 2436 | ret false |
| 2437 | end |
| 2438 | ov = jget e t_k_overflow |
| 2439 | if ge ov 0 |
| 2440 | ovi = ulong ov |
| 2441 | if eq get g_jn_t ovi JT_ARR |
| 2442 | cur = get g_jn_fc ovi |
| 2443 | while gt cur 0 |
| 2444 | if ne get g_jn_u cur 0 |
| 2445 | ret false |
| 2446 | end |
| 2447 | cur = get g_jn_nx cur |
| 2448 | end |
| 2449 | end |
| 2450 | end |
| 2451 | ret true |
| 2452 | end |
| 2453 | |
| 2454 | fn calc_win_pkg_uj w long to f64 |
| 2455 | if lt w 0 |
| 2456 | ret r15_nan |
| 2457 | end |
| 2458 | e0 = jget w t_k_e0 |
| 2459 | e1 = jget w t_k_e1 |
| 2460 | if not energy_ok e0 |
| 2461 | ret r15_nan |
| 2462 | end |
| 2463 | if not energy_ok e1 |
| 2464 | ret r15_nan |
| 2465 | end |
| 2466 | a = jau jget e0 t_k_energy_uj 0 |
| 2467 | b = jau jget e1 t_k_energy_uj 0 |
| 2468 | if ge b a |
| 2469 | ret f64 sub b a |
| 2470 | end |
| 2471 | ret r15_nan |
| 2472 | end |
| 2473 | |
| 2474 | fn calc_win_nvml_mj w long to f64 |
| 2475 | if lt w 0 |
| 2476 | ret r15_nan |
| 2477 | end |
| 2478 | e0 = jget w t_k_e0 |
| 2479 | e1 = jget w t_k_e1 |
| 2480 | if eq long jd e0 t_k_nvml_ok 0 |
| 2481 | ret r15_nan |
| 2482 | end |
| 2483 | if eq long jd e1 t_k_nvml_ok 0 |
| 2484 | ret r15_nan |
| 2485 | end |
| 2486 | ret sub jd e1 t_k_nvml_mj jd e0 t_k_nvml_mj |
| 2487 | end |
| 2488 | |
| 2489 | fn init_trial ti ulong to void |
| 2490 | put g_t_sil ti 0 |
| 2491 | put g_t_exit ti -1 |
| 2492 | put g_t_comp ti 0 |
| 2493 | put g_t_has_ep ti 0 |
| 2494 | put g_t_ep_cv ti 0 |
| 2495 | put g_t_toff ti get g_tel_n 0 |
| 2496 | put g_t_tcnt ti 0 |
| 2497 | put g_t_hboff ti 0 |
| 2498 | put g_t_hbcnt ti 0 |
| 2499 | for i ulong 11 |
| 2500 | put g_t_ep_u add mul ti 11 i 0 |
| 2501 | end |
| 2502 | for i ulong 4 |
| 2503 | put g_t_ep_inf add mul ti 4 i 0 |
| 2504 | end |
| 2505 | for i ulong 3 |
| 2506 | put g_t_ad_u add mul ti 3 i 0 |
| 2507 | end |
| 2508 | nan = r15_nan |
| 2509 | for i ulong 8 |
| 2510 | put g_t_ad_d add mul ti 8 i nan |
| 2511 | end |
| 2512 | put g_res_has ti 0 |
| 2513 | put g_res_hdg ti 0 |
| 2514 | put g_res_d mul ti 2 nan |
| 2515 | put g_res_d add mul ti 2 1 nan |
| 2516 | for w ulong W_N |
| 2517 | ws = add mul ti W_N w |
| 2518 | put g_w_has ws 0 |
| 2519 | put g_w_pmu mul ws 2 0 |
| 2520 | put g_w_pmu add mul ws 2 1 0 |
| 2521 | for k ulong 29 |
| 2522 | put g_w_d add mul ws 29 k nan |
| 2523 | end |
| 2524 | end |
| 2525 | for cw ulong C_N |
| 2526 | cs = add mul ti C_N cw |
| 2527 | put g_cw_has cs 0 |
| 2528 | put g_cw_hk cs 0 |
| 2529 | for k ulong 14 |
| 2530 | put g_cw_d add mul cs 14 k nan |
| 2531 | end |
| 2532 | end |
| 2533 | end |
| 2534 | |
| 2535 | fn init_l2 li ulong to void |
| 2536 | put g_l2_exit li -1 |
| 2537 | put g_l2_sil li 0 |
| 2538 | nan = r15_nan |
| 2539 | for k ulong 4 |
| 2540 | put g_l2_wd add mul li 4 k nan |
| 2541 | end |
| 2542 | for p ulong 5 |
| 2543 | put g_l2_off add mul li 5 p get g_l2_tot p |
| 2544 | put g_l2_cnt add mul li 5 p 0 |
| 2545 | end |
| 2546 | rs = add 512 li |
| 2547 | put g_res_has rs 0 |
| 2548 | put g_res_hdg rs 0 |
| 2549 | put g_res_d mul rs 2 nan |
| 2550 | put g_res_d add mul rs 2 1 nan |
| 2551 | end |
| 2552 | |
| 2553 | fn extract_episode ti ulong r long to void |
| 2554 | put g_t_has_ep ti 1 |
| 2555 | bo = mul ti 11 |
| 2556 | put g_t_ep_u bo ju r t_k_wrong |
| 2557 | put g_t_ep_u add bo 1 ju r t_k_illegal |
| 2558 | put g_t_ep_u add bo 2 ju r t_k_covf |
| 2559 | put g_t_ep_u add bo 3 ju r t_k_gstat |
| 2560 | put g_t_ep_u add bo 4 ju r t_k_gbefore |
| 2561 | put g_t_ep_u add bo 5 ju r t_k_gafter |
| 2562 | put g_t_ep_u add bo 6 ju r t_k_unprom |
| 2563 | put g_t_ep_u add bo 7 ju r t_k_aegisw |
| 2564 | put g_t_ep_u add bo 8 ju r t_k_rootw |
| 2565 | put g_t_ep_u add bo 9 ju r t_k_losttr |
| 2566 | put g_t_ep_cv ti long jd r t_k_cver |
| 2567 | inf = jget r t_k_inforce |
| 2568 | put g_t_ep_u add bo 10 0 |
| 2569 | if ge inf 0 |
| 2570 | ii = ulong inf |
| 2571 | if eq get g_jn_t ii JT_ARR |
| 2572 | if eq get g_jn_cnt ii 4 |
| 2573 | put g_t_ep_u add bo 10 1 |
| 2574 | io = mul ti 4 |
| 2575 | for k ulong 4 |
| 2576 | put g_t_ep_inf add io k jau inf k |
| 2577 | end |
| 2578 | end |
| 2579 | end |
| 2580 | end |
| 2581 | end |
| 2582 | |
| 2583 | fn extract_adapt ti ulong r long to void |
| 2584 | uo = mul ti 3 |
| 2585 | put g_t_ad_u uo ju r t_k_goal_t |
| 2586 | put g_t_ad_u add uo 1 ju r t_k_met_t |
| 2587 | put g_t_ad_u add uo 2 ju r t_k_plan_t |
| 2588 | do = mul ti 8 |
| 2589 | put g_t_ad_d do jd r t_k_select_t |
| 2590 | put g_t_ad_d add do 1 jd r t_k_plan_t |
| 2591 | put g_t_ad_d add do 2 jd r t_k_evid_t |
| 2592 | put g_t_ad_d add do 3 jd r t_k_claim_t |
| 2593 | put g_t_ad_d add do 4 jd r t_k_inforce_t |
| 2594 | put g_t_ad_d add do 5 jd r t_k_cand_t |
| 2595 | put g_t_ad_d add do 6 jd r t_k_ref_ps |
| 2596 | put g_t_ad_d add do 7 jd r t_k_sel_ps |
| 2597 | be = ju r t_k_b_enter |
| 2598 | if ne be 0 |
| 2599 | add_barrier 1 mul ti 24 be ju r t_k_b_begin ju r t_k_b_flip ju r t_k_b_receipt |
| 2600 | finish_barrier ju r t_k_b_commits long jd r t_k_b_res 1 |
| 2601 | end |
| 2602 | end |
| 2603 | |
| 2604 | fn extract_residency slot ulong r long to void |
| 2605 | tot = jget r t_k_total |
| 2606 | if lt tot 0 |
| 2607 | put g_res_has slot 0 |
| 2608 | ret |
| 2609 | end |
| 2610 | put g_res_has slot 1 |
| 2611 | put g_res_d mul slot 2 jd tot t_k_intervals |
| 2612 | put g_res_d add mul slot 2 1 jd tot t_k_seat_live |
| 2613 | uo = mul slot 12 |
| 2614 | put g_res_u uo ju tot t_k_intervals |
| 2615 | put g_res_u add uo 1 ju tot t_k_seat_live |
| 2616 | d = jget tot t_k_diag |
| 2617 | if lt d 0 |
| 2618 | put g_res_hdg slot 0 |
| 2619 | ret |
| 2620 | end |
| 2621 | put g_res_hdg slot 1 |
| 2622 | put g_res_u add uo 2 ju d t_k_dead_runs |
| 2623 | put g_res_u add uo 3 ju d t_k_dead_long |
| 2624 | put g_res_u add uo 4 ju d t_k_dead_end |
| 2625 | put g_res_u add uo 5 ju d t_k_late_2ms |
| 2626 | put g_res_u add uo 6 ju d t_k_late_10ms |
| 2627 | put g_res_u add uo 7 ju d t_k_max_gap |
| 2628 | put g_res_u add uo 8 ju d t_k_stale_max |
| 2629 | put g_res_u add uo 9 ju d t_k_fdead_t |
| 2630 | put g_res_u add uo 10 ju d t_k_t_first |
| 2631 | end |
| 2632 | |
| 2633 | fn extract_win_stats bo ulong st long to void |
| 2634 | put g_w_d add bo 7 jd st t_st_0 |
| 2635 | put g_w_d add bo 8 jd st t_st_1 |
| 2636 | put g_w_d add bo 9 jd st t_st_2 |
| 2637 | put g_w_d add bo 10 jd st t_st_3 |
| 2638 | put g_w_d add bo 11 jd st t_st_4 |
| 2639 | put g_w_d add bo 12 jd st t_st_5 |
| 2640 | put g_w_d add bo 13 jd st t_st_6 |
| 2641 | put g_w_d add bo 14 jd st t_st_7 |
| 2642 | put g_w_d add bo 15 jd st t_st_8 |
| 2643 | put g_w_d add bo 16 jd st t_st_9 |
| 2644 | put g_w_d add bo 17 jd st t_st_seqp |
| 2645 | put g_w_d add bo 18 jd st t_st_wakes |
| 2646 | end |
| 2647 | |
| 2648 | fn extract_win_pmu ws ulong bo ulong r long to void |
| 2649 | pm = jget r t_k_pmu |
| 2650 | pok = ulong 0 |
| 2651 | pmx = ulong 0 |
| 2652 | if ge pm 0 |
| 2653 | if ne long jd pm t_k_ok 0 |
| 2654 | pok = 1 |
| 2655 | end |
| 2656 | if ne long jd pm t_k_mux 0 |
| 2657 | pmx = 1 |
| 2658 | end |
| 2659 | end |
| 2660 | put g_w_pmu mul ws 2 pok |
| 2661 | put g_w_pmu add mul ws 2 1 pmx |
| 2662 | sm = jget pm t_k_sum |
| 2663 | put g_w_d add bo 19 jd sm t_pm_0 |
| 2664 | put g_w_d add bo 20 jd sm t_pm_1 |
| 2665 | put g_w_d add bo 21 jd sm t_pm_2 |
| 2666 | put g_w_d add bo 22 jd sm t_pm_3 |
| 2667 | put g_w_d add bo 23 jd sm t_pm_4 |
| 2668 | put g_w_d add bo 24 jd sm t_pm_5 |
| 2669 | sp = jget r t_k_sampler |
| 2670 | put g_w_d add bo 25 jd sp t_k_intervals |
| 2671 | put g_w_d add bo 26 jd sp t_k_slot_sum |
| 2672 | put g_w_d add bo 27 jd sp t_k_slot_max |
| 2673 | put g_w_d add bo 28 jd sp t_k_claims_max |
| 2674 | end |
| 2675 | |
| 2676 | fn extract_win ti ulong w ulong r long to void |
| 2677 | ws = add mul ti W_N w |
| 2678 | put g_w_has ws 1 |
| 2679 | bo = mul ws 29 |
| 2680 | put g_w_d bo jd r t_k_ops |
| 2681 | put g_w_d add bo 1 jd r t_k_wall_ns |
| 2682 | put g_w_d add bo 2 jd r t_k_gsb |
| 2683 | put g_w_d add bo 3 jd r t_k_cuser |
| 2684 | put g_w_d add bo 4 jd r t_k_csys |
| 2685 | put g_w_d add bo 5 calc_win_pkg_uj r |
| 2686 | put g_w_d add bo 6 calc_win_nvml_mj r |
| 2687 | extract_win_stats bo jget r t_k_stats |
| 2688 | extract_win_pmu ws bo r |
| 2689 | end |
| 2690 | |
| 2691 | fn extract_cwin_hist ti ulong r long to void |
| 2692 | lat = jget r t_k_latency |
| 2693 | b = jget lat t_k_b |
| 2694 | off = get g_hb_n 0 |
| 2695 | cnt = ulong 0 |
| 2696 | if ge b 0 |
| 2697 | bi = ulong b |
| 2698 | if eq get g_jn_t bi JT_ARR |
| 2699 | cur = get g_jn_fc bi |
| 2700 | while gt cur 0 |
| 2701 | if lt add off cnt R15_MAXHB |
| 2702 | put g_hb_lo add off cnt jau long cur 0 |
| 2703 | put g_hb_cnt add off cnt jau long cur 1 |
| 2704 | cnt = add cnt 1 |
| 2705 | end |
| 2706 | cur = get g_jn_nx cur |
| 2707 | end |
| 2708 | end |
| 2709 | end |
| 2710 | put g_t_hboff ti off |
| 2711 | put g_t_hbcnt ti cnt |
| 2712 | put g_hb_n 0 add off cnt |
| 2713 | end |
| 2714 | |
| 2715 | fn extract_cwin ti ulong cw ulong r long to void |
| 2716 | cs = add mul ti C_N cw |
| 2717 | put g_cw_has cs 1 |
| 2718 | bo = mul cs 14 |
| 2719 | put g_cw_d bo jd r t_k_t0 |
| 2720 | put g_cw_d add bo 1 jd r t_k_t1 |
| 2721 | put g_cw_d add bo 2 jd r t_k_scomm |
| 2722 | put g_cw_d add bo 3 jd r t_k_acost |
| 2723 | put g_cw_d add bo 4 jd r t_k_conseq |
| 2724 | put g_cw_d add bo 5 jd r t_k_replays |
| 2725 | put g_cw_d add bo 6 jd r t_k_acts |
| 2726 | k = jget r t_k_kinds |
| 2727 | if ge k 0 |
| 2728 | put g_cw_hk cs 1 |
| 2729 | put g_cw_d add bo 7 jd k t_k_inval |
| 2730 | put g_cw_d add bo 8 jd k t_k_blkauth |
| 2731 | put g_cw_d add bo 9 jd k t_k_rej |
| 2732 | put g_cw_d add bo 10 jd k t_k_failed |
| 2733 | put g_cw_d add bo 11 jd k t_k_noop |
| 2734 | put g_cw_d add bo 12 jd k t_k_quar |
| 2735 | put g_cw_d add bo 13 jd k t_k_commit |
| 2736 | else |
| 2737 | put g_cw_hk cs 0 |
| 2738 | end |
| 2739 | if eq cw C_SPAN |
| 2740 | extract_cwin_hist ti r |
| 2741 | end |
| 2742 | end |
| 2743 | |
| 2744 | fn handle_trial_line ti ulong r long sil ulong to void |
| 2745 | put g_t_sil ti sil |
| 2746 | if jstr_eq r t_k_kind t_k_episode |
| 2747 | extract_episode ti r |
| 2748 | ret |
| 2749 | end |
| 2750 | if jstr_eq r t_k_kind t_k_adapt |
| 2751 | extract_adapt ti r |
| 2752 | ret |
| 2753 | end |
| 2754 | if jstr_eq r t_k_kind t_k_residency |
| 2755 | extract_residency ti r |
| 2756 | ret |
| 2757 | end |
| 2758 | if jstr_eq r t_k_kind t_k_result |
| 2759 | put g_t_comp ti b2u ne long jd r t_k_complete 0 |
| 2760 | ret |
| 2761 | end |
| 2762 | if jstr_eq r t_k_kind t_k_window |
| 2763 | if jstr_eq r t_k_window t_w_idle |
| 2764 | extract_win ti W_IDLE r |
| 2765 | end |
| 2766 | if jstr_eq r t_k_window t_w_before |
| 2767 | extract_win ti W_BEFORE r |
| 2768 | end |
| 2769 | if jstr_eq r t_k_window t_w_after |
| 2770 | extract_win ti W_AFTER r |
| 2771 | end |
| 2772 | if jstr_eq r t_k_window t_w_span |
| 2773 | extract_win ti W_SPAN r |
| 2774 | end |
| 2775 | ret |
| 2776 | end |
| 2777 | if jstr_eq r t_k_kind t_k_cwindow |
| 2778 | if jstr_eq r t_k_window t_cw_adapt |
| 2779 | extract_cwin ti C_ADAPT r |
| 2780 | end |
| 2781 | if jstr_eq r t_k_window t_cw_cost |
| 2782 | extract_cwin ti C_COST r |
| 2783 | end |
| 2784 | if jstr_eq r t_k_window t_w_before |
| 2785 | extract_cwin ti C_BEFORE r |
| 2786 | end |
| 2787 | if jstr_eq r t_k_window t_w_after |
| 2788 | extract_cwin ti C_AFTER r |
| 2789 | end |
| 2790 | if jstr_eq r t_k_window t_w_span |
| 2791 | extract_cwin ti C_SPAN r |
| 2792 | end |
| 2793 | ret |
| 2794 | end |
| 2795 | if jstr_eq r t_k_kind t_k_telemetry |
| 2796 | e = jget r t_k_e |
| 2797 | tn = get g_tel_n 0 |
| 2798 | if lt tn R15_MAXTEL |
| 2799 | put g_tel_t tn ju e t_k_t_ns |
| 2800 | put g_tel_pkg tn jau jget e t_k_energy_uj 0 |
| 2801 | put g_tel_ok tn b2u ne long jd e t_k_spbm_ok 0 |
| 2802 | put g_tel_n 0 add tn 1 |
| 2803 | put g_t_tcnt ti add get g_t_tcnt ti 1 |
| 2804 | end |
| 2805 | end |
| 2806 | end |
| 2807 | |
| 2808 | fn l2_push_pool li ulong p ulong v ulong to void |
| 2809 | tot = get g_l2_tot p |
| 2810 | if ge tot R15_L2_CAP |
| 2811 | ret |
| 2812 | end |
| 2813 | if eq p 0 |
| 2814 | put g_l2_e2e tot v |
| 2815 | else |
| 2816 | if eq p 1 |
| 2817 | put g_l2_gpu tot v |
| 2818 | else |
| 2819 | if eq p 2 |
| 2820 | put g_l2_enq tot v |
| 2821 | else |
| 2822 | if eq p 3 |
| 2823 | put g_l2_pub tot v |
| 2824 | else |
| 2825 | put g_l2_dep tot v |
| 2826 | end |
| 2827 | end |
| 2828 | end |
| 2829 | end |
| 2830 | put g_l2_tot p add tot 1 |
| 2831 | idx = add mul li 5 p |
| 2832 | put g_l2_cnt idx add get g_l2_cnt idx 1 |
| 2833 | end |
| 2834 | |
| 2835 | fn handle_l2_claim li ulong r long sil ulong to void |
| 2836 | inp = ju r t_k_in_t |
| 2837 | ss = ju r t_k_ss_t |
| 2838 | sc = ju r t_k_sc_t |
| 2839 | ds = ju r t_k_ds_t |
| 2840 | g = ulong 0 |
| 2841 | if ne sil 0 |
| 2842 | pk = uint and ju r t_k_cpick 4294967295 |
| 2843 | dn = uint and ju r t_k_cdone 4294967295 |
| 2844 | g = ulong sub dn pk |
| 2845 | end |
| 2846 | if ne inp 0 |
| 2847 | if ge ss inp |
| 2848 | l2_push_pool li 2 sub ss inp |
| 2849 | end |
| 2850 | end |
| 2851 | if ne sil 0 |
| 2852 | l2_push_pool li 1 g |
| 2853 | end |
| 2854 | if ne ss 0 |
| 2855 | if ge sc ss |
| 2856 | dt = sub sc ss |
| 2857 | if gt dt g |
| 2858 | l2_push_pool li 3 sub dt g |
| 2859 | else |
| 2860 | l2_push_pool li 3 0 |
| 2861 | end |
| 2862 | end |
| 2863 | end |
| 2864 | if ne sc 0 |
| 2865 | if ge ds sc |
| 2866 | l2_push_pool li 4 sub ds sc |
| 2867 | end |
| 2868 | end |
| 2869 | if and ne inp 0 ne ds 0 |
| 2870 | if ge ds inp |
| 2871 | l2_push_pool li 0 sub ds inp |
| 2872 | end |
| 2873 | end |
| 2874 | end |
| 2875 | |
| 2876 | fn handle_l2_line li ulong r long sil ulong to void |
| 2877 | put g_l2_sil li sil |
| 2878 | if jstr_eq r t_k_kind t_k_window |
| 2879 | st = jget r t_k_stats |
| 2880 | bo = mul li 4 |
| 2881 | put g_l2_wd bo jd st t_st_grt |
| 2882 | put g_l2_wd add bo 1 jd st t_st_rc |
| 2883 | put g_l2_wd add bo 2 jd st t_st_ghw |
| 2884 | put g_l2_wd add bo 3 jd st t_st_gpe |
| 2885 | ret |
| 2886 | end |
| 2887 | if jstr_eq r t_k_kind t_k_residency |
| 2888 | extract_residency add 512 li r |
| 2889 | ret |
| 2890 | end |
| 2891 | if jstr_eq r t_k_kind t_k_l2_claim |
| 2892 | handle_l2_claim li r sil |
| 2893 | end |
| 2894 | end |
| 2895 | |
| 2896 | fn handle_l1_line r long to void |
| 2897 | if jstr_eq r t_k_kind t_k_l1 |
| 2898 | sb_reset |
| 2899 | sb_put_jstr r t_k_measure |
| 2900 | io_putc 2 uchar 124 |
| 2901 | sb_put_jstr r t_k_field |
| 2902 | io_putc 2 uchar 124 |
| 2903 | io_put_u64 2 ju r t_k_param |
| 2904 | io_putc 2 uchar 124 |
| 2905 | io_put_mem 2 12 0 get g_klen 0 |
| 2906 | sid = l1_find_or_add |
| 2907 | v = jget r t_k_v |
| 2908 | if ge v 0 |
| 2909 | vi = ulong v |
| 2910 | if eq get g_jn_t vi JT_ARR |
| 2911 | cur = get g_jn_fc vi |
| 2912 | while gt cur 0 |
| 2913 | l1_push sid get g_jn_u cur |
| 2914 | cur = get g_jn_nx cur |
| 2915 | end |
| 2916 | end |
| 2917 | end |
| 2918 | ret |
| 2919 | end |
| 2920 | if jstr_eq r t_k_kind t_k_tstat |
| 2921 | if eq long jd r t_k_ok 0 |
| 2922 | put g_l1_st 2 add get g_l1_st 2 1 |
| 2923 | end |
| 2924 | ret |
| 2925 | end |
| 2926 | if jstr_eq r t_k_kind t_k_l1_bf |
| 2927 | if ne ju r t_k_fsamp 0 |
| 2928 | put g_l1_st 3 add get g_l1_st 3 1 |
| 2929 | end |
| 2930 | ret |
| 2931 | end |
| 2932 | if jstr_eq r t_k_kind t_k_l1_g |
| 2933 | add_barrier 12 0 ju r t_k_enter ju r t_k_begin ju r t_k_flip ju r t_k_receipt |
| 2934 | finish_barrier ju r t_k_pcb long jd r t_k_prc 0 |
| 2935 | ret |
| 2936 | end |
| 2937 | if jstr_eq r t_k_kind t_k_window |
| 2938 | if jstr_starts r t_k_window t_w_timing |
| 2939 | nw = get g_nw 0 |
| 2940 | if lt nw R15_MAXW |
| 2941 | bo = mul nw 24 |
| 2942 | kl = get g_klen 0 |
| 2943 | for i ulong 24 |
| 2944 | c = uchar 0 |
| 2945 | if lt i kl |
| 2946 | c = get g_kbuf i |
| 2947 | end |
| 2948 | put g_wr_cfg add bo i c |
| 2949 | end |
| 2950 | put g_wr_tim nw b2u jstr_eq r t_k_window t_w_timing_on |
| 2951 | put g_wr_thr nw div jd r t_k_ops div jd r t_k_wall_ns f64 1000000000.0 |
| 2952 | put g_nw 0 add nw 1 |
| 2953 | end |
| 2954 | end |
| 2955 | end |
| 2956 | end |
| 2957 | |
| 2958 | fn build_dir_path tbl ulong off ulong flen ulong to ulong |
| 2959 | dl = get g_dirlen 0 |
| 2960 | for i ulong dl |
| 2961 | put g_path i get g_dir i |
| 2962 | end |
| 2963 | put g_path dl uchar 47 |
| 2964 | for i ulong flen |
| 2965 | put g_path add add dl 1 i tb_get tbl add off i |
| 2966 | end |
| 2967 | tot = add add dl 1 flen |
| 2968 | put g_path tot uchar 0 |
| 2969 | ret tot |
| 2970 | end |
| 2971 | |
| 2972 | fn copy_cfg_to_kbuf r long to void |
| 2973 | v = jget r t_k_config |
| 2974 | so = ulong 0 |
| 2975 | sl = ulong 0 |
| 2976 | if ge v 0 |
| 2977 | vi = ulong v |
| 2978 | if eq get g_jn_t vi JT_STR |
| 2979 | so = get g_jn_so vi |
| 2980 | sl = get g_jn_sl vi |
| 2981 | end |
| 2982 | end |
| 2983 | if gt sl 23 |
| 2984 | sl = 23 |
| 2985 | end |
| 2986 | for i ulong 24 |
| 2987 | c = uchar 0 |
| 2988 | if lt i sl |
| 2989 | c = get g_jstr add so i |
| 2990 | end |
| 2991 | put g_kbuf i c |
| 2992 | end |
| 2993 | put g_klen 0 sl |
| 2994 | end |
| 2995 | |
| 2996 | fn init_file_mode r long oi ulong to ulong |
| 2997 | copy_cfg_to_kbuf r |
| 2998 | if jstr_eq r t_k_level t_k_trial |
| 2999 | nt = get g_nt 0 |
| 3000 | if ge nt R15_MAXT |
| 3001 | io_puts 1 t_toomany_t |
| 3002 | io_flush 1 |
| 3003 | exit 3 |
| 3004 | end |
| 3005 | put g_nt 0 add nt 1 |
| 3006 | init_trial nt |
| 3007 | fl = get g_flen oi |
| 3008 | fo = mul oi 256 |
| 3009 | to_f = mul nt 256 |
| 3010 | for k ulong 256 |
| 3011 | c = uchar 0 |
| 3012 | if lt k fl |
| 3013 | c = get g_fname add fo k |
| 3014 | end |
| 3015 | put g_t_file add to_f k c |
| 3016 | end |
| 3017 | jcopy_cfg r t_k_config 0 mul nt 24 |
| 3018 | put g_t_rnd nt long jd r t_k_round |
| 3019 | put g_tmpu 0 nt |
| 3020 | ret 1 |
| 3021 | end |
| 3022 | if jstr_eq r t_k_level t_k_l2 |
| 3023 | nl2 = get g_nl2 0 |
| 3024 | if ge nl2 R15_MAXL2 |
| 3025 | io_puts 1 t_toomany_l2 |
| 3026 | io_flush 1 |
| 3027 | exit 3 |
| 3028 | end |
| 3029 | put g_nl2 0 add nl2 1 |
| 3030 | init_l2 nl2 |
| 3031 | jcopy_cfg r t_k_config 1 mul nl2 24 |
| 3032 | put g_tmpu 0 nl2 |
| 3033 | ret 2 |
| 3034 | end |
| 3035 | put g_l1_st 0 add get g_l1_st 0 1 |
| 3036 | put g_tmpu 0 0 |
| 3037 | ret 3 |
| 3038 | end |
| 3039 | |
| 3040 | fn read_jsonl_file oi ulong to long |
| 3041 | plen = build_dir_path 2 mul oi 256 get g_flen oi |
| 3042 | fd = fopen g_path 0 plen 0 0 |
| 3043 | if lt fd 0 |
| 3044 | ret -1 |
| 3045 | end |
| 3046 | rl_init |
| 3047 | mode = ulong 0 |
| 3048 | idx = ulong 0 |
| 3049 | sil = ulong 0 |
| 3050 | lineno = ulong 0 |
| 3051 | bad = false |
| 3052 | while eq rl_next int fd 1 |
| 3053 | lineno = add lineno 1 |
| 3054 | put g_jpos 0 0 |
| 3055 | put g_jn_n 0 1 |
| 3056 | put g_jslen 0 0 |
| 3057 | r = jp_parse |
| 3058 | if lt r 0 |
| 3059 | io_put_mem 1 2 mul oi 256 get g_flen oi |
| 3060 | io_putc 1 uchar 58 |
| 3061 | io_put_u64 1 lineno |
| 3062 | io_puts 1 t_notjson |
| 3063 | io_flush 1 |
| 3064 | bad = true |
| 3065 | break |
| 3066 | end |
| 3067 | if eq mode 0 |
| 3068 | mode = init_file_mode r oi |
| 3069 | idx = get g_tmpu 0 |
| 3070 | end |
| 3071 | if jstr_eq r t_k_kind t_k_start |
| 3072 | sil = b2u ne long jd r t_k_silicon 0 |
| 3073 | end |
| 3074 | if jstr_eq r t_k_kind t_k_end |
| 3075 | ex = long jd r t_k_exit |
| 3076 | if eq mode 1 |
| 3077 | put g_t_exit idx ex |
| 3078 | else |
| 3079 | if eq mode 2 |
| 3080 | put g_l2_exit idx ex |
| 3081 | else |
| 3082 | if ne ex 0 |
| 3083 | put g_l1_st 1 add get g_l1_st 1 1 |
| 3084 | end |
| 3085 | end |
| 3086 | end |
| 3087 | end |
| 3088 | if eq mode 1 |
| 3089 | handle_trial_line idx r sil |
| 3090 | else |
| 3091 | if eq mode 2 |
| 3092 | handle_l2_line idx r sil |
| 3093 | else |
| 3094 | handle_l1_line r |
| 3095 | end |
| 3096 | end |
| 3097 | end |
| 3098 | _fc = fclose int fd |
| 3099 | if bad |
| 3100 | ret -1 |
| 3101 | end |
| 3102 | ret 0 |
| 3103 | end |
| 3104 | |
| 3105 | note ---- SHA256SUMS + Directory Scan ---- |
| 3106 | fn ends_jsonl tbl ulong off ulong n ulong to bool |
| 3107 | if lt n 6 |
| 3108 | ret false |
| 3109 | end |
| 3110 | st = add off sub n 6 |
| 3111 | for i ulong 6 |
| 3112 | if ne tb_get tbl add st i get t_jsonl i |
| 3113 | ret false |
| 3114 | end |
| 3115 | end |
| 3116 | ret true |
| 3117 | end |
| 3118 | |
| 3119 | fn is_ws b uchar to bool |
| 3120 | ret or eq b 32 or eq b 9 or eq b 10 eq b 13 |
| 3121 | end |
| 3122 | |
| 3123 | fn sums_add_file nl ulong to void |
| 3124 | nf = get g_nfiles 0 |
| 3125 | if ge nf R15_MAXF |
| 3126 | ret |
| 3127 | end |
| 3128 | fo = mul nf 256 |
| 3129 | for i ulong nl |
| 3130 | put g_fname add fo i get g_sbuf i |
| 3131 | end |
| 3132 | put g_fname add fo nl uchar 0 |
| 3133 | put g_flen nf nl |
| 3134 | ho = mul nf 64 |
| 3135 | for i ulong 64 |
| 3136 | put g_fhash add ho i get g_hextmp i |
| 3137 | end |
| 3138 | put g_ford nf nf |
| 3139 | put g_nfiles 0 add nf 1 |
| 3140 | end |
| 3141 | |
| 3142 | fn sums_check_hash h0 ulong hl ulong nl ulong to ulong |
| 3143 | plen = build_dir_path 4 0 nl |
| 3144 | err = ulong 0 |
| 3145 | if lt hash_path plen 0 |
| 3146 | err = 1 |
| 3147 | else |
| 3148 | if ne hl 64 |
| 3149 | err = 1 |
| 3150 | else |
| 3151 | for i ulong 64 |
| 3152 | if ne get g_hextmp i get g_jbuf add h0 i |
| 3153 | err = 1 |
| 3154 | end |
| 3155 | end |
| 3156 | end |
| 3157 | end |
| 3158 | if ne err 0 |
| 3159 | io_puts 1 t_hbad |
| 3160 | io_put_mem 1 4 0 nl |
| 3161 | io_puts 1 t_nl |
| 3162 | io_flush 1 |
| 3163 | end |
| 3164 | ret err |
| 3165 | end |
| 3166 | |
| 3167 | fn parse_sums_line to long |
| 3168 | n = get g_jlen 0 |
| 3169 | p = ulong 0 |
| 3170 | while lt p n |
| 3171 | if not is_ws get g_jbuf p |
| 3172 | break |
| 3173 | end |
| 3174 | p = add p 1 |
| 3175 | end |
| 3176 | h0 = p |
| 3177 | while lt p n |
| 3178 | if is_ws get g_jbuf p |
| 3179 | break |
| 3180 | end |
| 3181 | p = add p 1 |
| 3182 | end |
| 3183 | hl = sub p h0 |
| 3184 | if eq hl 0 |
| 3185 | ret 0 |
| 3186 | end |
| 3187 | while lt p n |
| 3188 | if not is_ws get g_jbuf p |
| 3189 | break |
| 3190 | end |
| 3191 | p = add p 1 |
| 3192 | end |
| 3193 | n0 = p |
| 3194 | while lt p n |
| 3195 | if is_ws get g_jbuf p |
| 3196 | break |
| 3197 | end |
| 3198 | p = add p 1 |
| 3199 | end |
| 3200 | nl = sub p n0 |
| 3201 | if eq nl 0 |
| 3202 | ret 0 |
| 3203 | end |
| 3204 | if eq get g_jbuf n0 uchar 42 |
| 3205 | n0 = add n0 1 |
| 3206 | nl = sub nl 1 |
| 3207 | end |
| 3208 | if lt nl 6 |
| 3209 | ret 0 |
| 3210 | end |
| 3211 | for i ulong 6 |
| 3212 | if ne get g_jbuf add add n0 sub nl 6 i get t_jsonl i |
| 3213 | ret 0 |
| 3214 | end |
| 3215 | end |
| 3216 | if gt nl 255 |
| 3217 | nl = 255 |
| 3218 | end |
| 3219 | sb_reset |
| 3220 | for i ulong nl |
| 3221 | io_putc 2 get g_jbuf add n0 i |
| 3222 | end |
| 3223 | err = sums_check_hash h0 hl nl |
| 3224 | sums_add_file nl |
| 3225 | if ne err 0 |
| 3226 | ret -1 |
| 3227 | end |
| 3228 | ret 1 |
| 3229 | end |
| 3230 | |
| 3231 | fn fn_listed off ulong nl ulong to bool |
| 3232 | nf = get g_nfiles 0 |
| 3233 | for i ulong nf |
| 3234 | if eq get g_flen i nl |
| 3235 | fo = mul i 256 |
| 3236 | ok = true |
| 3237 | for k ulong nl |
| 3238 | if ne get g_fname add fo k get g_dent add off k |
| 3239 | ok = false |
| 3240 | end |
| 3241 | end |
| 3242 | if ok |
| 3243 | ret true |
| 3244 | end |
| 3245 | end |
| 3246 | end |
| 3247 | ret false |
| 3248 | end |
| 3249 | |
| 3250 | fn check_dent_entry pos ulong rl ulong to ulong |
| 3251 | ns = add pos 19 |
| 3252 | nl = ulong 0 |
| 3253 | lim = sub rl 19 |
| 3254 | while lt nl lim |
| 3255 | if eq get g_dent add ns nl 0 |
| 3256 | break |
| 3257 | end |
| 3258 | nl = add nl 1 |
| 3259 | end |
| 3260 | if lt nl 6 |
| 3261 | ret 0 |
| 3262 | end |
| 3263 | for i ulong 6 |
| 3264 | if ne get g_dent add add ns sub nl 6 i get t_jsonl i |
| 3265 | ret 0 |
| 3266 | end |
| 3267 | end |
| 3268 | if fn_listed ns nl |
| 3269 | ret 0 |
| 3270 | end |
| 3271 | io_puts 1 t_unlisted |
| 3272 | for i ulong nl |
| 3273 | io_putc 1 get g_dent add ns i |
| 3274 | end |
| 3275 | io_puts 1 t_nl |
| 3276 | io_flush 1 |
| 3277 | ret 1 |
| 3278 | end |
| 3279 | |
| 3280 | fn fn_lt a ulong b ulong to bool |
| 3281 | oa = mul a 256 |
| 3282 | ob = mul b 256 |
| 3283 | for i ulong 256 |
| 3284 | ca = get g_fname add oa i |
| 3285 | cb = get g_fname add ob i |
| 3286 | if ne ca cb |
| 3287 | ret lt ca cb |
| 3288 | end |
| 3289 | if eq ca 0 |
| 3290 | ret false |
| 3291 | end |
| 3292 | end |
| 3293 | ret false |
| 3294 | end |
| 3295 | |
| 3296 | fn sort_files to void |
| 3297 | nf = get g_nfiles 0 |
| 3298 | i = ulong 1 |
| 3299 | while lt i nf |
| 3300 | k = get g_ford i |
| 3301 | j = i |
| 3302 | while gt j 0 |
| 3303 | pv = get g_ford sub j 1 |
| 3304 | if not fn_lt k pv |
| 3305 | break |
| 3306 | end |
| 3307 | put g_ford j pv |
| 3308 | j = sub j 1 |
| 3309 | end |
| 3310 | put g_ford j k |
| 3311 | i = add i 1 |
| 3312 | end |
| 3313 | end |
| 3314 | |
| 3315 | fn load_sums_and_dir to long |
| 3316 | dl = get g_dirlen 0 |
| 3317 | for i ulong dl |
| 3318 | put g_path i get g_dir i |
| 3319 | end |
| 3320 | put g_path dl uchar 47 |
| 3321 | sn = len t_sums_name |
| 3322 | for i ulong sn |
| 3323 | put g_path add add dl 1 i get t_sums_name i |
| 3324 | end |
| 3325 | plen = add add dl 1 sn |
| 3326 | put g_path plen uchar 0 |
| 3327 | if lt hash_path plen 0 |
| 3328 | io_puts 1 t_nosums |
| 3329 | for i ulong dl |
| 3330 | io_putc 1 get g_dir i |
| 3331 | end |
| 3332 | io_puts 1 t_nl |
| 3333 | io_flush 1 |
| 3334 | ret -1 |
| 3335 | end |
| 3336 | for i ulong 64 |
| 3337 | put g_sums_hex i get g_hextmp i |
| 3338 | end |
| 3339 | sfd = fopen g_path 0 plen 0 0 |
| 3340 | errs = ulong 0 |
| 3341 | if ge sfd 0 |
| 3342 | rl_init |
| 3343 | while eq rl_next int sfd 1 |
| 3344 | if lt parse_sums_line 0 |
| 3345 | errs = add errs 1 |
| 3346 | end |
| 3347 | end |
| 3348 | _fc = fclose int sfd |
| 3349 | end |
| 3350 | dfd = fopen g_dir 0 dl 0 0 |
| 3351 | if ge dfd 0 |
| 3352 | while true |
| 3353 | n = getdnts int dfd g_dent 0 16384 |
| 3354 | if le n 0 |
| 3355 | break |
| 3356 | end |
| 3357 | pos = ulong 0 |
| 3358 | un = ulong n |
| 3359 | while lt pos un |
| 3360 | b0 = ulong get g_dent add pos 16 |
| 3361 | b1 = ulong get g_dent add pos 17 |
| 3362 | rl = or b0 shl b1 8 |
| 3363 | if eq rl 0 |
| 3364 | break |
| 3365 | end |
| 3366 | errs = add errs check_dent_entry pos rl |
| 3367 | pos = add pos rl |
| 3368 | end |
| 3369 | end |
| 3370 | _fc2 = fclose int dfd |
| 3371 | end |
| 3372 | if gt errs 0 |
| 3373 | ret -1 |
| 3374 | end |
| 3375 | sort_files |
| 3376 | ret 0 |
| 3377 | end |
| 3378 | |
| 3379 | note ---- Config name helper ---- |
| 3380 | fn cfg_eq_idx tbl ulong off ulong ci ulong to bool |
| 3381 | if eq ci 0 |
| 3382 | ret cs_eq_t tbl off 24 t_cfg0 |
| 3383 | end |
| 3384 | if eq ci 1 |
| 3385 | ret cs_eq_t tbl off 24 t_cfg1 |
| 3386 | end |
| 3387 | if eq ci 2 |
| 3388 | ret cs_eq_t tbl off 24 t_cfg2 |
| 3389 | end |
| 3390 | ret cs_eq_t tbl off 24 t_cfg3 |
| 3391 | end |
| 3392 | |
| 3393 | fn o_open_cfg ci ulong c uchar to void |
| 3394 | if eq ci 0 |
| 3395 | o_open t_cfg0 c |
| 3396 | else |
| 3397 | if eq ci 1 |
| 3398 | o_open t_cfg1 c |
| 3399 | else |
| 3400 | if eq ci 2 |
| 3401 | o_open t_cfg2 c |
| 3402 | else |
| 3403 | o_open t_cfg3 c |
| 3404 | end |
| 3405 | end |
| 3406 | end |
| 3407 | end |
| 3408 | |
| 3409 | fn o_num_cfg ci ulong x f64 to void |
| 3410 | if eq ci 0 |
| 3411 | o_num t_cfg0 x |
| 3412 | else |
| 3413 | if eq ci 1 |
| 3414 | o_num t_cfg1 x |
| 3415 | else |
| 3416 | if eq ci 2 |
| 3417 | o_num t_cfg2 x |
| 3418 | else |
| 3419 | o_num t_cfg3 x |
| 3420 | end |
| 3421 | end |
| 3422 | end |
| 3423 | end |
| 3424 | |
| 3425 | note ---- Derived per-trial metrics ---- |
| 3426 | fn win_d ti ulong w ulong f ulong to f64 |
| 3427 | ws = add mul ti W_N w |
| 3428 | if eq get g_w_has ws 0 |
| 3429 | ret r15_nan |
| 3430 | end |
| 3431 | ret get g_w_d add mul ws 29 f |
| 3432 | end |
| 3433 | |
| 3434 | fn cwin_d ti ulong cw ulong f ulong to f64 |
| 3435 | cs = add mul ti C_N cw |
| 3436 | if eq get g_cw_has cs 0 |
| 3437 | ret r15_nan |
| 3438 | end |
| 3439 | ret get g_cw_d add mul cs 14 f |
| 3440 | end |
| 3441 | |
| 3442 | fn win_thr ti ulong w ulong to f64 |
| 3443 | ws = add mul ti W_N w |
| 3444 | if eq get g_w_has ws 0 |
| 3445 | ret r15_nan |
| 3446 | end |
| 3447 | bo = mul ws 29 |
| 3448 | ret div get g_w_d bo div get g_w_d add bo 1 f64 1000000000.0 |
| 3449 | end |
| 3450 | |
| 3451 | fn idle_w ti ulong to f64 |
| 3452 | uj = win_d ti W_IDLE 5 |
| 3453 | wn = win_d ti W_IDLE 1 |
| 3454 | ret mul div uj wn f64 1000.0 |
| 3455 | end |
| 3456 | |
| 3457 | fn energy_per_op ti ulong w ulong to f64 |
| 3458 | uj = win_d ti w 5 |
| 3459 | p = idle_w ti |
| 3460 | wops = win_d ti w 0 |
| 3461 | if or is_nan uj or is_nan p not gt wops f64 0.0 |
| 3462 | ret r15_nan |
| 3463 | end |
| 3464 | wn = win_d ti w 1 |
| 3465 | base = mul div mul p wn f64 1000000000.0 f64 1000000.0 |
| 3466 | ret div sub uj base wops |
| 3467 | end |
| 3468 | |
| 3469 | fn gross_energy_per_op ti ulong w ulong to f64 |
| 3470 | uj = win_d ti w 5 |
| 3471 | wops = win_d ti w 0 |
| 3472 | if gt wops f64 0.0 |
| 3473 | ret div uj wops |
| 3474 | end |
| 3475 | ret r15_nan |
| 3476 | end |
| 3477 | |
| 3478 | fn tel_energy ti ulong a ulong b ulong to f64 |
| 3479 | off = get g_t_toff ti |
| 3480 | cnt = get g_t_tcnt ti |
| 3481 | has_lo = false |
| 3482 | lo_pkg = ulong 0 |
| 3483 | has_hi = false |
| 3484 | hi_pkg = ulong 0 |
| 3485 | for i ulong cnt |
| 3486 | idx = add off i |
| 3487 | if ne get g_tel_ok idx 0 |
| 3488 | tt = get g_tel_t idx |
| 3489 | if le tt a |
| 3490 | has_lo = true |
| 3491 | lo_pkg = get g_tel_pkg idx |
| 3492 | end |
| 3493 | if not has_hi |
| 3494 | if ge tt b |
| 3495 | has_hi = true |
| 3496 | hi_pkg = get g_tel_pkg idx |
| 3497 | end |
| 3498 | end |
| 3499 | end |
| 3500 | end |
| 3501 | if and has_lo has_hi |
| 3502 | if ge hi_pkg lo_pkg |
| 3503 | ret f64 sub hi_pkg lo_pkg |
| 3504 | end |
| 3505 | end |
| 3506 | ret r15_nan |
| 3507 | end |
| 3508 | |
| 3509 | fn trial_correct ti ulong to bool |
| 3510 | sb_reset |
| 3511 | ex = get g_t_exit ti |
| 3512 | if or ne ex 0 eq get g_t_comp ti 0 |
| 3513 | io_puts 2 t_w_nocomp |
| 3514 | io_put_i64 2 ex |
| 3515 | io_putc 2 uchar 41 |
| 3516 | ret false |
| 3517 | end |
| 3518 | if eq get g_t_has_ep ti 0 |
| 3519 | io_puts 2 t_w_noep |
| 3520 | ret false |
| 3521 | end |
| 3522 | bo = mul ti 11 |
| 3523 | if ne get g_t_ep_u bo 0 |
| 3524 | io_puts 2 t_w_wrong |
| 3525 | io_put_u64 2 get g_t_ep_u bo |
| 3526 | ret false |
| 3527 | end |
| 3528 | if ne get g_t_ep_u add bo 1 0 |
| 3529 | io_puts 2 t_w_illeg |
| 3530 | ret false |
| 3531 | end |
| 3532 | if not cs_has_sub 1 mul ti 24 24 t_nodig |
| 3533 | if ne get g_t_ep_cv ti 1 |
| 3534 | io_puts 2 t_w_crumbs |
| 3535 | ret false |
| 3536 | end |
| 3537 | end |
| 3538 | if ne get g_t_ep_u add bo 2 0 |
| 3539 | io_puts 2 t_w_covf |
| 3540 | ret false |
| 3541 | end |
| 3542 | if ne get g_t_ep_u add bo 3 2 |
| 3543 | io_puts 2 t_w_goal |
| 3544 | io_put_u64 2 get g_t_ep_u add bo 3 |
| 3545 | io_putc 2 uchar 41 |
| 3546 | ret false |
| 3547 | end |
| 3548 | if ne get g_t_ep_u add bo 5 add get g_t_ep_u add bo 4 1 |
| 3549 | io_puts 2 t_w_gen |
| 3550 | ret false |
| 3551 | end |
| 3552 | if ne get g_t_ep_u add bo 6 0 |
| 3553 | io_puts 2 t_w_unp |
| 3554 | ret false |
| 3555 | end |
| 3556 | if or ne get g_t_ep_u add bo 7 0 ne get g_t_ep_u add bo 8 0 |
| 3557 | io_puts 2 t_w_woken |
| 3558 | ret false |
| 3559 | end |
| 3560 | if ne get g_t_ep_u add bo 9 0 |
| 3561 | io_puts 2 t_w_lost |
| 3562 | ret false |
| 3563 | end |
| 3564 | ret true |
| 3565 | end |
| 3566 | |
| 3567 | fn same_realization a ulong b ulong to bool |
| 3568 | if eq get g_t_ep_u add mul a 11 10 0 |
| 3569 | ret false |
| 3570 | end |
| 3571 | if eq get g_t_ep_u add mul b 11 10 0 |
| 3572 | ret false |
| 3573 | end |
| 3574 | oa = mul a 4 |
| 3575 | ob = mul b 4 |
| 3576 | for i ulong 4 |
| 3577 | if ne get g_t_ep_inf add oa i get g_t_ep_inf add ob i |
| 3578 | ret false |
| 3579 | end |
| 3580 | end |
| 3581 | ret true |
| 3582 | end |
| 3583 | |
| 3584 | fn find_trial ci ulong rnd long to long |
| 3585 | nt = get g_nt 0 |
| 3586 | for i ulong nt |
| 3587 | if eq get g_t_rnd i rnd |
| 3588 | if cfg_eq_idx 1 mul i 24 ci |
| 3589 | ret long i |
| 3590 | end |
| 3591 | end |
| 3592 | end |
| 3593 | ret -1 |
| 3594 | end |
| 3595 | |
| 3596 | fn adapt_rate ti ulong to f64 |
| 3597 | cs = add mul ti C_N C_ADAPT |
| 3598 | if eq get g_cw_has cs 0 |
| 3599 | ret r15_nan |
| 3600 | end |
| 3601 | bo = mul cs 14 |
| 3602 | dt = div sub get g_cw_d add bo 1 get g_cw_d bo f64 1000000000.0 |
| 3603 | if gt dt f64 0.0 |
| 3604 | ret div get g_cw_d add bo 2 dt |
| 3605 | end |
| 3606 | ret r15_nan |
| 3607 | end |
| 3608 | |
| 3609 | fn cwin_wasted ti ulong cw ulong to f64 |
| 3610 | cs = add mul ti C_N cw |
| 3611 | if eq get g_cw_has cs 0 |
| 3612 | ret r15_nan |
| 3613 | end |
| 3614 | if eq get g_cw_hk cs 0 |
| 3615 | ret r15_nan |
| 3616 | end |
| 3617 | bo = mul cs 14 |
| 3618 | s = add get g_cw_d add bo 7 get g_cw_d add bo 8 |
| 3619 | s = add s get g_cw_d add bo 9 |
| 3620 | s = add s get g_cw_d add bo 10 |
| 3621 | s = add s get g_cw_d add bo 11 |
| 3622 | s = add s get g_cw_d add bo 12 |
| 3623 | ret s |
| 3624 | end |
| 3625 | |
| 3626 | fn per_cons ti ulong x f64 to f64 |
| 3627 | c = cwin_d ti C_SPAN 4 |
| 3628 | if gt c f64 0.0 |
| 3629 | ret div x c |
| 3630 | end |
| 3631 | ret r15_nan |
| 3632 | end |
| 3633 | |
| 3634 | fn wake_amp ti ulong to f64 |
| 3635 | ws = add mul ti W_N W_SPAN |
| 3636 | if eq get g_w_has ws 0 |
| 3637 | ret r15_nan |
| 3638 | end |
| 3639 | if cs_starts 1 mul ti 24 24 t_cfg2 |
| 3640 | ret per_cons ti win_d ti W_SPAN 17 |
| 3641 | end |
| 3642 | ret per_cons ti win_d ti W_SPAN 18 |
| 3643 | end |
| 3644 | |
| 3645 | fn crossover_ops ti ulong to f64 |
| 3646 | cost = cwin_d ti C_COST 3 |
| 3647 | do = mul ti 8 |
| 3648 | gain = div sub get g_t_ad_d add do 6 get g_t_ad_d add do 7 f64 1000.0 |
| 3649 | if gt gain f64 0.0 |
| 3650 | ret div cost gain |
| 3651 | end |
| 3652 | ret r15_nan |
| 3653 | end |
| 3654 | |
| 3655 | note ---- TrialVal selector (0=after_thr, 1=before_thr, 2=adapt_rate, 3=energy_after, 4=wasted, 5=crossover_ops, 6=wake_amp) ---- |
| 3656 | fn trial_val ti ulong fnid ulong to f64 |
| 3657 | if eq fnid 0 |
| 3658 | ret win_thr ti W_AFTER |
| 3659 | end |
| 3660 | if eq fnid 1 |
| 3661 | ret win_thr ti W_BEFORE |
| 3662 | end |
| 3663 | if eq fnid 2 |
| 3664 | ret adapt_rate ti |
| 3665 | end |
| 3666 | if eq fnid 3 |
| 3667 | ret energy_per_op ti W_AFTER |
| 3668 | end |
| 3669 | if eq fnid 4 |
| 3670 | ret per_cons ti cwin_wasted ti C_SPAN |
| 3671 | end |
| 3672 | if eq fnid 5 |
| 3673 | ret crossover_ops ti |
| 3674 | end |
| 3675 | ret wake_amp ti |
| 3676 | end |
| 3677 | |
| 3678 | fn paired_one i ulong den_ci ulong fnid ulong need_same bool to void |
| 3679 | b = find_trial den_ci get g_t_rnd i |
| 3680 | if lt b 0 |
| 3681 | ret |
| 3682 | end |
| 3683 | bi = ulong b |
| 3684 | if need_same |
| 3685 | if not same_realization i bi |
| 3686 | put g_tmpu 1 add get g_tmpu 1 1 |
| 3687 | ret |
| 3688 | end |
| 3689 | end |
| 3690 | x = trial_val i fnid |
| 3691 | y = trial_val bi fnid |
| 3692 | if and not is_nan x and not is_nan y gt y f64 0.0 |
| 3693 | n = get g_tmpu 0 |
| 3694 | if lt n 512 |
| 3695 | put g_vd n div x y |
| 3696 | put g_tmpu 0 add n 1 |
| 3697 | end |
| 3698 | else |
| 3699 | put g_tmpu 1 add get g_tmpu 1 1 |
| 3700 | end |
| 3701 | end |
| 3702 | |
| 3703 | fn paired slot ulong num_ci ulong den_ci ulong fnid ulong need_same bool to void |
| 3704 | nt = get g_nt 0 |
| 3705 | put g_tmpu 0 0 |
| 3706 | put g_tmpu 1 0 |
| 3707 | for i ulong nt |
| 3708 | if cfg_eq_idx 1 mul i 24 num_ci |
| 3709 | paired_one i den_ci fnid need_same |
| 3710 | end |
| 3711 | end |
| 3712 | n = get g_tmpu 0 |
| 3713 | excl = get g_tmpu 1 |
| 3714 | bo = mul slot 3 |
| 3715 | put g_cmp_d bo median_vd n 0 |
| 3716 | boot_ci_vd n slot |
| 3717 | put g_cmp_u mul slot 2 n |
| 3718 | put g_cmp_u add mul slot 2 1 excl |
| 3719 | end |
| 3720 | |
| 3721 | fn o_cmp k view uchar * slot ulong to void |
| 3722 | bo = mul slot 3 |
| 3723 | uo = mul slot 2 |
| 3724 | o_open k uchar 123 |
| 3725 | o_num t_o_mrat get g_cmp_d bo |
| 3726 | o_num t_o_cilo get g_cmp_d add bo 1 |
| 3727 | o_num t_o_cihi get g_cmp_d add bo 2 |
| 3728 | o_u t_o_pairs get g_cmp_u uo |
| 3729 | o_u t_o_pexcl get g_cmp_u add uo 1 |
| 3730 | o_close uchar 125 |
| 3731 | end |
| 3732 | |
| 3733 | fn med_of ci ulong fnid ulong to f64 |
| 3734 | nt = get g_nt 0 |
| 3735 | n = ulong 0 |
| 3736 | for i ulong nt |
| 3737 | if cfg_eq_idx 1 mul i 24 ci |
| 3738 | x = trial_val i fnid |
| 3739 | if not is_nan x |
| 3740 | if lt n 512 |
| 3741 | put g_vd n x |
| 3742 | n = add n 1 |
| 3743 | end |
| 3744 | end |
| 3745 | end |
| 3746 | end |
| 3747 | put g_tmpu 0 n |
| 3748 | ret median_vd n 0 |
| 3749 | end |
| 3750 | |
| 3751 | fn hist_pct ci ulong to void |
| 3752 | nt = get g_nt 0 |
| 3753 | n = ulong 0 |
| 3754 | total = ulong 0 |
| 3755 | for i ulong nt |
| 3756 | if cfg_eq_idx 1 mul i 24 ci |
| 3757 | off = get g_t_hboff i |
| 3758 | cnt = get g_t_hbcnt i |
| 3759 | for j ulong cnt |
| 3760 | if lt n R15_MAXHB |
| 3761 | lo = get g_hb_lo add off j |
| 3762 | ct = get g_hb_cnt add off j |
| 3763 | put g_hs_lo n lo |
| 3764 | put g_hs_cnt n ct |
| 3765 | total = add total ct |
| 3766 | n = add n 1 |
| 3767 | end |
| 3768 | end |
| 3769 | end |
| 3770 | end |
| 3771 | for k ulong 7 |
| 3772 | put g_pct k 0 |
| 3773 | end |
| 3774 | if eq total 0 |
| 3775 | ret |
| 3776 | end |
| 3777 | sort_hs n |
| 3778 | put g_tmpu 0 ceil_u f64 0.5 total |
| 3779 | put g_tmpu 1 ceil_u f64 0.9 total |
| 3780 | put g_tmpu 2 ceil_u f64 0.95 total |
| 3781 | put g_tmpu 3 ceil_u f64 0.99 total |
| 3782 | put g_tmpu 4 ceil_u f64 0.999 total |
| 3783 | cum = ulong 0 |
| 3784 | k = ulong 0 |
| 3785 | for i ulong n |
| 3786 | cum = add cum get g_hs_cnt i |
| 3787 | lv = get g_hs_lo i |
| 3788 | while lt k 5 |
| 3789 | if lt cum get g_tmpu k |
| 3790 | break |
| 3791 | end |
| 3792 | put g_pct add k 1 lv |
| 3793 | k = add k 1 |
| 3794 | end |
| 3795 | put g_pct 6 lv |
| 3796 | end |
| 3797 | put g_pct 0 total |
| 3798 | end |
| 3799 | |
| 3800 | note ---- Output: trials array ---- |
| 3801 | fn emit_trial_after_per_op ti ulong to void |
| 3802 | ws = add mul ti W_N W_AFTER |
| 3803 | wops = win_d ti W_AFTER 0 |
| 3804 | o_open t_o_apo uchar 123 |
| 3805 | o_num t_st_0 div win_d ti W_AFTER 7 wops |
| 3806 | o_num t_st_1 div win_d ti W_AFTER 8 wops |
| 3807 | o_num t_st_2 div win_d ti W_AFTER 9 wops |
| 3808 | o_num t_st_3 div win_d ti W_AFTER 10 wops |
| 3809 | o_num t_st_4 div win_d ti W_AFTER 11 wops |
| 3810 | o_num t_st_5 div win_d ti W_AFTER 12 wops |
| 3811 | o_num t_st_6 div win_d ti W_AFTER 13 wops |
| 3812 | o_num t_st_7 div win_d ti W_AFTER 14 wops |
| 3813 | o_num t_st_8 div win_d ti W_AFTER 15 wops |
| 3814 | o_num t_st_9 div win_d ti W_AFTER 16 wops |
| 3815 | o_num t_k_gsb div win_d ti W_AFTER 2 wops |
| 3816 | o_num t_o_cpuns div add win_d ti W_AFTER 3 win_d ti W_AFTER 4 wops |
| 3817 | pok = false |
| 3818 | if ne get g_w_has ws 0 |
| 3819 | if ne get g_w_pmu mul ws 2 0 |
| 3820 | if eq get g_w_pmu add mul ws 2 1 0 |
| 3821 | pok = true |
| 3822 | end |
| 3823 | end |
| 3824 | end |
| 3825 | nan = r15_nan |
| 3826 | if pok |
| 3827 | o_num t_pm_0 div win_d ti W_AFTER 19 wops |
| 3828 | o_num t_pm_1 div win_d ti W_AFTER 20 wops |
| 3829 | o_num t_o_dram div mul win_d ti W_AFTER 21 f64 64.0 wops |
| 3830 | o_num t_o_bus div mul win_d ti W_AFTER 22 f64 64.0 wops |
| 3831 | o_num t_pm_4 div win_d ti W_AFTER 23 wops |
| 3832 | o_num t_pm_5 div win_d ti W_AFTER 24 wops |
| 3833 | else |
| 3834 | o_num t_pm_0 nan |
| 3835 | o_num t_pm_1 nan |
| 3836 | o_num t_o_dram nan |
| 3837 | o_num t_o_bus nan |
| 3838 | o_num t_pm_4 nan |
| 3839 | o_num t_pm_5 nan |
| 3840 | end |
| 3841 | si = win_d ti W_AFTER 25 |
| 3842 | if gt si f64 0.0 |
| 3843 | o_num t_o_r5m div win_d ti W_AFTER 26 si |
| 3844 | else |
| 3845 | o_num t_o_r5m nan |
| 3846 | end |
| 3847 | o_num t_o_r5p win_d ti W_AFTER 27 |
| 3848 | o_num t_o_rcp win_d ti W_AFTER 28 |
| 3849 | o_close uchar 125 |
| 3850 | end |
| 3851 | |
| 3852 | fn record_g1_why ti ulong to void |
| 3853 | put g_tr_st 0 0 |
| 3854 | wlen = get g_slen 0 |
| 3855 | for k ulong wlen |
| 3856 | put g_kbuf k get g_sbuf k |
| 3857 | end |
| 3858 | put g_klen 0 wlen |
| 3859 | sb_reset |
| 3860 | io_put_cs 2 1 mul ti 24 24 |
| 3861 | io_puts 2 t_gn_rnd |
| 3862 | io_put_i64 2 get g_t_rnd ti |
| 3863 | io_puts 2 t_col |
| 3864 | io_putc 2 uchar 32 |
| 3865 | io_put_mem 2 12 0 wlen |
| 3866 | gl = get g_slen 0 |
| 3867 | if gt gl 255 |
| 3868 | gl = 255 |
| 3869 | end |
| 3870 | for k ulong gl |
| 3871 | put g_g1_why k get g_sbuf k |
| 3872 | end |
| 3873 | put g_g1_why gl uchar 0 |
| 3874 | put g_g1_wlen 0 gl |
| 3875 | sb_reset |
| 3876 | io_put_mem 2 12 0 wlen |
| 3877 | end |
| 3878 | |
| 3879 | fn emit_trial_adapt ti ulong to void |
| 3880 | uo = mul ti 3 |
| 3881 | g = get g_t_ad_u uo |
| 3882 | met = get g_t_ad_u add uo 1 |
| 3883 | if and gt met g ne g 0 |
| 3884 | o_num t_o_epw f64 sub met g |
| 3885 | else |
| 3886 | o_num t_o_epw r15_nan |
| 3887 | end |
| 3888 | if and ne g 0 ne met 0 |
| 3889 | o_num t_o_epe tel_energy ti g met |
| 3890 | else |
| 3891 | o_num t_o_epe r15_nan |
| 3892 | end |
| 3893 | o_num t_o_cog sub f64 get g_t_ad_u add uo 2 f64 g |
| 3894 | do = mul ti 8 |
| 3895 | o_num t_o_srch sub get g_t_ad_d do get g_t_ad_d add do 1 |
| 3896 | o_num t_o_gexp sub get g_t_ad_d add do 2 get g_t_ad_d add do 3 |
| 3897 | o_num t_o_prom sub get g_t_ad_d add do 4 get g_t_ad_d add do 5 |
| 3898 | o_num t_k_acost cwin_d ti C_COST 3 |
| 3899 | o_num t_o_gain div sub get g_t_ad_d add do 6 get g_t_ad_d add do 7 f64 1000.0 |
| 3900 | co = crossover_ops ti |
| 3901 | o_num t_o_xops co |
| 3902 | o_num t_o_xs div co win_thr ti W_AFTER |
| 3903 | o_num t_o_wamp wake_amp ti |
| 3904 | o_num t_o_cps per_cons ti cwin_d ti C_SPAN 13 |
| 3905 | o_num t_o_wps per_cons ti cwin_wasted ti C_SPAN |
| 3906 | o_num t_k_replays cwin_d ti C_SPAN 5 |
| 3907 | act = cwin_d ti C_ADAPT 6 |
| 3908 | if gt act f64 0.0 |
| 3909 | inv = cwin_d ti C_ADAPT 7 |
| 3910 | rej = cwin_d ti C_ADAPT 9 |
| 3911 | o_num t_o_ira div inv act |
| 3912 | o_num t_o_cra div add inv rej act |
| 3913 | else |
| 3914 | o_num t_o_ira r15_nan |
| 3915 | o_num t_o_cra r15_nan |
| 3916 | end |
| 3917 | end |
| 3918 | |
| 3919 | fn emit_one_trial ti ulong to void |
| 3920 | ok = trial_correct ti |
| 3921 | put g_tr_st 1 add get g_tr_st 1 1 |
| 3922 | put g_tr_st 2 add get g_tr_st 2 get g_t_sil ti |
| 3923 | if not ok |
| 3924 | if ne get g_tr_st 0 0 |
| 3925 | record_g1_why ti |
| 3926 | end |
| 3927 | end |
| 3928 | o_open_anon uchar 123 |
| 3929 | o_str_cs t_o_file 0 mul ti 256 256 |
| 3930 | o_str_cs t_k_config 1 mul ti 24 24 |
| 3931 | o_num t_k_round f64 get g_t_rnd ti |
| 3932 | o_bool t_k_silicon ne get g_t_sil ti 0 |
| 3933 | o_bool t_o_correct ok |
| 3934 | o_str_mem t_o_why 4 0 get g_slen 0 |
| 3935 | o_num t_o_bops win_thr ti W_BEFORE |
| 3936 | o_num t_o_adops adapt_rate ti |
| 3937 | o_num t_o_afops win_thr ti W_AFTER |
| 3938 | o_num t_o_idlew idle_w ti |
| 3939 | o_num t_o_ean energy_per_op ti W_AFTER |
| 3940 | o_num t_o_eag gross_energy_per_op ti W_AFTER |
| 3941 | o_num t_o_ebn energy_per_op ti W_BEFORE |
| 3942 | o_num t_o_nvml win_d ti W_AFTER 6 |
| 3943 | emit_trial_adapt ti |
| 3944 | emit_trial_after_per_op ti |
| 3945 | if and ne get g_t_sil ti 0 gt get g_res_d mul ti 2 f64 0.0 |
| 3946 | o_num t_o_gres div get g_res_d add mul ti 2 1 get g_res_d mul ti 2 |
| 3947 | else |
| 3948 | o_num t_o_gres r15_nan |
| 3949 | end |
| 3950 | o_close uchar 125 |
| 3951 | end |
| 3952 | |
| 3953 | note ---- Output: metrics 1..17 ---- |
| 3954 | fn emit_m1_m2_m3 to void |
| 3955 | o_open t_o_m1 uchar 123 |
| 3956 | for c ulong 4 |
| 3957 | o_open_cfg c uchar 123 |
| 3958 | bm = med_of c 1 |
| 3959 | nt_c = get g_tmpu 0 |
| 3960 | o_num t_o_bmed bm |
| 3961 | o_num t_o_admed med_of c 2 |
| 3962 | o_num t_o_afmed med_of c 0 |
| 3963 | o_u t_o_trials nt_c |
| 3964 | o_close uchar 125 |
| 3965 | if gt nt_c 0 |
| 3966 | put g_have 1 1 |
| 3967 | end |
| 3968 | end |
| 3969 | o_close uchar 125 |
| 3970 | |
| 3971 | l1_pct_key t_l1m_A t_l1f_lat 0 1 |
| 3972 | for i ulong 7 |
| 3973 | put g_a_res i get g_pct i |
| 3974 | end |
| 3975 | o_open t_o_m2 uchar 123 |
| 3976 | o_pct t_o_l1ar |
| 3977 | l1_pct_key t_l1m_A t_l1f_lat 0 2 |
| 3978 | o_pct t_o_l1as |
| 3979 | for c ulong 4 |
| 3980 | sb_reset |
| 3981 | io_puts 2 t_o_tc_p |
| 3982 | if eq c 0 |
| 3983 | io_puts 2 t_cfg0 |
| 3984 | else |
| 3985 | if eq c 1 |
| 3986 | io_puts 2 t_cfg1 |
| 3987 | else |
| 3988 | if eq c 2 |
| 3989 | io_puts 2 t_cfg2 |
| 3990 | else |
| 3991 | io_puts 2 t_cfg3 |
| 3992 | end |
| 3993 | end |
| 3994 | end |
| 3995 | kl = get g_slen 0 |
| 3996 | for i ulong kl |
| 3997 | put g_kbuf i get g_sbuf i |
| 3998 | end |
| 3999 | put g_klen 0 kl |
| 4000 | hist_pct c |
| 4001 | o_pct_kbuf |
| 4002 | end |
| 4003 | o_close uchar 125 |
| 4004 | if gt get g_a_res 0 0 |
| 4005 | put g_have 2 1 |
| 4006 | end |
| 4007 | |
| 4008 | o_open t_o_m3 uchar 123 |
| 4009 | fan = ulong 1 |
| 4010 | for f ulong 9 |
| 4011 | sb_reset |
| 4012 | io_puts 2 t_o_fan_p |
| 4013 | io_put_u64 2 fan |
| 4014 | kl = get g_slen 0 |
| 4015 | for i ulong kl |
| 4016 | put g_kbuf i get g_sbuf i |
| 4017 | end |
| 4018 | put g_klen 0 kl |
| 4019 | o_open_kbuf uchar 123 |
| 4020 | l1_pct_key t_l1m_B t_l1f_ww fan 1 |
| 4021 | wp50 = get g_pct 1 |
| 4022 | wn = get g_pct 0 |
| 4023 | o_pct t_o_wwall |
| 4024 | l1_pct_key t_l1m_B t_l1f_wc fan 1 |
| 4025 | cp50 = get g_pct 1 |
| 4026 | o_pct t_o_wcpu |
| 4027 | o_num t_o_wp50 div f64 wp50 f64 fan |
| 4028 | o_num t_o_cp50 div f64 cp50 f64 fan |
| 4029 | o_close uchar 125 |
| 4030 | if gt wn 0 |
| 4031 | put g_have 3 1 |
| 4032 | end |
| 4033 | fan = mul fan 2 |
| 4034 | end |
| 4035 | o_num t_o_ffan f64 get g_l1_st 3 |
| 4036 | o_close uchar 125 |
| 4037 | end |
| 4038 | |
| 4039 | fn emit_m4_one c ulong m ulong f ulong to void |
| 4040 | sb_reset |
| 4041 | if eq m 0 |
| 4042 | io_puts 2 t_l1m_Cu |
| 4043 | else |
| 4044 | if eq m 1 |
| 4045 | io_puts 2 t_l1m_Cb |
| 4046 | else |
| 4047 | io_puts 2 t_l1m_Cp |
| 4048 | end |
| 4049 | end |
| 4050 | io_putc 2 uchar 46 |
| 4051 | if eq f 0 |
| 4052 | io_puts 2 t_l1f_sc |
| 4053 | else |
| 4054 | if eq f 1 |
| 4055 | io_puts 2 t_l1f_sw |
| 4056 | else |
| 4057 | if eq f 2 |
| 4058 | io_puts 2 t_l1f_rr |
| 4059 | else |
| 4060 | io_puts 2 t_l1f_dr |
| 4061 | end |
| 4062 | end |
| 4063 | end |
| 4064 | kl = get g_slen 0 |
| 4065 | for i ulong kl |
| 4066 | put g_kbuf i get g_sbuf i |
| 4067 | end |
| 4068 | put g_klen 0 kl |
| 4069 | |
| 4070 | sb_reset |
| 4071 | if eq m 0 |
| 4072 | io_puts 2 t_l1m_Cu |
| 4073 | else |
| 4074 | if eq m 1 |
| 4075 | io_puts 2 t_l1m_Cb |
| 4076 | else |
| 4077 | io_puts 2 t_l1m_Cp |
| 4078 | end |
| 4079 | end |
| 4080 | io_putc 2 uchar 124 |
| 4081 | if eq f 0 |
| 4082 | io_puts 2 t_l1f_sc |
| 4083 | else |
| 4084 | if eq f 1 |
| 4085 | io_puts 2 t_l1f_sw |
| 4086 | else |
| 4087 | if eq f 2 |
| 4088 | io_puts 2 t_l1f_rr |
| 4089 | else |
| 4090 | io_puts 2 t_l1f_dr |
| 4091 | end |
| 4092 | end |
| 4093 | end |
| 4094 | io_putc 2 uchar 124 |
| 4095 | io_putc 2 uchar 48 |
| 4096 | io_putc 2 uchar 124 |
| 4097 | if eq c 0 |
| 4098 | io_puts 2 t_cfg1 |
| 4099 | else |
| 4100 | io_puts 2 t_cfg2 |
| 4101 | end |
| 4102 | idx = l1_find |
| 4103 | if lt idx 0 |
| 4104 | pct_of_sortu 0 |
| 4105 | else |
| 4106 | n = l1_load_sortu ulong idx false |
| 4107 | pct_of_sortu n |
| 4108 | end |
| 4109 | o_pct_kbuf |
| 4110 | if gt get g_pct 0 0 |
| 4111 | put g_have 4 1 |
| 4112 | end |
| 4113 | end |
| 4114 | |
| 4115 | fn emit_m6_bycfg_one src ulong c ulong to void |
| 4116 | nb = get g_nbar 0 |
| 4117 | sn = ulong 0 |
| 4118 | slive = ulong 0 |
| 4119 | for i ulong nb |
| 4120 | if eq get g_bar_tr i src |
| 4121 | if cfg_eq_idx 8 mul i 24 c |
| 4122 | uo = mul i 5 |
| 4123 | rec = get g_bar_u add uo 3 |
| 4124 | if and eq get g_bar_rc i 0 ne rec 0 |
| 4125 | if lt sn R15_SORT_CAP |
| 4126 | put g_sort_u sn sub rec get g_bar_u uo |
| 4127 | end |
| 4128 | sn = add sn 1 |
| 4129 | if gt get g_bar_u add uo 4 0 |
| 4130 | slive = add slive 1 |
| 4131 | end |
| 4132 | end |
| 4133 | end |
| 4134 | end |
| 4135 | end |
| 4136 | if gt sn 0 |
| 4137 | o_open_cfg c uchar 123 |
| 4138 | o_u t_o_bars sn |
| 4139 | o_u t_o_wpc slive |
| 4140 | o_num t_o_frac div f64 slive f64 sn |
| 4141 | pct_of_sortu sn |
| 4142 | o_pct t_o_latns |
| 4143 | o_close uchar 125 |
| 4144 | end |
| 4145 | end |
| 4146 | |
| 4147 | fn emit_m6_bycfg to void |
| 4148 | o_open t_o_bycfg uchar 123 |
| 4149 | for src ulong 2 |
| 4150 | if eq src 0 |
| 4151 | o_open t_k_l1_g uchar 123 |
| 4152 | else |
| 4153 | o_open t_k_trial uchar 123 |
| 4154 | end |
| 4155 | for c ulong 4 |
| 4156 | emit_m6_bycfg_one src c |
| 4157 | end |
| 4158 | o_close uchar 125 |
| 4159 | end |
| 4160 | o_close uchar 125 |
| 4161 | end |
| 4162 | |
| 4163 | fn emit_m4_m5_m6 to void |
| 4164 | o_open t_o_m4 uchar 123 |
| 4165 | for c ulong 2 |
| 4166 | o_open_cfg add c 1 uchar 123 |
| 4167 | for m ulong 3 |
| 4168 | for f ulong 4 |
| 4169 | emit_m4_one c m f |
| 4170 | end |
| 4171 | end |
| 4172 | o_close uchar 125 |
| 4173 | end |
| 4174 | o_close uchar 125 |
| 4175 | |
| 4176 | l1_pct_key_d100 t_l1m_E t_l1f_b100 0 1 |
| 4177 | for i ulong 7 |
| 4178 | put g_e_res i get g_pct i |
| 4179 | end |
| 4180 | o_open t_o_m5 uchar 123 |
| 4181 | o_pct t_o_vchk |
| 4182 | l1_pct_key t_l1m_Ea t_l1f_rtv 0 1 |
| 4183 | o_pct t_o_awgr |
| 4184 | l1_pct_key t_l1m_Ea t_l1f_rtv 0 2 |
| 4185 | o_pct t_o_awgs |
| 4186 | o_close uchar 125 |
| 4187 | if gt get g_e_res 0 0 |
| 4188 | put g_have 5 1 |
| 4189 | end |
| 4190 | |
| 4191 | nb = get g_nbar 0 |
| 4192 | bn = ulong 0 |
| 4193 | blive = ulong 0 |
| 4194 | bfail = ulong 0 |
| 4195 | for i ulong nb |
| 4196 | uo = mul i 5 |
| 4197 | rec = get g_bar_u add uo 3 |
| 4198 | if or ne get g_bar_rc i 0 eq rec 0 |
| 4199 | bfail = add bfail 1 |
| 4200 | else |
| 4201 | if lt bn R15_SORT_CAP |
| 4202 | put g_sort_u bn sub rec get g_bar_u uo |
| 4203 | end |
| 4204 | bn = add bn 1 |
| 4205 | if gt get g_bar_u add uo 4 0 |
| 4206 | blive = add blive 1 |
| 4207 | end |
| 4208 | end |
| 4209 | end |
| 4210 | pct_of_sortu bn |
| 4211 | for i ulong 7 |
| 4212 | put g_bp i get g_pct i |
| 4213 | end |
| 4214 | put g_bar_st 0 bn |
| 4215 | put g_bar_st 1 blive |
| 4216 | put g_bar_st 2 bfail |
| 4217 | o_open t_o_m6 uchar 123 |
| 4218 | o_pct t_o_latns |
| 4219 | o_u t_o_bars bn |
| 4220 | o_u t_o_barf bfail |
| 4221 | if gt bn 0 |
| 4222 | o_num t_o_fpc div f64 blive f64 bn |
| 4223 | else |
| 4224 | o_num t_o_fpc r15_nan |
| 4225 | end |
| 4226 | emit_m6_bycfg |
| 4227 | o_close uchar 125 |
| 4228 | if gt bn 0 |
| 4229 | put g_have 6 1 |
| 4230 | end |
| 4231 | end |
| 4232 | |
| 4233 | fn emit_m7_field c ulong b ulong to void |
| 4234 | nt = get g_nt 0 |
| 4235 | n = ulong 0 |
| 4236 | fidx = add b 7 |
| 4237 | if eq b 10 |
| 4238 | fidx = 2 |
| 4239 | end |
| 4240 | for i ulong nt |
| 4241 | if cfg_eq_idx 1 mul i 24 c |
| 4242 | if ne get g_w_has add mul i W_N W_AFTER 0 |
| 4243 | wops = win_d i W_AFTER 0 |
| 4244 | x = win_d i W_AFTER fidx |
| 4245 | if and gt wops f64 0.0 not is_nan x |
| 4246 | if lt n 512 |
| 4247 | put g_vd n div x wops |
| 4248 | n = add n 1 |
| 4249 | end |
| 4250 | end |
| 4251 | end |
| 4252 | end |
| 4253 | end |
| 4254 | m = median_vd n 0 |
| 4255 | if eq b 0 |
| 4256 | o_num t_st_0 m |
| 4257 | else |
| 4258 | if eq b 1 |
| 4259 | o_num t_st_1 m |
| 4260 | else |
| 4261 | if eq b 2 |
| 4262 | o_num t_st_2 m |
| 4263 | else |
| 4264 | if eq b 3 |
| 4265 | o_num t_st_3 m |
| 4266 | else |
| 4267 | if eq b 4 |
| 4268 | o_num t_st_4 m |
| 4269 | else |
| 4270 | if eq b 5 |
| 4271 | o_num t_st_5 m |
| 4272 | else |
| 4273 | if eq b 6 |
| 4274 | o_num t_st_6 m |
| 4275 | else |
| 4276 | if eq b 7 |
| 4277 | o_num t_st_7 m |
| 4278 | else |
| 4279 | if eq b 8 |
| 4280 | o_num t_st_8 m |
| 4281 | else |
| 4282 | if eq b 9 |
| 4283 | o_num t_st_9 m |
| 4284 | else |
| 4285 | o_num t_k_gsb m |
| 4286 | end |
| 4287 | end |
| 4288 | end |
| 4289 | end |
| 4290 | end |
| 4291 | end |
| 4292 | end |
| 4293 | end |
| 4294 | end |
| 4295 | end |
| 4296 | if gt n 0 |
| 4297 | put g_have 7 1 |
| 4298 | end |
| 4299 | end |
| 4300 | |
| 4301 | fn l2_pool_val p ulong idx ulong to ulong |
| 4302 | if eq p 0 |
| 4303 | ret get g_l2_e2e idx |
| 4304 | end |
| 4305 | if eq p 1 |
| 4306 | ret get g_l2_gpu idx |
| 4307 | end |
| 4308 | if eq p 2 |
| 4309 | ret get g_l2_enq idx |
| 4310 | end |
| 4311 | if eq p 3 |
| 4312 | ret get g_l2_pub idx |
| 4313 | end |
| 4314 | ret get g_l2_dep idx |
| 4315 | end |
| 4316 | |
| 4317 | fn l2_pct_pool c ulong p ulong to void |
| 4318 | nl2 = get g_nl2 0 |
| 4319 | n = ulong 0 |
| 4320 | for i ulong nl2 |
| 4321 | if cfg_eq_idx 9 mul i 24 add c 1 |
| 4322 | off = get g_l2_off add mul i 5 p |
| 4323 | cnt = get g_l2_cnt add mul i 5 p |
| 4324 | for j ulong cnt |
| 4325 | if lt n R15_SORT_CAP |
| 4326 | put g_sort_u n l2_pool_val p add off j |
| 4327 | n = add n 1 |
| 4328 | end |
| 4329 | end |
| 4330 | end |
| 4331 | end |
| 4332 | pct_of_sortu n |
| 4333 | end |
| 4334 | |
| 4335 | fn emit_m8_cfg c ulong to void |
| 4336 | nl2 = get g_nl2 0 |
| 4337 | nsyn = ulong 0 |
| 4338 | nspin = ulong 0 |
| 4339 | runs = ulong 0 |
| 4340 | failed = ulong 0 |
| 4341 | for i ulong nl2 |
| 4342 | if cfg_eq_idx 9 mul i 24 add c 1 |
| 4343 | runs = add runs 1 |
| 4344 | if ne get g_l2_exit i 0 |
| 4345 | failed = add failed 1 |
| 4346 | end |
| 4347 | bo = mul i 4 |
| 4348 | res = get g_l2_wd bo |
| 4349 | if gt res f64 0.0 |
| 4350 | s = add get g_l2_wd add bo 1 mul f64 2.0 res |
| 4351 | s = add s get g_l2_wd add bo 2 |
| 4352 | if lt nsyn 512 |
| 4353 | put g_vd nsyn div s res |
| 4354 | nsyn = add nsyn 1 |
| 4355 | end |
| 4356 | if lt nspin 512 |
| 4357 | put g_vd2 nspin div get g_l2_wd add bo 3 res |
| 4358 | nspin = add nspin 1 |
| 4359 | end |
| 4360 | end |
| 4361 | end |
| 4362 | end |
| 4363 | sm = median_vd nsyn 0 |
| 4364 | spm = median_vd nspin 1 |
| 4365 | put g_sync_m c sm |
| 4366 | put g_spin_m c spm |
| 4367 | o_open_cfg add c 1 uchar 123 |
| 4368 | o_num t_o_runs f64 runs |
| 4369 | o_num t_o_runsf f64 failed |
| 4370 | o_num t_o_smed sm |
| 4371 | o_str t_o_sdef t_o_sdef_v |
| 4372 | o_num t_o_hspin spm |
| 4373 | o_str t_o_hsdef t_o_hsdef_v |
| 4374 | l2_pct_pool c 2 |
| 4375 | o_pct t_o_enq |
| 4376 | l2_pct_pool c 1 |
| 4377 | o_pct t_o_gexec |
| 4378 | l2_pct_pool c 3 |
| 4379 | o_pct t_o_cpub |
| 4380 | l2_pct_pool c 4 |
| 4381 | o_pct t_o_dwake |
| 4382 | l2_pct_pool c 0 |
| 4383 | o_pct t_o_e2e |
| 4384 | o_close uchar 125 |
| 4385 | if gt nsyn 0 |
| 4386 | put g_have 8 1 |
| 4387 | end |
| 4388 | end |
| 4389 | |
| 4390 | fn emit_m7_m8 to void |
| 4391 | o_open t_o_m7 uchar 123 |
| 4392 | for c ulong 4 |
| 4393 | o_open_cfg c uchar 123 |
| 4394 | for b ulong 11 |
| 4395 | emit_m7_field c b |
| 4396 | end |
| 4397 | o_close uchar 125 |
| 4398 | end |
| 4399 | o_str t_o_ctb t_o_ctb_v |
| 4400 | o_close uchar 125 |
| 4401 | |
| 4402 | o_open t_o_m8 uchar 123 |
| 4403 | for c ulong 2 |
| 4404 | emit_m8_cfg c |
| 4405 | end |
| 4406 | o_close uchar 125 |
| 4407 | end |
| 4408 | |
| 4409 | fn emit_m9_field c ulong e ulong to void |
| 4410 | nt = get g_nt 0 |
| 4411 | n = ulong 0 |
| 4412 | mux = ulong 0 |
| 4413 | fidx = ulong 21 |
| 4414 | if eq e 1 |
| 4415 | fidx = 22 |
| 4416 | else |
| 4417 | if eq e 2 |
| 4418 | fidx = 23 |
| 4419 | else |
| 4420 | if eq e 3 |
| 4421 | fidx = 24 |
| 4422 | else |
| 4423 | if eq e 4 |
| 4424 | fidx = 19 |
| 4425 | else |
| 4426 | if eq e 5 |
| 4427 | fidx = 20 |
| 4428 | end |
| 4429 | end |
| 4430 | end |
| 4431 | end |
| 4432 | end |
| 4433 | for i ulong nt |
| 4434 | if cfg_eq_idx 1 mul i 24 c |
| 4435 | ws = add mul i W_N W_AFTER |
| 4436 | if ne get g_w_has ws 0 |
| 4437 | if ne get g_w_pmu mul ws 2 0 |
| 4438 | if ne get g_w_pmu add mul ws 2 1 0 |
| 4439 | if eq e 0 |
| 4440 | mux = add mux 1 |
| 4441 | end |
| 4442 | else |
| 4443 | if lt n 512 |
| 4444 | put g_vd n div win_d i W_AFTER fidx win_d i W_AFTER 0 |
| 4445 | n = add n 1 |
| 4446 | end |
| 4447 | end |
| 4448 | end |
| 4449 | end |
| 4450 | end |
| 4451 | end |
| 4452 | m = median_vd n 0 |
| 4453 | if eq e 0 |
| 4454 | o_num t_pm_2 m |
| 4455 | put g_tmpu 0 n |
| 4456 | put g_tmpu 1 mux |
| 4457 | else |
| 4458 | if eq e 1 |
| 4459 | o_num t_pm_3 m |
| 4460 | else |
| 4461 | if eq e 2 |
| 4462 | o_num t_pm_4 m |
| 4463 | else |
| 4464 | if eq e 3 |
| 4465 | o_num t_pm_5 m |
| 4466 | else |
| 4467 | if eq e 4 |
| 4468 | o_num t_pm_0 m |
| 4469 | else |
| 4470 | o_num t_pm_1 m |
| 4471 | end |
| 4472 | end |
| 4473 | end |
| 4474 | end |
| 4475 | end |
| 4476 | end |
| 4477 | |
| 4478 | fn emit_res_diag slot ulong to void |
| 4479 | if eq get g_res_has slot 0 |
| 4480 | ret |
| 4481 | end |
| 4482 | uo = mul slot 12 |
| 4483 | lost = sub get g_res_u uo get g_res_u add uo 1 |
| 4484 | o_open t_o_wpd uchar 123 |
| 4485 | o_str_mem t_o_proc 6 0 get g_wnlen 0 |
| 4486 | o_u t_o_lsamp lost |
| 4487 | if eq lost 0 |
| 4488 | o_str t_o_class t_o_noloss |
| 4489 | else |
| 4490 | if eq get g_res_hdg slot 0 |
| 4491 | o_str t_o_class t_o_unmeas |
| 4492 | o_str t_o_why t_o_unmeas_w |
| 4493 | else |
| 4494 | longest = get g_res_u add uo 3 |
| 4495 | if ge longest 100 |
| 4496 | o_str t_o_class t_o_stop |
| 4497 | else |
| 4498 | o_str t_o_class t_o_scat |
| 4499 | end |
| 4500 | o_u t_k_dead_runs get g_res_u add uo 2 |
| 4501 | o_u t_k_dead_long longest |
| 4502 | o_u t_k_dead_end get g_res_u add uo 4 |
| 4503 | o_u t_k_late_2ms get g_res_u add uo 5 |
| 4504 | o_u t_k_late_10ms get g_res_u add uo 6 |
| 4505 | o_bool t_o_slobs gt get g_res_u add uo 6 0 |
| 4506 | o_u t_k_max_gap get g_res_u add uo 7 |
| 4507 | o_u t_k_stale_max get g_res_u add uo 8 |
| 4508 | fd = get g_res_u add uo 9 |
| 4509 | tf = get g_res_u add uo 10 |
| 4510 | if and ne fd 0 ne tf 0 |
| 4511 | o_u t_o_fdead_a sub fd tf |
| 4512 | end |
| 4513 | end |
| 4514 | end |
| 4515 | o_close uchar 125 |
| 4516 | end |
| 4517 | |
| 4518 | fn emit_m9 to void |
| 4519 | o_open t_o_m9 uchar 123 |
| 4520 | for c ulong 4 |
| 4521 | o_open_cfg c uchar 123 |
| 4522 | for e ulong 6 |
| 4523 | emit_m9_field c e |
| 4524 | end |
| 4525 | used = get g_tmpu 0 |
| 4526 | mux = get g_tmpu 1 |
| 4527 | o_u t_o_wused used |
| 4528 | o_u t_o_wmux mux |
| 4529 | o_str t_o_deriv t_o_deriv_v |
| 4530 | o_close uchar 125 |
| 4531 | if gt used 0 |
| 4532 | put g_have 9 1 |
| 4533 | end |
| 4534 | end |
| 4535 | o_close uchar 125 |
| 4536 | end |
| 4537 | |
| 4538 | fn save_wname to void |
| 4539 | wl = get g_slen 0 |
| 4540 | for k ulong wl |
| 4541 | put g_wname k get g_sbuf k |
| 4542 | end |
| 4543 | put g_wnlen 0 wl |
| 4544 | end |
| 4545 | |
| 4546 | fn emit_m10 to void |
| 4547 | rmin = r15_nan |
| 4548 | rn = ulong 0 |
| 4549 | worst = long -1 |
| 4550 | nt = get g_nt 0 |
| 4551 | for i ulong nt |
| 4552 | if ne get g_t_sil i 0 |
| 4553 | if ne get g_res_has i 0 |
| 4554 | iv = get g_res_d mul i 2 |
| 4555 | if gt iv f64 0.0 |
| 4556 | r = div get g_res_d add mul i 2 1 iv |
| 4557 | if or is_nan rmin lt r rmin |
| 4558 | rmin = r |
| 4559 | worst = long i |
| 4560 | sb_reset |
| 4561 | io_put_cs 2 0 mul i 256 250 |
| 4562 | save_wname |
| 4563 | end |
| 4564 | rn = add rn 1 |
| 4565 | end |
| 4566 | end |
| 4567 | end |
| 4568 | end |
| 4569 | nl2 = get g_nl2 0 |
| 4570 | for i ulong nl2 |
| 4571 | if ne get g_l2_sil i 0 |
| 4572 | rs = add 512 i |
| 4573 | if ne get g_res_has rs 0 |
| 4574 | iv = get g_res_d mul rs 2 |
| 4575 | if gt iv f64 0.0 |
| 4576 | r = div get g_res_d add mul rs 2 1 iv |
| 4577 | if or is_nan rmin lt r rmin |
| 4578 | rmin = r |
| 4579 | worst = long rs |
| 4580 | sb_reset |
| 4581 | io_puts 2 t_l2_pref |
| 4582 | io_put_cs 2 9 mul i 24 20 |
| 4583 | io_putc 2 uchar 45 |
| 4584 | io_put_u64 2 i |
| 4585 | save_wname |
| 4586 | end |
| 4587 | rn = add rn 1 |
| 4588 | end |
| 4589 | end |
| 4590 | end |
| 4591 | end |
| 4592 | put g_res_min 0 rmin |
| 4593 | put g_res_st 0 rn |
| 4594 | o_open t_o_m10 uchar 123 |
| 4595 | o_num t_o_mfl rmin |
| 4596 | o_u t_o_sproc rn |
| 4597 | if ge worst 0 |
| 4598 | emit_res_diag ulong worst |
| 4599 | end |
| 4600 | o_close uchar 125 |
| 4601 | if gt rn 0 |
| 4602 | put g_have 10 1 |
| 4603 | end |
| 4604 | end |
| 4605 | |
| 4606 | fn emit_m9_m10_m11 to void |
| 4607 | emit_m9 |
| 4608 | emit_m10 |
| 4609 | nt = get g_nt 0 |
| 4610 | o_open t_o_m11 uchar 123 |
| 4611 | for c ulong 4 |
| 4612 | nc = ulong 0 |
| 4613 | ns = ulong 0 |
| 4614 | for i ulong nt |
| 4615 | if cfg_eq_idx 1 mul i 24 c |
| 4616 | if ne get g_w_has add mul i W_N W_AFTER 0 |
| 4617 | if lt nc 512 |
| 4618 | put g_vd nc div add win_d i W_AFTER 3 win_d i W_AFTER 4 win_d i W_AFTER 1 |
| 4619 | nc = add nc 1 |
| 4620 | end |
| 4621 | si = win_d i W_AFTER 25 |
| 4622 | if gt si f64 0.0 |
| 4623 | if lt ns 512 |
| 4624 | put g_vd2 ns div win_d i W_AFTER 26 si |
| 4625 | ns = add ns 1 |
| 4626 | end |
| 4627 | end |
| 4628 | end |
| 4629 | end |
| 4630 | end |
| 4631 | o_open_cfg c uchar 123 |
| 4632 | o_num t_o_pcbm median_vd nc 0 |
| 4633 | o_num t_o_r5mm median_vd ns 1 |
| 4634 | o_close uchar 125 |
| 4635 | if gt nc 0 |
| 4636 | put g_have 11 1 |
| 4637 | end |
| 4638 | end |
| 4639 | o_str t_o_pthr t_o_pthr_v |
| 4640 | o_close uchar 125 |
| 4641 | end |
| 4642 | |
| 4643 | fn emit_m12_15 to void |
| 4644 | nt = get g_nt 0 |
| 4645 | o_open t_o_m1215 uchar 123 |
| 4646 | for c ulong 4 |
| 4647 | o_open_cfg c uchar 123 |
| 4648 | o_num t_o_wpsm med_of c 4 |
| 4649 | ni = ulong 0 |
| 4650 | for i ulong nt |
| 4651 | if cfg_eq_idx 1 mul i 24 c |
| 4652 | if ne get g_cw_has add mul i C_N C_ADAPT 0 |
| 4653 | act = cwin_d i C_ADAPT 6 |
| 4654 | if gt act f64 0.0 |
| 4655 | inv = cwin_d i C_ADAPT 7 |
| 4656 | rej = cwin_d i C_ADAPT 9 |
| 4657 | if lt ni 512 |
| 4658 | put g_vd ni div inv act |
| 4659 | put g_vd2 ni div add inv rej act |
| 4660 | ni = add ni 1 |
| 4661 | end |
| 4662 | end |
| 4663 | end |
| 4664 | end |
| 4665 | end |
| 4666 | o_num t_o_iram median_vd ni 0 |
| 4667 | o_num t_o_cram median_vd ni 1 |
| 4668 | na = ulong 0 |
| 4669 | for i ulong nt |
| 4670 | if cfg_eq_idx 1 mul i 24 c |
| 4671 | if ne get g_cw_has add mul i C_N C_ADAPT 0 |
| 4672 | a = wake_amp i |
| 4673 | if not is_nan a |
| 4674 | if lt na 512 |
| 4675 | put g_vd na a |
| 4676 | na = add na 1 |
| 4677 | end |
| 4678 | end |
| 4679 | end |
| 4680 | end |
| 4681 | end |
| 4682 | o_num t_o_wampm median_vd na 0 |
| 4683 | if gt ni 0 |
| 4684 | put g_have 12 1 |
| 4685 | put g_have 13 1 |
| 4686 | put g_have 14 1 |
| 4687 | end |
| 4688 | if gt na 0 |
| 4689 | put g_have 15 1 |
| 4690 | end |
| 4691 | o_close uchar 125 |
| 4692 | end |
| 4693 | o_close uchar 125 |
| 4694 | end |
| 4695 | |
| 4696 | fn pmu_valid ti ulong to bool |
| 4697 | ws = add mul ti W_N W_AFTER |
| 4698 | if eq get g_w_has ws 0 |
| 4699 | ret false |
| 4700 | end |
| 4701 | if eq get g_w_pmu mul ws 2 0 |
| 4702 | ret false |
| 4703 | end |
| 4704 | ret eq get g_w_pmu add mul ws 2 1 0 |
| 4705 | end |
| 4706 | |
| 4707 | fn emit_m16 to void |
| 4708 | nt = get g_nt 0 |
| 4709 | o_open t_o_m16 uchar 123 |
| 4710 | o_cmp t_o_c_nd 6 |
| 4711 | ncy = ulong 0 |
| 4712 | for i ulong nt |
| 4713 | if cfg_eq_idx 1 mul i 24 1 |
| 4714 | b = find_trial 3 get g_t_rnd i |
| 4715 | if ge b 0 |
| 4716 | bi = ulong b |
| 4717 | if same_realization i bi |
| 4718 | if and pmu_valid i pmu_valid bi |
| 4719 | x = div win_d i W_AFTER 19 win_d i W_AFTER 0 |
| 4720 | y = div win_d bi W_AFTER 19 win_d bi W_AFTER 0 |
| 4721 | if gt y f64 0.0 |
| 4722 | if lt ncy 512 |
| 4723 | put g_vd ncy div x y |
| 4724 | ncy = add ncy 1 |
| 4725 | end |
| 4726 | end |
| 4727 | end |
| 4728 | end |
| 4729 | end |
| 4730 | end |
| 4731 | end |
| 4732 | o_num t_o_cprm median_vd ncy 0 |
| 4733 | o_close uchar 125 |
| 4734 | if gt get g_cmp_u 12 0 |
| 4735 | put g_have 16 1 |
| 4736 | end |
| 4737 | end |
| 4738 | |
| 4739 | fn emit_m17_cfg c ulong to ulong |
| 4740 | nt = get g_nt 0 |
| 4741 | nep = ulong 0 |
| 4742 | ngrs = ulong 0 |
| 4743 | for i ulong nt |
| 4744 | if cfg_eq_idx 1 mul i 24 c |
| 4745 | x = energy_per_op i W_AFTER |
| 4746 | if not is_nan x |
| 4747 | if lt nep 512 |
| 4748 | put g_vd nep x |
| 4749 | nep = add nep 1 |
| 4750 | end |
| 4751 | end |
| 4752 | x2 = gross_energy_per_op i W_AFTER |
| 4753 | if not is_nan x2 |
| 4754 | if lt ngrs 512 |
| 4755 | put g_vd2 ngrs x2 |
| 4756 | ngrs = add ngrs 1 |
| 4757 | end |
| 4758 | end |
| 4759 | end |
| 4760 | end |
| 4761 | m_ep = median_vd nep 0 |
| 4762 | m_eg = median_vd ngrs 1 |
| 4763 | nee = ulong 0 |
| 4764 | nnv = ulong 0 |
| 4765 | for i ulong nt |
| 4766 | if cfg_eq_idx 1 mul i 24 c |
| 4767 | uo = mul i 3 |
| 4768 | g = get g_t_ad_u uo |
| 4769 | met = get g_t_ad_u add uo 1 |
| 4770 | if and ne g 0 ne met 0 |
| 4771 | xe = tel_energy i g met |
| 4772 | if not is_nan xe |
| 4773 | if lt nee 512 |
| 4774 | put g_vd nee xe |
| 4775 | nee = add nee 1 |
| 4776 | end |
| 4777 | end |
| 4778 | end |
| 4779 | xn = div win_d i W_AFTER 6 win_d i W_AFTER 0 |
| 4780 | if not is_nan xn |
| 4781 | if lt nnv 512 |
| 4782 | put g_vd2 nnv xn |
| 4783 | nnv = add nnv 1 |
| 4784 | end |
| 4785 | end |
| 4786 | end |
| 4787 | end |
| 4788 | o_open_cfg c uchar 123 |
| 4789 | o_num t_o_pnet m_ep |
| 4790 | o_num t_o_pgrs m_eg |
| 4791 | o_num t_o_pepi median_vd nee 0 |
| 4792 | o_num t_o_nvmed median_vd nnv 1 |
| 4793 | o_u t_o_wins nep |
| 4794 | o_close uchar 125 |
| 4795 | ret nep |
| 4796 | end |
| 4797 | |
| 4798 | fn emit_m12_to_m17 to void |
| 4799 | emit_m12_15 |
| 4800 | emit_m16 |
| 4801 | o_open t_o_m17 uchar 123 |
| 4802 | en_n = ulong 0 |
| 4803 | for c ulong 4 |
| 4804 | en_n = add en_n emit_m17_cfg c |
| 4805 | end |
| 4806 | o_cmp t_o_c_en 7 |
| 4807 | o_str t_o_unc t_o_unc_v |
| 4808 | o_close uchar 125 |
| 4809 | if gt en_n 0 |
| 4810 | put g_have 17 1 |
| 4811 | end |
| 4812 | o_open t_o_instov uchar 123 |
| 4813 | nw = get g_nw 0 |
| 4814 | for c ulong 2 |
| 4815 | non = ulong 0 |
| 4816 | noff = ulong 0 |
| 4817 | for i ulong nw |
| 4818 | if cfg_eq_idx 10 mul i 24 add c 1 |
| 4819 | if ne get g_wr_tim i 0 |
| 4820 | if lt non 512 |
| 4821 | put g_vd non get g_wr_thr i |
| 4822 | non = add non 1 |
| 4823 | end |
| 4824 | else |
| 4825 | if lt noff 512 |
| 4826 | put g_vd2 noff get g_wr_thr i |
| 4827 | noff = add noff 1 |
| 4828 | end |
| 4829 | end |
| 4830 | end |
| 4831 | end |
| 4832 | o_num_cfg add c 1 div median_vd non 0 median_vd noff 1 |
| 4833 | end |
| 4834 | o_close uchar 125 |
| 4835 | end |
| 4836 | |
| 4837 | note ---- Gates ---- |
| 4838 | fn set_gate idx ulong val f64 pass bool to void |
| 4839 | put g_gt_val idx val |
| 4840 | put g_gt_pass idx b2u pass |
| 4841 | nl = get g_slen 0 |
| 4842 | if gt nl 199 |
| 4843 | nl = 199 |
| 4844 | end |
| 4845 | no = mul idx 200 |
| 4846 | for i ulong nl |
| 4847 | put g_gt_note add no i get g_sbuf i |
| 4848 | end |
| 4849 | put g_gt_note add no nl uchar 0 |
| 4850 | put g_gt_nlen idx nl |
| 4851 | end |
| 4852 | |
| 4853 | fn eval_g5_g8 to void |
| 4854 | sb_reset |
| 4855 | io_puts 2 t_gn_p50 |
| 4856 | io_put_u64 2 get g_a_res 1 |
| 4857 | io_puts 2 t_gn_p99 |
| 4858 | io_put_u64 2 get g_a_res 4 |
| 4859 | io_puts 2 t_gn_nsn |
| 4860 | io_put_u64 2 get g_a_res 0 |
| 4861 | p5 = and gt get g_a_res 0 0 le get g_a_res 1 50000 |
| 4862 | p5 = and p5 le get g_a_res 4 221000 |
| 4863 | p5 = and p5 eq get g_l1_st 2 0 |
| 4864 | set_gate 4 f64 get g_a_res 4 p5 |
| 4865 | |
| 4866 | sb_reset |
| 4867 | io_puts 2 t_gn_p50 |
| 4868 | io_put_u64 2 get g_e_res 1 |
| 4869 | io_puts 2 t_gn_p99 |
| 4870 | io_put_u64 2 get g_e_res 4 |
| 4871 | io_puts 2 t_gn_pchk |
| 4872 | p6 = and gt get g_e_res 0 0 le get g_e_res 1 1000 |
| 4873 | p6 = and p6 le get g_e_res 4 5000 |
| 4874 | set_gate 5 f64 get g_e_res 4 p6 |
| 4875 | |
| 4876 | bn = get g_bar_st 0 |
| 4877 | blive = get g_bar_st 1 |
| 4878 | bfail = get g_bar_st 2 |
| 4879 | lfrac = r15_nan |
| 4880 | if gt bn 0 |
| 4881 | lfrac = div f64 blive f64 bn |
| 4882 | end |
| 4883 | sb_reset |
| 4884 | io_put_u64 2 bn |
| 4885 | io_puts 2 t_gn_bars |
| 4886 | io_put_u64 2 bfail |
| 4887 | io_puts 2 t_gn_bfail |
| 4888 | io_put_u64 2 get g_bp 4 |
| 4889 | io_puts 2 t_gn_ns |
| 4890 | p7 = and gt bn 0 eq bfail 0 |
| 4891 | p7 = and p7 ge lfrac f64 0.90 |
| 4892 | p7 = and p7 le get g_bp 4 500000000 |
| 4893 | set_gate 6 lfrac p7 |
| 4894 | |
| 4895 | sb_reset |
| 4896 | io_put_u64 2 get g_cmp_u 12 |
| 4897 | io_puts 2 t_gn_vp |
| 4898 | set_gate 7 get g_cmp_d 18 and ge get g_cmp_u 12 10 ge get g_cmp_d 18 f64 0.50 |
| 4899 | end |
| 4900 | |
| 4901 | fn eval_gates_1 to void |
| 4902 | nt = get g_nt 0 |
| 4903 | enough = true |
| 4904 | for c ulong 4 |
| 4905 | nc = ulong 0 |
| 4906 | for i ulong nt |
| 4907 | if cfg_eq_idx 1 mul i 24 c |
| 4908 | nc = add nc 1 |
| 4909 | end |
| 4910 | end |
| 4911 | if lt nc 12 |
| 4912 | enough = false |
| 4913 | end |
| 4914 | end |
| 4915 | sb_reset |
| 4916 | gl = get g_g1_wlen 0 |
| 4917 | io_put_mem 2 5 0 gl |
| 4918 | if not enough |
| 4919 | if gt gl 0 |
| 4920 | io_puts 2 t_gn_semi |
| 4921 | end |
| 4922 | io_puts 2 t_gn_f12 |
| 4923 | end |
| 4924 | g1_ok = ne get g_tr_st 0 0 |
| 4925 | comp = get g_tr_st 1 |
| 4926 | set_gate 0 f64 comp and g1_ok and enough gt comp 0 |
| 4927 | |
| 4928 | sb_reset |
| 4929 | io_put_u64 2 get g_cmp_u 0 |
| 4930 | io_puts 2 t_gn_vp10 |
| 4931 | p2 = and ge get g_cmp_u 0 10 ge get g_cmp_d 0 f64 0.90 |
| 4932 | p2 = and p2 ge get g_cmp_d 1 f64 0.85 |
| 4933 | set_gate 1 get g_cmp_d 0 p2 |
| 4934 | |
| 4935 | sb_reset |
| 4936 | set_gate 2 get g_cmp_d 10 and ge get g_cmp_u 6 2 gt get g_cmp_d 10 f64 1.0 |
| 4937 | |
| 4938 | n4 = ulong 0 |
| 4939 | for i ulong nt |
| 4940 | if cfg_eq_idx 1 mul i 24 0 |
| 4941 | a = adapt_rate i |
| 4942 | b = win_thr i W_BEFORE |
| 4943 | if and not is_nan a gt b f64 0.0 |
| 4944 | if lt n4 512 |
| 4945 | put g_vd n4 div a b |
| 4946 | n4 = add n4 1 |
| 4947 | end |
| 4948 | end |
| 4949 | end |
| 4950 | end |
| 4951 | g4 = median_vd n4 0 |
| 4952 | sb_reset |
| 4953 | set_gate 3 g4 and gt n4 0 ge g4 f64 0.50 |
| 4954 | eval_g5_g8 |
| 4955 | end |
| 4956 | |
| 4957 | fn eval_g13_g16 to void |
| 4958 | sb_reset |
| 4959 | set_gate 12 get g_cmp_d 24 and gt get g_cmp_u 16 0 le get g_cmp_d 24 f64 1.10 |
| 4960 | |
| 4961 | nt = get g_nt 0 |
| 4962 | ncr = ulong 0 |
| 4963 | for i ulong nt |
| 4964 | if cfg_eq_idx 1 mul i 24 0 |
| 4965 | if ne get g_cw_has add mul i C_N C_ADAPT 0 |
| 4966 | act = cwin_d i C_ADAPT 6 |
| 4967 | if gt act f64 0.0 |
| 4968 | if lt ncr 512 |
| 4969 | put g_vd ncr div add cwin_d i C_ADAPT 7 cwin_d i C_ADAPT 9 act |
| 4970 | ncr = add ncr 1 |
| 4971 | end |
| 4972 | end |
| 4973 | end |
| 4974 | end |
| 4975 | end |
| 4976 | cr = median_vd ncr 0 |
| 4977 | sb_reset |
| 4978 | set_gate 13 cr and not is_nan cr le cr f64 0.25 |
| 4979 | |
| 4980 | rn = get g_res_st 0 |
| 4981 | silt = get g_tr_st 2 |
| 4982 | rmin = get g_res_min 0 |
| 4983 | sb_reset |
| 4984 | io_put_u64 2 rn |
| 4985 | io_puts 2 t_gn_g15a |
| 4986 | io_put_u64 2 silt |
| 4987 | io_puts 2 t_gn_g15b |
| 4988 | set_gate 14 rmin and gt rn 0 and gt silt 0 ge rmin f64 0.99 |
| 4989 | |
| 4990 | all17 = true |
| 4991 | sb_reset |
| 4992 | m = ulong 1 |
| 4993 | while le m 17 |
| 4994 | if eq get g_have m 0 |
| 4995 | all17 = false |
| 4996 | if eq get g_slen 0 0 |
| 4997 | io_puts 2 t_gn_miss |
| 4998 | else |
| 4999 | io_putc 2 uchar 44 |
| 5000 | end |
| 5001 | io_put_u64 2 m |
| 5002 | end |
| 5003 | m = add m 1 |
| 5004 | end |
| 5005 | v16 = f64 0.0 |
| 5006 | if all17 |
| 5007 | v16 = f64 1.0 |
| 5008 | end |
| 5009 | set_gate 15 v16 all17 |
| 5010 | end |
| 5011 | |
| 5012 | fn eval_gates_2 to void |
| 5013 | sb_reset |
| 5014 | io_put_u64 2 get g_cmp_u 14 |
| 5015 | io_puts 2 t_gn_vp |
| 5016 | p9 = and ge get g_cmp_u 14 10 le get g_cmp_d 21 f64 1.15 |
| 5017 | p9 = and p9 le get g_cmp_d 23 f64 1.25 |
| 5018 | set_gate 8 get g_cmp_d 21 p9 |
| 5019 | |
| 5020 | s0 = get g_sync_m 0 |
| 5021 | s1 = get g_sync_m 1 |
| 5022 | sb_reset |
| 5023 | io_puts 2 t_gn_g10a |
| 5024 | io_put_fix 2 s0 3 |
| 5025 | io_puts 2 t_gn_g10b |
| 5026 | io_put_fix 2 s1 3 |
| 5027 | io_puts 2 t_gn_g10c |
| 5028 | io_put_fix 2 get g_spin_m 0 1 |
| 5029 | io_puts 2 t_gn_g10b |
| 5030 | io_put_fix 2 get g_spin_m 1 1 |
| 5031 | io_puts 2 t_gn_g10d |
| 5032 | set_gate 9 s0 and not is_nan s0 and not is_nan s1 le s0 s1 |
| 5033 | |
| 5034 | co = med_of 0 5 |
| 5035 | nco = get g_tmpu 0 |
| 5036 | sb_reset |
| 5037 | set_gate 10 co and gt nco 0 le co f64 10000000.0 |
| 5038 | |
| 5039 | wa4 = med_of 0 6 |
| 5040 | was = med_of 2 6 |
| 5041 | sb_reset |
| 5042 | io_puts 2 t_gn_g12a |
| 5043 | io_put_fix 2 wa4 3 |
| 5044 | io_puts 2 t_gn_g10b |
| 5045 | io_put_fix 2 was 3 |
| 5046 | io_puts 2 t_gn_g12b |
| 5047 | set_gate 11 wa4 and not is_nan wa4 and not is_nan was le wa4 was |
| 5048 | eval_g13_g16 |
| 5049 | end |
| 5050 | |
| 5051 | fn emit_gate_id ch ulong i ulong to void |
| 5052 | if eq i 0 |
| 5053 | io_puts ch t_gid_0 |
| 5054 | else |
| 5055 | if eq i 1 |
| 5056 | io_puts ch t_gid_1 |
| 5057 | else |
| 5058 | if eq i 2 |
| 5059 | io_puts ch t_gid_2 |
| 5060 | else |
| 5061 | if eq i 3 |
| 5062 | io_puts ch t_gid_3 |
| 5063 | else |
| 5064 | if eq i 4 |
| 5065 | io_puts ch t_gid_4 |
| 5066 | else |
| 5067 | if eq i 5 |
| 5068 | io_puts ch t_gid_5 |
| 5069 | else |
| 5070 | if eq i 6 |
| 5071 | io_puts ch t_gid_6 |
| 5072 | else |
| 5073 | if eq i 7 |
| 5074 | io_puts ch t_gid_7 |
| 5075 | else |
| 5076 | if eq i 8 |
| 5077 | io_puts ch t_gid_8 |
| 5078 | else |
| 5079 | if eq i 9 |
| 5080 | io_puts ch t_gid_9 |
| 5081 | else |
| 5082 | if eq i 10 |
| 5083 | io_puts ch t_gid_10 |
| 5084 | else |
| 5085 | if eq i 11 |
| 5086 | io_puts ch t_gid_11 |
| 5087 | else |
| 5088 | if eq i 12 |
| 5089 | io_puts ch t_gid_12 |
| 5090 | else |
| 5091 | if eq i 13 |
| 5092 | io_puts ch t_gid_13 |
| 5093 | else |
| 5094 | if eq i 14 |
| 5095 | io_puts ch t_gid_14 |
| 5096 | else |
| 5097 | io_puts ch t_gid_15 |
| 5098 | end |
| 5099 | end |
| 5100 | end |
| 5101 | end |
| 5102 | end |
| 5103 | end |
| 5104 | end |
| 5105 | end |
| 5106 | end |
| 5107 | end |
| 5108 | end |
| 5109 | end |
| 5110 | end |
| 5111 | end |
| 5112 | end |
| 5113 | end |
| 5114 | |
| 5115 | fn emit_gate_what i ulong to void |
| 5116 | if eq i 0 |
| 5117 | o_str t_o_crit t_gw_0 |
| 5118 | else |
| 5119 | if eq i 1 |
| 5120 | o_str t_o_crit t_gw_1 |
| 5121 | else |
| 5122 | if eq i 2 |
| 5123 | o_str t_o_crit t_gw_2 |
| 5124 | else |
| 5125 | if eq i 3 |
| 5126 | o_str t_o_crit t_gw_3 |
| 5127 | else |
| 5128 | if eq i 4 |
| 5129 | o_str t_o_crit t_gw_4 |
| 5130 | else |
| 5131 | if eq i 5 |
| 5132 | o_str t_o_crit t_gw_5 |
| 5133 | else |
| 5134 | if eq i 6 |
| 5135 | o_str t_o_crit t_gw_6 |
| 5136 | else |
| 5137 | if eq i 7 |
| 5138 | o_str t_o_crit t_gw_7 |
| 5139 | else |
| 5140 | if eq i 8 |
| 5141 | o_str t_o_crit t_gw_8 |
| 5142 | else |
| 5143 | if eq i 9 |
| 5144 | o_str t_o_crit t_gw_9 |
| 5145 | else |
| 5146 | if eq i 10 |
| 5147 | o_str t_o_crit t_gw_10 |
| 5148 | else |
| 5149 | if eq i 11 |
| 5150 | o_str t_o_crit t_gw_11 |
| 5151 | else |
| 5152 | if eq i 12 |
| 5153 | o_str t_o_crit t_gw_12 |
| 5154 | else |
| 5155 | if eq i 13 |
| 5156 | o_str t_o_crit t_gw_13 |
| 5157 | else |
| 5158 | if eq i 14 |
| 5159 | o_str t_o_crit t_gw_14 |
| 5160 | else |
| 5161 | o_str t_o_crit t_gw_15 |
| 5162 | end |
| 5163 | end |
| 5164 | end |
| 5165 | end |
| 5166 | end |
| 5167 | end |
| 5168 | end |
| 5169 | end |
| 5170 | end |
| 5171 | end |
| 5172 | end |
| 5173 | end |
| 5174 | end |
| 5175 | end |
| 5176 | end |
| 5177 | end |
| 5178 | |
| 5179 | fn emit_gate_thr i ulong to void |
| 5180 | if eq i 0 |
| 5181 | o_str t_o_thr t_gt_0 |
| 5182 | else |
| 5183 | if eq i 1 |
| 5184 | o_str t_o_thr t_gt_1 |
| 5185 | else |
| 5186 | if eq i 2 |
| 5187 | o_str t_o_thr t_gt_2 |
| 5188 | else |
| 5189 | if eq i 3 |
| 5190 | o_str t_o_thr t_gt_3 |
| 5191 | else |
| 5192 | if eq i 4 |
| 5193 | o_str t_o_thr t_gt_4 |
| 5194 | else |
| 5195 | if eq i 5 |
| 5196 | o_str t_o_thr t_gt_5 |
| 5197 | else |
| 5198 | if eq i 6 |
| 5199 | o_str t_o_thr t_gt_6 |
| 5200 | else |
| 5201 | if eq i 7 |
| 5202 | o_str t_o_thr t_gt_7 |
| 5203 | else |
| 5204 | if eq i 8 |
| 5205 | o_str t_o_thr t_gt_8 |
| 5206 | else |
| 5207 | if eq i 9 |
| 5208 | o_str t_o_thr t_gt_9 |
| 5209 | else |
| 5210 | if eq i 10 |
| 5211 | o_str t_o_thr t_gt_10 |
| 5212 | else |
| 5213 | if eq i 11 |
| 5214 | o_str t_o_thr t_gt_11 |
| 5215 | else |
| 5216 | if eq i 12 |
| 5217 | o_str t_o_thr t_gt_12 |
| 5218 | else |
| 5219 | if eq i 13 |
| 5220 | o_str t_o_thr t_gt_13 |
| 5221 | else |
| 5222 | if eq i 14 |
| 5223 | o_str t_o_thr t_gt_14 |
| 5224 | else |
| 5225 | o_str t_o_thr t_gt_15 |
| 5226 | end |
| 5227 | end |
| 5228 | end |
| 5229 | end |
| 5230 | end |
| 5231 | end |
| 5232 | end |
| 5233 | end |
| 5234 | end |
| 5235 | end |
| 5236 | end |
| 5237 | end |
| 5238 | end |
| 5239 | end |
| 5240 | end |
| 5241 | end |
| 5242 | |
| 5243 | fn emit_gates_and_footer to bool |
| 5244 | all = true |
| 5245 | o_open t_o_gates uchar 91 |
| 5246 | for i ulong 16 |
| 5247 | o_open_anon uchar 123 |
| 5248 | o_key t_o_id |
| 5249 | io_putc 0 uchar 34 |
| 5250 | emit_gate_id 0 i |
| 5251 | io_putc 0 uchar 34 |
| 5252 | emit_gate_what i |
| 5253 | emit_gate_thr i |
| 5254 | o_num t_o_val get g_gt_val i |
| 5255 | if ne get g_gt_pass i 0 |
| 5256 | o_str t_o_outc t_pass |
| 5257 | else |
| 5258 | o_str t_o_outc t_fail |
| 5259 | all = false |
| 5260 | end |
| 5261 | o_str_mem t_o_note 7 mul i 200 get g_gt_nlen i |
| 5262 | o_close uchar 125 |
| 5263 | end |
| 5264 | o_close uchar 93 |
| 5265 | o_open t_o_inps uchar 123 |
| 5266 | o_num t_o_trials f64 get g_nt 0 |
| 5267 | o_num t_o_l1p f64 get g_l1_st 0 |
| 5268 | o_num t_o_l1pf f64 get g_l1_st 1 |
| 5269 | o_num t_o_l1tb f64 get g_l1_st 2 |
| 5270 | o_num t_o_l2p f64 get g_nl2 0 |
| 5271 | o_close uchar 125 |
| 5272 | o_bool t_o_agp all |
| 5273 | o_close uchar 125 |
| 5274 | io_putc 0 uchar 10 |
| 5275 | io_flush 0 |
| 5276 | ret all |
| 5277 | end |
| 5278 | |
| 5279 | fn print_stderr_gates all bool to void |
| 5280 | for i ulong 16 |
| 5281 | emit_gate_id 1 i |
| 5282 | if lt i 9 |
| 5283 | io_putc 1 uchar 32 |
| 5284 | io_putc 1 uchar 32 |
| 5285 | else |
| 5286 | io_putc 1 uchar 32 |
| 5287 | end |
| 5288 | io_putc 1 uchar 32 |
| 5289 | if ne get g_gt_pass i 0 |
| 5290 | io_puts 1 t_pass |
| 5291 | else |
| 5292 | io_puts 1 t_fail |
| 5293 | end |
| 5294 | io_putc 1 uchar 32 |
| 5295 | io_put_mem 1 7 mul i 200 get g_gt_nlen i |
| 5296 | io_putc 1 uchar 10 |
| 5297 | end |
| 5298 | io_puts 1 t_all_gates |
| 5299 | if all |
| 5300 | io_puts 1 t_pass |
| 5301 | else |
| 5302 | io_puts 1 t_fail |
| 5303 | end |
| 5304 | io_putc 1 uchar 10 |
| 5305 | io_flush 1 |
| 5306 | end |
| 5307 | |
| 5308 | fn run_comparisons to void |
| 5309 | paired 0 1 2 0 true |
| 5310 | paired 1 0 2 0 true |
| 5311 | paired 2 1 2 1 false |
| 5312 | paired 3 0 2 2 false |
| 5313 | paired 4 1 2 2 false |
| 5314 | paired 5 0 1 0 true |
| 5315 | paired 6 1 3 0 true |
| 5316 | paired 7 1 2 3 true |
| 5317 | paired 8 1 2 4 false |
| 5318 | o_open t_o_cmps uchar 123 |
| 5319 | o_cmp t_o_c_a1s 0 |
| 5320 | o_cmp t_o_c_a4s 1 |
| 5321 | o_cmp t_o_c_a41 5 |
| 5322 | o_cmp t_o_c_b1s 2 |
| 5323 | o_cmp t_o_c_ad4s 3 |
| 5324 | o_cmp t_o_c_ad1s 4 |
| 5325 | o_cmp t_o_c_nd 6 |
| 5326 | o_cmp t_o_c_en 7 |
| 5327 | o_cmp t_o_c_wa 8 |
| 5328 | o_close uchar 125 |
| 5329 | end |
| 5330 | |
| 5331 | fn main to int |
| 5332 | put g_ofd 0 -1 |
| 5333 | put g_l1_nb 0 1 |
| 5334 | ac = argcnt |
| 5335 | if ne ac 3 |
| 5336 | io_puts 1 t_usg |
| 5337 | io_flush 1 |
| 5338 | ret 64 |
| 5339 | end |
| 5340 | dl = argread 1 g_dir 0 1023 |
| 5341 | if lt dl 0 |
| 5342 | ret 2 |
| 5343 | end |
| 5344 | put g_dirlen 0 ulong dl |
| 5345 | ol = argread 2 g_outpath 0 1023 |
| 5346 | if lt ol 0 |
| 5347 | ret 2 |
| 5348 | end |
| 5349 | put g_outlen 0 ulong ol |
| 5350 | |
| 5351 | if lt load_sums_and_dir 0 |
| 5352 | ret 2 |
| 5353 | end |
| 5354 | nf = get g_nfiles 0 |
| 5355 | for i ulong nf |
| 5356 | oi = get g_ford i |
| 5357 | if lt read_jsonl_file oi 0 |
| 5358 | io_puts 1 t_unread |
| 5359 | io_put_mem 1 2 mul oi 256 get g_flen oi |
| 5360 | io_puts 1 t_nl |
| 5361 | io_flush 1 |
| 5362 | ret 2 |
| 5363 | end |
| 5364 | end |
| 5365 | |
| 5366 | fd = fopen g_outpath 0 ulong ol 577 420 |
| 5367 | if lt fd 0 |
| 5368 | ret 2 |
| 5369 | end |
| 5370 | put g_ofd 0 fd |
| 5371 | put g_fdepth 0 0 |
| 5372 | put g_fstack 0 1 |
| 5373 | o_open_anon uchar 123 |
| 5374 | o_str t_o_schema t_o_schema_v |
| 5375 | o_str_mem t_o_rdig 11 0 64 |
| 5376 | o_str t_o_boot t_o_boot_v |
| 5377 | o_open t_o_files uchar 91 |
| 5378 | for i ulong nf |
| 5379 | oi = get g_ford i |
| 5380 | o_open_anon uchar 123 |
| 5381 | o_str_mem t_o_name 2 mul oi 256 get g_flen oi |
| 5382 | o_str_mem t_o_sha256 3 mul oi 64 64 |
| 5383 | o_close uchar 125 |
| 5384 | end |
| 5385 | o_close uchar 93 |
| 5386 | |
| 5387 | put g_tr_st 0 1 |
| 5388 | put g_tr_st 1 0 |
| 5389 | put g_tr_st 2 0 |
| 5390 | put g_g1_wlen 0 0 |
| 5391 | o_open t_o_trials uchar 91 |
| 5392 | nt = get g_nt 0 |
| 5393 | for i ulong nt |
| 5394 | emit_one_trial i |
| 5395 | end |
| 5396 | o_close uchar 93 |
| 5397 | |
| 5398 | run_comparisons |
| 5399 | |
| 5400 | o_open t_o_metrics uchar 123 |
| 5401 | emit_m1_m2_m3 |
| 5402 | emit_m4_m5_m6 |
| 5403 | emit_m7_m8 |
| 5404 | emit_m9_m10_m11 |
| 5405 | emit_m12_to_m17 |
| 5406 | o_close uchar 125 |
| 5407 | |
| 5408 | eval_gates_1 |
| 5409 | eval_gates_2 |
| 5410 | all = emit_gates_and_footer |
| 5411 | _fc = fclose int fd |
| 5412 | put g_ofd 0 -1 |
| 5413 | print_stderr_gates all |
| 5414 | ret 0 |
| 5415 | end |