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 / dispatch_trace.om

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