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/om/streams/streams.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 / om / streams / streams.om` 242 lines · 5722 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note C4 streams (CUDApp#115): the pure part of src/omega_gpu_cmdlist.c emit_chunk / submit_pair and of the 3 note queue selection (AIEN_OMEGA_GPU_CHANNELS). Pure computation: no host 4 note words. The C shell writes the words into the pushbuffer and submits; the effectful pieces (ioctl, mmap, 5 note GPPut, doorbell) wait for omega-bridge#29. 6 note Entry streams_words op a o: a is the input record, o the output words (each below 2^32), o 30 the 7 note barrier chosen and o 31 the launch kind for op 1. The value is the word count, or the op's scalar result. 8 note op 0 setup: the 18 compute-class setup words 9 note op 1 launch: a = i done wait_va indep skip first_none barrier stamps stamps_va mode q1_va 10 note wait_for ACQUIRE (clc96f SEM_ADDR_LO 0x5c .. SEM_EXECUTE 0x6c, payload DONE 6, OPERATION_ACQUIRE 0), 11 note the barrier choice and its words, PCAS send; o 31 = 0 skipped, 1 PCAS sent, 2 inline QMDs follow 12 note op 2 inline QMD header: a = va (3 words; C copies the 96 QMD words after it) 13 note op 3 end: a = stamps stamps_va end marker_va (final WAIT_FOR_IDLE + stamp, then the 17 tail words) 14 note op 4 channels: a = present len c0 max_extra; value = channel count (1 unless one digit 2..1+max_extra) 15 note op 5 pair marker: a = marker_page_va k (k 0 queue 0, 1 queue 1); value = completion marker va, 16 note o 0 and o 1 = the two 32-bit marker words (index from the 0x100 marker offset) to clear 17 note (extra-queue admission is the scalar freestanding unit om/streams/xq.om) 18 const WMASK ulong `4294967295` 19 const MTHDTAG ulong `536870912` 20 const DONE ulong 6 21 const MARKER1 ulong `1145324612` 22 const MARKER2 ulong `1179010630` 23 const SEMREL ulong `1048577` 24 const INVALL ulong 4113 25 const INVDATA ulong 16 26 const INVFLUSH ulong 20 27 const BWFI ulong 0 28 const BNONE ulong 1 29 const BWDATA ulong 3 30 const BFLUSH ulong 4 31 note REFUSED: an op outside 0..6 or a pair queue above 1; the C caller treats it as a broken generator 32 const REFUSED ulong `18446744073709551615` 33 fn mthd s ulong m ulong c ulong to ulong 34 ret or or or MTHDTAG shl c 16 shl s 13 shr m 2 35 end 36 37 fn pw o edit ulong 32 n ulong v ulong to ulong 38 put o n v 39 ret add n 1 40 end 41 42 fn stamp o edit ulong 32 n ulong sva ulong slot ulong to ulong 43 va = add sva mul slot 16 44 k = pw o n mthd 1 344 5 45 k = pw o k slot 46 k = pw o k 0 47 k = pw o k and va WMASK 48 k = pw o k shr va 32 49 ret pw o k 0 50 end 51 52 fn setup o edit ulong 32 to ulong 53 k = pw o 0 `536944737` 54 k = pw o k 52928 55 k = pw o k `536944786` 56 k = pw o k 1 57 k = pw o k `536944808` 58 k = pw o k 15 59 k = pw o k `536946013` 60 k = pw o k 3 61 k = pw o k `536946014` 62 k = pw o k `536870912` 63 k = pw o k `536946015` 64 k = pw o k `1048575` 65 k = pw o k `536946007` 66 k = pw o k 3 67 k = pw o k `536946008` 68 k = pw o k `570425344` 69 k = pw o k `536946009` 70 ret pw o k 0 71 end 72 73 note wait_for: host semaphore ACQUIRE of the other list's launch semaphore, before the barrier 74 fn acquire o edit ulong 32 va ulong to ulong 75 k = pw o 0 mthd 0 92 5 76 k = pw o k and va WMASK 77 k = pw o k shr va 32 78 k = pw o k DONE 79 k = pw o k 0 80 ret pw o k 0 81 end 82 83 note barrier: a waited launch always WFI; the first of a submission WFI unless first_none at launch 0; 84 note a launch marked independent none; otherwise the submission's barrier 85 fn choose a view ulong 16 to ulong 86 if ne get a 2 0 87 ret BWFI 88 end 89 if eq get a 0 get a 1 90 if and eq get a 0 0 ne get a 5 0 91 ret BNONE 92 end 93 ret BWFI 94 end 95 if ne get a 3 0 96 ret BNONE 97 end 98 ret get a 6 99 end 100 101 fn barrier o edit ulong 32 n ulong a view ulong 16 b ulong to ulong 102 k = n 103 if ne b BFLUSH 104 k = pw o k mthd 1 272 1 105 k = pw o k 0 106 else 107 k = pw o k mthd 1 540 1 108 k = pw o k INVFLUSH 109 end 110 if ne get a 7 0 111 k = stamp o k get a 8 get a 0 112 end 113 if eq b BWFI 114 k = pw o k mthd 1 540 1 115 k = pw o k INVALL 116 end 117 if eq b BWDATA 118 k = pw o k mthd 1 540 1 119 k = pw o k INVDATA 120 end 121 ret k 122 end 123 124 fn launch a view ulong 16 o edit ulong 32 to ulong 125 n = ulong 0 126 if ne get a 2 0 127 n = acquire o get a 2 128 end 129 put o 31 0 130 put o 30 BNONE 131 if ne get a 4 0 132 if eq get a 0 sub get a 4 1 133 ret n 134 end 135 end 136 b = choose a 137 put o 30 b 138 if and ne get a 0 get a 1 ne get a 3 0 139 if ne get a 7 0 140 n = stamp o n get a 8 get a 0 141 end 142 end 143 if ne b BNONE 144 n = barrier o n a b 145 end 146 if ne get a 9 0 147 put o 31 2 148 ret n 149 end 150 n = pw o n mthd 1 692 1 151 n = pw o n and shr get a 10 8 WMASK 152 n = pw o n mthd 1 704 1 153 n = pw o n 3 154 put o 31 1 155 ret n 156 end 157 158 fn inlinehd a view ulong 16 o edit ulong 32 to ulong 159 va = get a 0 160 k = pw o 0 mthd 1 792 98 161 k = pw o k or `1073741824` and shr va 40 511 162 ret pw o k and shr va 8 WMASK 163 end 164 165 fn finish a view ulong 16 o edit ulong 32 to ulong 166 n = ulong 0 167 if ne get a 0 0 168 n = pw o n mthd 1 272 1 169 n = pw o n 0 170 n = stamp o n get a 1 get a 2 171 end 172 mva = get a 3 173 n = pw o n mthd 0 92 5 174 n = pw o n and mva WMASK 175 n = pw o n shr mva 32 176 n = pw o n MARKER1 177 n = pw o n 0 178 n = pw o n SEMREL 179 n = pw o n mthd 0 40 4 180 n = pw o n 0 181 n = pw o n 0 182 n = pw o n 0 183 n = pw o n `2147483648` 184 mva = add mva 16 185 n = pw o n mthd 0 92 5 186 n = pw o n and mva WMASK 187 n = pw o n shr mva 32 188 n = pw o n MARKER2 189 n = pw o n 0 190 ret pw o n SEMREL 191 end 192 193 note AIEN_OMEGA_GPU_CHANNELS: unset, empty, longer than one character or not 2..1+max_extra -> 1 194 fn channels a view ulong 16 to ulong 195 if eq get a 0 0 196 ret 1 197 end 198 if ne get a 1 1 199 ret 1 200 end 201 c = get a 2 202 if lt c 50 203 ret 1 204 end 205 if gt c add 49 get a 3 206 ret 1 207 end 208 ret sub c 48 209 end 210 211 note submit_pair: queue k's completion markers at the page's 0x100 + k * 0x80 (and +0x10 for the second) 212 fn pairmk a view ulong 16 o edit ulong 32 to ulong 213 k = get a 1 214 if gt k 1 215 ret REFUSED 216 end 217 put o 0 mul k 32 218 put o 1 add mul k 32 4 219 ret add add get a 0 256 mul k 128 220 end 221 222 fn streams_words op ulong a view ulong 16 o edit ulong 32 to ulong 223 if eq op 0 224 ret setup o 225 end 226 if eq op 1 227 ret launch a o 228 end 229 if eq op 2 230 ret inlinehd a o 231 end 232 if eq op 3 233 ret finish a o 234 end 235 if eq op 4 236 ret channels a 237 end 238 if eq op 5 239 ret pairmk a o 240 end 241 ret REFUSED 242 end