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 / liveness.c
| 1 | /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ |
| 2 | #include "omega_gpu_om_ir.h" |
| 3 | #include <stdio.h> |
| 4 | #include <string.h> |
| 5 | static uint32_t emit(uint64_t *ret,uint64_t kind,uint64_t a,uint64_t b,uint64_t c,void *ip,uint64_t ni,void *mp,uint64_t nm) { |
| 6 | (void)a;(void)b;(void)c; |
| 7 | if(ni!=8192 || nm!=512) return 1; |
| 8 | uint64_t *i=ip,*m=mp; |
| 9 | m[0]=4;m[1]=kind==5?161:160;m[7]=kind==0?0:kind==2?2:1; |
| 10 | for(unsigned v=0;v<m[1];++v) m[64+v]=1; |
| 11 | for(unsigned k=0;k<4;++k) for(unsigned f=1;f<=5;++f) i[k*8+f]=UINT64_MAX; |
| 12 | i[0]=BW_IR_MOV_RZ;i[1]=159; |
| 13 | i[8]=BW_IR_NOP; |
| 14 | i[16]=BW_IR_MOV_RZ;i[17]=159; |
| 15 | i[24]=BW_IR_EXIT; |
| 16 | m[511]=kind==3?1:kind==4?4:3; |
| 17 | *ret=0;return 0; |
| 18 | } |
| 19 | int main(void) { |
| 20 | BlackwellIRProgram a,b; |
| 21 | int expect[]={0,0,OMEGA_OM_IR_LIVE_FLAG,OMEGA_OM_IR_LIVE_RANGE,OMEGA_OM_IR_LIVE_RANGE,OMEGA_OM_IR_LIVE_RANGE}; |
| 22 | for(unsigned k=0;k<6;++k) { |
| 23 | int rc=omega_gpu_om_ir_replay(emit,k,0,0,0,&a,NULL); |
| 24 | if(rc!=expect[k]) {fprintf(stderr,"FAIL liveness case=%u rc=%d expected=%d\n",k,rc,expect[k]);return 1;} |
| 25 | if(k==0) b=a; |
| 26 | if(k==1 && (a.regalloc.intervals[159].last_use!=3 || b.regalloc.intervals[159].last_use!=2)) return 2; |
| 27 | } |
| 28 | BlackwellIRProgram direct; |
| 29 | omega_bw_ir_init(&direct); |
| 30 | for(unsigned v=0;v<160;++v) omega_bw_ir_alloc_vreg(&direct); |
| 31 | BlackwellIRInsn in={0};in.dst_vreg=in.src1_vreg=in.src2_vreg=in.src3_vreg=in.ureg=-1; |
| 32 | in.op=BW_IR_MOV_RZ;in.dst_vreg=159;omega_bw_ir_append(&direct,&in); |
| 33 | in.op=BW_IR_NOP;in.dst_vreg=-1;omega_bw_ir_append(&direct,&in); |
| 34 | in.op=BW_IR_MOV_RZ;in.dst_vreg=159;omega_bw_ir_append(&direct,&in); |
| 35 | in.op=BW_IR_EXIT;in.dst_vreg=-1;omega_bw_ir_append(&direct,&in); |
| 36 | omega_bw_regalloc_solve(&direct); |
| 37 | if(memcmp(&direct,&b,sizeof b)) {fputs("FAIL zero flag changed default replay\n",stderr);return 3;} |
| 38 | puts("PASS exact-liveness flag-zero flag-invalid shortened past-end v159 v160"); |
| 39 | return 0; |
| 40 | } |