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 / codegen_tc_host_cubin.c

33 lines · 1945 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2#include "omega_blackwell_codegen_tc.h"
3#include "omega_blackwell_codegen_tc2.h"
4#include "omega_cubin.h"
5#include <stdio.h>
6#include <string.h>
7extern int oracle_omega_blackwell_codegen_tcgemm_prog(const OmegaTcGemmSpec *,BlackwellIRProgram *);
8extern int oracle_omega_blackwell_codegen_tc2_prog(const OmegaTc2Spec *,BlackwellIRProgram *);
9extern uint32_t oracle_omega_tcgemm_shared_bytes(const OmegaTcGemmSpec *);
10extern uint32_t oracle_omega_tc2_shared_bytes(const OmegaTc2Spec *);
11static BlackwellIRProgram a,b;
12static uint8_t x[BW_MAX_IR_INSNS*16],y[BW_MAX_IR_INSNS*16];
13static int equal(uint32_t sa,uint32_t sb) {
14 size_t nx=0,ny=0,cx=0,cy=0;uint8_t *u=NULL,*v=NULL;char err[128];int ok=0;
15 if(omega_bw_encode_program(&a,x,sizeof x,&nx)||omega_bw_encode_program(&b,y,sizeof y,&ny))return 0;
16 if(omega_cubin_pack("tc_host",x,nx,NULL,0,OMEGA_CUBIN_PARAM_BASE,omega_bw_gpr_declared(a.regalloc.peak_gpr_usage),sa,&u,&cx,err,sizeof err)) { fprintf(stderr,"oracle cubin: %s\n",err);return 0; }
17 if(!omega_cubin_pack("tc_host",y,ny,NULL,0,OMEGA_CUBIN_PARAM_BASE,omega_bw_gpr_declared(b.regalloc.peak_gpr_usage),sb,&v,&cy,err,sizeof err))ok=cx==cy&&!memcmp(u,v,cx);
18 omega_cubin_free(u);omega_cubin_free(v);return ok;
19}
20int main(void) {
21 unsigned cases=0;
22 for(int m=0;m<=4;m++) {
23 OmegaTcGemmSpec s={2048,4,2,8,m};
24 if(oracle_omega_blackwell_codegen_tcgemm_prog(&s,&a)||omega_blackwell_codegen_tcgemm_prog(&s,&b)||!equal(oracle_omega_tcgemm_shared_bytes(&s),omega_tcgemm_shared_bytes(&s)))return 1;
25 cases++;
26 for(unsigned ep=0;ep<=1;ep++)for(unsigned dr=0;dr<=1;dr++) {
27 OmegaTc2Spec t={2048,8,2,16,1,ep,dr,1536,m};
28 if(oracle_omega_blackwell_codegen_tc2_prog(&t,&a)||omega_blackwell_codegen_tc2_prog(&t,&b)||!equal(oracle_omega_tc2_shared_bytes(&t),omega_tc2_shared_bytes(&t)))return 1;
29 cases++;
30 }
31 }
32 printf("TC-HOST-CUBIN-IDENTITY PASS cases=%u\n",cases);return 0;
33}