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/m16/m16_native.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 / m16 / m16_native.h` 55 lines · 2169 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* 3 * m16_native.h -- M16 libcuda-free native accelerator interface. 4 * 5 * Wraps the generic NVIDIA RM/UVM substrate (nvrm/) for independent 6 * milestone qualification and testability. 7 */ 8 #ifndef M16_NATIVE_H 9 #define M16_NATIVE_H 10 11 #include "nvrm.h" 12 #include 13 #include 14 15 typedef struct { 16 Nvrm rm; 17 NvrmMem pb_mem; 18 NvrmMem marker_mem; 19 NvrmMem legacy_allocs[64]; 20 } M16NativeContext; 21 22 /* Open RM client, device, VA space, and query card state */ 23 int m16_native_open(M16NativeContext *ctx); 24 25 /* Allocate coherent unified memory mapped identically in CPU and GPU VA */ 26 int m16_native_alloc_memory(M16NativeContext *ctx, size_t size, void **cpu_addr, uint64_t *gpu_va); 27 int m16_native_free_memory(M16NativeContext *ctx, void *cpu_addr); 28 29 /* Create channel group, context share, GPFIFO ring, and schedule channel */ 30 int m16_native_create_channel(M16NativeContext *ctx); 31 32 /* Build the standard M16 semaphore-release method stream */ 33 int m16_native_build_release(uint32_t *words, uint64_t marker_va, uint32_t payload, uint32_t compute_class); 34 35 /* Enqueue method stream to GPFIFO ring (without ringing doorbell) */ 36 int m16_native_enqueue_methods(M16NativeContext *ctx, const uint32_t *methods, size_t count); 37 38 /* Ring usermode doorbell with work-submit token */ 39 void m16_native_ring_doorbell(M16NativeContext *ctx); 40 41 /* Enqueue and ring doorbell */ 42 int m16_native_submit_methods(M16NativeContext *ctx, const uint32_t *methods, size_t count); 43 44 /* Poll coherent marker until it equals expected value or timeout_ms expires */ 45 int m16_native_wait_marker(volatile uint32_t *marker, uint32_t expected, uint64_t timeout_ms); 46 47 /* Poll coherent marker until (int32_t)(*marker - target) >= 0 (monotonic, 48 * serial-number compare per RFC 1982: correct across uint32_t wraparound) 49 * or timeout_ms expires. Returns 0 once satisfied, -1 on timeout. */ 50 int m16_native_wait_marker_ge(volatile uint32_t *marker, uint32_t target, uint64_t timeout_ms); 51 52 /* Free all RM objects, mappings, and close file descriptors */ 53 int m16_native_close(M16NativeContext *ctx); 54 55 #endif /* M16_NATIVE_H */