interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / tests / test_model_graphs_warp.c

31 lines · 1726 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#include "omega_blackwell_codegen_dec.h"
3#include "cudapp_native.h"
4#include "bw_warp_sim_k.h"
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8int main(void){
9 static BlackwellIRProgram prog;uint32_t in[1280] __attribute__((aligned(16))),out[1024] __attribute__((aligned(16))),tab[256] __attribute__((aligned(16)));
10 WsSim *sim=calloc(1,sizeof *sim);if(!sim)return 1;
11 for(unsigned i=0;i<1280;i++){in[i]=i;}
12 for(unsigned i=0;i<256;i++){tab[i]=i;}
13 uint64_t v[16]={(uintptr_t)in,(uintptr_t)tab,(uintptr_t)out},w[32],r=0;
14 if(omega_mg_wire(&r,v,16,w,32,4)||r!=1){free(sim);return 1;}
15 unsigned killed=0;
16 for(unsigned mutant=0;mutant<2;mutant++){
17 OmegaDecSpec spec={.kind=OMEGA_DEC_GATHER,.stride=256,.width=256,.mutant=(int)mutant};
18 if(omega_blackwell_codegen_dec_prog(&spec,&prog)){free(sim);return 1;}
19 for(unsigned order=0;order<2;order++){
20 memset(sim,0,sizeof *sim);memset(out,0xff,sizeof out);sim->p=&prog;sim->threads=256;sim->order=(int)order;
21 for(unsigned i=0;i<6;i++)sim->cbank[OMEGA_DEC_GA_IN/4+i]=(uint32_t)w[i];
22 sim->nranges=3;sim->ranges[0].lo=(uintptr_t)in;sim->ranges[0].hi=(uintptr_t)(in+1280);
23 sim->ranges[1].lo=(uintptr_t)tab;sim->ranges[1].hi=(uintptr_t)(tab+256);
24 sim->ranges[2].lo=(uintptr_t)out;sim->ranges[2].hi=(uintptr_t)(out+1024);
25 int rc=ws_run(sim,1,4),same=!memcmp(in,out,sizeof out);
26 if((!mutant&&(rc||!same))||(mutant&&!rc&&same)){fprintf(stderr,"FAIL graph gather warp mutant=%u order=%u rc=%d %s\n",mutant,order,rc,sim->msg);free(sim);return 1;}
27 if(mutant)killed++;
28 }
29 }
30 free(sim);printf("MODEL-GRAPHS gather warp PASS orders=2 rows=4 source-index-mutant-killed=%u\n",killed);return 0;
31}