interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / gpu / driver / tests / seq_trace.om

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