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/driver/tests/seq_trace.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 / driver / tests / seq_trace.om` 301 lines ยท 4983 bytes Raw Blame History 1 note tests/seq_trace.om: host trace of gsp/seq.om (sqrun) on the in-.om simulator (gsp/sim.om, mode 0). 2 note Reads the cases on stdin, one per line, decimal: name busy budget core corefail nwords end m w0 .. w(m-1) 3 note (busy = scfg busy_reads, budget = sqbud, core = sqcore, corefail = the opcode sqcorefn fails on, words past 4 note m are 0; a token starting with # skips the rest of its line). Prints, per case, what tests/seq_ref.c 5 note prints for the C gsp_seq_run on the C simulator: 6 note == name rc=0|-1 why=TEXT delays=CALLS/US core=CALLS ops=OP,.. save=%#x,..(8) nlog=N violations=N 7 note then the register log, one "W|R %06x %08x" line per access (the first 1024). 8 note Build: cat gsp/mmio.om gsp/sim.om gsp/seq.om tests/seq_trace.om | omc. Host only, mode 0 only. 9 text zqtx "== | rc=| why=| delays=| core=| ops=| save=| nlog=| violations=|" 10 global zqin uchar 262144 11 global zqn ulong 1 12 global zqp ulong 1 13 global zqt uchar 64 14 global zqtl ulong 1 15 global zqnm uchar 64 16 global zqnml ulong 1 17 global zqob uchar 65536 18 global zqo ulong 1 19 global zqops ulong 16 20 global zqnop ulong 1 21 global zqfail ulong 1 22 note the core callback gsp/seq.om calls: records the opcode, fails on zqfail 23 fn sqcorefn op ulong to long 24 n = get zqnop 0 25 if lt n 16 26 put zqops n op 27 end 28 put zqnop 0 add n 1 29 if eq op get zqfail 0 30 ret -1 31 end 32 ret 0 33 end 34 fn zqflush to void 35 n = get zqo 0 36 if gt n 0 37 r = write 1 zqob 0 n 38 if ne r long n 39 exit 1 40 end 41 end 42 put zqo 0 0 43 end 44 note malformed input: print what is done, then exit 2 (the C referee does the same) 45 fn zqbad to void 46 zqflush 47 exit 2 48 end 49 fn zqch c uchar to void 50 p = get zqo 0 51 put zqob p c 52 put zqo 0 add p 1 53 if ge add p 1 65000 54 zqflush 55 end 56 end 57 fn zqfr k ulong to void 58 w = ulong 0 59 for i ulong len zqtx 60 c = get zqtx i 61 if eq c 124 62 w = add w 1 63 else 64 if eq w k 65 zqch c 66 end 67 end 68 end 69 end 70 fn zqdec v ulong to void 71 d = ulong 1 72 while le d div v 10 bound 20 73 d = mul d 10 74 end 75 while ne d 0 bound 20 76 zqch uchar add rem div v d 10 48 77 d = div d 10 78 end 79 end 80 fn zqsdec v long to void 81 if lt v 0 82 zqch 45 83 zqdec ulong sub 0 v 84 ret 85 end 86 zqdec ulong v 87 end 88 fn zqdig d ulong to void 89 if lt d 10 90 zqch uchar add d 48 91 else 92 zqch uchar add d 87 93 end 94 end 95 note %0Nx: at least w digits, zero padded 96 fn zqhexw v ulong w ulong to void 97 nd = ulong 0 98 t = v 99 while ne t 0 bound 17 100 nd = add nd 1 101 t = shr t 4 102 end 103 if lt nd w 104 nd = w 105 end 106 for i ulong nd 107 zqdig and shr v mul sub sub nd i 1 4 15 108 end 109 end 110 note %#x: 0 prints as 0, otherwise 0x and the digits 111 fn zqhex v ulong to void 112 if eq v 0 113 zqch 48 114 ret 115 end 116 zqch 48 117 zqch 120 118 zqhexw v 1 119 end 120 fn zqsp c uchar to bool 121 ret or eq c 32 and ge c 9 le c 13 122 end 123 note next whitespace-separated token into zqt[0..zqtl); its length, 0 at the end of input 124 fn zqtok to ulong 125 p = get zqp 0 126 n = get zqn 0 127 while and lt p n zqsp get zqin p bound 300000 128 p = add p 1 129 end 130 l = ulong 0 131 while and lt p n not zqsp get zqin p bound 300000 132 if ge l 63 133 zqbad 134 end 135 put zqt l get zqin p 136 l = add l 1 137 p = add p 1 138 end 139 put zqp 0 p 140 put zqtl 0 l 141 ret l 142 end 143 fn zqskipl to void 144 p = get zqp 0 145 n = get zqn 0 146 while and lt p n ne get zqin p 10 bound 300000 147 p = add p 1 148 end 149 put zqp 0 p 150 end 151 note next token as a decimal number; anything else (or more than `4294967295`) stops the run with zqbad 152 fn zqnum to ulong 153 l = zqtok 154 if eq l 0 155 zqbad 156 end 157 v = ulong 0 158 for i ulong l 159 c = get zqt i 160 if or lt c 48 gt c 57 161 zqbad 162 end 163 v = add mul v 10 sub ulong c 48 164 if gt v `4294967295` 165 zqbad 166 end 167 end 168 ret v 169 end 170 fn zqcase busy ulong bud ulong con ulong fail ulong nw ulong ci ulong to void 171 for i ulong 10 172 put scfg i 0 173 end 174 put scfg 0 busy 175 siminit 176 put spm 0 0 177 put gspmode 0 0 178 for j ulong SQSAVE 179 put sqsave j 0 180 end 181 put sqdly 0 0 182 put sqdly 1 0 183 put zqnop 0 0 184 put sqbud 0 bud 185 put sqcore 0 con 186 put zqfail 0 fail 187 rc = sqrun nw ci 188 sqwhy rc 189 zqfr 0 190 for k ulong get zqnml 0 191 zqch get zqnm k 192 end 193 zqfr 1 194 note the C returns -1 for every refusal; the why text below names which one 195 if lt rc 0 196 zqsdec -1 197 else 198 zqsdec rc 199 end 200 zqfr 2 201 if eq get sqwl 0 0 202 zqch 45 203 end 204 for k ulong get sqwl 0 205 zqch get sqwb k 206 end 207 zqfr 3 208 zqdec get sqdly 0 209 zqch 47 210 zqdec and get sqdly 1 M32 211 zqfr 4 212 zqdec get zqnop 0 213 zqfr 5 214 for k ulong get zqnop 0 215 if lt k 16 216 zqdec get zqops k 217 zqch 44 218 end 219 end 220 zqfr 6 221 for k ulong SQSAVE 222 zqhex get sqsave k 223 zqch 44 224 end 225 zqfr 7 226 zqdec sg SNLOG 227 zqfr 8 228 zqdec sg SVIOL 229 zqch 10 230 for k ulong sg SNLOG 231 if lt k LOGMAX 232 if eq get slogw k 1 233 zqch 87 234 else 235 zqch 82 236 end 237 zqch 32 238 zqhexw get slogo k 6 239 zqch 32 240 zqhexw get slogv k 8 241 zqch 10 242 end 243 end 244 end 245 fn main to int 246 p = ulong 0 247 while lt p 262144 bound 300000 248 r = read int 0 zqin p sub 262144 p 249 if lt r 0 250 zqbad 251 end 252 if eq r 0 253 break 254 end 255 p = add p ulong r 256 end 257 put zqn 0 p 258 put zqp 0 0 259 while true bound 100000 260 l = zqtok 261 if eq l 0 262 break 263 end 264 if eq get zqt 0 35 265 zqskipl 266 continue 267 end 268 for i ulong l 269 put zqnm i get zqt i 270 end 271 put zqnml 0 l 272 busy = zqnum 273 bud = zqnum 274 con = zqnum 275 fail = zqnum 276 nw = zqnum 277 ci = zqnum 278 m = zqnum 279 if gt m nw 280 zqbad 281 end 282 for i ulong m 283 w = zqnum 284 if lt i SQMAX 285 put sqbuf i uint w 286 end 287 end 288 lim = nw 289 if gt lim SQMAX 290 lim = SQMAX 291 end 292 for i ulong lim 293 if ge i m 294 put sqbuf i 0 295 end 296 end 297 zqcase busy bud con fail nw ci 298 end 299 zqflush 300 ret 0 301 end