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_ampere_qmd.c # 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_ampere_qmd.c` 72 lines · 3217 bytes Raw Blame History 1 /* ORACLE: default-OFF C ABI reference below; all policy/QMD packing is om/encoder/amp_runtime.om + amp_qmd.om. */ 2 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 3 #include "omega_ampere_qmd.h" 4 #include 5 #include 6 #ifdef CUDAPP_MIGRATION_PENDING_AMP_QMD_DIFF 7 /* The differential oracle aborts, so it is hosted-only; NO_POSIX builds never include it. */ 8 #ifndef OMEGA_GPU_NO_POSIX 9 #include 10 #endif 11 #endif 12 /* Original C caller retained for differential verification, never the default. */ 13 #if defined(CUDAPP_MIGRATION_PENDING_AMP_QMD) || defined(CUDAPP_MIGRATION_PENDING_AMP_QMD_DIFF) 14 extern uint32_t omega_amp_runtime(uint64_t *, const void *, uint64_t, void *, uint64_t); 15 static int c_ampere_policy(const uint64_t m[16], uint32_t q[64]) { 16 uint64_t out[64] = {0}, accepted = 0; 17 if (!m || omega_amp_runtime(&accepted, m, 16, out, 64) != 0 || accepted != 1) return -1; 18 if (q) for (size_t i = 0; i < 64; i++) q[i] = (uint32_t)out[i]; 19 return 0; 20 } 21 static int c_ampere_build_qmd(uint32_t q[64], uint64_t code, uint64_t cbank, 22 uint64_t semaphore, uint32_t tx, uint32_t ty, 23 uint32_t gx, uint32_t gy, uint32_t registers, 24 uint32_t shared_bytes) { 25 const uint64_t m[16] = {3, code, cbank, semaphore, tx, ty, gx, gy, registers, shared_bytes}; 26 return q ? c_ampere_policy(m, q) : -1; 27 } 28 #endif 29 #ifndef CUDAPP_MIGRATION_PENDING_AMP_QMD 30 #ifdef OMEGA_GPU_NO_POSIX 31 #include "omega_native.h" 32 #define omega_amp_qmd omega2_amp_qmd 33 #else 34 #include "cudapp_native.h" 35 #endif 36 _Static_assert(__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__, "amp_qmd.om emits little-endian uint32 bytes"); 37 #endif 38 int omega_ampere_policy(const uint64_t m[16], uint32_t q[64]) { 39 #ifdef CUDAPP_MIGRATION_PENDING_AMP_QMD 40 return c_ampere_policy(m, q); 41 #else 42 uint8_t scratch[256]; 43 uint64_t accepted = 0; 44 if (!m) return -1; 45 int rc = omega_amp_qmd(&accepted, 0, m, 16, q ? (void *)q : scratch, 256) == 0 && accepted == 1 ? 0 : -1; 46 #ifdef CUDAPP_MIGRATION_PENDING_AMP_QMD_DIFF 47 uint32_t oracle[64] = {0}; 48 int crc = c_ampere_policy(m, oracle); 49 if (rc != crc || (rc == 0 && q && memcmp(q, oracle, sizeof oracle))) abort(); 50 #endif 51 return rc; 52 #endif 53 } 54 int omega_ampere_build_qmd(uint32_t q[64], uint64_t code, uint64_t cbank, 55 uint64_t semaphore, uint32_t tx, uint32_t ty, 56 uint32_t gx, uint32_t gy, uint32_t registers, 57 uint32_t shared_bytes) { 58 #ifdef CUDAPP_MIGRATION_PENDING_AMP_QMD 59 return c_ampere_build_qmd(q, code, cbank, semaphore, tx, ty, gx, gy, registers, shared_bytes); 60 #else 61 const uint64_t a[16] = {code, cbank, semaphore, tx, ty, gx, gy, registers, shared_bytes}; 62 uint64_t accepted = 0; 63 if (!q) return -1; 64 int rc = omega_amp_qmd(&accepted, 1, a, 16, (void *)q, 256) == 0 && accepted == 1 ? 0 : -1; 65 #ifdef CUDAPP_MIGRATION_PENDING_AMP_QMD_DIFF 66 uint32_t oracle[64] = {0}; 67 int crc = c_ampere_build_qmd(oracle, code, cbank, semaphore, tx, ty, gx, gy, registers, shared_bytes); 68 if (rc != crc || (rc == 0 && memcmp(q, oracle, sizeof oracle))) abort(); 69 #endif 70 return rc; 71 #endif 72 }