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_mem_cached.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | #ifndef OMEGA_GPU_MEM_CACHED_H |
| 3 | #define OMEGA_GPU_MEM_CACHED_H |
| 4 | /* GPU-cached device-visible DATA memory for weights or chip-only intermediates. |
| 5 | * No CPU_READ or HOST_POLLED right is granted: nvos.h NVOS32_ATTR2_GPU_CACHEABLE |
| 6 | * says system memory is not coherent with direct CPU mappings. Session command, |
| 7 | * constant-bank, QMD and completion buffers therefore stay GPU-uncached. |
| 8 | * |
| 9 | * CPU initialization or rewrite requires omega_gpu_session_sync_to_gpu before |
| 10 | * submission (the Linux platform tracks required L2 invalidation). To read a |
| 11 | * chip-produced region on the host, copy it on the GPU into uncached staging, |
| 12 | * observe completion, then sync/read staging; never dereference this cached |
| 13 | * buffer as a CPU readback shortcut. The existing q38 graph uses that protocol. |
| 14 | * |
| 15 | * Caller holds the session lock with the device open, and retains the allocation |
| 16 | * until GPU completion. Where an existing versioned slot owns it, pin that slot |
| 17 | * before taking its address and unpin only after completion, without holding the |
| 18 | * slot-table lock while polling. Uncertain completion must use the session latch |
| 19 | * and parking protocol, not release memory still reachable by the device. This |
| 20 | * allocator does not introduce another lifetime table or select caller roles. */ |
| 21 | #include <stddef.h> |
| 22 | #include "omega_gpu_session.h" |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | int omega_gpu_session_alloc_cached(size_t bytes, OmegaGpuMem *out); |
| 27 | #ifdef __cplusplus |
| 28 | } |
| 29 | #endif |
| 30 | #endif |