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 / test_model_graphs_om.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | /* Host-only independent C oracle; no platform or device linked. */ |
| 3 | #include <stdint.h> |
| 4 | #include <stdio.h> |
| 5 | #include <string.h> |
| 6 | #include "cudapp_native.h" |
| 7 | static uint64_t rng=0x429071234ULL; |
| 8 | static uint64_t rand64(void) { rng^=rng<<13; rng^=rng>>7; rng^=rng<<17; return rng; } |
| 9 | static void ref_wire(uint32_t out[32],const uint64_t in[16],uint32_t kind) { |
| 10 | memset(out,0,128); |
| 11 | unsigned n=kind==1?5:kind==2?2:kind==3?4:kind==4?3:kind==5?3:kind==6?5:7; |
| 12 | for(unsigned i=0;i<n;i++) {out[2*i]=(uint32_t)in[i];out[2*i+1]=(uint32_t)(in[i]>>32);} |
| 13 | if(kind==1){out[10]=(uint32_t)in[5];out[11]=(uint32_t)in[6];} |
| 14 | if(kind==2)out[4]=(uint32_t)in[2]; |
| 15 | if(kind==5)out[6]=(uint32_t)in[3]; |
| 16 | if(kind==6)out[10]=(uint32_t)in[5]; |
| 17 | if(kind==7){out[14]=(uint32_t)in[7];out[15]=(uint32_t)in[8];} |
| 18 | } |
| 19 | int main(void) { |
| 20 | uint64_t in[16],result,raw[32];uint32_t old[32],got[32];unsigned cases=0; |
| 21 | for(unsigned k=1;k<=7;k++)for(unsigned j=0;j<10032;j++) { |
| 22 | for(unsigned i=0;i<16;i++)in[i]=j<32?(j==0?0:UINT64_MAX>>(j-1)):rand64(); |
| 23 | ref_wire(old,in,k);memset(got,0xa5,sizeof got);result=0; |
| 24 | int rc=omega_mg_wire(&result,in,16,raw,32,k); |
| 25 | if(rc||result!=1){fprintf(stderr,"FAIL graph wire adapter kind=%u case=%u rc=%d result=%llu\n",k,j,rc,(unsigned long long)result);return 1;} |
| 26 | for(unsigned i=0;i<32;i++)got[i]=(uint32_t)raw[i]; |
| 27 | if(memcmp(old,got,sizeof got)) { |
| 28 | fprintf(stderr,"FAIL graph wire kind=%u case=%u\n",k,j);return 1; |
| 29 | } |
| 30 | got[j%32]^=1; |
| 31 | if(!memcmp(old,got,sizeof got)){fputs("FAIL record flip accepted\n",stderr);return 1;} |
| 32 | cases++; |
| 33 | } |
| 34 | printf("MODEL-GRAPHS wire PASS cases=%u record-flip=CAUGHT\n",cases); |
| 35 | return 0; |
| 36 | } |