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 / om / prefill-shape / cache-check.c

38 lines · 2017 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
2/* Exercise the real prefill cache admission without opening a GPU. Stop exactly
3 * at code allocation, after the generator and resource checks have run. */
4#include "omega_gpu_prefill.h"
5#include "omega_blackwell_codegen_qg.h"
6#include <stdio.h>
7#include <string.h>
8#include "../standalone-oracles/oracle.h"
9static unsigned allocations;
10int __wrap_omega_gpu_session_alloc_code(size_t bytes, OmegaGpuMem *out) {
11 (void)bytes; (void)out; allocations=(unsigned)so_call(5,allocations,1,0,0); return -1;
12}
13static int gen(const OmegaPfKey *key, void *vp) {
14 BlackwellIRProgram *p = vp;
15 OmegaQgSpec s; memset(&s, 0, sizeof s);
16 s.k=5120; s.n=16384; s.rt=key->words[0]; s.warps=8; s.wait=45; s.direct=1;
17 int rc=omega_blackwell_codegen_qgemm_prog(&s,p);
18 if (so_all(so_eq(rc,0),so_eq(key->words[1],1),1)) p->regalloc.gpr_limit=0;
19 if (so_all(so_eq(rc,0),so_eq(key->words[1],2),1)) p->regalloc.gpr_limit=(int)so_call(5,BW_PHYS_GPR_HW_LIMIT,1,0,0);
20 if (so_all(so_eq(rc,0),so_eq(key->words[1],3),1)) p->regalloc.peak_gpr_usage=(int)so_call(5,BW_PHYS_GPR_HW_LIMIT,1,0,0);
21 return rc;
22}
23int main(void) {
24 unsigned failed=0;
25 for(unsigned i=0;i<5;i++) {
26 OmegaPfKey key; memset(&key,0,sizeof key); key.kind=999;
27 key.words[0]=(unsigned)so_call(11,i,0,0,0); key.words[1]=(unsigned)so_call(12,i,0,0,0);
28 OmegaPfKernel out; allocations=0;
29 int rc=omega_gpu_pf_kernel_locked(&key,gen,&out);
30 unsigned want=(unsigned)so_call(13,i,0,0,0);
31 int expected=(int)(int64_t)so_call(41,want,(uint64_t)(int64_t)OMEGA_GPU_PF_TOO_LARGE,(uint64_t)(int64_t)OMEGA_GPU_PF_CHIP_FAIL,0);
32 if(!so_call(14,allocations,want,(uint64_t)(int64_t)rc,(uint64_t)(int64_t)expected)) {
33 fprintf(stderr,"cache case %u rc=%d allocations=%u wanted=%u\n",i,rc,allocations,want); failed=so_bad(failed,0);
34 }
35 }
36 printf("prefill cache admission: %s\n",failed?"FAIL":"PASS");
37 return failed?1:0;
38}