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 / src / omega_gpu_chip.h

87 lines · 4858 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2/* omega_gpu_chip.h: which GPUs CUDA++ has machine code for, and what it says about the others.
3 *
4 * Developer bars D2 and D6 (docs/PAIN_POINTS.md). Two layers:
5 * - the doctor (tools/doctor) reports the qualified-target table below and, for any other GPU,
6 * the long refusal text of omega_gpu_chip_refusal;
7 * - the library itself refuses at device open: nvrm_open calls omega_gpu_chip_admit_open before it
8 * opens any /dev/nvidia node, and omega_gpu_chip_admit_card on the driver-reported card before it
9 * opens /dev/nvidiaN. The decision is the seeded Omega unit om/admission/chip_admit.om; this C
10 * only reads sysfs, compares the CUDAPP_GPU_BDF string and formats the sentence.
11 * The library admits the GB10 (sm_121) and the prepared, chip-NOT_RUN Ampere ids of
12 * docs/PORT-AMPERE.md (sm_86); the doctor's qualified table holds only the GB10.
13 *
14 * A chip is named by its PCI vendor and device id, read from /sys/bus/pci/devices. That needs no
15 * device open and no driver call. (The driver's SM-version field reads 0xa04 on the GB10, which does
16 * not tell sm_120 from sm_121: evidence/m16-blackwell-native-path-requalification-receipt.json.)
17 * New rows require durable raw evidence and a receipt. The existing GB10 row points to a
18 * historical M16 summary whose raw logs are absent; it is not qualification of this checkout. */
19#ifndef OMEGA_GPU_CHIP_H
20#define OMEGA_GPU_CHIP_H
21
22#include <stddef.h>
23#include <stdint.h>
24
25#define OMEGA_GPU_PCI_VENDOR_NVIDIA 0x10deu
26
27typedef struct {
28 uint16_t vendor, device;
29 const char *name; /* "NVIDIA GB10" */
30 const char *sm; /* "sm_121" */
31 const char *receipt; /* historical summary path, not current-commit qualification */
32} OmegaGpuChipRow;
33
34typedef struct {
35 char bdf[64]; /* PCI address, e.g. "000f:01:00.0" */
36 uint16_t vendor, device;
37 uint32_t class_code; /* 0x03xxxx: display or 3D controller */
38} OmegaGpuPciDev;
39
40/* The supported target row for vendor:device, or NULL. This is not an admission check. */
41const OmegaGpuChipRow *omega_gpu_chip_find(uint16_t vendor, uint16_t device);
42
43/* Every NVIDIA display/3D-class PCI function under <root>/sys/bus/pci/devices (root "" = the real
44 * system). Fills up to max entries; returns how many were found (may exceed max), or -1 when the
45 * folder cannot be read. */
46int omega_gpu_chip_scan(const char *root, OmegaGpuPciDev *out, int max);
47
48/* The doctor refusal text for a GPU with no target row: what it is, why the diagnostic refuses,
49 * what is missing, and what to do. Returns the length written (snprintf rules). */
50int omega_gpu_chip_refusal(const OmegaGpuPciDev *d, char *buf, size_t n);
51
52/* Library admission. Status values are those of om/admission/chip_admit.om, plus two C-side ones. */
53enum {
54 OMEGA_GPU_ADMIT_OK = 0,
55 OMEGA_GPU_ADMIT_NO_GPU = 1, /* no NVIDIA display/3D-class PCI function */
56 OMEGA_GPU_ADMIT_NO_BDF = 2, /* CUDAPP_GPU_BDF names no NVIDIA display/3D-class function */
57 OMEGA_GPU_ADMIT_REFUSED = 3, /* an NVIDIA GPU that is not a CUDA++ target */
58 OMEGA_GPU_ADMIT_BAD_INPUT = 4, /* more than OMEGA_GPU_ADMIT_MAX GPUs, or the address matched twice */
59 OMEGA_GPU_ADMIT_NO_SYSFS = 5, /* <root>/sys/bus/pci/devices cannot be read */
60 OMEGA_GPU_ADMIT_UNIT = 6, /* the Omega unit returned a nonzero binding status */
61};
62#define OMEGA_GPU_ADMIT_MAX 16
63
64typedef struct {
65 int status; /* OMEGA_GPU_ADMIT_* */
66 int index; /* entry the decision is about (refused or first admitted) */
67 uint32_t target_sm; /* 121 or 86 when admitted, else 0 */
68 uint16_t device; /* PCI device id of that entry */
69} OmegaGpuChipAdmission;
70
71/* Pure decision over n scanned functions (no I/O): bdf NULL = the driver's first card, else the
72 * canonical dddd:bb:ss.f address. Fills *out and returns out->status. */
73int omega_gpu_chip_admit(const OmegaGpuPciDev *devs, int n, const char *bdf, OmegaGpuChipAdmission *out);
74
75/* Before any device open: scan sysfs (root set by omega_gpu_chip_set_root, default the real
76 * system), decide, and on refusal write one sentence (under 240 bytes) to why. 0 admitted. */
77int omega_gpu_chip_admit_open(const char *bdf, char *why, size_t n);
78
79/* After the driver names the card it will open (NV_ESC_CARD_INFO): decide again on the driver's PCI
80 * vendor:device; *target_sm gets the admitted target. On refusal writes the sentence. 0 admitted. */
81int omega_gpu_chip_admit_card(uint32_t domain, uint32_t bus, uint32_t slot, uint32_t function, uint16_t vendor,
82 uint16_t device, uint32_t *target_sm, char *why, size_t n);
83
84/* Tests only: read <root>/sys/bus/pci/devices instead of /sys/bus/pci/devices (NULL restores). */
85void omega_gpu_chip_set_root(const char *root);
86
87#endif