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
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | #ifndef NVRM_STRUCT_H |
| 3 | #define NVRM_STRUCT_H |
| 4 | #include <stddef.h> |
| 5 | #include <stdint.h> |
| 6 | #include <stdlib.h> |
| 7 | #include "cudapp_native.h" |
| 8 | #ifndef CUDAPP_MIGRATION_PENDING_C_NVRM_STRUCT |
| 9 | #define CUDAPP_MIGRATION_PENDING_C_NVRM_STRUCT 0 |
| 10 | #endif |
| 11 | static inline int ns_pack(void *p, size_t n, uint64_t kind, const uint64_t *a, size_t count) { |
| 12 | uint64_t got = 0; |
| 13 | return omega_nvrm_struct(&got, 0, kind, a, count, p, n) || got != n; |
| 14 | } |
| 15 | /* Internal schema/bridge errors are programming defects, never a decoded zero. |
| 16 | * This cannot encounter driver-controlled sizes: every caller passes sizeof. */ |
| 17 | static inline uint64_t ns_get(void *p, size_t n, uint64_t kind, uint64_t field, uint64_t index) { |
| 18 | uint64_t a[2] = {field, index}, got = 0; |
| 19 | if (omega_nvrm_struct(&got, 1, kind, a, 2, p, n)) abort(); |
| 20 | return got; |
| 21 | } |
| 22 | #define NS_PACK(p, kind, ...) ns_pack(&(p), sizeof(p), (kind), (const uint64_t[]){__VA_ARGS__}, sizeof((const uint64_t[]){__VA_ARGS__}) / sizeof(uint64_t)) |
| 23 | #define NS_FILL(p, kind, ...) do { if (NS_PACK(p, kind, __VA_ARGS__)) return fail(rm, "Omega RM/UVM struct refused"); } while (0) |
| 24 | #if CUDAPP_MIGRATION_PENDING_C_NVRM_STRUCT |
| 25 | #define NS_VALUE(p, kind, field, legacy) (legacy) |
| 26 | #else |
| 27 | #define NS_VALUE(p, kind, field, legacy) NS_GET(p, kind, field) |
| 28 | #endif |
| 29 | #define NS_GET(p, kind, field) ns_get(&(p), sizeof(p), (kind), (field), 0) |
| 30 | #endif |