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 / smi / rmfake.om

297 lines · 5492 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note rmfake.om: host-only stand-in for the NVIDIA resource manager, for the cudapp-smi --rm tier.
3note tests/smi/run.sh rewrites every OS effect in private copies of native/nvrm/context.om and
4note native/smi/util.om into the words below and appends this unit between them and native/smi/rm.om.
5note No device file is opened.
6note Replies imitate a GB10 with one GPU; they are synthetic, not a hardware record.
7note SMIFAULT=<c> in the environment selects one fault:
8note o open of the control node fails s subdevice reports a different SM version
9note c name control fails (0x56) n name has no terminating zero
10note t a thermal instruction is not executed
11note p GET_PIDS count above its table f the device free fails
12note u pstate control not supported m pstate reply has two bits set
13note q pstate control refused with NV_ERR_INSUFFICIENT_PERMISSIONS (0x1b)
14note w utilization control not supported e utilization ring empty (count 0)
15note z newest utilization sample has a zero timestamp
16note y utilization control refused with NV_ERR_INSUFFICIENT_PERMISSIONS (0x1b)
17note r utilization tracker 72 (outside the ring) x newest gr.util 10001
18note Without a fault the pstate is P8 (0x100), the value nvidia-smi showed on the live GB10, and the
19note utilization ring is full with tracker 5: the newest sample (index 4) holds gr 4200 and fb 1300
20note (42 % and 13 %); every other sample k holds gr 100*k and fb 50*k, so a wrong index is visible.
21note Every control command outside the allowlist fails with 0x56 and logs "FAKE UNKNOWN".
22note Each effect writes one stderr line "FAKE <what>" for the runner to count.
23
24text sfkey "SMIFAULT="
25text sfalc "FAKE alloc\n"
26text sfctl "FAKE control\n"
27text sffree "FAKE free\n"
28text sfcls "FAKE close\n"
29text sfopn "FAKE open\n"
30text sfunk "FAKE UNKNOWN\n"
31text sfbad "FAKE UNEXPECTED\n"
32text sfgpu "NVIDIA GB10"
33global sfenv uchar 256
34global sfst ulong 4
35
36fn sflog t view uchar * to void
37n = write 2 t 0 len t
38end
39
40note Fault letter from SMIFAULT, read once (gst-like cache: sfst 0 = letter + 1, 0 unread).
41fn sfmode to uchar
42if ne get sfst 0 0
43ret uchar sub get sfst 0 1
44end
45m = uchar 0
46ec = envcnt
47for i ulong ulong ec
48n = envread i sfenv 0 len sfenv
49if le n long len sfkey
50continue
51end
52same = true
53for k ulong len sfkey
54if ne get sfenv k get sfkey k
55same = false
56end
57end
58if same
59m = get sfenv len sfkey
60end
61end
62put sfst 0 add ulong m 1
63ret m
64end
65
66fn sfcard to void
67put nvcard 0 1
68put nvcard 16 0
69put nvcard 17 15
70end
71
72fn sfname bad bool to void
73for i ulong len sfgpu
74put nvpar add 4 i get sfgpu i
75end
76if bad
77for i ulong 64
78put nvpar add 4 i 65
79end
80end
81end
82
83fn sftherm to void
84n = ulong npget 20
85for k ulong n
86o = add 24 mul k 44
87op = npget add o 8
88npput o 0
89npput add o 4 1
90if eq op 256
91npput add o 12 1
92end
93if eq op 1280
94npput add o 12 1
95end
96if eq op 257
97npput add o 16 1
98end
99if eq op 1312
100npput add o 16 0
101end
102if eq op 5376
103npput add o 16 37
104end
105end
106if eq sfmode 116
107npput 28 0
108end
109end
110
111fn sfpinfo to void
112n = ulong npget 0
113for i ulong n
114o = add 8 mul i 72
115npput add o 8 0
116npp64 add o 16 add mul ulong 335 1048576 12345
117end
118end
119
120note Utilization samples (NV2080_CTRL_CMD_PERF_GET_GPUMON_PERFMON_UTIL_SAMPLES_V2) into smbig.
121note A request other than type 2 with bufSize 55872 is unexpected.
122fn sfutil to uint
123if or ne get smbig 0 2 ne sbget 4 55872
124sflog sfbad
125ret 31
126end
127if eq sfmode 119
128ret 86
129end
130if eq sfmode 121
131ret 27
132end
133if eq sfmode 101
134ret 0
135end
136sbput 8 72
137if eq sfmode 114
138sbput 12 72
139else
140sbput 12 5
141end
142for k ulong 72
143o = add 16 mul k 776
144put smbig o 1
145sbput add o 136 uint mul k 100
146sbput add o 8 uint mul k 50
147end
148o = ulong 3120
149sbput add o 136 4200
150sbput add o 8 1300
151if eq sfmode 120
152sbput add o 136 10001
153end
154if eq sfmode 122
155put smbig o 0
156end
157ret 0
158end
159
160fn sfctrl to uint
161cmd = nhget 8
162sflog sfctl
163if eq cmd 517
164npput 8 7
165ret 0
166end
167if eq cmd 8389266
168npput 0 3
169npput 4 52928
170npput 8 51567
171npput 12 50017
172ret 0
173end
174if eq cmd 545264168
175if eq sfmode 115
176npput 8 2561
177else
178npput 8 2564
179end
180ret 0
181end
182if eq cmd 545259792
183if eq sfmode 99
184ret 86
185end
186sfname eq sfmode 110
187ret 0
188end
189if eq cmd 545260819
190sftherm
191ret 0
192end
193if eq cmd 545259917
194if eq sfmode 112
195npput 8 951
196else
197npput 8 1
198npput 12 4242
199end
200ret 0
201end
202if eq cmd 545267816
203if eq sfmode 113
204ret 27
205end
206if eq sfmode 117
207ret 86
208end
209if eq sfmode 109
210npput 0 384
211else
212npput 0 256
213end
214ret 0
215end
216if eq cmd 545259918
217sfpinfo
218ret 0
219end
220if eq cmd 545267862
221ret sfutil
222end
223sflog sfunk
224ret 86
225end
226
227note Every RM ioctl request number context.om uses on the smi path; anything else is unexpected.
228fn smdrv q uint to long
229if eq q 3223340587
230sflog sfalc
231if eq nhget 12 65
232nhput 8 3251634177
233end
234nhput 28 0
235ret 0
236end
237if eq q 3223340586
238nhput 28 sfctrl
239ret 0
240end
241if eq q 3222292009
242sflog sffree
243if and eq sfmode 102 eq nhget 8 nvbad
244nhput 12 86
245else
246nhput 12 0
247end
248ret 0
249end
250if eq q 3523233480
251sfcard
252ret 0
253end
254if eq q 3221505737
255ret 0
256end
257sflog sfbad
258ret neg long 1
259end
260
261note The device handle context.om allocates first after the root (its handle counter start).
262fn nvbad to uint
263ret 3472883713
264end
265
266fn smfopen to long
267sflog sfopn
268if eq sfmode 111
269ret neg long 2
270end
271put sfst 1 add get sfst 1 1
272ret long add 39 get sfst 1
273end
274
275fn smclose fd int to long
276sflog sfcls
277if or lt fd 40 gt fd 41
278sflog sfbad
279ret neg long 9
280end
281ret 0
282end
283
284fn smbad to long
285sflog sfbad
286ret neg long 1
287end
288
289fn smget m long off ulong w ulong to ulong
290sflog sfbad
291ret 0
292end
293
294fn smaddr m long to ulong
295sflog sfbad
296ret 0
297end