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