aien-train
AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.
Brought by drakestapleton
aien-train / native / collective / admit / cli-main.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note DRA-15 / aien-train#26 P0 admission, one case per process. Appended after |
| 3 | note every line of native/collective/admit_p0.om before its fn main, |
| 4 | note byte-identical, by native/collective/admit/run.sh. argv[1] is a case |
| 5 | note number 0..45 in decimal. An admitted case writes "Y y0 y1" and a newline |
| 6 | note and exits 0. A refused case writes nothing to stdout and exits with |
| 7 | note minus its status (1..16). Usage errors exit 96..99, never 0. The |
| 8 | note judge is expected-cli.out (Wolfram); this tail checks nothing itself. |
| 9 | |
| 10 | global Buf uchar 128 |
| 11 | global Pos ulong 1 |
| 12 | global Ab uchar 32 |
| 13 | |
| 14 | text ty "Y" |
| 15 | |
| 16 | fn pc c ulong to void |
| 17 | p = get Pos 0 |
| 18 | put Buf p uchar c |
| 19 | put Pos 0 add p 1 |
| 20 | end |
| 21 | |
| 22 | note Appends one space and the signed decimal of v to Buf. |
| 23 | fn pnum v long to void |
| 24 | d = new uchar 20 0 |
| 25 | pc 32 |
| 26 | u = ulong 0 |
| 27 | if lt v 0 |
| 28 | pc 45 |
| 29 | u = ulong neg v |
| 30 | else |
| 31 | u = ulong v |
| 32 | end |
| 33 | n = ulong 0 |
| 34 | c = true |
| 35 | while c bound 20 |
| 36 | put d n uchar add rem u 10 48 |
| 37 | n = add n 1 |
| 38 | u = div u 10 |
| 39 | if eq u 0 |
| 40 | c = false |
| 41 | end |
| 42 | end |
| 43 | for i ulong 20 |
| 44 | if lt i n |
| 45 | pc ulong get d sub sub n 1 i |
| 46 | end |
| 47 | end |
| 48 | end |
| 49 | |
| 50 | fn flush to void |
| 51 | p = get Pos 0 |
| 52 | put Buf p uchar 10 |
| 53 | k = write 1 Buf 0 add p 1 |
| 54 | put Pos 0 0 |
| 55 | end |
| 56 | |
| 57 | note Decimal argv[1]; 99 when absent, 98 when empty or too long, 97 on a |
| 58 | note non-digit, 96 when not below NCASE. |
| 59 | fn argcase to ulong |
| 60 | if lt argcnt 2 |
| 61 | exit 99 |
| 62 | end |
| 63 | k = argread 1 Ab 0 32 |
| 64 | if le k 0 |
| 65 | exit 98 |
| 66 | end |
| 67 | if gt k 4 |
| 68 | exit 98 |
| 69 | end |
| 70 | m = ulong k |
| 71 | n = ulong 0 |
| 72 | for i ulong m |
| 73 | ch = ulong get Ab i |
| 74 | if lt ch 48 |
| 75 | exit 97 |
| 76 | end |
| 77 | if gt ch 57 |
| 78 | exit 97 |
| 79 | end |
| 80 | n = add mul n 10 sub ch 48 |
| 81 | end |
| 82 | if ge n NCASE |
| 83 | exit 96 |
| 84 | end |
| 85 | ret n |
| 86 | end |
| 87 | |
| 88 | fn main to int |
| 89 | n = argcase |
| 90 | setcase n |
| 91 | s = run |
| 92 | if ne s 0 |
| 93 | ret int neg s |
| 94 | end |
| 95 | k = write 1 ty 0 len ty |
| 96 | pnum get Yv 0 |
| 97 | pnum get Yv 1 |
| 98 | flush |
| 99 | ret 0 |
| 100 | end |