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/gpu/head-to-head/main.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 / gpu / head-to-head / main.om` 294 lines ยท 6271 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gpu/head-to-head/main.om: CLI reading paired benchmark records on stdin and printing verified 3 note comparison statistics, numerical parity results, mutant-control verification, and verdict on stdout. 4 note Compose with: si/directives/om2.om gpu/head-to-head/lib.om gpu/head-to-head/main.om 5 note Stdin line grammar (comments start with #): 6 note BYTES 7 note TOL 8 note PAIR 9 note ELEM 10 note MUTANT 11 12 text h2h_cli_bytes "BYTES" 13 text h2h_cli_tol "TOL" 14 text h2h_cli_pair "PAIR" 15 text h2h_cli_elem "ELEM" 16 text h2h_cli_mut "MUTANT" 17 text h2h_cli_err "ERROR invalid input on stdin\n" 18 text h2h_cli_nan "NaN" 19 text h2h_cli_inf "Inf" 20 text h2h_cli_ninf "-Inf" 21 22 global h2h_inbuf uchar 65536 23 global h2h_arm_a_ns ulong 512 24 global h2h_arm_b_ns ulong 512 25 global h2h_arm_a_f f64 1024 26 global h2h_arm_b_f f64 1024 27 global h2h_mut_f f64 1024 28 29 fn h2h_read_stdin to long 30 total = ulong 0 31 while lt total 65536 bound 65536 32 k = read 0 h2h_inbuf total sub 65536 total 33 if lt k 0 34 ret k 35 end 36 if eq k 0 37 break 38 end 39 total = add total ulong k 40 end 41 ret long total 42 end 43 44 fn h2h_parse_f64_or_special line view uchar * s ulong e ulong dst edit f64 1 to bool 45 if h2h_tok_eq line s e h2h_cli_nan 46 put dst 0 bitcast f64 ulong 0x7ff8000000000000 47 ret true 48 end 49 if h2h_tok_eq line s e h2h_cli_inf 50 put dst 0 bitcast f64 ulong 0x7ff0000000000000 51 ret true 52 end 53 if h2h_tok_eq line s e h2h_cli_ninf 54 put dst 0 bitcast f64 ulong 0xfff0000000000000 55 ret true 56 end 57 if not h2h_parse_f64_ok line s e 58 ret false 59 end 60 put dst 0 h2h_parse_f64_val line s e 61 ret true 62 end 63 64 fn h2h_parse_line line view uchar * state edit ulong 4 tol edit H2hTol to bool 65 note state[0]=bytes_moved state[1]=n_pairs state[2]=n_elems state[3]=n_mut 66 v1 = new f64 1 0.0f64 67 v2 = new f64 1 0.0f64 68 n = len line 69 p = h2h_skip_ws line 0 n 70 if ge p n 71 ret true 72 end 73 if eq get line p 35 74 ret true 75 end 76 t0e = h2h_next_tok_end line p n 77 if h2h_tok_eq line p t0e h2h_cli_bytes 78 p1 = h2h_skip_ws line t0e n 79 t1e = h2h_next_tok_end line p1 n 80 if not h2h_parse_u64_ok line p1 t1e 81 ret false 82 end 83 put state 0 h2h_parse_u64_val line p1 t1e 84 ret true 85 end 86 if h2h_tok_eq line p t0e h2h_cli_tol 87 p1 = h2h_skip_ws line t0e n 88 t1e = h2h_next_tok_end line p1 n 89 p2 = h2h_skip_ws line t1e n 90 t2e = h2h_next_tok_end line p2 n 91 if not h2h_parse_f64_or_special line p1 t1e v1 92 ret false 93 end 94 if not h2h_parse_f64_or_special line p2 t2e v2 95 ret false 96 end 97 put tol atol get v1 0 98 put tol rtol get v2 0 99 ret true 100 end 101 if h2h_tok_eq line p t0e h2h_cli_pair 102 p1 = h2h_skip_ws line t0e n 103 t1e = h2h_next_tok_end line p1 n 104 p2 = h2h_skip_ws line t1e n 105 t2e = h2h_next_tok_end line p2 n 106 if not h2h_parse_u64_ok line p1 t1e 107 ret false 108 end 109 if not h2h_parse_u64_ok line p2 t2e 110 ret false 111 end 112 idx = get state 1 113 if ge idx 512 114 ret false 115 end 116 put h2h_arm_a_ns idx h2h_parse_u64_val line p1 t1e 117 put h2h_arm_b_ns idx h2h_parse_u64_val line p2 t2e 118 put state 1 add idx 1 119 ret true 120 end 121 if h2h_tok_eq line p t0e h2h_cli_elem 122 p1 = h2h_skip_ws line t0e n 123 t1e = h2h_next_tok_end line p1 n 124 p2 = h2h_skip_ws line t1e n 125 t2e = h2h_next_tok_end line p2 n 126 if not h2h_parse_f64_or_special line p1 t1e v1 127 ret false 128 end 129 if not h2h_parse_f64_or_special line p2 t2e v2 130 ret false 131 end 132 idx = get state 2 133 if ge idx 1024 134 ret false 135 end 136 put h2h_arm_a_f idx get v1 0 137 put h2h_arm_b_f idx get v2 0 138 put state 2 add idx 1 139 ret true 140 end 141 if h2h_tok_eq line p t0e h2h_cli_mut 142 p1 = h2h_skip_ws line t0e n 143 t1e = h2h_next_tok_end line p1 n 144 if not h2h_parse_f64_or_special line p1 t1e v1 145 ret false 146 end 147 idx = get state 3 148 if ge idx 1024 149 ret false 150 end 151 put h2h_mut_f idx get v1 0 152 put state 3 add idx 1 153 ret true 154 end 155 ret false 156 end 157 158 fn h2h_copy_line pos ulong total ulong dst edit uchar 512 to long 159 cnt = ulong 0 160 p = pos 161 while lt p total bound 65536 162 c = get h2h_inbuf p 163 if eq c 10 164 break 165 end 166 if ge cnt 512 167 ret -1 168 end 169 put dst cnt c 170 cnt = add cnt 1 171 p = add p 1 172 end 173 ret long cnt 174 end 175 176 fn h2h_eval_timings np ulong sa edit H2hStats sb edit H2hStats to void 177 ta = new ulong 512 0 178 tb = new ulong 512 0 179 scr = new ulong 512 0 180 i = ulong 0 181 while lt i np bound 512 182 put ta i get h2h_arm_a_ns i 183 put tb i get h2h_arm_b_ns i 184 i = add i 1 185 end 186 oka = h2h_compute_stats part ta 0 np scr sa 187 okb = h2h_compute_stats part tb 0 np scr sb 188 if and oka okb 189 ret 190 end 191 end 192 193 fn h2h_eval_parity_mut nel ulong nm ulong tol view H2hTol par edit H2hParity to ulong 194 fa = new f64 1024 0.0f64 195 fb = new f64 1024 0.0f64 196 fm = new f64 1024 0.0f64 197 mpar = new H2hParity 0 0 0 0 0 0.0f64 0.0f64 198 j = ulong 0 199 while lt j nel bound 1024 200 put fa j get h2h_arm_a_f j 201 put fb j get h2h_arm_b_f j 202 j = add j 1 203 end 204 h2h_check_parity part fa 0 nel part fb 0 nel tol par 205 if eq nel 0 206 ret ulong 0 207 end 208 if eq nm 0 209 mn = h2h_make_wrong_kernel_mutant part fa 0 nel fm 210 if eq mn nel 211 if h2h_verify_mutant part fa 0 nel part fm 0 nel tol mpar 212 ret ulong 2 213 end 214 end 215 ret ulong 1 216 end 217 k = ulong 0 218 while lt k nm bound 1024 219 put fm k get h2h_mut_f k 220 k = add k 1 221 end 222 if h2h_verify_mutant part fa 0 nel part fm 0 nm tol mpar 223 ret ulong 2 224 end 225 ret ulong 1 226 end 227 228 fn h2h_run_eval np ulong nel ulong nm ulong bytes_moved ulong tol view H2hTol to int 229 sa = new H2hStats 0 0 0 0 0.0f64 0 0 0 0 230 sb = new H2hStats 0 0 0 0 0.0f64 0 0 0 0 231 par = new H2hParity 0 0 0 0 0 0.0f64 0.0f64 232 sum = new H2hSummary 2 0 bytes_moved 0.0f64 0.0f64 0.0f64 0 0 0 0 233 h2h_eval_timings np sa sb 234 mst = h2h_eval_parity_mut nel nm tol par 235 mchk = ulong 0 236 mcaught = ulong 0 237 if gt mst 0 238 mchk = ulong 1 239 end 240 if eq mst 2 241 mcaught = ulong 1 242 end 243 h2h_finalize_summary sa sb par mchk mcaught sum 244 h2h_emit_report 1 sa sb par sum 245 v = get sum verdict 246 if eq v H2H_VERDICT_PASS 247 ret 0 248 end 249 if eq v H2H_VERDICT_FAIL 250 ret 1 251 end 252 ret 2 253 end 254 255 fn main to int 256 got = h2h_read_stdin 257 if lt got 0 258 okw = h2h_write_all 2 h2h_cli_err 259 if okw 260 ret 2 261 end 262 ret 2 263 end 264 total = ulong got 265 state = new ulong 4 0 266 tol = new H2hTol 0.`000001f64` 0.`00001f64` 267 line = new uchar 512 0 268 pos = ulong 0 269 while lt pos total bound 65536 270 ln_s = h2h_copy_line pos total line 271 if lt ln_s 0 272 oke_l = h2h_write_all 2 h2h_cli_err 273 if oke_l 274 ret 2 275 end 276 ret 2 277 end 278 ln = ulong ln_s 279 if not h2h_parse_line part line 0 ln state tol 280 oke = h2h_write_all 2 h2h_cli_err 281 if oke 282 ret 2 283 end 284 ret 2 285 end 286 pos = add pos ln 287 if lt pos total 288 if eq get h2h_inbuf pos 10 289 pos = add pos 1 290 end 291 end 292 end 293 ret h2h_run_eval get state 1 get state 2 get state 3 get state 0 tol 294 end