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 / share / share-test.om

340 lines · 8206 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Host test for native/share/share.om against tests/share/fake-rm.om. The runner appends
3note fn main returning tall (full suite) or trowrite (read-only write must trap 103).
4note Records are forged here byte by byte ("OMZC" = 79 77 90 67), not via nvexport, so a
5note wrong layout in share.om cannot agree with itself.
6note Size constants (Wolfram): 2^13 8192, 2^14 16384, 2^36 68719476736, 2^36+2^12 68719480832.
7global tchecks ulong 1
8global tbuf uchar 64
9global tnum uchar 24
10text tok "ZERO_COPY_SHARE_HOST_PASS\n"
11text tarmed "ZERO_COPY_SHARE_RO_ARMED\n"
12text tbad "ZERO_COPY_SHARE_HOST_FAIL check "
13text tnl "\n"
14fn tprintn fd int v ulong to void
15i = ulong 23
16x = v
17put tnum i uchar add 48 rem x 10
18x = div x 10
19while ne x 0 bound 24
20i = sub i 1
21put tnum i uchar add 48 rem x 10
22x = div x 10
23end
24w = write fd tnum i sub 24 i
25end
26fn tcheck yes bool to void
27put tchecks 0 add get tchecks 0 1
28if not yes
29w = write 2 tbad 0 len tbad
30tprintn 2 get tchecks 0
31w = write 2 tnl 0 len tnl
32tprintn 2 ulong neg get nverr 0
33w = write 2 tnl 0 len tnl
34exit int 1
35end
36end
37fn tsetup to void
38put nvfd 0 900
39put nvfd 1 901
40put nvfd 2 902
41put nvfd 3 903
42put nvobj 0 1000001
43put nvobj 1 1000002
44put nvobj 2 1000003
45put nvobj 3 1000004
46put nvobj 4 1000005
47put nvseq 0 1000100
48put nvstate 0 1
49put nvreg 0 1
50put nvreg 1 1
51put nvfault 0 0
52put nvnext 0 68719476736
53for i ulong 16
54put nvuuid i uchar add i 1
55end
56end
57fn tslots to ulong
58n = ulong 0
59for i ulong 96
60if ne get nvmflag i 0
61n = add n 1
62end
63end
64ret n
65end
66fn trec cli uint h uint size ulong to void
67for i ulong 24
68put nvshrec i 0
69end
70put nvshrec 0 79
71put nvshrec 1 77
72put nvshrec 2 90
73put nvshrec 3 67
74put nvshrec 4 1
75for i ulong 4
76put nvshrec add 8 i uchar and shr cli mul i 8 255
77put nvshrec add 12 i uchar and shr h mul i 8 255
78end
79for i ulong 8
80put nvshrec add 16 i uchar and shr size mul i 8 255
81end
82end
83fn tfill v long size ulong seed ulong to void
84off = ulong 0
85ok = true
86while lt off size bound 4096
87for j ulong 64
88put tbuf j uchar and add add seed j shr off 6 255
89end
90if ne mapwrite v off tbuf 0 64 64
91ok = false
92end
93off = add off 64
94end
95tcheck ok
96end
97fn tverify v long size ulong seed ulong to void
98off = ulong 0
99ok = true
100while lt off size bound 4096
101if ne mapread v off tbuf 0 64 64
102ok = false
103end
104for j ulong 64
105if ne ulong get tbuf j and add add seed j shr off 6 255
106ok = false
107end
108end
109off = add off 64
110end
111tcheck ok
112end
113note Every refused import: no slot, no fault, descriptors balanced, no extra live object.
114fn tclean slots ulong live ulong to void
115tcheck eq tslots slots
116tcheck eq get nvfault 0 0
117tcheck eq get fcnt 10 get fcnt 11
118tcheck eq fklivecnt get nvobj 0 live
119end
120note A malformed or mismatched record is refused before any RM or UVM call.
121fn tnocall want ulong code long to void
122c = get fcnt 0
123s = tslots
124l = fklivecnt get nvobj 0
125tcheck eq nvimport want false neg long 1
126tcheck eq get nverr 0 code
127tcheck eq get fcnt 0 c
128tclean s l
129end
130note An RM refusal of the dup: -1 with the RM status in nverr, nothing kept, no further call.
131fn trmref want ulong status ulong to void
132d = get fcnt 2
133c = get fcnt 0
134s = tslots
135l = fklivecnt get nvobj 0
136tcheck eq nvimport want false neg long 1
137tcheck eq get nverr 0 long status
138tcheck eq get fcnt 2 d
139tcheck eq get fcnt 0 add c 1
140tclean s l
141end
142note A size the object does not have: dup made, proven wrong by RM_MAP_MEMORY, then freed.
143note maps is how many RM_MAP_MEMORY calls RM accepts on the way (the probe, for a larger object).
144fn tsize want ulong maps ulong to void
145d = get fcnt 2
146f = get fcnt 3
147m = get fcnt 4
148s = tslots
149l = fklivecnt get nvobj 0
150tcheck eq nvimport want false neg long 1
151tcheck eq get nverr 0 neg long 34
152tcheck eq get fcnt 2 add d 1
153tcheck eq get fcnt 3 add f 1
154tcheck eq get fcnt 4 add m maps
155tclean s l
156end
157
158fn town to long
159m = nvalloc 8192 false
160tcheck gt m 0
161s = nvfind m
162tcheck lt s 96
163h = get nvmobj s
164tcheck nvexport m
165tcheck eq get fcnt 1 1
166tcheck eq get flast 4 0
167tcheck eq ulong get flast 5 kshdupbit
168tcheck eq ulong get flast 6 kshtoken
169tcheck eq get flast 7 0
170tcheck eq get nvshrec 0 79
171tcheck eq get nvshrec 1 77
172tcheck eq get nvshrec 2 90
173tcheck eq get nvshrec 3 67
174tcheck eq nvshget 4 1
175tcheck eq nvshget 8 get nvobj 0
176tcheck eq nvshget 12 h
177tcheck eq nvshg64 16 8192
178tcheck eq get fkshr fkfind get nvobj 0 h 1
179note Export refusals: unknown mapping, faulted context. No RM call either way.
180c = get fcnt 0
181tcheck not nvexport 777
182tcheck eq get nverr 0 neg long 22
183put nvfault 0 1
184tcheck not nvexport m
185tcheck eq get nverr 0 neg long 5
186put nvfault 0 0
187tcheck eq get fcnt 0 c
188tcheck eq get fcnt 1 1
189note Same-process import of the owner's record aliases the owner's pages.
190tfill m 8192 11
191i = nvimport 8192 false
192tcheck gt i 0
193tcheck ne i m
194tverify i 8192 11
195tfill i 8192 23
196tverify m 8192 23
197tcheck nvdrop i
198tverify m 8192 23
199ret m
200end
201fn tforeign to void
202note Owner process B (RM client 2000001) shares object 5001; this process imports it.
203fi = fkforeign 2000001 5001 16384 true
204b = get fkbk fi
205tfill get fbview b 16384 7
206trec 2000001 5001 16384
207d = get fcnt 2
208s = tslots
209i = nvimport 16384 false
210tcheck gt i 0
211tcheck eq tslots add s 1
212tcheck eq get fcnt 2 add d 1
213tcheck eq ulong and get flast 0 3 0
214tcheck eq get flast 3 3
215tcheck eq ulong and get flast 1 3 0
216tcheck eq ulong get flast 2 kextrw
217tcheck eq ulong get flast 8 kdupflagsnone
218tverify i 16384 7
219tfill i 16384 41
220tverify get fbview b 16384 41
221note Read-only import of the same object.
222ro = nvimport 16384 true
223tcheck gt ro 0
224tcheck eq ulong and get flast 0 3 kmapro
225tcheck eq get flast 3 1
226tcheck eq ulong and get flast 1 3 kdmaro
227tcheck eq ulong get flast 2 kextro
228tverify ro 16384 41
229note An import is not re-exportable.
230c = get fcnt 0
231tcheck not nvexport i
232tcheck eq get nverr 0 neg long 1
233tcheck eq get fcnt 0 c
234note Owner frees first: the backing lives on through both dups.
235r = get fcnt 12
236fkunobj fi
237tcheck eq get fcnt 12 r
238tverify i 16384 41
239tverify ro 16384 41
240u = get fcnt 9
241x = get fcnt 6
242f = get fcnt 3
243tcheck nvdrop i
244tcheck eq get fcnt 9 add u 1
245tcheck eq get fcnt 6 add x 1
246tcheck eq get fcnt 3 add f 1
247tcheck eq get fcnt 12 r
248tcheck nvdrop ro
249tcheck eq get fcnt 12 add r 1
250tcheck eq tslots s
251end
252fn tnegative m long to void
253f2 = fkforeign 2000001 5002 8192 true
254f3 = fkforeign 2000001 5003 8192 false
255f4 = fkforeign 2000001 5004 16384 true
256note Wrong handle, wrong client, object not shared.
257trec 2000001 5099 8192
258trmref 8192 kerrnotfound
259trec 3000001 5002 8192
260trmref 8192 kerrclient
261trec 2000001 5003 8192
262trmref 8192 kerrperm
263note Size mismatch against the real object, both directions.
264trec 2000001 5002 16384
265tsize 16384 0
266trec 2000001 5004 8192
267tsize 8192 1
268note Caller's expected size differs from the record.
269trec 2000001 5002 8192
270tnocall 4096 neg long 34
271note Malformed records.
272trec 2000001 5002 8192
273put nvshrec 0 80
274tnocall 8192 neg long 22
275trec 2000001 5002 8192
276put nvshrec 4 2
277tnocall 8192 neg long 22
278trec 0 5002 8192
279tnocall 8192 neg long 22
280trec 2000001 0 8192
281tnocall 8192 neg long 22
282trec 2000001 5002 0
283tnocall 0 neg long 22
284trec 2000001 5002 4097
285tnocall 4097 neg long 22
286trec 2000001 5002 68719480832
287tnocall 68719480832 neg long 22
288note Faulted context.
289trec 2000001 5002 8192
290put nvfault 0 1
291c = get fcnt 0
292tcheck eq nvimport 8192 false neg long 1
293tcheck eq get nverr 0 neg long 5
294tcheck eq get fcnt 0 c
295put nvfault 0 0
296note GPU-side failure after the CPU map: quarantined slot and faulted context, as nvalloc.
297s = tslots
298put finj 0 kuvmrange
299put finjst 0 uint kerrlimit
300tcheck eq nvimport 8192 false neg long 1
301tcheck eq get nvfault 0 1
302tcheck eq tslots add s 1
303q = ulong 96
304for i ulong 96
305if and ne get nvmflag i 0 ne i nvfind m
306q = i
307end
308end
309tcheck lt q 96
310tcheck eq get nvmflag q 3
311tcheck nvmrel q
312tcheck eq tslots s
313put nvfault 0 0
314end
315fn tall to int
316tsetup
317m = town
318tforeign
319tnegative m
320tcheck nvdrop m
321tcheck eq tslots 0
322tcheck eq fklivecnt get nvobj 0 0
323tcheck eq get fcnt 10 get fcnt 11
324for j ulong 16
325tcheck eq get frlive j 0
326tcheck eq get fdmlive j 0
327end
328w = write 1 tok 0 len tok
329ret 0
330end
331fn trowrite to int
332tsetup
333fi = fkforeign 2000001 6001 8192 true
334trec 2000001 6001 8192
335ro = nvimport 8192 true
336tcheck gt ro 0
337w = write 1 tarmed 0 len tarmed
338x = mapwrite ro 0 tbuf 0 1
339ret 1
340end