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 / dual_experiment / applic_run.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note Copyright 2026 Drake Stapleton (AIEN / aien-dev) |
| 3 | note |
| 4 | note DUAL applicability experiment runner (pure seeded OM-2, composed after |
| 5 | note src/dual_experiment/applic.om). Exact port of applic_run.c: |
| 6 | note Usage: applic_run [out_dir] |
| 7 | note Writes <out_dir>/results.csv, params.txt, results.md and prints summary to stdout. |
| 8 | |
| 9 | global ar_dir uchar 512 |
| 10 | global ar_path uchar 1024 |
| 11 | global ar_io uchar 4096 |
| 12 | global ar_fd int 2 |
| 13 | global ar_dir_len ulong 1 |
| 14 | |
| 15 | note accumulator storage for section_per_workload (13 accs x 3 f64 = 39) |
| 16 | note each acc: [sum, sum2, n] |
| 17 | global ar_acc f64 39 |
| 18 | global ar_v1 f64 192 |
| 19 | global ar_v2 f64 192 |
| 20 | global ar_vc f64 192 |
| 21 | |
| 22 | text ar_t_defdir "evidence/DUAL/applicability" |
| 23 | text ar_t_csv "/results.csv" |
| 24 | text ar_t_par "/params.txt" |
| 25 | text ar_t_md "/results.md" |
| 26 | text ar_t_err_camp "campaign failed (ledger or pool)\n" |
| 27 | text ar_t_err_open "cannot write output file\n" |
| 28 | text ar_t_wrote1 "wrote " |
| 29 | text ar_t_wrote2 "/results.csv, params.txt, results.md\n" |
| 30 | |
| 31 | text ar_t_h1 "# DUAL applicability experiment: results (DUAL-APPLIC-V1)\n\n" |
| 32 | text ar_t_h2 "EXPERIMENTAL. Synthetic workloads. Not a production gate, not a production classifier. Nothing inserted into production.\n\n" |
| 33 | text ar_t_h3 "- parameter digest (SHA-256 of params.txt): `" |
| 34 | text ar_t_h4 "`\n- results digest (SHA-256 of results.csv text): `" |
| 35 | text ar_t_h5 "`\n- runs: 192 (8 workloads x 24 seeds), 100 windows of 20 steps each, 5 warm-up windows unscored\n\n" |
| 36 | |
| 37 | text ar_t_s1a "## 1. Aggregate predictor error per workload (mean over seeds, sd in parentheses)\n\n" |
| 38 | text ar_t_s1b "| workload | completions NRMSE (primary) | known-arrivals completions NRMSE | queue RMSE | blocked RMSE | composite | known-arrivals composite | shuffled composite | cv_demand | top5 share | max item share | class entropy | arrival cv | rejected/run |\n" |
| 39 | text ar_t_s1c "|---|---|---|---|---|---|---|---|---|---|---|---|---|---|\n" |
| 40 | |
| 41 | text ar_t_s2a "\n## 2. Correlation of aggregate prediction error with heterogeneity measurements (Pearson r over all 192 runs)\n\n" |
| 42 | text ar_t_s2b "| measurement | r vs completions NRMSE (primary) | r vs known-arrivals completions NRMSE | r vs queue RMSE | r vs blocked RMSE | r vs composite | covariance vs completions NRMSE | note |\n|---|---|---|---|---|---|---|---|\n" |
| 43 | text ar_t_m0 "cv_demand" |
| 44 | text ar_t_m1 "top5_share" |
| 45 | text ar_t_m2 "max_item_share" |
| 46 | text ar_t_m3 "class_entropy" |
| 47 | text ar_t_m4 "arrival_cv" |
| 48 | text ar_t_m5 "broken_const (control)" |
| 49 | text ar_t_m6 "broken_noise (control)" |
| 50 | text ar_t_n5 "zero variance: covariance exactly 0, r reported as 0" |
| 51 | text ar_t_n6 "independent of the run: expected near 0" |
| 52 | |
| 53 | text ar_t_s2ba "\n## 2b. Heterogeneity sweep (workload h only, 24 runs, offered load held at 0.80, spread rises with seed index)\n\n" |
| 54 | text ar_t_s2bb "- r(cv_demand, completions NRMSE) = " |
| 55 | text ar_t_s2bc "; r(cv_demand, known-arrivals completions NRMSE) = " |
| 56 | text ar_t_s2bd "\n- r(top5_share, completions NRMSE) = " |
| 57 | text ar_t_s2be "; r(top5_share, known-arrivals completions NRMSE) = " |
| 58 | text ar_t_s2bf "\n\n| seed_index | sigma | cv_demand | top5 share | max item share | completions NRMSE | known-arrivals completions NRMSE | blocked RMSE |\n|---|---|---|---|---|---|---|---|\n" |
| 59 | |
| 60 | text ar_t_s3a "\n## 3. Negative control: shuffled-window predictor must be worse than the real predictor\n\n" |
| 61 | text ar_t_s3b "| workload | runs where shuffled composite > real composite | mean real composite | mean shuffled composite |\n|---|---|---|---|\n" |
| 62 | text ar_t_s3c "\nshuffled worse in " |
| 63 | text ar_t_s3d " / 192 runs: " |
| 64 | text ar_t_s3p "CONTROL PASS (majority)\n" |
| 65 | text ar_t_s3f "CONTROL FAIL\n" |
| 66 | |
| 67 | text ar_t_s4a "\n## 4. Regime grid (pre-registered thresholds): PRIMARY measure = completions NRMSE of runs with cv_demand < Y and top5 share < Z (composite beside it)\n\n" |
| 68 | text ar_t_s4b "| Y (cv) | Z (top5) | runs | mean completions NRMSE | p90 | max | mean composite | p90 composite | runs also arrival_cv < 0.50 | p90 completions NRMSE (that subset) |\n|---|---|---|---|---|---|---|---|---|---|\n" |
| 69 | text ar_t_s4c "\ncomplement (cv >= 1.2 or top5 >= 0.30): " |
| 70 | text ar_t_s4d " runs, mean completions NRMSE " |
| 71 | text ar_t_s4e ", p10 " |
| 72 | text ar_t_s4f ", p90 " |
| 73 | text ar_t_s4g "temporal complement (arrival_cv >= 0.50): " |
| 74 | text ar_t_verd "\nVerdict line: EXPERIMENTAL; recommends a future regime classifier; nothing inserted into production.\n" |
| 75 | |
| 76 | text ar_t_bar "| " |
| 77 | text ar_t_sep " | " |
| 78 | text ar_t_end " |\n" |
| 79 | text ar_t_lp " (" |
| 80 | text ar_t_rp ")" |
| 81 | text ar_t_sl " / " |
| 82 | |
| 83 | fn ar_write_fd fd int n ulong to void |
| 84 | off = ulong 0 |
| 85 | while lt off n bound 256 |
| 86 | k = write fd ar_io off sub n off |
| 87 | if le k 0 |
| 88 | ret |
| 89 | end |
| 90 | off = add off ulong k |
| 91 | end |
| 92 | end |
| 93 | |
| 94 | fn ar_emit_io n ulong to void |
| 95 | ar_write_fd int 1 n |
| 96 | mfd = get ar_fd 0 |
| 97 | if ge mfd 0 |
| 98 | ar_write_fd mfd n |
| 99 | end |
| 100 | end |
| 101 | |
| 102 | fn ar_emit_txt s view uchar * to void |
| 103 | n = len s |
| 104 | for i ulong n bound 4096 |
| 105 | put ar_io i get s i |
| 106 | end |
| 107 | ar_emit_io n |
| 108 | end |
| 109 | |
| 110 | fn ar_emit_buf buf view uchar * n ulong to void |
| 111 | for i ulong n bound 4096 |
| 112 | put ar_io i get buf i |
| 113 | end |
| 114 | ar_emit_io n |
| 115 | end |
| 116 | |
| 117 | fn ar_open_out suffix view uchar * to int |
| 118 | dlen = get ar_dir_len 0 |
| 119 | for i ulong dlen bound 512 |
| 120 | put ar_path i get ar_dir i |
| 121 | end |
| 122 | sn = len suffix |
| 123 | for i ulong sn bound 64 |
| 124 | put ar_path add dlen i get suffix i |
| 125 | end |
| 126 | tot = add dlen sn |
| 127 | note O_WRONLY|O_CREAT|O_TRUNC = 1|64|512 = 577, mode 0644 = 420 |
| 128 | fd = fopen ar_path 0 tot int 577 int 420 |
| 129 | if lt fd 0 |
| 130 | ret int -1 |
| 131 | end |
| 132 | ret int fd |
| 133 | end |
| 134 | |
| 135 | fn ar_acc_reset to void |
| 136 | for i ulong 39 |
| 137 | put ar_acc i 0.0f64 |
| 138 | end |
| 139 | end |
| 140 | |
| 141 | fn ar_acc_add idx ulong x f64 to void |
| 142 | b = mul idx 3 |
| 143 | put ar_acc b add get ar_acc b x |
| 144 | put ar_acc add b 1 add get ar_acc add b 1 mul x x |
| 145 | put ar_acc add b 2 add get ar_acc add b 2 1.0f64 |
| 146 | end |
| 147 | |
| 148 | fn ar_acc_mean idx ulong to f64 |
| 149 | b = mul idx 3 |
| 150 | n = get ar_acc add b 2 |
| 151 | if le n 0.0f64 |
| 152 | ret 0.0f64 |
| 153 | end |
| 154 | ret div get ar_acc b n |
| 155 | end |
| 156 | |
| 157 | fn ar_acc_sd idx ulong to f64 |
| 158 | b = mul idx 3 |
| 159 | n = get ar_acc add b 2 |
| 160 | if le n 0.0f64 |
| 161 | ret 0.0f64 |
| 162 | end |
| 163 | m = div get ar_acc b n |
| 164 | v = sub div get ar_acc add b 1 n mul m m |
| 165 | if gt v 0.0f64 |
| 166 | ret fsqrt v |
| 167 | end |
| 168 | ret 0.0f64 |
| 169 | end |
| 170 | |
| 171 | fn ar_sort_f64 a edit f64 * n ulong to void |
| 172 | if lt n 2 |
| 173 | ret |
| 174 | end |
| 175 | i = ulong 1 |
| 176 | while lt i n bound 256 |
| 177 | key = get a i |
| 178 | j = i |
| 179 | while gt j 0 bound 256 |
| 180 | prev = get a sub j 1 |
| 181 | if le prev key |
| 182 | break |
| 183 | end |
| 184 | put a j prev |
| 185 | j = sub j 1 |
| 186 | end |
| 187 | put a j key |
| 188 | i = add i 1 |
| 189 | end |
| 190 | end |
| 191 | |
| 192 | fn ar_quantile a edit f64 * n ulong q f64 to f64 |
| 193 | if eq n 0 |
| 194 | ret 0.0f64 |
| 195 | end |
| 196 | ar_sort_f64 a n |
| 197 | k = ulong add mul q f64 sub n 1 0.5f64 |
| 198 | if ge k n |
| 199 | k = sub n 1 |
| 200 | end |
| 201 | ret get a k |
| 202 | end |
| 203 | |
| 204 | fn ar_buf_ms dst edit uchar * pos ulong idx ulong to ulong |
| 205 | p = pos |
| 206 | p = ap_buf_f64 dst p ar_acc_mean idx 3 false |
| 207 | p = ap_buf_copy dst p ar_t_lp |
| 208 | p = ap_buf_f64 dst p ar_acc_sd idx 3 false |
| 209 | p = ap_buf_copy dst p ar_t_rp |
| 210 | ret p |
| 211 | end |
| 212 | |
| 213 | fn ar_section_per_workload to void |
| 214 | buf = new uchar 512 0 |
| 215 | ar_emit_txt ar_t_s1a |
| 216 | ar_emit_txt ar_t_s1b |
| 217 | ar_emit_txt ar_t_s1c |
| 218 | for wl ulong AP_WL_COUNT |
| 219 | ar_acc_reset |
| 220 | for j ulong AP_NROWS |
| 221 | if eq get ap_row_u mul j 7 wl |
| 222 | rfb = mul j 19 |
| 223 | ar_acc_add 0 get ap_row_f rfb |
| 224 | ar_acc_add 1 get ap_row_f add rfb 4 |
| 225 | ar_acc_add 2 get ap_row_f add rfb 1 |
| 226 | ar_acc_add 3 get ap_row_f add rfb 2 |
| 227 | ar_acc_add 4 get ap_row_f add rfb 3 |
| 228 | ar_acc_add 5 get ap_row_f add rfb 7 |
| 229 | ar_acc_add 6 get ap_row_f add rfb 11 |
| 230 | ar_acc_add 7 get ap_row_f add rfb 12 |
| 231 | ar_acc_add 8 get ap_row_f add rfb 13 |
| 232 | ar_acc_add 9 get ap_row_f add rfb 14 |
| 233 | ar_acc_add 10 get ap_row_f add rfb 15 |
| 234 | ar_acc_add 11 get ap_row_f add rfb 16 |
| 235 | ar_acc_add 12 f64 get ap_row_u add mul j 7 5 |
| 236 | end |
| 237 | end |
| 238 | p = ulong 0 |
| 239 | p = ap_buf_copy buf p ar_t_bar |
| 240 | p = ap_buf_wl_name buf p wl |
| 241 | for c ulong 7 |
| 242 | p = ap_buf_copy buf p ar_t_sep |
| 243 | p = ar_buf_ms buf p c |
| 244 | end |
| 245 | p = ap_buf_copy buf p ar_t_sep |
| 246 | p = ap_buf_f64 buf p ar_acc_mean 7 3 false |
| 247 | p = ap_buf_copy buf p ar_t_sep |
| 248 | p = ap_buf_f64 buf p ar_acc_mean 8 3 false |
| 249 | p = ap_buf_copy buf p ar_t_sep |
| 250 | p = ap_buf_f64 buf p ar_acc_mean 9 4 false |
| 251 | p = ap_buf_copy buf p ar_t_sep |
| 252 | p = ap_buf_f64 buf p ar_acc_mean 10 3 false |
| 253 | p = ap_buf_copy buf p ar_t_sep |
| 254 | p = ap_buf_f64 buf p ar_acc_mean 11 3 false |
| 255 | p = ap_buf_copy buf p ar_t_sep |
| 256 | p = ap_buf_f64 buf p ar_acc_mean 12 1 false |
| 257 | p = ap_buf_copy buf p ar_t_end |
| 258 | ar_emit_buf buf p |
| 259 | end |
| 260 | end |
| 261 | |
| 262 | fn ar_buf_mname dst edit uchar * pos ulong m ulong to ulong |
| 263 | if eq m 0 |
| 264 | ret ap_buf_copy dst pos ar_t_m0 |
| 265 | end |
| 266 | if eq m 1 |
| 267 | ret ap_buf_copy dst pos ar_t_m1 |
| 268 | end |
| 269 | if eq m 2 |
| 270 | ret ap_buf_copy dst pos ar_t_m2 |
| 271 | end |
| 272 | if eq m 3 |
| 273 | ret ap_buf_copy dst pos ar_t_m3 |
| 274 | end |
| 275 | if eq m 4 |
| 276 | ret ap_buf_copy dst pos ar_t_m4 |
| 277 | end |
| 278 | if eq m 5 |
| 279 | ret ap_buf_copy dst pos ar_t_m5 |
| 280 | end |
| 281 | ret ap_buf_copy dst pos ar_t_m6 |
| 282 | end |
| 283 | |
| 284 | fn ar_corr_row m ulong to void |
| 285 | xs = new f64 192 0.0f64 |
| 286 | ys = new f64 192 0.0f64 |
| 287 | for i ulong AP_NROWS |
| 288 | put xs i get ap_row_f add mul i 19 add 12 m |
| 289 | end |
| 290 | buf = new uchar 512 0 |
| 291 | p = ulong 0 |
| 292 | p = ap_buf_copy buf p ar_t_bar |
| 293 | p = ar_buf_mname buf p m |
| 294 | for i ulong AP_NROWS |
| 295 | put ys i get ap_row_f mul i 19 |
| 296 | end |
| 297 | rn = ap_pearson xs ys AP_NROWS |
| 298 | cov = get ap_pearson_f 1 |
| 299 | p = ap_buf_copy buf p ar_t_sep |
| 300 | p = ap_buf_f64 buf p rn 3 true |
| 301 | for i ulong AP_NROWS |
| 302 | put ys i get ap_row_f add mul i 19 4 |
| 303 | end |
| 304 | p = ap_buf_copy buf p ar_t_sep |
| 305 | p = ap_buf_f64 buf p ap_pearson xs ys AP_NROWS 3 true |
| 306 | for i ulong AP_NROWS |
| 307 | put ys i get ap_row_f add mul i 19 1 |
| 308 | end |
| 309 | p = ap_buf_copy buf p ar_t_sep |
| 310 | p = ap_buf_f64 buf p ap_pearson xs ys AP_NROWS 3 true |
| 311 | for i ulong AP_NROWS |
| 312 | put ys i get ap_row_f add mul i 19 2 |
| 313 | end |
| 314 | p = ap_buf_copy buf p ar_t_sep |
| 315 | p = ap_buf_f64 buf p ap_pearson xs ys AP_NROWS 3 true |
| 316 | for i ulong AP_NROWS |
| 317 | put ys i get ap_row_f add mul i 19 3 |
| 318 | end |
| 319 | p = ap_buf_copy buf p ar_t_sep |
| 320 | p = ap_buf_f64 buf p ap_pearson xs ys AP_NROWS 3 true |
| 321 | p = ap_buf_copy buf p ar_t_sep |
| 322 | p = ap_buf_f64 buf p cov 6 true |
| 323 | p = ap_buf_copy buf p ar_t_sep |
| 324 | if eq m 5 |
| 325 | p = ap_buf_copy buf p ar_t_n5 |
| 326 | end |
| 327 | if eq m 6 |
| 328 | p = ap_buf_copy buf p ar_t_n6 |
| 329 | end |
| 330 | p = ap_buf_copy buf p ar_t_end |
| 331 | ar_emit_buf buf p |
| 332 | end |
| 333 | |
| 334 | fn ar_section_correlations to void |
| 335 | ar_emit_txt ar_t_s2a |
| 336 | ar_emit_txt ar_t_s2b |
| 337 | for m ulong 7 |
| 338 | ar_corr_row m |
| 339 | end |
| 340 | end |
| 341 | |
| 342 | fn ar_section_sweep to void |
| 343 | ar_emit_txt ar_t_s2ba |
| 344 | sx = new f64 24 0.0f64 |
| 345 | st = new f64 24 0.0f64 |
| 346 | sy = new f64 24 0.0f64 |
| 347 | sk = new f64 24 0.0f64 |
| 348 | k = ulong 0 |
| 349 | for i ulong AP_NROWS |
| 350 | if and eq get ap_row_u mul i 7 7 lt k AP_SEEDS |
| 351 | rfb = mul i 19 |
| 352 | put sx k get ap_row_f add rfb 12 |
| 353 | put st k get ap_row_f add rfb 13 |
| 354 | put sy k get ap_row_f rfb |
| 355 | put sk k get ap_row_f add rfb 4 |
| 356 | k = add k 1 |
| 357 | end |
| 358 | end |
| 359 | buf = new uchar 512 0 |
| 360 | p = ulong 0 |
| 361 | p = ap_buf_copy buf p ar_t_s2bb |
| 362 | p = ap_buf_f64 buf p ap_pearson sx sy k 3 true |
| 363 | p = ap_buf_copy buf p ar_t_s2bc |
| 364 | p = ap_buf_f64 buf p ap_pearson sx sk k 3 true |
| 365 | p = ap_buf_copy buf p ar_t_s2bd |
| 366 | p = ap_buf_f64 buf p ap_pearson st sy k 3 true |
| 367 | p = ap_buf_copy buf p ar_t_s2be |
| 368 | p = ap_buf_f64 buf p ap_pearson st sk k 3 true |
| 369 | ar_emit_buf buf p |
| 370 | ar_emit_txt ar_t_s2bf |
| 371 | for i ulong AP_NROWS |
| 372 | if eq get ap_row_u mul i 7 7 |
| 373 | si = get ap_row_u add mul i 7 1 |
| 374 | rfb = mul i 19 |
| 375 | p = ulong 0 |
| 376 | p = ap_buf_copy buf p ar_t_bar |
| 377 | p = ap_buf_u64 buf p si |
| 378 | p = ap_buf_copy buf p ar_t_sep |
| 379 | p = ap_buf_f64 buf p ap_sweep_sigma si 3 false |
| 380 | p = ap_buf_copy buf p ar_t_sep |
| 381 | p = ap_buf_f64 buf p get ap_row_f add rfb 12 3 false |
| 382 | p = ap_buf_copy buf p ar_t_sep |
| 383 | p = ap_buf_f64 buf p get ap_row_f add rfb 13 3 false |
| 384 | p = ap_buf_copy buf p ar_t_sep |
| 385 | p = ap_buf_f64 buf p get ap_row_f add rfb 14 4 false |
| 386 | p = ap_buf_copy buf p ar_t_sep |
| 387 | p = ap_buf_f64 buf p get ap_row_f rfb 3 false |
| 388 | p = ap_buf_copy buf p ar_t_sep |
| 389 | p = ap_buf_f64 buf p get ap_row_f add rfb 4 3 false |
| 390 | p = ap_buf_copy buf p ar_t_sep |
| 391 | p = ap_buf_f64 buf p get ap_row_f add rfb 2 3 false |
| 392 | p = ap_buf_copy buf p ar_t_end |
| 393 | ar_emit_buf buf p |
| 394 | end |
| 395 | end |
| 396 | end |
| 397 | |
| 398 | fn ar_section_shuffled to void |
| 399 | ar_emit_txt ar_t_s3a |
| 400 | ar_emit_txt ar_t_s3b |
| 401 | wtot = ulong 0 |
| 402 | buf = new uchar 256 0 |
| 403 | for wl ulong AP_WL_COUNT |
| 404 | worse = ulong 0 |
| 405 | cnt = ulong 0 |
| 406 | ar_acc_reset |
| 407 | for j ulong AP_NROWS |
| 408 | if eq get ap_row_u mul j 7 wl |
| 409 | rfb = mul j 19 |
| 410 | cnt = add cnt 1 |
| 411 | rc = get ap_row_f add rfb 3 |
| 412 | sc = get ap_row_f add rfb 11 |
| 413 | ar_acc_add 0 rc |
| 414 | ar_acc_add 1 sc |
| 415 | if gt sc rc |
| 416 | worse = add worse 1 |
| 417 | end |
| 418 | end |
| 419 | end |
| 420 | wtot = add wtot worse |
| 421 | p = ulong 0 |
| 422 | p = ap_buf_copy buf p ar_t_bar |
| 423 | p = ap_buf_wl_name buf p wl |
| 424 | p = ap_buf_copy buf p ar_t_sep |
| 425 | p = ap_buf_u64 buf p worse |
| 426 | p = ap_buf_copy buf p ar_t_sl |
| 427 | p = ap_buf_u64 buf p cnt |
| 428 | p = ap_buf_copy buf p ar_t_sep |
| 429 | p = ap_buf_f64 buf p ar_acc_mean 0 3 false |
| 430 | p = ap_buf_copy buf p ar_t_sep |
| 431 | p = ap_buf_f64 buf p ar_acc_mean 1 3 false |
| 432 | p = ap_buf_copy buf p ar_t_end |
| 433 | ar_emit_buf buf p |
| 434 | end |
| 435 | p = ulong 0 |
| 436 | p = ap_buf_copy buf p ar_t_s3c |
| 437 | p = ap_buf_u64 buf p wtot |
| 438 | p = ap_buf_copy buf p ar_t_s3d |
| 439 | if gt mul wtot 2 AP_NROWS |
| 440 | p = ap_buf_copy buf p ar_t_s3p |
| 441 | else |
| 442 | p = ap_buf_copy buf p ar_t_s3f |
| 443 | end |
| 444 | ar_emit_buf buf p |
| 445 | end |
| 446 | |
| 447 | fn ar_grid_emit gcv f64 gtop f64 k ulong k2 ulong to void |
| 448 | buf = new uchar 256 0 |
| 449 | p = ulong 0 |
| 450 | p = ap_buf_copy buf p ar_t_bar |
| 451 | p = ap_buf_f64 buf p gcv 1 false |
| 452 | p = ap_buf_copy buf p ar_t_sep |
| 453 | p = ap_buf_f64 buf p gtop 2 false |
| 454 | p = ap_buf_copy buf p ar_t_sep |
| 455 | p = ap_buf_u64 buf p k |
| 456 | p = ap_buf_copy buf p ar_t_sep |
| 457 | p = ap_buf_f64 buf p ar_acc_mean 0 3 false |
| 458 | p = ap_buf_copy buf p ar_t_sep |
| 459 | p = ap_buf_f64 buf p get ar_acc 6 3 false |
| 460 | p = ap_buf_copy buf p ar_t_sep |
| 461 | p = ap_buf_f64 buf p get ar_acc 7 3 false |
| 462 | p = ap_buf_copy buf p ar_t_sep |
| 463 | p = ap_buf_f64 buf p ar_acc_mean 1 3 false |
| 464 | p = ap_buf_copy buf p ar_t_sep |
| 465 | p = ap_buf_f64 buf p get ar_acc 8 3 false |
| 466 | p = ap_buf_copy buf p ar_t_sep |
| 467 | p = ap_buf_u64 buf p k2 |
| 468 | p = ap_buf_copy buf p ar_t_sep |
| 469 | p = ap_buf_f64 buf p get ar_acc 9 3 false |
| 470 | p = ap_buf_copy buf p ar_t_end |
| 471 | ar_emit_buf buf p |
| 472 | end |
| 473 | |
| 474 | fn ar_grid_cell gcv f64 gtop f64 to void |
| 475 | v1 = new f64 192 0.0f64 |
| 476 | v2 = new f64 192 0.0f64 |
| 477 | vc = new f64 192 0.0f64 |
| 478 | k = ulong 0 |
| 479 | k2 = ulong 0 |
| 480 | mx = 0.0f64 |
| 481 | ar_acc_reset |
| 482 | for j ulong AP_NROWS |
| 483 | rfb = mul j 19 |
| 484 | if lt get ap_row_f add rfb 12 gcv |
| 485 | if lt get ap_row_f add rfb 13 gtop |
| 486 | cn = get ap_row_f rfb |
| 487 | cm = get ap_row_f add rfb 3 |
| 488 | put v1 k cn |
| 489 | put vc k cm |
| 490 | k = add k 1 |
| 491 | ar_acc_add 0 cn |
| 492 | ar_acc_add 1 cm |
| 493 | if gt cn mx |
| 494 | mx = cn |
| 495 | end |
| 496 | if lt get ap_row_f add rfb 16 0.5f64 |
| 497 | put v2 k2 cn |
| 498 | k2 = add k2 1 |
| 499 | end |
| 500 | end |
| 501 | end |
| 502 | end |
| 503 | put ar_acc 6 ar_quantile v1 k 0.9f64 |
| 504 | put ar_acc 7 mx |
| 505 | put ar_acc 8 ar_quantile vc k 0.9f64 |
| 506 | put ar_acc 9 ar_quantile v2 k2 0.9f64 |
| 507 | ar_grid_emit gcv gtop k k2 |
| 508 | end |
| 509 | |
| 510 | fn ar_grid_comp_emit lbl view uchar * k ulong p10 f64 p90 f64 to void |
| 511 | buf = new uchar 256 0 |
| 512 | p = ulong 0 |
| 513 | p = ap_buf_copy buf p lbl |
| 514 | p = ap_buf_u64 buf p k |
| 515 | p = ap_buf_copy buf p ar_t_s4d |
| 516 | p = ap_buf_f64 buf p ar_acc_mean 0 3 false |
| 517 | p = ap_buf_copy buf p ar_t_s4e |
| 518 | p = ap_buf_f64 buf p p10 3 false |
| 519 | p = ap_buf_copy buf p ar_t_s4f |
| 520 | p = ap_buf_f64 buf p p90 3 false |
| 521 | p = ap_buf_byte buf p uchar 10 |
| 522 | ar_emit_buf buf p |
| 523 | end |
| 524 | |
| 525 | fn ar_grid_complements to void |
| 526 | v = new f64 192 0.0f64 |
| 527 | k = ulong 0 |
| 528 | ar_acc_reset |
| 529 | for j ulong AP_NROWS |
| 530 | rfb = mul j 19 |
| 531 | ok = false |
| 532 | if ge get ap_row_f add rfb 12 1.2f64 |
| 533 | ok = true |
| 534 | end |
| 535 | if ge get ap_row_f add rfb 13 0.30f64 |
| 536 | ok = true |
| 537 | end |
| 538 | if ok |
| 539 | cn = get ap_row_f rfb |
| 540 | put v k cn |
| 541 | k = add k 1 |
| 542 | ar_acc_add 0 cn |
| 543 | end |
| 544 | end |
| 545 | ar_grid_comp_emit ar_t_s4c k ar_quantile v k 0.1f64 ar_quantile v k 0.9f64 |
| 546 | k = ulong 0 |
| 547 | ar_acc_reset |
| 548 | for j ulong AP_NROWS |
| 549 | rfb = mul j 19 |
| 550 | if ge get ap_row_f add rfb 16 0.5f64 |
| 551 | cn = get ap_row_f rfb |
| 552 | put v k cn |
| 553 | k = add k 1 |
| 554 | ar_acc_add 0 cn |
| 555 | end |
| 556 | end |
| 557 | ar_grid_comp_emit ar_t_s4g k ar_quantile v k 0.1f64 ar_quantile v k 0.9f64 |
| 558 | end |
| 559 | |
| 560 | fn ar_section_grid to void |
| 561 | ar_emit_txt ar_t_s4a |
| 562 | ar_emit_txt ar_t_s4b |
| 563 | gcv = new f64 3 0.0f64 |
| 564 | gtop = new f64 3 0.0f64 |
| 565 | put gcv 0 0.4f64 |
| 566 | put gcv 1 0.8f64 |
| 567 | put gcv 2 1.2f64 |
| 568 | put gtop 0 0.10f64 |
| 569 | put gtop 1 0.20f64 |
| 570 | put gtop 2 0.30f64 |
| 571 | for a ulong 3 |
| 572 | for b ulong 3 |
| 573 | ar_grid_cell get gcv a get gtop b |
| 574 | end |
| 575 | end |
| 576 | ar_grid_complements |
| 577 | end |
| 578 | |
| 579 | fn ar_write_csv_file to int |
| 580 | fd = ar_open_out ar_t_csv |
| 581 | if lt fd 0 |
| 582 | ret int -1 |
| 583 | end |
| 584 | hn = ap_row_header_to_line |
| 585 | for i ulong hn bound 512 |
| 586 | put ar_io i get ap_line_buf i |
| 587 | end |
| 588 | put ar_io hn uchar 10 |
| 589 | ar_write_fd fd add hn 1 |
| 590 | for r ulong AP_NROWS |
| 591 | ln = ap_row_format_to_line 0 r |
| 592 | for i ulong ln bound 512 |
| 593 | put ar_io i get ap_line_buf i |
| 594 | end |
| 595 | put ar_io ln uchar 10 |
| 596 | ar_write_fd fd add ln 1 |
| 597 | end |
| 598 | cl = fclose fd |
| 599 | ret int 0 |
| 600 | end |
| 601 | |
| 602 | fn ar_write_params_file to int |
| 603 | fd = ar_open_out ar_t_par |
| 604 | if lt fd 0 |
| 605 | ret int -1 |
| 606 | end |
| 607 | pn = ap_params_text_to_pbuf |
| 608 | for i ulong pn bound 2048 |
| 609 | put ar_io i get ap_pbuf i |
| 610 | end |
| 611 | ar_write_fd fd pn |
| 612 | cl = fclose fd |
| 613 | ret int 0 |
| 614 | end |
| 615 | |
| 616 | fn ar_err_die msg view uchar * to void |
| 617 | n = len msg |
| 618 | for i ulong n bound 256 |
| 619 | put ar_io i get msg i |
| 620 | end |
| 621 | ar_write_fd int 2 n |
| 622 | end |
| 623 | |
| 624 | fn main to int |
| 625 | put ar_fd 0 int -1 |
| 626 | ac = argcnt |
| 627 | if gt ac 1 |
| 628 | al = argread 1 ar_dir 0 512 |
| 629 | if le al 0 |
| 630 | ar_err_die ar_t_err_open |
| 631 | ret int 2 |
| 632 | end |
| 633 | put ar_dir_len 0 ulong al |
| 634 | else |
| 635 | dn = len ar_t_defdir |
| 636 | for i ulong dn bound 64 |
| 637 | put ar_dir i get ar_t_defdir i |
| 638 | end |
| 639 | put ar_dir_len 0 dn |
| 640 | end |
| 641 | if ne ap_campaign 0 0 0 |
| 642 | ar_err_die ar_t_err_camp |
| 643 | ret int 2 |
| 644 | end |
| 645 | if lt ar_write_csv_file 0 |
| 646 | ar_err_die ar_t_err_open |
| 647 | ret int 2 |
| 648 | end |
| 649 | if lt ar_write_params_file 0 |
| 650 | ar_err_die ar_t_err_open |
| 651 | ret int 2 |
| 652 | end |
| 653 | mfd = ar_open_out ar_t_md |
| 654 | if lt mfd 0 |
| 655 | ar_err_die ar_t_err_open |
| 656 | ret int 2 |
| 657 | end |
| 658 | put ar_fd 0 mfd |
| 659 | ar_emit_txt ar_t_h1 |
| 660 | ar_emit_txt ar_t_h2 |
| 661 | ar_emit_txt ar_t_h3 |
| 662 | pd = new uchar 32 0 |
| 663 | hx = new uchar 64 0 |
| 664 | ap_params_digest pd |
| 665 | p1 = ap_buf_hex32 hx 0 pd |
| 666 | ar_emit_buf hx 64 |
| 667 | ar_emit_txt ar_t_h4 |
| 668 | rd = new uchar 32 0 |
| 669 | ap_rows_digest 0 AP_NROWS rd |
| 670 | p2 = ap_buf_hex32 hx 0 rd |
| 671 | ar_emit_buf hx 64 |
| 672 | ar_emit_txt ar_t_h5 |
| 673 | ar_section_per_workload |
| 674 | ar_section_correlations |
| 675 | ar_section_sweep |
| 676 | ar_section_shuffled |
| 677 | ar_section_grid |
| 678 | ar_emit_txt ar_t_verd |
| 679 | cl = fclose mfd |
| 680 | put ar_fd 0 int -1 |
| 681 | buf = new uchar 600 0 |
| 682 | p = ulong 0 |
| 683 | p = ap_buf_copy buf p ar_t_wrote1 |
| 684 | dlen = get ar_dir_len 0 |
| 685 | for i ulong dlen bound 512 |
| 686 | put buf add p i get ar_dir i |
| 687 | end |
| 688 | p = add p dlen |
| 689 | p = ap_buf_copy buf p ar_t_wrote2 |
| 690 | ar_emit_buf buf p |
| 691 | ret int 0 |
| 692 | end |