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_host_policy.h
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | #ifndef OMEGA_HOST_POLICY_H |
| 3 | #define OMEGA_HOST_POLICY_H |
| 4 | #include "cudapp_native.h" |
| 5 | #ifndef CUDAPP_MIGRATION_PENDING_C_API_POLICY |
| 6 | #define CUDAPP_MIGRATION_PENDING_C_API_POLICY 0 |
| 7 | #endif |
| 8 | /* Internal, not a public runtime API. All dimensions arrive as uint32_t. */ |
| 9 | static inline int omega_host_shape(unsigned mode, uint32_t a, uint32_t b, uint32_t c) { |
| 10 | /* MIGRATION-PENDING C (freestanding only): the pinned bridge-freest converter refuses om/components/api_policy.om |
| 11 | * (toc line 16, error 24, "unsupported freest scalar capability") and the hosted bridge output needs the hosted |
| 12 | * trap runtime, which the freestanding link forbids. OMEGA_GPU_NO_POSIX builds keep the C rules below, as before |
| 13 | * the migration; every hosted build runs the Omega unit. */ |
| 14 | #if CUDAPP_MIGRATION_PENDING_C_API_POLICY || defined(OMEGA_GPU_NO_POSIX) |
| 15 | switch (mode) { |
| 16 | case 0: return (!a || !b || !c) ? -1 : (a > 8192u || b > 16384u || c > 262144u) ? -2 : 0; |
| 17 | case 1: return (!a || !b || b % 128u) ? -1 : b > 16384u ? -2 : 0; |
| 18 | case 2: return (!a || b < 2u || (b & 1u)) ? -1 : b > 2048u ? -2 : 0; |
| 19 | case 3: return (!a || !b || !c) ? -1 : (c > 256u || a > 1024u) ? -2 : a % b ? -1 : 0; |
| 20 | case 4: return a > c || b > c - a ? -1 : 0; |
| 21 | case 5: return (!a || !b || b % 256u) ? -1 : b > c ? -2 : 0; |
| 22 | case 6: return ((a != 128u && a != 256u) || b > 1u) ? -1 : 0; |
| 23 | default: return -1; |
| 24 | } |
| 25 | #else |
| 26 | uint64_t result = 1; |
| 27 | if (omega_api_policy(&result, mode, a, b, c) != OMEGA_OK || result > 2) return -1; |
| 28 | return -(int)result; |
| 29 | #endif |
| 30 | } |
| 31 | #endif |