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/amd-kfd-launch/publication.c # 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 / amd-kfd-launch / publication.c` 67 lines · 3288 bytes Raw Blame History 1 /* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 * CPU-only AArch64 instruction-step observer of real Omega packet stores. */ 3 #define _GNU_SOURCE 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 static pid_t child; 18 static void fail(const char *s) { fprintf(stderr,"PUBLICATION FAIL %s\n",s); exit(1); } 19 #define CHECK(x) do { if(!(x)) fail(#x); } while(0) 20 static void readmem(uint64_t a,void *p,size_t n) { 21 for(size_t i=0;i=0); 29 if(!child) { CHECK(!ptrace(PTRACE_TRACEME,0,0,0)); raise(SIGSTOP); execl(argv[1],argv[1],(char *)0); _exit(92); } 30 int st; CHECK(waitpid(child,&st,0)==child && WIFSTOPPED(st)); 31 CHECK(!ptrace(PTRACE_SETOPTIONS,child,0,PTRACE_O_TRACESYSGOOD|PTRACE_O_EXITKILL)); 32 int entry=1,armed=0,stepping=0,published=0,rang=0; uint64_t a[6]={0}; 33 for(;;) { 34 CHECK(!ptrace(stepping?PTRACE_SINGLESTEP:PTRACE_SYSCALL,child,0,0)); 35 CHECK(waitpid(child,&st,0)==child); 36 if(WIFEXITED(st)) { CHECK(WEXITSTATUS(st)==0 && published && rang); fprintf(stderr,"PUBLICATION PASS body-before-header-before-wptr-before-doorbell\n"); return 0; } 37 CHECK(WIFSTOPPED(st)); 38 if(!stepping) { 39 if(WSTOPSIG(st)==SIGTRAP) continue; 40 CHECK(WSTOPSIG(st)==(SIGTRAP|0x80)); 41 struct user_pt_regs r; struct iovec v={&r,sizeof r}; 42 CHECK(!ptrace(PTRACE_GETREGSET,child,(void *)NT_PRSTATUS,&v)); 43 if(entry && r.regs[8]==SYS_write && r.regs[0]==1) { 44 CHECK(!armed && r.regs[2]==sizeof a); readmem(r.regs[1],a,sizeof a); armed=1; 45 } 46 if(!entry && armed) stepping=1; 47 entry=!entry; 48 } else { 49 CHECK(WSTOPSIG(st)==SIGTRAP); 50 uint32_t h=(uint32_t)u64(a[0]); 51 if((h&65535)==0x1502) { 52 CHECK(h==0x21502); 53 uint16_t wg[3]; uint32_t grid[3]; 54 readmem(a[0]+4,wg,sizeof wg); readmem(a[0]+12,grid,sizeof grid); 55 CHECK(wg[0]==64 && wg[1]==1 && wg[2]==1); 56 CHECK(grid[0]==256 && grid[1]==1 && grid[2]==1); 57 /* HSA dispatch private at 24, group at 28; descriptor order is the reverse. */ 58 CHECK(u64(a[0]+24)==((UINT64_C(4096)<<32) | (getenv("EXPECTED_PRIVATE")?strtoul(getenv("EXPECTED_PRIVATE"),NULL,10):0)) && u64(a[0]+32)==a[1]+64); 59 CHECK(u64(a[0]+40)==a[2] && !u64(a[0]+48) && u64(a[0]+56)==a[3]); 60 if(!published) { unsigned char packet[64]; readmem(a[0],packet,64); CHECK(write(1,packet,64)==64); } 61 published=1; 62 } else CHECK(h==1); 63 if(u64(a[4])) CHECK(published && u64(a[4])==1); 64 if(u64(a[5])!=UINT64_MAX) { CHECK(published && u64(a[4])==1 && !u64(a[5])); rang=1; } 65 } 66 } 67 }