Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/tests/components/native-frame.h # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / tests / components / native-frame.h` 53 lines · 2960 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ 2 /* Verification-only deserializer into the existing BlackwellIRProgram. 3 * No instructions, allocator, numerical algorithm, or interpreter live here. */ 4 #ifndef COMPONENT_NATIVE_FRAME_H 5 #define COMPONENT_NATIVE_FRAME_H 6 static BlackwellIRProgram native_program; 7 static int frame_word(FILE *f, uint64_t *v) { 8 unsigned char b[8]; 9 if (fread(b,1,8,f)!=8) return 0; 10 *v=0; for(unsigned j=0;j<8;j++) *v|=(uint64_t)b[j]<<(j*8); 11 return 1; 12 } 13 static int frame_reg(uint64_t n) { return n==UINT64_MAX ? -1 : (int)n; } 14 static int frame_load(const char *path,int staged) { 15 FILE *f=fopen(path,"rb"); if(!f) return 0; 16 uint64_t h[6],q[8],v; int ok=0; 17 memset(&native_program,0,sizeof native_program); 18 if(staged && (!frame_word(f,&v)||v)) goto done; 19 for(unsigned j=0;j<6;j++) if(!frame_word(f,&h[j])) goto done; 20 if(!h[0]||h[0]>BW_MAX_IR_INSNS||h[1]>BW_MAX_VREGS||h[2]>BW_MAX_UVREGS||h[4]>256||h[5]>64) goto done; 21 native_program.count=(size_t)h[0]; 22 OmegaRegAlloc *r=&native_program.regalloc; 23 r->num_vregs=(int)h[1];r->num_uvregs=(int)h[2];r->peak_gpr_usage=(uint32_t)h[4];r->peak_ugpr_usage=(uint32_t)h[5]; 24 for(unsigned bank=0;bank<2;bank++) for(int j=0;j<(bank?r->num_uvregs:r->num_vregs);j++) { 25 uint64_t width,phys; 26 if(!frame_word(f,&width)||!frame_word(f,&phys)||!width||width>128|| 27 (phys!=UINT64_MAX&&(phys>=(bank?64u:256u)||width>(bank?64u:256u)-phys))) goto done; 28 OmegaLiveInterval *l=bank?&r->uintervals[j]:&r->intervals[j]; 29 l->bundle_size=(uint32_t)width;l->is_pair=width==2;l->is_quad=width==4;l->vreg=j;l->phys_reg=frame_reg(phys); 30 if(bank) r->uvreg_to_phys[j]=frame_reg(phys);else r->vreg_to_phys[j]=frame_reg(phys); 31 } 32 for(size_t j=0;jop=(BlackwellIROpcode)q[0];i->dst_vreg=frame_reg(q[1]);i->src1_vreg=frame_reg(q[2]);i->src2_vreg=frame_reg(q[3]);i->src3_vreg=frame_reg(q[4]);i->ureg=frame_reg(q[5]); 36 i->imm=(uint32_t)q[6];i->control=(uint32_t)(q[6]>>32); 37 i->is_uniform=q[7]&1;i->predicate_p0=(q[7]>>1)&1;i->predicate_not=(q[7]>>2)&1; 38 i->bar_reg=(uint8_t)(q[7]>>8);i->dst_subreg=(uint8_t)(q[7]>>16);i->src1_subreg=(uint8_t)(q[7]>>24);i->src2_subreg=(uint8_t)(q[7]>>32);i->src3_subreg=(uint8_t)(q[7]>>40); 39 } 40 /* Code is independently compared/disassembled by the native Omega conductor, never interpreted here. */ 41 { size_t bytes=0;while(fgetc(f)!=EOF) bytes++; 42 if(ferror(f)||bytes16384) goto done; } 43 ok=1; 44 done: 45 fclose(f);return ok; 46 } 47 static int frame_wrong_result(void) { 48 for(size_t j=0;j