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 / src / omega_gpu_platform_linux.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* omega_gpu_platform_linux.h -- the Linux REFERENCE implementation of OmegaGpuPlatform (ABI 1.1). |
| 3 | * |
| 4 | * REFERENCE ONLY (native v1 P07 cut C, session part; aienos#286). This is today's GB10 path under Linux |
| 5 | * (physics nvrm + m16_native, the open NVIDIA kernel driver), wrapped in the platform contract so the |
| 6 | * portable session (src/omega_gpu_session.c) runs the same launch words it always ran. It is NOT the |
| 7 | * native platform and is not part of the freestanding closure: it includes Linux headers, takes pthread |
| 8 | * mutexes, reads CLOCK_MONOTONIC and calls malloc. The AIENOS platform implements the same table over its |
| 9 | * own device ownership (cut B); nothing in the session may depend on anything this file does beyond the |
| 10 | * contract in src/omega_gpu_platform.h. |
| 11 | * |
| 12 | * What it provides: TIME, WAIT, LOCK, DMA, SYNC, COMPLETION (polling: m16_native_wait_marker, a 50 us |
| 13 | * sleep-poll), DEVICE, QUEUE, CLOCK_NS, HOST_MEM. Not MMIO (the RM driver owns the registers) and not IRQ |
| 14 | * (polling is never claimed as interrupt support). One device (ordinal 0), one queue (the m16 channel, |
| 15 | * GPFIFO entries carrying the method words copied into the BUF_QUEUE ring), every buffer GPU-uncached |
| 16 | * (nvrm_alloc_gpu_uncached; a GPU_CACHED request is refused with REFUSED_CACHE_POLICY because nothing here |
| 17 | * would flush it). The bus address is reported as 0: the RM driver owns the IOMMU mapping and does not |
| 18 | * expose it. Closing the device makes every buffer and queue handle of it stale (generation bump); the RM |
| 19 | * client close releases the driver objects, as the session always did. |
| 20 | * |
| 21 | * Tested by tests/test_omega_gpu_platform_linux.c on the simulated driver (tests/fake_m16_native.c); |
| 22 | * GB10 execution through it is the same driver calls as before this cut and is NOT re-run here. |
| 23 | * Policy (prefix words, channel count, range, alloc class, page round, min-free parse, inflight, |
| 24 | * submit fit, poll checks, extra-queue slot, target SM) is om/platform-linux/plat_policy.om. |
| 25 | * Ring publication and the CPU fence are om/platform-linux/plat_effects.om (cpufence, byte store). |
| 26 | * Channel submit, ioctl and mmap stay in C. CUDAPP_MIGRATION_PENDING_C_PLATFORM_LINUX defaults OFF; defining it selects the C oracle. |
| 27 | */ |
| 28 | #ifndef OMEGA_GPU_PLATFORM_LINUX_H |
| 29 | #define OMEGA_GPU_PLATFORM_LINUX_H |
| 30 | |
| 31 | #include "omega_gpu_platform.h" |
| 32 | |
| 33 | #ifdef __cplusplus |
| 34 | extern "C" { |
| 35 | #endif |
| 36 | |
| 37 | #define OMEGA_GPU_PLATFORM_LINUX_LOCKS 4u /* lock ids 0..3 */ |
| 38 | |
| 39 | /* The process-wide Linux reference platform and its caps (written to *caps when caps is not NULL). */ |
| 40 | const OmegaGpuPlatform *omega_gpu_platform_linux(OmegaGpuPlatformCaps *caps); |
| 41 | |
| 42 | /* L136: channels (GPFIFO queues) the next device_open creates, from env AIEN_OMEGA_GPU_CHANNELS: 1 (unset, empty, "1" or |
| 43 | * anything not 2..4) is today's single channel exactly; 2..4 adds that many minus one channels in the same channel group |
| 44 | * (nvrm_channel_n). Queue i (0-based, in queue_open order) submits on channel i. Read at every device_open. */ |
| 45 | uint32_t omega_gpu_platform_linux_channels_env(void); |
| 46 | /* Exact target of the open Linux device, or 0 while closed. */ |
| 47 | uint32_t omega_gpu_platform_linux_target_sm(void); |
| 48 | int omega_gpu_platform_linux_vram_info(uint64_t *free_bytes, uint64_t *total_bytes); |
| 49 | |
| 50 | /* TEST ONLY. The D1 memory reserve check reads MemAvailable from path instead of /proc/meminfo; NULL or "" restores |
| 51 | * /proc/meminfo. A path that does not open, without following a final symlink and without blocking, to a regular file |
| 52 | * falls back to /proc/meminfo. Returns 0, or -1 (nothing changed) when path is 4096 bytes or longer. */ |
| 53 | int omega_gpu_platform_linux_test_set_meminfo(const char *path); |
| 54 | |
| 55 | #ifdef __cplusplus |
| 56 | } |
| 57 | #endif |
| 58 | #endif |