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 / gpu / driver / tests / dispatch_trace.om
| 1 | note tests/dispatch_trace.om: host trace of gsp/dispatch.om on the in-.om simulator. |
| 2 | note Reads cases on stdin, decimal: |
| 3 | note name busy budget core corefail perms gen_off tok_off bstate pkt_trunc nwords end m w0 .. w(m-1) |
| 4 | note Prints, per case, what tests/dispatch_ref.c prints for the C reference on the C simulator: |
| 5 | note == name rc=RC state=S dead=D why=WHY delays=CALLS/US core=CALLS ops=OP,.. save=%#x,..(8) nlog=N violations=N |
| 6 | note then the register log, one "W|R %06x %08x" line per access. |
| 7 | note Host only, mode 0 only. Never touches real hardware. |
| 8 | text zqtx "== | rc=| state=| dead=| why=| delays=| core=| ops=| save=| nlog=| violations=|" |
| 9 | global zqin uchar 262144 |
| 10 | global zqn ulong 1 |
| 11 | global zqp ulong 1 |
| 12 | global zqt uchar 64 |
| 13 | global zqtl ulong 1 |
| 14 | global zqnm uchar 64 |
| 15 | global zqnml ulong 1 |
| 16 | global zqob uchar 65536 |
| 17 | global zqo ulong 1 |
| 18 | global zqops ulong 16 |
| 19 | global zqnop ulong 1 |
| 20 | global zqfail ulong 1 |
| 21 | global zqbusy ulong 1 |
| 22 | global zqbud ulong 1 |
| 23 | global zqcon ulong 1 |
| 24 | global zqperm ulong 1 |
| 25 | global zqgenoff ulong 1 |
| 26 | global zqtokoff ulong 1 |
| 27 | global zqistat ulong 1 |
| 28 | global zqtrunc ulong 1 |
| 29 | global zqmode ulong 1 |
| 30 | global zqnw ulong 1 |
| 31 | global zqci ulong 1 |
| 32 | fn sqcorefn op ulong to long |
| 33 | k = get zqnop 0 |
| 34 | if lt k 16 |
| 35 | put zqops k op |
| 36 | end |
| 37 | put zqnop 0 add k 1 |
| 38 | if eq op get zqfail 0 |
| 39 | ret -1 |
| 40 | end |
| 41 | ret 0 |
| 42 | end |
| 43 | fn zqflush to void |
| 44 | n = get zqo 0 |
| 45 | if eq n 0 |
| 46 | ret |
| 47 | end |
| 48 | p = ulong 0 |
| 49 | while lt p n bound 100000 |
| 50 | w = write 1 zqob p sub n p |
| 51 | if le w 0 |
| 52 | exit 1 |
| 53 | end |
| 54 | p = add p ulong w |
| 55 | end |
| 56 | put zqo 0 0 |
| 57 | end |
| 58 | fn zqbad to void |
| 59 | zqflush |
| 60 | exit 2 |
| 61 | end |
| 62 | fn zqch c uchar to void |
| 63 | p = get zqo 0 |
| 64 | put zqob p c |
| 65 | put zqo 0 add p 1 |
| 66 | if ge add p 1 65000 |
| 67 | zqflush |
| 68 | end |
| 69 | end |
| 70 | fn zqfr k ulong to void |
| 71 | w = ulong 0 |
| 72 | for i ulong len zqtx |
| 73 | c = get zqtx i |
| 74 | if eq c 124 |
| 75 | w = add w 1 |
| 76 | else |
| 77 | if eq w k |
| 78 | zqch c |
| 79 | end |
| 80 | end |
| 81 | end |
| 82 | end |
| 83 | fn zqdec v ulong to void |
| 84 | d = ulong 1 |
| 85 | while le d div v 10 bound 20 |
| 86 | d = mul d 10 |
| 87 | end |
| 88 | while ne d 0 bound 20 |
| 89 | zqch uchar add rem div v d 10 48 |
| 90 | d = div d 10 |
| 91 | end |
| 92 | end |
| 93 | fn zqsdec v long to void |
| 94 | if lt v 0 |
| 95 | zqch 45 |
| 96 | zqdec ulong sub 0 v |
| 97 | else |
| 98 | zqdec ulong v |
| 99 | end |
| 100 | end |
| 101 | fn zqdig v ulong to void |
| 102 | if lt v 10 |
| 103 | zqch uchar add v 48 |
| 104 | else |
| 105 | zqch uchar add sub v 10 97 |
| 106 | end |
| 107 | end |
| 108 | fn zqhexw v ulong w ulong to void |
| 109 | t = v |
| 110 | nd = ulong 0 |
| 111 | while ne t 0 bound 17 |
| 112 | nd = add nd 1 |
| 113 | t = shr t 4 |
| 114 | end |
| 115 | if lt nd w |
| 116 | nd = w |
| 117 | end |
| 118 | for i ulong nd |
| 119 | zqdig and shr v mul sub sub nd i 1 4 15 |
| 120 | end |
| 121 | end |
| 122 | fn zqhex v ulong to void |
| 123 | if eq v 0 |
| 124 | zqch 48 |
| 125 | ret |
| 126 | end |
| 127 | zqch 48 |
| 128 | zqch 120 |
| 129 | zqhexw v 1 |
| 130 | end |
| 131 | fn zqsp c uchar to bool |
| 132 | ret or eq c 32 and ge c 9 le c 13 |
| 133 | end |
| 134 | fn zqtok to ulong |
| 135 | p = get zqp 0 |
| 136 | n = get zqn 0 |
| 137 | while and lt p n zqsp get zqin p bound 300000 |
| 138 | p = add p 1 |
| 139 | end |
| 140 | l = ulong 0 |
| 141 | while and lt p n not zqsp get zqin p bound 300000 |
| 142 | if ge l 63 |
| 143 | zqbad |
| 144 | end |
| 145 | put zqt l get zqin p |
| 146 | l = add l 1 |
| 147 | p = add p 1 |
| 148 | end |
| 149 | put zqp 0 p |
| 150 | put zqtl 0 l |
| 151 | ret l |
| 152 | end |
| 153 | fn zqskipl to void |
| 154 | p = get zqp 0 |
| 155 | n = get zqn 0 |
| 156 | while and lt p n ne get zqin p 10 bound 300000 |
| 157 | p = add p 1 |
| 158 | end |
| 159 | put zqp 0 p |
| 160 | end |
| 161 | fn zqnum to ulong |
| 162 | l = zqtok |
| 163 | if eq l 0 |
| 164 | zqbad |
| 165 | end |
| 166 | v = ulong 0 |
| 167 | for i ulong l |
| 168 | c = get zqt i |
| 169 | if or lt c 48 gt c 57 |
| 170 | zqbad |
| 171 | end |
| 172 | v = add mul v 10 ulong sub c 48 |
| 173 | if gt v 4294967295 |
| 174 | zqbad |
| 175 | end |
| 176 | end |
| 177 | ret v |
| 178 | end |
| 179 | fn zqexec to void |
| 180 | busy = get zqbusy 0 |
| 181 | for i ulong 10 |
| 182 | put scfg i 0 |
| 183 | end |
| 184 | put scfg 0 busy |
| 185 | siminit |
| 186 | put spm 0 0 |
| 187 | put gspmode 0 get zqmode 0 |
| 188 | for j ulong SQSAVE |
| 189 | put sqsave j 0 |
| 190 | end |
| 191 | put sqdly 0 0 |
| 192 | put sqdly 1 0 |
| 193 | put zqnop 0 0 |
| 194 | put sqbud 0 get zqbud 0 |
| 195 | put sqcore 0 get zqcon 0 |
| 196 | dspinit |
| 197 | dspperms get zqperm 0 |
| 198 | put bgen 0 42 |
| 199 | put btoken 0 1001 |
| 200 | put bprev 0 9 |
| 201 | put bstate 0 get zqistat 0 |
| 202 | put rqdead 0 0 |
| 203 | nw = get zqnw 0 |
| 204 | ci = get zqci 0 |
| 205 | trunc = get zqtrunc 0 |
| 206 | if eq trunc 1 |
| 207 | put bselen 0 100 |
| 208 | else |
| 209 | put bselen 0 add 120 mul nw 4 |
| 210 | end |
| 211 | dspp32 80 nw |
| 212 | dspp32 84 ci |
| 213 | for k ulong SQSAVE |
| 214 | dspp32 add 88 mul k 4 0 |
| 215 | end |
| 216 | gen = add 42 get zqgenoff 0 |
| 217 | tok = add 1001 get zqtokoff 0 |
| 218 | rc = dspseq gen tok |
| 219 | dspwhy rc |
| 220 | zqfr 0 |
| 221 | for k ulong get zqnml 0 |
| 222 | zqch get zqnm k |
| 223 | end |
| 224 | zqfr 1 |
| 225 | zqsdec rc |
| 226 | zqfr 2 |
| 227 | zqdec get bstate 0 |
| 228 | zqfr 3 |
| 229 | zqdec ulong get rqdead 0 |
| 230 | zqfr 4 |
| 231 | if eq get dspwl 0 0 |
| 232 | zqch 45 |
| 233 | else |
| 234 | for k ulong get dspwl 0 |
| 235 | zqch get dspwb k |
| 236 | end |
| 237 | end |
| 238 | zqfr 5 |
| 239 | zqdec get sqdly 0 |
| 240 | zqch 47 |
| 241 | zqdec and get sqdly 1 M32 |
| 242 | zqfr 6 |
| 243 | zqdec get zqnop 0 |
| 244 | zqfr 7 |
| 245 | for k ulong get zqnop 0 |
| 246 | if lt k 16 |
| 247 | zqdec get zqops k |
| 248 | zqch 44 |
| 249 | end |
| 250 | end |
| 251 | zqfr 8 |
| 252 | for k ulong SQSAVE |
| 253 | zqhex dspu32 add 88 mul k 4 |
| 254 | zqch 44 |
| 255 | end |
| 256 | zqfr 9 |
| 257 | zqdec sg SNLOG |
| 258 | zqfr 10 |
| 259 | zqdec sg SVIOL |
| 260 | zqch 10 |
| 261 | for k ulong sg SNLOG |
| 262 | if lt k LOGMAX |
| 263 | if eq get slogw k 1 |
| 264 | zqch 87 |
| 265 | else |
| 266 | zqch 82 |
| 267 | end |
| 268 | zqch 32 |
| 269 | zqhexw get slogo k 6 |
| 270 | zqch 32 |
| 271 | zqhexw get slogv k 8 |
| 272 | zqch 10 |
| 273 | end |
| 274 | end |
| 275 | end |
| 276 | fn main to int |
| 277 | p = ulong 0 |
| 278 | while lt p 262144 bound 300000 |
| 279 | r = read int 0 zqin p sub 262144 p |
| 280 | if lt r 0 |
| 281 | zqbad |
| 282 | end |
| 283 | if eq r 0 |
| 284 | break |
| 285 | end |
| 286 | p = add p ulong r |
| 287 | end |
| 288 | put zqn 0 p |
| 289 | put zqp 0 0 |
| 290 | while true bound 100000 |
| 291 | l = zqtok |
| 292 | if eq l 0 |
| 293 | break |
| 294 | end |
| 295 | if eq get zqt 0 35 |
| 296 | zqskipl |
| 297 | continue |
| 298 | end |
| 299 | for i ulong l |
| 300 | put zqnm i get zqt i |
| 301 | end |
| 302 | put zqnml 0 l |
| 303 | put zqbusy 0 zqnum |
| 304 | put zqbud 0 zqnum |
| 305 | put zqcon 0 zqnum |
| 306 | put zqfail 0 zqnum |
| 307 | put zqperm 0 zqnum |
| 308 | put zqgenoff 0 zqnum |
| 309 | put zqtokoff 0 zqnum |
| 310 | put zqistat 0 zqnum |
| 311 | put zqtrunc 0 zqnum |
| 312 | put zqmode 0 zqnum |
| 313 | put zqnw 0 zqnum |
| 314 | put zqci 0 zqnum |
| 315 | m = zqnum |
| 316 | for i ulong 65536 |
| 317 | put bsevent i 0 |
| 318 | end |
| 319 | for i ulong m |
| 320 | w = zqnum |
| 321 | if lt i get zqnw 0 |
| 322 | dspp32 add 120 mul i 4 w |
| 323 | end |
| 324 | end |
| 325 | zqexec |
| 326 | end |
| 327 | zqflush |
| 328 | ret 0 |
| 329 | end |