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 / tests / runtime / cm_route_unit.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | #include <stdint.h> |
| 3 | #include <stdio.h> |
| 4 | #include <string.h> |
| 5 | #ifndef CM_ROUTE_IMPL |
| 6 | #define CM_ROUTE_IMPL "cudapp_om_cm_route.c" |
| 7 | #endif |
| 8 | #include CM_ROUTE_IMPL |
| 9 | static int one(uint64_t n, int red) { |
| 10 | uint64_t d[16] = {n}, r = 0; |
| 11 | if (omega_cm_route(&r, 0, d, 16) || r != 1 || d[1] != n / 64 || |
| 12 | d[2] != n % 64 || d[3] != (n / 64) * 64 + (unsigned)red) return 1; |
| 13 | return 0; |
| 14 | } |
| 15 | int main(int argc, char **argv) { |
| 16 | (void)argv; |
| 17 | const uint64_t cases[] = {0,1,62,63,64,65,126,127,128,129,UINT32_MAX-1, |
| 18 | UINT32_MAX,(uint64_t)UINT32_MAX+1,UINT64_MAX-1,UINT64_MAX}; |
| 19 | for (unsigned i=0;i<sizeof cases/sizeof cases[0];++i) |
| 20 | if (one(cases[i],argc>1)) { fputs("FAIL cm route block plan\n",stderr); return 1; } |
| 21 | for (unsigned field=0;field<6;++field) for (unsigned i=0;i<sizeof cases/sizeof cases[0];++i) { |
| 22 | uint64_t d[16]={1,2,3,4,5,6}, expected=0, result=0; |
| 23 | d[field]=cases[i]; |
| 24 | for (unsigned j=0;j<6;++j) expected+=d[j]; |
| 25 | if (omega_cm_route(&result,1,d,16) || result!=expected) { |
| 26 | fputs("FAIL cm route layout sum\n",stderr); return 1; |
| 27 | } |
| 28 | } |
| 29 | for (unsigned i=0;i<sizeof cases/sizeof cases[0];++i) |
| 30 | for (unsigned j=0;j<sizeof cases/sizeof cases[0];++j) { |
| 31 | uint64_t d[16]={cases[i],cases[j]}, result; |
| 32 | if (omega_cm_route(&result,2,d,16) || result!=(cases[i]<cases[j]) || |
| 33 | omega_cm_route(&result,3,d,16) || result!=cases[i]+cases[j] || |
| 34 | omega_cm_route(&result,4,d,16) || result!=cases[i]-cases[j]) { |
| 35 | fputs("FAIL cm route scalar admission/offset\n",stderr); return 1; |
| 36 | } |
| 37 | } |
| 38 | uint64_t d[16]={0}, result=99; |
| 39 | if (omega_cm_route(&result,UINT64_MAX,d,16) || result!=0) return 1; |
| 40 | if (omega_cm_route(&result,0,d,15)!=32) return 1; |
| 41 | puts("PASS cm route source-partition differential (block, tail, layout, ABI refusal)"); |
| 42 | return 0; |
| 43 | } |