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/backend/amd/kfd/launch/main.om # 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 / backend / amd / kfd / launch / main.om` 207 lines · 3982 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 text manifestmagic "OMEGA refuse manifest field=magic\n" 3 text runmode "run" 4 text inspectmode "inspect" 5 text vaddmode "vadd" 6 text parsed "OMEGA elf=accepted image_bytes=" 7 text argslabel " kernarg_bytes=" 8 text passed "OMEGA vadd=PASS count=256\n" 9 global config ulong 3 10 fn mode name view uchar * to bool 11 n = patharg 1 12 if ne n len name 13 ret false 14 end 15 for i ulong n bound 4096 16 if ne get pathbuf i get name i 17 ret false 18 end 19 end 20 ret true 21 end 22 fn configread to void 23 fd = argfile 6 0 24 put config 0 ulong fd 25 size = filesize fd 26 span 0 48 size 27 note Eight ASCII bytes OMKFD001. 28 if ne fword fd 0 8 0x31303044464b4d4f 29 emitfd 2 manifestmagic 30 exit 64 31 end 32 if ne fword fd 8 8 get el 8 33 exit 64 34 end 35 put launch 4 fword fd 16 8 36 put launch 2 fword fd 24 8 37 put launch 3 fword fd 32 8 38 put config 1 fword fd 40 8 39 if gt get config 1 div get el 8 8 40 exit 64 41 end 42 put config 2 add 48 mul get config 1 16 43 span get config 2 get el 8 size 44 if ne add get config 2 get el 8 size 45 exit 64 46 end 47 if or eq get launch 4 0 eq get launch 2 0 48 exit 64 49 end 50 if gt get launch 2 `9223372036854775807` 51 exit 64 52 end 53 for i ulong get config 1 bound `9223372036854775807` 54 p = add 48 mul i 16 55 off = fword fd p 8 56 span off 8 get el 8 57 if ne rem off 8 0 58 exit 64 59 end 60 if gt fword fd add p 8 8 get launch 1 61 exit 64 62 end 63 if ne fword fd add get config 2 off 8 0 64 exit 64 65 end 66 for j ulong i bound `9223372036854775807` 67 if eq off fword fd add 48 mul j 16 8 68 exit 64 69 end 70 end 71 end 72 end 73 fn prepare to void 74 n = mul add get launch 1 8 24 75 put launch 0 ulong checked mapnew -1 0 n 3 34 76 r = allocate 0 get el 7 0xe0000001 77 stepbegin stload get el 7 78 loadelf r 79 stepend 80 r = allocate 1 get el 8 0xa4000002 81 r = allocate 2 get launch 4 0xa0000001 82 end 83 fn loadinputs to void 84 for i ulong get launch 1 bound `9223372036854775807` 85 fd = argfile add i 7 0 86 size = filesize fd 87 if eq size 0 88 exit 64 89 end 90 h = allocate add i 8 size 0xa0000001 91 filecopy fd 0 h 0 size 92 r = checked fclose fd 93 end 94 filecopy int get config 0 get config 2 lh 1 0 get el 8 95 for i ulong get config 1 bound `9223372036854775807` 96 p = add 48 mul i 16 97 off = fword int get config 0 p 8 98 idx = fword int get config 0 add p 8 8 99 h = lh 2 100 if lt idx get launch 1 101 h = lh add idx 8 102 end 103 r = checked mapset lh 1 off 8 mapaddr h 104 end 105 r = checked fclose int get config 0 106 end 107 fn vaddinputs to void 108 if ne get el 8 28 109 exit 65 110 end 111 h = allocate 8 1024 0xa0000001 112 h = allocate 9 1024 0xa0000001 113 note IEEE754 binary32 1 + 1 = 2; exact independent host oracle in the gate. 114 for i ulong 256 115 r = checked mapset lh 8 mul i 4 4 0x3f800000 116 r = checked mapset lh 9 mul i 4 4 0x3f800000 117 r = checked mapset lh 2 mul i 4 4 0x7fc00000 118 end 119 r = checked mapset lh 1 0 8 mapaddr lh 8 120 r = checked mapset lh 1 8 8 mapaddr lh 9 121 r = checked mapset lh 1 16 8 mapaddr lh 2 122 r = checked mapset lh 1 24 4 256 123 end 124 fn vaddcheck to void 125 for i ulong 256 126 if ne mapget lh 2 mul i 4 4 0x40000000 127 steprow 5 false 128 exit 76 129 end 130 end 131 emit passed 132 end 133 fn main to int 134 if ge argcnt 3 135 if mode planmode 136 ret planmain 137 end 138 end 139 if lt argcnt 4 140 ret 64 141 end 142 isinspect = mode inspectmode 143 isvadd = mode vaddmode 144 isrun = mode runmode 145 if not or isinspect or isvadd isrun 146 ret 64 147 end 148 parseelf 2 3 149 if isinspect 150 emit parsed 151 printnum get el 7 152 emit argslabel 153 printnum get el 8 154 emit newline 155 r = checked fclose int get el 0 156 ret 0 157 end 158 if isvadd 159 if not or eq argcnt 4 eq argcnt 5 160 ret 64 161 end 162 put launch 1 2 163 put diagstate 0 1 164 put launch 2 1 165 put launch 3 0 166 if eq argcnt 5 167 put launch 3 argnum 4 168 end 169 put launch 4 1024 170 put launch 5 4 171 put launch 6 1 172 else 173 if lt argcnt 8 174 ret 64 175 end 176 put launch 1 sub ulong argcnt 8 177 put launch 5 argnum 4 178 put launch 6 argnum 5 179 if or eq get launch 5 0 gt get launch 5 div ulong `4294967295` 64 180 ret 64 181 end 182 if or eq get launch 6 0 gt get launch 6 `4294967295` 183 ret 64 184 end 185 configread 186 end 187 connectkfd 188 prepare 189 if isvadd 190 vaddinputs 191 else 192 loadinputs 193 end 194 queueinit 195 dispatch 196 stepbegin streadback get launch 4 197 if isvadd 198 vaddcheck 199 else 200 fd = argfile sub ulong argcnt 1 577 201 savefile fd lh 2 get launch 4 202 r = checked fclose fd 203 end 204 stepend 205 teardown 206 ret 0 207 end