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 / si / benchmarks / native / neuralese / nl1r / io.om
| 1 | om2 |
| 2 | note NL6 continuation: independent strict parser, never reads producer summaries. |
| 3 | const JCAP ulong 16384 |
| 4 | global JBuf uchar JCAP |
| 5 | global JIo ulong 2 |
| 6 | global JC ulong 8 |
| 7 | global JR ulong 50 |
| 8 | global JP f64 83 |
| 9 | global JH f64 4 |
| 10 | global JU f64 8 |
| 11 | global JS f64 4 |
| 12 | global JB uchar 32 |
| 13 | global Seen ulong 15 |
| 14 | global Logs uchar 7680 |
| 15 | global Sizes ulong 240 |
| 16 | global Stats ulong 360 |
| 17 | text JBAD "NL1RJ INVALID\n" |
| 18 | text JMAG "NL1RJ1,schema,unit,seed,trainmask,group,partition,total,exact,accepted_correct,wrong_accepted,abstained,feature_errors,collision_pairs,encode_ns,decode_ns\n" |
| 19 | text JREC "M," |
| 20 | text JSEP "," |
| 21 | text JLF "\n" |
| 22 | text JEND "NL1RJ END\n" |
| 23 | fn jout a view uchar * to void |
| 24 | p = ulong 0 |
| 25 | while lt p len a |
| 26 | n = write 1 a p sub len a p |
| 27 | if le n 0 |
| 28 | exit 93 |
| 29 | end |
| 30 | p = add p ulong n |
| 31 | end |
| 32 | end |
| 33 | fn jinvalid to void |
| 34 | n = write 2 JBAD 0 len JBAD |
| 35 | exit 90 |
| 36 | end |
| 37 | fn jnext to long |
| 38 | if eq get JIo 0 get JIo 1 |
| 39 | n = read 0 JBuf 0 JCAP |
| 40 | if lt n 0 |
| 41 | jinvalid |
| 42 | end |
| 43 | if eq n 0 |
| 44 | ret -1 |
| 45 | end |
| 46 | put JIo 0 0 |
| 47 | put JIo 1 ulong n |
| 48 | end |
| 49 | p = get JIo 0 |
| 50 | put JIo 0 add p 1 |
| 51 | ret long get JBuf p |
| 52 | end |
| 53 | fn jexpect c long to void |
| 54 | if ne jnext c |
| 55 | jinvalid |
| 56 | end |
| 57 | end |
| 58 | fn jvalue delim long to ulong |
| 59 | v = ulong 0 |
| 60 | n = ulong 0 |
| 61 | first = long -1 |
| 62 | while true bound 21 |
| 63 | c = jnext |
| 64 | if eq c delim |
| 65 | if eq n 0 |
| 66 | jinvalid |
| 67 | end |
| 68 | if and gt n 1 eq first 48 |
| 69 | jinvalid |
| 70 | end |
| 71 | ret v |
| 72 | end |
| 73 | if or lt c 48 gt c 57 |
| 74 | jinvalid |
| 75 | end |
| 76 | if eq n 0 |
| 77 | first = c |
| 78 | end |
| 79 | if or gt v 1844674407370955161 and eq v 1844674407370955161 gt c 53 |
| 80 | jinvalid |
| 81 | end |
| 82 | v = add mul v 10 ulong sub c 48 |
| 83 | n = add n 1 |
| 84 | end |
| 85 | ret 0 |
| 86 | end |
| 87 | fn jnumber v ulong to void |
| 88 | b = new uchar 20 0 |
| 89 | p = ulong 20 |
| 90 | while true bound 20 |
| 91 | p = sub p 1 |
| 92 | put b p uchar add rem v 10 48 |
| 93 | v = div v 10 |
| 94 | if eq v 0 |
| 95 | break |
| 96 | end |
| 97 | end |
| 98 | while lt p 20 bound 20 |
| 99 | n = write 1 b p sub ulong 20 p |
| 100 | if le n 0 |
| 101 | exit 93 |
| 102 | end |
| 103 | p = add p ulong n |
| 104 | end |
| 105 | end |
| 106 | fn jfield v ulong to void |
| 107 | jnumber v |
| 108 | jout JSEP |
| 109 | end |
| 110 | fn jparity id ulong to ulong |
| 111 | ret and xor xor xor id shr id 1 shr id 2 shr id 3 1 |
| 112 | end |
| 113 | fn jsoft x f64 to f64 |
| 114 | ret div x add 1.0f64 fabs x |
| 115 | end |
| 116 | fn jrelu x f64 to f64 |
| 117 | if gt x 0.0f64 |
| 118 | ret x |
| 119 | end |
| 120 | ret 0.0f64 |
| 121 | end |
| 122 | fn jstore k ulong v ulong to void |
| 123 | for b ulong 8 |
| 124 | put JB add mul k 8 b uchar and shr v mul b 8 255 |
| 125 | end |
| 126 | end |
| 127 | fn jload k ulong to ulong |
| 128 | v = ulong 0 |
| 129 | for b ulong 8 |
| 130 | v = or v shl get JR add 3 add mul k 8 b mul b 8 |
| 131 | end |
| 132 | ret v |
| 133 | end |
| 134 | fn jstat group ulong phase ulong col ulong to ulong |
| 135 | ret add mul add mul group 3 phase 8 col |
| 136 | end |
| 137 | fn jinc group ulong phase ulong col ulong val ulong to void |
| 138 | ix = jstat group phase col |
| 139 | put Stats ix add get Stats ix val |
| 140 | end |