Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/src/omega_gpu_mem_reserve.h # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / src / omega_gpu_mem_reserve.h` 30 lines · 1864 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* omega_gpu_mem_reserve.h -- developer bar D1 (docs/PAIN_POINTS.md, docs/issues/D1-memory.md), shared by the hosted 3 * platforms (src/omega_gpu_platform_linux.c, src/omega_gpu_platform_aien.c). 4 * 5 * On the GB10 every buffer a platform hands out is the machine's own memory, which the CPU and GPU share, and the 6 * machine has no swap by default. Running it out does not end in an error message: the whole box can freeze until a 7 * power cycle. So an allocation that would leave less than a reserve free is refused before a handle slot or the 8 * driver is touched, with a sentence. The reserve is CUDAPP_MEM_RESERVE_MIB (MiB, default 4096; 0 turns the check 9 * off). Tests point the check at a fake meminfo file with omega_gpu_platform_linux_test_set_meminfo (declared in 10 * src/omega_gpu_platform_linux.h, defined in src/omega_gpu_mem_reserve.c for both platforms); no environment variable 11 * chooses that file (CodeQL cpp/path-injection #40). Every open is O_NOFOLLOW|O_NONBLOCK|O_CLOEXEC and must reach a 12 * regular file; a test path that cannot be used that way falls back to /proc/meminfo. When /proc/meminfo itself cannot 13 * be read the check cannot know, and allows the allocation. 14 */ 15 #ifndef OMEGA_GPU_MEM_RESERVE_H 16 #define OMEGA_GPU_MEM_RESERVE_H 17 18 #include 19 #include 20 21 #define CUDAPP_MEM_RESERVE_DEFAULT_MIB 4096ull 22 23 /* The reserve in bytes from CUDAPP_MEM_RESERVE_MIB (default CUDAPP_MEM_RESERVE_DEFAULT_MIB; saturates at UINT64_MAX; 24 * 0 = check off). The Linux reference uses it for local VRAM on a discrete GPU. */ 25 uint64_t omega_gpu_mem_reserve_bytes(void); 26 27 /* Shared host memory: OMEGA_GPU_PLAT_OK, or OMEGA_GPU_PLAT_REFUSED_LIMIT with the sentence in diag (diag_len bytes). */ 28 int omega_gpu_mem_reserve_check(uint64_t bytes, char *diag, size_t diag_len); 29 30 #endif