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 / om / admission / chip_admit.om

82 lines · 2169 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Library admission (developer bars D2, D6): which PCI GPU CUDA++ may open, decided before nvrm_open opens any /dev/nvidia node.
3note The C side (src/omega_gpu_chip.c) only reads /sys/bus/pci/devices, compares the CUDAPP_GPU_BDF string and formats the sentence.
4note PCI ids: vendor NVIDIA 0x10de=4318. GB10 0x2e12=11794 runs sm_121 (the chip row of src/omega_gpu_chip.c).
5note Prepared Ampere rows, device tests NOT_RUN (docs/PORT-AMPERE.md, tests/ampere/README.md): GA102 0x2204=8708, GA104 0x2486=9350, 0x2489=9353, sm_86.
6note Class word: PCI base class 0x03 (display or 3D controller) is class shr 16.
7fn chip_target vendor ulong device ulong cls ulong to ulong
8if or ne vendor 4318 ne shr cls 16 3
9ret 0
10end
11if eq device 11794
12ret 121
13end
14if or eq device 8708 or eq device 9350 eq device 9353
15ret 86
16end
17ret 0
18end
19note Bad input: every output word is cleared, then status 4.
20fn chip_bad o edit ulong 4 to ulong
21for k ulong 4
22put o k 0
23end
24put o 0 4
25ret 4
26end
27note d[4i..4i+3] = vendor, device, class, bdf match (0 or 1) for i below n, n at most 16. want=1 when CUDAPP_GPU_BDF is set.
28note Without want every NVIDIA display GPU must be a target (the driver picks the first card). With want only the matched one counts.
29note o[0] status: 0 admitted, 1 no NVIDIA display GPU, 2 the BDF matches no NVIDIA display GPU, 3 not a CUDA++ target, 4 bad input.
30note o[1] entry index, o[2] target sm (0 unless admitted), o[3] PCI device id. Returns o[0].
31fn chip_admit d view ulong 64 n ulong want ulong o edit ulong 4 to ulong
32for k ulong 4
33put o k 0
34end
35if or gt n 16 gt want 1
36ret chip_bad o
37end
38seen = ulong 0
39for i ulong 16
40if ge i n
41break
42end
43b = mul i 4
44v = get d b
45dev = get d add b 1
46cls = get d add b 2
47hit = get d add b 3
48if gt hit 1
49ret chip_bad o
50end
51if and eq v 4318 eq shr cls 16 3
52if or eq want 0 eq hit 1
53seen = add seen 1
54if and eq want 1 gt seen 1
55ret chip_bad o
56end
57t = chip_target v dev cls
58if eq t 0
59put o 0 3
60put o 1 i
61put o 2 0
62put o 3 dev
63ret 3
64end
65if eq seen 1
66put o 1 i
67put o 2 t
68put o 3 dev
69end
70end
71end
72end
73if eq seen 0
74if eq want 1
75put o 0 2
76ret 2
77end
78put o 0 1
79ret 1
80end
81ret 0
82end