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 / regalloc_om / packers_units.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | #include "cudapp_native.h" |
| 3 | #include <stdint.h> |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <string.h> |
| 7 | #define CHECK(x) do { if (!(x)) { fprintf(stderr,"FAIL provider line %d\n",__LINE__); return 1; } } while (0) |
| 8 | int main(void) { |
| 9 | uint64_t r, p[12] = {0,1,1,16,16}; |
| 10 | CHECK(omega_cg_pklen(&r,p,12)==0 && r==0 && p[8]==2 && p[9]==256); |
| 11 | uint16_t s=0x1234,d[256],before[256]; |
| 12 | memset(d,0x5a,sizeof d); memcpy(before,d,sizeof d); |
| 13 | CHECK(omega_cg_pkh(&r,p,12,&s,1,d,256)==0 && (int64_t)r==-1 && !memcmp(d,before,sizeof d)); |
| 14 | CHECK(omega_cg_pkh(&r,p,12,&s,2,d,255)==0 && (int64_t)r==-1 && !memcmp(d,before,sizeof d)); |
| 15 | p[0]=9; CHECK(omega_cg_pklen(&r,p,12)==0 && (int64_t)r==-1); |
| 16 | p[0]=0;p[1]=17; CHECK(omega_cg_pklen(&r,p,12)==0 && (int64_t)r==-1); |
| 17 | p[1]=1;p[3]=17; CHECK(omega_cg_pklen(&r,p,12)==0 && (int64_t)r==-1); |
| 18 | p[3]=16;p[2]=17; CHECK(omega_cg_pklen(&r,p,12)==0 && (int64_t)r==-1); |
| 19 | p[2]=1;p[4]=17; CHECK(omega_cg_pklen(&r,p,12)==0 && (int64_t)r==-1); |
| 20 | p[0]=2;p[4]=16;p[6]=2;p[7]=1; CHECK(omega_cg_pklen(&r,p,12)==0 && (int64_t)r==-1); |
| 21 | const uint32_t dims[]={0,1,2,7,8,15,16,17,31}; |
| 22 | for(unsigned mi=0;mi<sizeof dims/sizeof *dims;++mi) for(unsigned ni=0;ni<sizeof dims/sizeof *dims;++ni) { |
| 23 | uint64_t m=dims[mi],n=dims[ni],np=n+3,q[3]={m,n,np}; |
| 24 | size_t sn=m*np,dn=m*n; |
| 25 | float *src=malloc((sn+1)*sizeof *src),*dst=malloc((dn+1)*sizeof *dst),*exp=malloc((dn+1)*sizeof *exp); |
| 26 | CHECK(src&&dst&&exp); |
| 27 | for(size_t i=0;i<sn+1;++i) { uint32_t bits=0x7fc00000u+(uint32_t)i; memcpy(src+i,&bits,4); } |
| 28 | memset(dst,0xa5,(dn+1)*sizeof *dst);memcpy(exp,dst,(dn+1)*sizeof *dst); |
| 29 | for(size_t row=0;row<m;++row) memcpy(exp+row*n,src+row*np,n*sizeof *exp); |
| 30 | CHECK(omega_mrow(&r,q,3,src,sn,dst,dn)==0 && r==0 && !memcmp(dst,exp,(dn+1)*sizeof *dst)); |
| 31 | if(sn) CHECK(omega_mrow(&r,q,3,src,sn-1,dst,dn)==0 && (int64_t)r==-1); |
| 32 | if(dn) CHECK(omega_mrow(&r,q,3,src,sn,dst,dn-1)==0 && (int64_t)r==-1); |
| 33 | free(src);free(dst);free(exp); |
| 34 | } |
| 35 | uint64_t q[3]={1,2,1};float a[4]={0}; |
| 36 | CHECK(omega_mrow(&r,q,3,a,2,a+2,2)==0 && (int64_t)r==-1); |
| 37 | q[0]=UINT64_MAX;q[1]=q[2]=0; |
| 38 | CHECK(omega_mrow(&r,q,3,a,0,a+2,0)==0 && (int64_t)r==-1); |
| 39 | q[0]=q[1]=q[2]=1; |
| 40 | CHECK(omega_mrow(&r,q,3,a,1,a,1)!=0); |
| 41 | puts("PASS fragment metadata, short-view refusal and row-compaction bitwise differential"); |
| 42 | return 0; |
| 43 | } |