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 / host-trace / launch-test.om

170 lines · 3300 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Host check of native/trace/htlaunch.om over tests/host-trace/fakenv.om (no device). Compose:
3note fakenv.om vector.om launch.om htrec.om htlaunch.om launch-test.om. With a path in argv 1 it
4note writes the OTR1 dump there. Prints HOSTTRACE_LAUNCH_PASS <checks> or _FAIL <failures>.
5global tally ulong 2
6global digits uchar 32
7global path uchar 4096
8text passmsg "HOSTTRACE_LAUNCH_PASS "
9text failmsg "HOSTTRACE_LAUNCH_FAIL "
10text appnames "launch-test:main|host.upload:a.b|host.verify"
11fn number n ulong to void
12if ge n 10
13number div n 10
14end
15put digits 0 uchar add 48 rem n 10
16w = write 1 digits 0 1
17end
18fn ck yes bool to void
19put tally 0 add get tally 0 1
20if not yes
21put tally 1 add get tally 1 1
22number get tally 0
23put digits 0 10
24w = write 1 digits 0 1
25end
26end
27fn appname to bool
28id = uint 201
29ok = htnbeg id
30for i ulong len appnames
31b = get appnames i
32if eq b 124
33ok = and ok htnend
34id = add id 1
35ok = and ok htnbeg id
36else
37ok = and ok htnbyte b
38end
39end
40ret and ok htnend
41end
42fn aval i ulong to ulong
43ret and add mul i 2654435761 7 4294967295
44end
45fn bval i ulong to ulong
46ret and xor mul i 2246822519 3266489917 4294967295
47end
48fn upload n uint to void
49s = htbeg 6 202
50for i ulong ulong n
51r = mapset get gbmem 5 mul i 4 4 aval i
52r = mapset get gbmem 6 mul i 4 4 bval i
53r = mapset get gbmem 7 mul i 4 4 0
54end
55b = htend s mul ulong n 8 1 0
56end
57fn readback n uint to ulong
58s = htbeg 6 106
59bad = ulong 0
60for i ulong ulong n
61c = mapget get gbmem 7 mul i 4 4
62if ne c and add aval i bval i 4294967295
63bad = add bad 1
64end
65end
66b = htend s mul ulong n 4 2 long bad
67ret bad
68end
69note count launch spans that ended with stage st and status rc
70fn spans st ulong rc long to ulong
71k = ulong 0
72n = get htst 1
73for i ulong n
74if eq get htkind i 4
75if eq get hta1 i st
76if eq get htrc i rc
77k = add k 1
78end
79end
80end
81end
82ret k
83end
84fn kinds k uint to ulong
85c = ulong 0
86for i ulong get htst 1
87if eq get htkind i k
88c = add c 1
89end
90end
91ret c
92end
93fn opened to void
94ck htopen 4097
95ck eq get fkn 0 8
96for i ulong 8
97ck eq get fksz i htgbsz i 4097
98end
99ck eq kinds 5 8
100note event 0 is the launch-test:main span, event 1 the gpu.open span
101ck eq get htkind 1 3
102ck eq get hta1 1 get gblen 0
103ck eq get htrc 1 0
104end
105fn launched to void
106upload 4097
107ck htlaunch 4097
108ck eq readback 4097 0
109ck eq spans 43 0 1
110put fkmode 0 1
111ck not htlaunch 64
112ck eq spans 41 -5 1
113put fkmode 0 2
114ck not htlaunch 64
115ck eq spans 42 -110 1
116put fkmode 0 3
117ck not htlaunch 64
118ck eq spans 43 -5 1
119ck eq get nvfault 0 1
120put fkmode 0 0
121ck not htlaunch 64
122ck eq spans 0 -22 1
123ck eq get nvstage 0 43
124ck not htlaunch 0
125ck eq spans 0 -22 2
126end
127fn dumpto to void
128if lt argcnt 2
129ret
130end
131n = argread 1 path 0 4095
132ck gt n 0
133fd = fopen path 0 ulong n 577 384
134ck ge fd 0
135r = htdump int fd
136ck gt r 0
137c = fclose int fd
138end
139fn main to int
140ck appname
141ck htlname
142ck not htlive
143ck htinit
144m = htbeg 9 201
145opened
146launched
147ck eq kinds 4 6
148ck eq kinds 11 5
149ck eq kinds 6 2
150ck htend m 0 0 0
151ck eq get htst 7 0
152ck eq get htst 3 0
153ck eq get htst 2 0
154dumpto
155htstop
156ck not htlaunch 64
157ck eq kinds 4 6
158if ne get tally 1 0
159w = write 1 failmsg 0 len failmsg
160number get tally 1
161put digits 0 10
162w = write 1 digits 0 1
163ret 1
164end
165w = write 1 passmsg 0 len passmsg
166number get tally 0
167put digits 0 10
168w = write 1 digits 0 1
169ret 0
170end