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 / core / rsi / tests / reuse-eval / gen-train.om
| 1 | note units: sha256 ref |
| 2 | note needs: gen |
| 3 | note gen-train: TRAIN, TRAINP and CALIB are what contract 7.1 / 7.2 and clarification K8 (f, g) say. |
| 4 | note Generates the three splits into argv[1]; replays every request through ref.om and checks the |
| 5 | note index (magic, version, split id, groups, sessions, request and QUERY counts, group counts, |
| 6 | note holdout digest), every .exp record, the sessions file (ordinal, group, type, family, n class, |
| 7 | note n in {64, 512, 4096}, shape id, program digest, counts, first request index). TRAIN and TRAINP: |
| 8 | note BEGIN + 8 x (SET, QUERY); session s is FSM iff s mod 6 = 5; 10 distinct machines used 4 times |
| 9 | note each, 5 of them permutation machines; at most 24 AGG shapes; at least 50 AGG sessions repeat an |
| 10 | note earlier AGG program exactly; TRAINP's AGG shapes are disjoint from TRAIN's. CALIB: BEGIN + |
| 11 | note 16 x (change, QUERY) with one change class per session (0, 1, 2..64, > 64; only SET and BATCH |
| 12 | note of SET), the session type matching it, and every family x n class x change class cell (the |
| 13 | note R1CAL001 cells) holding at least 4 sessions. |
| 14 | note Exit 0 pass; 1 args; 2 a gen run failed; codes 20..76 name the failed check. |
| 15 | text tgnull "/dev/null" |
| 16 | text tgs1 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" |
| 17 | global TGB uchar 16777216 |
| 18 | global TGC uchar 16777216 |
| 19 | global TGP uchar 4096 |
| 20 | global TGK uchar 4096 |
| 21 | global TGA uchar 4096 |
| 22 | global TGS uchar 4096 |
| 23 | global TGT ulong 16 |
| 24 | global TGST uchar 4 |
| 25 | global TGIX ulong 128 |
| 26 | global TGSS ulong 3840 |
| 27 | global TGPR ulong 15360 |
| 28 | global TGSH ulong 240 |
| 29 | global TGCU ulong 32 |
| 30 | global TGOP ulong 256 |
| 31 | global TGQ ulong 4097 |
| 32 | global TGCN ulong 64 |
| 33 | |
| 34 | note TGT: 0 scratch length, 1 gen path length, 2 path length, 3 packet position, 4 record count, |
| 35 | note 5 directory path length |
| 36 | note TGCU: 0 open session (1), 1 session requests, 2 session QUERYs, 3 cold pending, 5 family, |
| 37 | note 7 ordinal, 8 first failure, 9 requests, 10 QUERYs, 11 slot in group, 12 group, |
| 38 | note 14 changes since the previous QUERY, 15 session change class, 16 split id |
| 39 | |
| 40 | fn tgpput v ulong n ulong to void |
| 41 | l = get TGT 2 |
| 42 | x = v |
| 43 | for i ulong n |
| 44 | put TGP add l i uchar and x 255 |
| 45 | x = shr x 8 |
| 46 | end |
| 47 | put TGT 2 add l n |
| 48 | end |
| 49 | |
| 50 | fn tgdir c ulong to void |
| 51 | l = get TGT 0 |
| 52 | for i ulong l |
| 53 | put TGP i get TGS i |
| 54 | end |
| 55 | put TGT 2 l |
| 56 | tgpput add 47 mul c 256 2 |
| 57 | put TGT 5 get TGT 2 |
| 58 | end |
| 59 | |
| 60 | fn tgfile v ulong n ulong to void |
| 61 | put TGT 2 get TGT 5 |
| 62 | tgpput 47 1 |
| 63 | tgpput v n |
| 64 | end |
| 65 | |
| 66 | fn tggfile g ulong ext ulong to void |
| 67 | put TGT 2 get TGT 5 |
| 68 | tgpput 26415 2 |
| 69 | tgpput add 48 div g 10 1 |
| 70 | tgpput add 48 rem g 10 1 |
| 71 | if eq ext 0 |
| 72 | tgpput 1902473774 4 |
| 73 | else |
| 74 | tgpput 1886938414 4 |
| 75 | end |
| 76 | end |
| 77 | |
| 78 | fn tgkhdr n ulong to ulong |
| 79 | p = get TGT 3 |
| 80 | put TGK p uchar and n 255 |
| 81 | put TGK add p 1 uchar shr n 8 |
| 82 | put TGT 3 add p add n 2 |
| 83 | put TGT 4 add get TGT 4 1 |
| 84 | ret add p 2 |
| 85 | end |
| 86 | |
| 87 | fn tgkgen to void |
| 88 | n = get TGT 1 |
| 89 | p = tgkhdr n |
| 90 | for i ulong n |
| 91 | put TGK add p i get TGA i |
| 92 | end |
| 93 | end |
| 94 | |
| 95 | fn tgkval v ulong n ulong to void |
| 96 | p = tgkhdr n |
| 97 | x = v |
| 98 | for i ulong n |
| 99 | put TGK add p i uchar and x 255 |
| 100 | x = shr x 8 |
| 101 | end |
| 102 | end |
| 103 | |
| 104 | fn tgkpath to void |
| 105 | n = get TGT 2 |
| 106 | p = tgkhdr n |
| 107 | for i ulong n |
| 108 | put TGK add p i get TGP i |
| 109 | end |
| 110 | end |
| 111 | |
| 112 | fn tgkseed to void |
| 113 | p = tgkhdr 64 |
| 114 | for i ulong 64 |
| 115 | put TGK add p i get tgs1 i |
| 116 | end |
| 117 | end |
| 118 | |
| 119 | fn tgexec to ulong |
| 120 | put TGK 0 uchar get TGT 4 |
| 121 | put TGK 1 0 |
| 122 | pid = fork |
| 123 | if lt pid 0 |
| 124 | ret 256 |
| 125 | end |
| 126 | if eq pid 0 |
| 127 | fd = fopen tgnull 0 len tgnull 1 0 |
| 128 | if ge fd 0 |
| 129 | d = dupfd int fd 1 0 |
| 130 | end |
| 131 | r = execprog TGK 0 get TGT 3 |
| 132 | exit 97 |
| 133 | end |
| 134 | w = waitpid int pid TGST 0 4 0 |
| 135 | if or ne w pid ne get TGST 0 0 |
| 136 | ret 256 |
| 137 | end |
| 138 | ret ulong get TGST 1 |
| 139 | end |
| 140 | |
| 141 | fn tggen v ulong n ulong c ulong w ulong to ulong |
| 142 | put TGT 3 2 |
| 143 | put TGT 4 0 |
| 144 | tgkgen |
| 145 | tgkval v n |
| 146 | tgdir c |
| 147 | tgkpath |
| 148 | if ne w 0 |
| 149 | tgkseed |
| 150 | end |
| 151 | ret tgexec |
| 152 | end |
| 153 | |
| 154 | fn tgreadb to ulong |
| 155 | fd = fopen TGP 0 get TGT 2 0 0 |
| 156 | if lt fd 0 |
| 157 | ret 0 |
| 158 | end |
| 159 | n = read int fd TGB 0 len TGB |
| 160 | x = fclose int fd |
| 161 | if lt n 0 |
| 162 | ret 0 |
| 163 | end |
| 164 | ret ulong n |
| 165 | end |
| 166 | |
| 167 | fn tgreadc to ulong |
| 168 | fd = fopen TGP 0 get TGT 2 0 0 |
| 169 | if lt fd 0 |
| 170 | ret 0 |
| 171 | end |
| 172 | n = read int fd TGC 0 len TGC |
| 173 | x = fclose int fd |
| 174 | if lt n 0 |
| 175 | ret 0 |
| 176 | end |
| 177 | ret ulong n |
| 178 | end |
| 179 | |
| 180 | fn tgwb i ulong to ulong |
| 181 | v = ulong 0 |
| 182 | b = mul i 8 |
| 183 | for j ulong 8 |
| 184 | v = or v shl ulong get TGB add b j mul j 8 |
| 185 | end |
| 186 | ret v |
| 187 | end |
| 188 | |
| 189 | fn tgwc i ulong to ulong |
| 190 | v = ulong 0 |
| 191 | b = mul i 8 |
| 192 | for j ulong 8 |
| 193 | v = or v shl ulong get TGC add b j mul j 8 |
| 194 | end |
| 195 | ret v |
| 196 | end |
| 197 | |
| 198 | fn tgerr code ulong to void |
| 199 | if eq get TGCU 8 0 |
| 200 | put TGCU 8 code |
| 201 | end |
| 202 | end |
| 203 | |
| 204 | |
| 205 | fn tgperm to bool |
| 206 | s = get RFP 2 |
| 207 | a = get RFP 3 |
| 208 | for x ulong a |
| 209 | seen = ulong 0 |
| 210 | for st ulong s |
| 211 | t = rfdelta st x |
| 212 | b = shl ulong 1 t |
| 213 | if ne and seen b 0 |
| 214 | ret false |
| 215 | end |
| 216 | seen = or seen b |
| 217 | end |
| 218 | end |
| 219 | ret true |
| 220 | end |
| 221 | |
| 222 | |
| 223 | fn tgabs nb ulong to void |
| 224 | off = ulong 0 |
| 225 | while lt off nb bound 999 |
| 226 | k = sub nb off |
| 227 | if gt k 65536 |
| 228 | k = 65536 |
| 229 | end |
| 230 | for i ulong k |
| 231 | put RFHB i get TGB add off i |
| 232 | end |
| 233 | rfhabs 0 k |
| 234 | off = add off k |
| 235 | end |
| 236 | end |
| 237 | |
| 238 | |
| 239 | note the expected record k against the reference's response; per-QUERY change class |
| 240 | fn tgexpchk k ulong op ulong st ulong to void |
| 241 | b = mul k 8 |
| 242 | if ne st 0 |
| 243 | tgerr 50 |
| 244 | end |
| 245 | if ne tgwc b 0 |
| 246 | tgerr 51 |
| 247 | end |
| 248 | if ne tgwc add b 1 get RFRS 1 |
| 249 | tgerr 51 |
| 250 | end |
| 251 | if ne tgwc add b 2 get RFRS 2 |
| 252 | tgerr 52 |
| 253 | end |
| 254 | if ne tgwc add b 3 get RFRS 3 |
| 255 | tgerr 52 |
| 256 | end |
| 257 | if ne tgwc add b 4 op |
| 258 | tgerr 53 |
| 259 | end |
| 260 | if ne tgwc add b 5 get TGCU 7 |
| 261 | tgerr 53 |
| 262 | end |
| 263 | cold = ulong 0 |
| 264 | if eq op 2 |
| 265 | if eq get TGCU 3 1 |
| 266 | cold = 1 |
| 267 | end |
| 268 | put TGCU 3 0 |
| 269 | put TGCU 2 add get TGCU 2 1 |
| 270 | put TGCU 10 add get TGCU 10 1 |
| 271 | tgqclass |
| 272 | end |
| 273 | if or eq op 1 eq op 8 |
| 274 | put TGCU 3 1 |
| 275 | end |
| 276 | if ne tgwc add b 6 cold |
| 277 | tgerr 54 |
| 278 | end |
| 279 | if ne tgwc add b 7 0 |
| 280 | tgerr 54 |
| 281 | end |
| 282 | end |
| 283 | |
| 284 | note change class of the changes since the previous QUERY: 0, 1, 2..64, > 64; all QUERYs of a |
| 285 | note session must have the same class (TGCU 15, 9 = not yet seen) |
| 286 | fn tgqclass to void |
| 287 | n = get TGCU 14 |
| 288 | c = ulong 3 |
| 289 | if le n 64 |
| 290 | c = 2 |
| 291 | end |
| 292 | if le n 1 |
| 293 | c = n |
| 294 | end |
| 295 | if eq get TGCU 15 9 |
| 296 | put TGCU 15 c |
| 297 | end |
| 298 | if ne get TGCU 15 c |
| 299 | tgerr 58 |
| 300 | end |
| 301 | put TGCU 14 0 |
| 302 | end |
| 303 | |
| 304 | fn tgrec i ulong to ulong |
| 305 | ret get TGSS add mul get TGCU 7 16 i |
| 306 | end |
| 307 | |
| 308 | fn tgendsess to void |
| 309 | if eq get TGCU 0 0 |
| 310 | ret |
| 311 | end |
| 312 | put TGCU 0 0 |
| 313 | nr = get TGCU 1 |
| 314 | nq = get TGCU 2 |
| 315 | if ne tgrec 12 nr |
| 316 | tgerr 20 |
| 317 | end |
| 318 | if ne tgrec 13 nq |
| 319 | tgerr 20 |
| 320 | end |
| 321 | if ne get TGOP sub nr 1 2 |
| 322 | tgerr 21 |
| 323 | end |
| 324 | cl = get TGCU 15 |
| 325 | sid = get TGCU 16 |
| 326 | if eq sid 2 |
| 327 | if ne nq 16 |
| 328 | tgerr 21 |
| 329 | end |
| 330 | want = ulong 33 |
| 331 | if eq cl 0 |
| 332 | want = 17 |
| 333 | end |
| 334 | if ne nr want |
| 335 | tgerr 21 |
| 336 | end |
| 337 | typ = ulong 3 |
| 338 | if lt cl 2 |
| 339 | typ = add cl 1 |
| 340 | end |
| 341 | if ne tgrec 3 typ |
| 342 | tgerr 27 |
| 343 | end |
| 344 | fm = sub get TGCU 5 1 |
| 345 | nc = tgrec 5 |
| 346 | c = add mul fm 12 add mul nc 4 cl |
| 347 | put TGCN c add get TGCN c 1 |
| 348 | else |
| 349 | if or ne nq 8 ne nr 17 |
| 350 | tgerr 21 |
| 351 | end |
| 352 | if ne cl 1 |
| 353 | tgerr 21 |
| 354 | end |
| 355 | if ne tgrec 3 2 |
| 356 | tgerr 27 |
| 357 | end |
| 358 | end |
| 359 | end |
| 360 | |
| 361 | fn tgnewsess k ulong to void |
| 362 | tgendsess |
| 363 | ord = add mul get TGCU 12 8 get TGCU 11 |
| 364 | put TGCU 11 add get TGCU 11 1 |
| 365 | put TGCU 7 ord |
| 366 | put TGCU 0 1 |
| 367 | put TGCU 1 0 |
| 368 | put TGCU 2 0 |
| 369 | put TGCU 14 0 |
| 370 | put TGCU 15 9 |
| 371 | if ge ord 240 |
| 372 | tgerr 22 |
| 373 | put TGCU 7 0 |
| 374 | ret |
| 375 | end |
| 376 | if ne tgrec 0 ord |
| 377 | tgerr 22 |
| 378 | end |
| 379 | if ne tgrec 1 get TGCU 12 |
| 380 | tgerr 22 |
| 381 | end |
| 382 | if ne tgrec 14 k |
| 383 | tgerr 22 |
| 384 | end |
| 385 | if ne tgrec 15 0 |
| 386 | tgerr 22 |
| 387 | end |
| 388 | if ne tgrec 4 0 |
| 389 | tgerr 22 |
| 390 | end |
| 391 | end |
| 392 | |
| 393 | fn tgbegpost to void |
| 394 | n = get RFN 0 |
| 395 | if ne tgrec 2 get RFP 1 |
| 396 | tgerr 23 |
| 397 | end |
| 398 | if ne tgrec 6 n |
| 399 | tgerr 23 |
| 400 | end |
| 401 | nc = tgrec 5 |
| 402 | want = ulong 64 |
| 403 | if eq nc 1 |
| 404 | want = 512 |
| 405 | end |
| 406 | if eq nc 2 |
| 407 | want = 4096 |
| 408 | end |
| 409 | if or gt nc 2 ne n want |
| 410 | tgerr 24 |
| 411 | end |
| 412 | if ne tgrec 7 rfshape |
| 413 | tgerr 25 |
| 414 | end |
| 415 | rfpdig |
| 416 | for j ulong 4 |
| 417 | if ne tgrec add 8 j get RFPD j |
| 418 | tgerr 26 |
| 419 | end |
| 420 | end |
| 421 | put TGCU 5 get RFP 1 |
| 422 | o = get TGCU 7 |
| 423 | for i ulong 64 |
| 424 | put TGPR add mul o 64 i get RFP i |
| 425 | end |
| 426 | end |
| 427 | |
| 428 | fn tgchg op ulong to void |
| 429 | sid = get TGCU 16 |
| 430 | if eq op 3 |
| 431 | put TGCU 14 add get TGCU 14 1 |
| 432 | ret |
| 433 | end |
| 434 | if and eq op 7 eq sid 2 |
| 435 | m = get RFRQ 2 |
| 436 | for i ulong m |
| 437 | if ne get RFRQ add 3 mul i 3 3 |
| 438 | tgerr 42 |
| 439 | end |
| 440 | end |
| 441 | put TGCU 14 add get TGCU 14 m |
| 442 | ret |
| 443 | end |
| 444 | tgerr 42 |
| 445 | end |
| 446 | |
| 447 | fn tgstep w ulong k ulong to ulong |
| 448 | op = tgwb w |
| 449 | p = tgwb add w 1 |
| 450 | if gt p 7234 |
| 451 | tgerr 55 |
| 452 | ret 18446744073709551615 |
| 453 | end |
| 454 | for j ulong add p 2 |
| 455 | put RFRQ j tgwb add w j |
| 456 | end |
| 457 | if eq op 1 |
| 458 | tgnewsess k |
| 459 | else |
| 460 | if ne op 2 |
| 461 | tgchg op |
| 462 | end |
| 463 | end |
| 464 | st = ulong rfreq |
| 465 | if eq op 1 |
| 466 | tgbegpost |
| 467 | end |
| 468 | tgexpchk k op st |
| 469 | r = get TGCU 1 |
| 470 | if lt r 256 |
| 471 | put TGOP r op |
| 472 | end |
| 473 | put TGCU 1 add r 1 |
| 474 | put TGCU 9 add get TGCU 9 1 |
| 475 | ret add w add p 2 |
| 476 | end |
| 477 | |
| 478 | fn tggroup c ulong g ulong to void |
| 479 | tgdir c |
| 480 | tggfile g 0 |
| 481 | nb = tgreadb |
| 482 | tgdir c |
| 483 | tggfile g 1 |
| 484 | ne8 = tgreadc |
| 485 | tgabs nb |
| 486 | nw = div nb 8 |
| 487 | put TGCU 12 g |
| 488 | put TGCU 11 0 |
| 489 | rfreset |
| 490 | w = ulong 0 |
| 491 | k = ulong 0 |
| 492 | while lt w nw bound 99999 |
| 493 | w = tgstep w k |
| 494 | k = add k 1 |
| 495 | end |
| 496 | tgendsess |
| 497 | if ne w nw |
| 498 | tgerr 56 |
| 499 | end |
| 500 | if ne mul k 64 ne8 |
| 501 | tgerr 56 |
| 502 | end |
| 503 | if ne get TGCU 11 8 |
| 504 | tgerr 57 |
| 505 | end |
| 506 | gc = get TGIX add 16 g |
| 507 | if ne k gc |
| 508 | tgerr 57 |
| 509 | end |
| 510 | end |
| 511 | |
| 512 | note index and sessions of directory c into TGIX / TGSS for split sid with G groups |
| 513 | fn tgload c ulong sid ulong g ulong to ulong |
| 514 | s = mul g 8 |
| 515 | tgdir c |
| 516 | tgfile 517097156201 5 |
| 517 | if ne tgreadb mul add 16 g 8 |
| 518 | ret 60 |
| 519 | end |
| 520 | for i ulong add 16 g |
| 521 | put TGIX i tgwb i |
| 522 | end |
| 523 | tgdir c |
| 524 | tgfile 8317708060499076467 8 |
| 525 | if ne tgreadb mul s 128 |
| 526 | ret 61 |
| 527 | end |
| 528 | for j ulong mul s 16 |
| 529 | put TGSS j tgwb j |
| 530 | end |
| 531 | if ne get TGIX 0 3544386032354079058 |
| 532 | ret 62 |
| 533 | end |
| 534 | if ne get TGIX 1 1 |
| 535 | ret 62 |
| 536 | end |
| 537 | if ne get TGIX 2 sid |
| 538 | ret 62 |
| 539 | end |
| 540 | if ne get TGIX 3 g |
| 541 | ret 62 |
| 542 | end |
| 543 | if ne get TGIX 4 s |
| 544 | ret 63 |
| 545 | end |
| 546 | for z ulong 5 |
| 547 | if ne get TGIX add 11 z 0 |
| 548 | ret 62 |
| 549 | end |
| 550 | end |
| 551 | ret 0 |
| 552 | end |
| 553 | |
| 554 | fn tgsplit c ulong sid ulong g ulong nr ulong nq ulong to ulong |
| 555 | e = tgload c sid g |
| 556 | if ne e 0 |
| 557 | ret e |
| 558 | end |
| 559 | for u ulong 64 |
| 560 | put TGCN u 0 |
| 561 | end |
| 562 | put TGCU 8 0 |
| 563 | put TGCU 9 0 |
| 564 | put TGCU 10 0 |
| 565 | put TGCU 16 sid |
| 566 | rfhini 0 |
| 567 | tot = ulong 0 |
| 568 | for i ulong g |
| 569 | tggroup c i |
| 570 | tot = add tot get TGIX add 16 i |
| 571 | end |
| 572 | if ne get TGCU 8 0 |
| 573 | ret get TGCU 8 |
| 574 | end |
| 575 | rfhfin 0 |
| 576 | for d ulong 4 |
| 577 | if ne get RFHD d get TGIX add 7 d |
| 578 | ret 64 |
| 579 | end |
| 580 | end |
| 581 | if or ne tot nr ne get TGIX 5 nr |
| 582 | ret 65 |
| 583 | end |
| 584 | if or ne get TGCU 9 nr ne get TGIX 6 nq |
| 585 | ret 65 |
| 586 | end |
| 587 | if ne get TGCU 10 nq |
| 588 | ret 65 |
| 589 | end |
| 590 | ret 0 |
| 591 | end |
| 592 | |
| 593 | note ---- split-level checks on the BEGIN programs TGPR ---- |
| 594 | |
| 595 | fn tgpreq a ulong b ulong to bool |
| 596 | for j ulong 64 |
| 597 | if ne get TGPR add mul a 64 j get TGPR add mul b 64 j |
| 598 | ret false |
| 599 | end |
| 600 | end |
| 601 | ret true |
| 602 | end |
| 603 | |
| 604 | fn tgrfp r ulong to void |
| 605 | for j ulong 64 |
| 606 | put RFP j get TGPR add mul r 64 j |
| 607 | end |
| 608 | end |
| 609 | |
| 610 | note rows equal to row s (s included); TGCU 20 = 1 when an earlier row is equal |
| 611 | fn tgdup s ulong to ulong |
| 612 | put TGCU 20 0 |
| 613 | cnt = ulong 0 |
| 614 | for t ulong 240 |
| 615 | if tgpreq s t |
| 616 | if lt t s |
| 617 | put TGCU 20 1 |
| 618 | end |
| 619 | cnt = add cnt 1 |
| 620 | end |
| 621 | end |
| 622 | ret cnt |
| 623 | end |
| 624 | |
| 625 | note TRAIN / TRAINP: families by ordinal, 10 machines x 4 (5 permutation), at most 24 AGG shapes, |
| 626 | note at least 50 AGG sessions repeating an earlier AGG program; shapes kept in TGSH (which 1 TRAIN) |
| 627 | note or checked disjoint from them (which 5) |
| 628 | fn tglist which ulong to ulong |
| 629 | mach = ulong 0 |
| 630 | perms = ulong 0 |
| 631 | reuse = ulong 0 |
| 632 | for s ulong 240 |
| 633 | f = get TGPR add mul s 64 1 |
| 634 | want = ulong 1 |
| 635 | if eq rem s 6 5 |
| 636 | want = 2 |
| 637 | end |
| 638 | if ne f want |
| 639 | ret 70 |
| 640 | end |
| 641 | cnt = tgdup s |
| 642 | first = eq get TGCU 20 0 |
| 643 | tgrfp s |
| 644 | if eq f 2 |
| 645 | if ne cnt 4 |
| 646 | ret 71 |
| 647 | end |
| 648 | if first |
| 649 | mach = add mach 1 |
| 650 | if tgperm |
| 651 | perms = add perms 1 |
| 652 | end |
| 653 | end |
| 654 | else |
| 655 | if not first |
| 656 | reuse = add reuse 1 |
| 657 | end |
| 658 | sh = rfshape |
| 659 | if eq which 1 |
| 660 | put TGSH s sh |
| 661 | else |
| 662 | if tghas sh |
| 663 | ret 74 |
| 664 | end |
| 665 | end |
| 666 | end |
| 667 | end |
| 668 | if or ne mach 10 ne perms 5 |
| 669 | ret 72 |
| 670 | end |
| 671 | if lt reuse 50 |
| 672 | ret 73 |
| 673 | end |
| 674 | if gt tgnshape 24 |
| 675 | ret 75 |
| 676 | end |
| 677 | ret 0 |
| 678 | end |
| 679 | |
| 680 | fn tghas sh ulong to bool |
| 681 | for s ulong 240 |
| 682 | if and ne rem s 6 5 eq get TGSH s sh |
| 683 | ret true |
| 684 | end |
| 685 | end |
| 686 | ret false |
| 687 | end |
| 688 | |
| 689 | note distinct AGG shapes of the current split (TGPR rows) |
| 690 | fn tgnshape to ulong |
| 691 | d = ulong 0 |
| 692 | for s ulong 240 |
| 693 | if ne rem s 6 5 |
| 694 | tgrfp s |
| 695 | sh = rfshape |
| 696 | put TGQ s sh |
| 697 | seen = false |
| 698 | for t ulong s |
| 699 | if and ne rem t 6 5 eq get TGQ t sh |
| 700 | seen = true |
| 701 | end |
| 702 | end |
| 703 | if not seen |
| 704 | d = add d 1 |
| 705 | end |
| 706 | end |
| 707 | end |
| 708 | ret d |
| 709 | end |
| 710 | |
| 711 | note CALIB: every cell family x n class x change class has at least 4 sessions |
| 712 | fn tgcells to ulong |
| 713 | for c ulong 24 |
| 714 | if lt get TGCN c 4 |
| 715 | ret 76 |
| 716 | end |
| 717 | end |
| 718 | ret 0 |
| 719 | end |
| 720 | |
| 721 | fn main to int |
| 722 | if lt argcnt 3 |
| 723 | ret 1 |
| 724 | end |
| 725 | l = argread 1 TGS 0 3000 |
| 726 | m = argread 2 TGA 0 3000 |
| 727 | if or le l 0 le m 0 |
| 728 | ret 1 |
| 729 | end |
| 730 | put TGT 0 ulong l |
| 731 | put TGT 1 ulong m |
| 732 | r = tggen 336236466772 5 84 0 |
| 733 | r = or r tggen 88297166688852 6 80 0 |
| 734 | r = or r tggen 284697575747 5 67 0 |
| 735 | if ne r 0 |
| 736 | ret 2 |
| 737 | end |
| 738 | e = tgsplit 84 1 30 4080 1920 |
| 739 | if ne e 0 |
| 740 | ret int e |
| 741 | end |
| 742 | e = tglist 1 |
| 743 | if ne e 0 |
| 744 | ret int e |
| 745 | end |
| 746 | e = tgsplit 80 5 30 4080 1920 |
| 747 | if ne e 0 |
| 748 | ret int e |
| 749 | end |
| 750 | e = tglist 5 |
| 751 | if ne e 0 |
| 752 | ret int e |
| 753 | end |
| 754 | e = tgsplit 67 2 12 2784 1536 |
| 755 | if ne e 0 |
| 756 | ret int e |
| 757 | end |
| 758 | ret int tgcells |
| 759 | end |