interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / tests / speculation / service-test.om

259 lines · 4419 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Actual native parent/child pipe exchange. Synthetic policy data, no model or GPU.
3global xreq uchar 2048
4global xresp uchar 128
5global xexec uchar 4096
6global xfds uchar 16
7global xstat uchar 4
8global xmeta ulong 5
9fn xput i ulong v ulong to void
10for j ulong 8
11put xreq add mul i 8 j uchar and shr v mul j 8 255
12end
13end
14fn xget i ulong to ulong
15v = ulong 0
16for j ulong 8
17v = or v shl ulong get xresp add mul i 8 j mul j 8
18end
19ret v
20end
21fn xfd off ulong to int
22v = ulong 0
23for j ulong 4
24v = or v shl ulong get xfds add off j mul j 8
25end
26ret int v
27end
28fn xspawn to int
29n = argread 1 xexec 4 4092
30if lt n 1
31ret 65
32end
33put xexec 0 1
34put xexec 1 0
35put xexec 2 uchar and ulong n 255
36put xexec 3 uchar shr ulong n 8
37if ne pipefds xfds 0 8 524288 0
38ret 74
39end
40if ne pipefds xfds 8 8 524288 0
41ret 74
42end
43pid = fork
44if lt pid 0
45ret 74
46end
47if eq pid 0
48if ne dupfd xfd 0 0 0 0
49exit 111
50end
51if ne dupfd xfd 12 1 0 1
52exit 111
53end
54for i ulong 4
55r = fclose xfd mul i 4
56end
57r = execprog xexec 0 add ulong n 4
58exit 111
59end
60r = fclose xfd 0
61r = fclose xfd 12
62put xmeta 0 ulong pid
63put xmeta 1 ulong xfd 4
64put xmeta 2 ulong xfd 8
65put xmeta 3 1
66ret 0
67end
68fn xread off ulong n ulong to int
69done = ulong 0
70for attempt ulong 128
71if eq done n
72ret 0
73end
74r = waitio int get xmeta 2 1 5000000000
75if le r 0
76ret 74
77end
78r = read int get xmeta 2 xresp add off done sub n done
79if le r 0
80ret 74
81end
82done = add done ulong r
83end
84ret 74
85end
86fn xcall op ulong count ulong to ulong
87xput 0 827343699
88xput 1 1
89xput 2 op
90xput 3 get xmeta 3
91xput 4 count
92bytes = mul add count 5 8
93started = monons
94r = write int get xmeta 1 xreq 0 bytes
95check eq r long bytes
96v = xread 0 56
97check eq v 0
98if ne v 0
99ret 999
100end
101check eq xget 0 827343699
102check eq xget 1 1
103check eq xget 2 op
104check eq xget 3 get xmeta 3
105check le xget 5 5
106put xmeta 3 add get xmeta 3 1
107if gt xget 5 5
108ret 999
109end
110check eq xread 56 mul xget 5 8 0
111check gt xget 6 0
112check le xget 6 ulong sub monons started
113if ne xget 4 0
114check eq xget 5 0
115end
116ret xget 4
117end
118fn xinit to void
119for i ulong 64
120xput add i 5 get sid i
121end
122for i ulong 6
123xput add i 69 get sprofile i
124end
125for i ulong 77
126xput add i 75 get srows i
127end
128for i ulong 31
129xput add i 152 get sprior i
130end
131check eq xcall 1 178 0
132end
133fn xbegin warm ulong device ulong to ulong
134xput 5 warm
135xput 6 device
136xput 7 0
137ret xcall 2 3
138end
139fn xselect context ulong remain ulong mode ulong k ulong to ulong
140xput 5 context
141xput 6 remain
142xput 7 1000
143xput 8 7
144xput 9 mode
145xput 10 k
146ret xcall 3 6
147end
148fn xobs a ulong n ulong eos ulong full ulong to ulong
149xput 5 a
150xput 6 n
151xput 7 100
152xput 8 eos
153xput 9 full
154ret xcall 4 5
155end
156fn xreap code ulong to void
157if ne get xmeta 1 18446744073709551615
158r = fclose int get xmeta 1
159end
160r = fclose int get xmeta 2
161r = waitpid int get xmeta 0 xstat 0 4 0
162check eq r long get xmeta 0
163check eq get xstat 0 0
164check eq ulong get xstat 1 code
165end
166fn exchange to void
167check eq xspawn 0
168xinit
169check eq xcall 1 178 75
170check eq xbegin 0 1 69
171check eq xbegin 1 0 69
172check eq xbegin 0 0 0
173check eq xbegin 0 0 75
174check eq xcall 8 0 75
175check eq xcall 7 0 75
176check eq xselect 1000 64 2 0 0
177check eq xget 7 31
178check eq xget 8 32
179check eq xget 9 32000000
180check eq xselect 1000 64 2 0 75
181check eq xobs 2 3 0 0 75
182check eq xobs 2 3 0 1 0
183check eq xget 7 3
184check eq xget 8 2
185check eq xget 9 1
186check eq xget 10 0
187check eq xselect 1003 61 2 0 75
188check eq xcall 5 0 0
189check eq xselect 1002 61 2 0 69
190check eq xselect 1003 61 2 0 0
191check eq xget 7 31
192check eq xcall 6 0 0
193check eq xbegin 1 0 0
194check eq xselect 1000 2 1 1 0
195check eq xget 7 1
196check eq xobs 0 1 1 1 0
197check eq xget 10 1
198check eq xcall 7 0 0
199check eq xcall 8 0 0
200xreap 0
201end
202fn broken kind ulong code ulong to void
203check eq xspawn 0
204if eq kind 3
205xinit
206check eq xbegin 0 0 0
207else
208xput 0 827343699
209xput 1 1
210xput 2 8
211xput 3 1
212xput 4 0
213bytes = ulong 40
214if eq kind 0
215xput 3 2
216end
217if eq kind 1
218bytes = 7
219end
220if eq kind 2
221xput 1 2
222end
223if eq kind 4
224xput 4 1
225end
226if eq kind 5
227xput 2 2
228xput 4 3
229bytes = 48
230end
231if eq kind 6
232xput 2 9
233end
234r = write int get xmeta 1 xreq 0 bytes
235check eq r long bytes
236end
237r = fclose int get xmeta 1
238put xmeta 1 18446744073709551615
239r = waitio int get xmeta 2 1 5000000000
240check gt r 0
241r = read int get xmeta 2 xresp 0 128
242check eq r 0
243xreap code
244end
245fn main to int
246if ne argcnt 2
247ret 64
248end
249fixture
250exchange
251broken 0 69
252broken 1 65
253broken 2 69
254broken 3 75
255broken 4 65
256broken 5 65
257broken 6 77
258ret finish
259end