Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/bench/inference_cost/io.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / bench / inference_cost / io.om` 131 lines ยท 1939 bytes Raw Blame History 1 note bench/inference_cost/io.om -- stdin argument reader and decimal writer. 2 note driver.sh builds an Omega candidate's unit as: the line "om2 diag", the candidate, 3 note this unit, then a generated fn main that calls the candidate once per case of 4 note inputs.txt. Exit 90..93 are harness I/O failures. 5 global bxin uchar 65536 6 global bxst ulong 2 7 global bxob uchar 24 8 9 fn bench_load to void 10 p = ulong 0 11 note every pass adds at least one byte to the 65536-byte buffer or leaves the loop 12 while lt p 65536 bound 65537 13 k = read 0 bxin p sub 65536 p 14 if lt k 0 15 exit 90 16 end 17 if eq k 0 18 break 19 end 20 p = add p ulong k 21 end 22 if ge p 65536 23 exit 91 24 end 25 put bxst 0 0 26 put bxst 1 p 27 end 28 29 fn bench_ws to void 30 p = get bxst 0 31 n = get bxst 1 32 while lt p n bound 65537 33 c = get bxin p 34 if gt c 32 35 break 36 end 37 p = add p 1 38 end 39 put bxst 0 p 40 end 41 42 fn bench_skip to void 43 bench_ws 44 p = get bxst 0 45 n = get bxst 1 46 while lt p n bound 65537 47 c = get bxin p 48 if le c 32 49 break 50 end 51 p = add p 1 52 end 53 put bxst 0 p 54 end 55 56 fn bench_arg to long 57 bench_ws 58 p = get bxst 0 59 n = get bxst 1 60 sg = long 1 61 if lt p n 62 if eq get bxin p 45 63 sg = long -1 64 p = add p 1 65 end 66 end 67 v = long 0 68 d = ulong 0 69 note at most 20 digits fit a long-sized decimal; more is refused below by the checked mul 70 while lt p n bound 65537 71 c = get bxin p 72 if lt c 48 73 break 74 end 75 if gt c 57 76 break 77 end 78 v = add mul v 10 long sub c 48 79 p = add p 1 80 d = add d 1 81 end 82 if eq d 0 83 exit 92 84 end 85 put bxst 0 p 86 ret mul v sg 87 end 88 89 fn bench_cases to ulong 90 bench_skip 91 bench_skip 92 bench_skip 93 v = bench_arg 94 if lt v 0 95 exit 92 96 end 97 ret ulong v 98 end 99 100 fn bench_putu x ulong to void 101 v = x 102 i = ulong 23 103 put bxob i 10 104 note a ulong has at most 20 decimal digits 105 for j ulong 21 106 i = sub i 1 107 put bxob i uchar add rem v 10 48 108 v = div v 10 109 if eq v 0 110 break 111 end 112 end 113 n = sub 24 i 114 w = write 1 bxob i n 115 if ne w long n 116 exit 93 117 end 118 end 119 120 fn bench_puti x long to void 121 if lt x 0 122 put bxob 0 45 123 w = write 1 bxob 0 1 124 if ne w 1 125 exit 93 126 end 127 bench_putu ulong neg x 128 else 129 bench_putu ulong x 130 end 131 end