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_api_views_rest.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_api_views_rest.h` 80 lines · 3703 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 #ifndef OMEGA_API_VIEWS_REST_H 3 #define OMEGA_API_VIEWS_REST_H 4 #include "cudapp_native.h" 5 #include "omega_gpu_session.h" 6 #include 7 #include 8 #ifndef CUDAPP_MIGRATION_PENDING_API_VIEWS_REST 9 #define CUDAPP_MIGRATION_PENDING_API_VIEWS_REST 0 10 #endif 11 /* A bridge trap is an internal shape/layout error, never a successful partial conversion. */ 12 static inline void ar_check(uint32_t trap) { if (trap) abort(); } 13 static inline void ar_args(uint32_t *out, size_t words, const uint64_t *va, size_t count) { 14 uint64_t r = 0; 15 ar_check(omega_arargs(&r, va, count, out, words)); 16 if (r) abort(); 17 } 18 static inline void ar_fill(uint32_t *out, size_t n, uint32_t value) { 19 uint64_t r = 0; 20 ar_check(omega_arfill(&r, value, out, n)); 21 } 22 static inline size_t ar_count(const uint32_t *p, size_t n, uint32_t value) { 23 uint64_t r = 0; 24 ar_check(omega_arcount(&r, value, p, n)); 25 return (size_t)r; 26 } 27 static inline void ar_words(void *out, size_t words, const uint32_t *in, size_t count) { 28 uint64_t r = 0; 29 ar_check(omega_arpad(&r, in, count, out, words)); 30 if (r) abort(); 31 } 32 static inline void ar_copy(void *out, const void *in, size_t bytes) { 33 uint64_t r = 0; 34 ar_check(omega_arcopy(&r, in, bytes, out, bytes)); 35 if (r) abort(); 36 } 37 static inline uint64_t ar_plan(uint64_t q[32]) { 38 uint64_t r = 0; 39 ar_check(omega_arcalc(&r, q, 32)); 40 return r; 41 } 42 static inline void ar_args_extra(uint32_t *out, size_t words, const uint64_t *va, size_t count, 43 const uint32_t *scalar, size_t nscalar) { 44 uint64_t r = 0; 45 ar_check(omega_arargsx(&r, va, count, scalar, nscalar, out, words)); 46 if (r) abort(); 47 } 48 static inline void ar_key(void *out, size_t words, uint32_t kind, const void *spec, size_t count) { 49 uint64_t r = 0; 50 ar_check(omega_arkey(&r, kind, spec, count, out, words)); 51 if (r) abort(); 52 } 53 static inline size_t ar_cache(const void *slots, size_t bytes, size_t count, size_t stride, 54 size_t valid, size_t offset, const void *key, size_t keybytes) { 55 const uint64_t q[8] = {count, stride, valid, offset, keybytes}; 56 uint64_t r = UINT64_MAX; 57 ar_check(omega_arcache(&r, q, 8, slots, bytes, key, keybytes)); 58 return (size_t)r; 59 } 60 _Static_assert(sizeof(void *) == sizeof(uint64_t), "launch pointer width"); 61 _Static_assert(sizeof(OmegaGpuLaunch) == 80, "launch view extent"); 62 _Static_assert(offsetof(OmegaGpuLaunch, code_va) == 0, "launch code offset"); 63 _Static_assert(offsetof(OmegaGpuLaunch, gpr_count) == 8, "launch gpr offset"); 64 _Static_assert(offsetof(OmegaGpuLaunch, threads_x) == 12, "launch threads offset"); 65 _Static_assert(offsetof(OmegaGpuLaunch, threads_y) == 16, "launch threads y offset"); 66 _Static_assert(offsetof(OmegaGpuLaunch, grid_x) == 20, "launch grid offset"); 67 _Static_assert(offsetof(OmegaGpuLaunch, grid_y) == 24, "launch grid y offset"); 68 _Static_assert(offsetof(OmegaGpuLaunch, num_elements) == 32, "launch elements offset"); 69 _Static_assert(offsetof(OmegaGpuLaunch, args) == 40, "launch args offset"); 70 _Static_assert(offsetof(OmegaGpuLaunch, n_args) == 48, "launch argc offset"); 71 _Static_assert(offsetof(OmegaGpuLaunch, timeout_ms) == 56, "launch timeout offset"); 72 _Static_assert(offsetof(OmegaGpuLaunch, shared_bytes) == 64, "launch shared offset"); 73 _Static_assert(offsetof(OmegaGpuLaunch, spin_us) == 68, "launch spin offset"); 74 _Static_assert(offsetof(OmegaGpuLaunch, target_sm) == 72, "launch sm offset"); 75 static inline void ar_launch(OmegaGpuLaunch *launch, const uint64_t q[16]) { 76 uint64_t r = 0; 77 ar_check(omega_arlaunch(&r, q, 16, launch, 20)); 78 if (r) abort(); 79 } 80 #endif