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/omega-gpu-driver/blob/main/tests/chan_trace.om # omega-gpu-driver aien-dev/omega-gpu-driver 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 `omega-gpu-driver / tests / chan_trace.om` 264 lines ยท 5222 bytes Raw Blame History 1 note tests/chan_trace.om: the differential trace driver for the channel port. It replays aienux PR #441 2 note native/kernel/tests/gpu_chan_trace.c (branch pr441 @ `c5bb3a4b`) line for line on chan/sim.om and 3 note prints the same text: after every operation its rc, every register access the simulator logged 4 note since the last line, the doorbell count and FNV-1a 64 of the whole 8 MiB simulated memory. 5 note Build: cat chan/dma.om chan/gmmu.om chan/mem.om chan/chan.om chan/sim.om tests/chan_trace.om | omc > prog. 6 note Prefix ct. Host only: mmmode is 0 (the simulator) for the whole run. 7 note memory: 8 MiB at bus address 0x80000000, page-table pool there (64 pages), data at 0x80040000 8 note (128 pages), GPU VA base 0x200000000 9 const CTPA ulong `2147483648` 10 const CTMEM ulong `8388608` 11 const CTDATA ulong `2147745792` 12 const CTVA ulong `8589934592` 13 note FNV-1a 64 offset basis 0xcbf29ce484222325 and prime 0x100000001b3 14 const CTFNVO ulong `14695981039346656037` 15 const CTFNVP ulong `1099511628211` 16 const CTFOR ulong 1000 17 text ctt "setup|create chid>max|create runlist=0x7f|create entries=24|create entries=1|create|alloc pb|alloc sem|submit off=2|submit nwords=0|submit past end|submit foreign buf|submit |retire put=| ret=|retire past put ret=|teardown idle|teardown again|submit after close|create (hung run)|teardown hung| rc=| doorbells=| mem=|token=| rl=|quarantined_pages=| free_pages=|setup failed\n" 18 global ctob uchar 262144 19 global ctpos ulong 1 20 global ctcnt ulong 1 21 global ctlab ulong 1 22 global ctdig uchar 24 23 global ctstep ulong 1 24 global ctseen ulong 1 25 fn ctflush to void 26 n = get ctpos 0 27 if gt n 0 28 r = write 1 ctob 0 n 29 if ne r long n 30 exit 1 31 end 32 end 33 put ctpos 0 0 34 end 35 fn ctch c uchar to void 36 p = get ctpos 0 37 put ctob p c 38 put ctpos 0 add p 1 39 put ctcnt 0 add get ctcnt 0 1 40 if ge add p 1 262000 41 ctflush 42 end 43 end 44 note the k-th '|'-separated fragment of ctt 45 fn ctfrag k ulong to void 46 w = ulong 0 47 for i ulong len ctt 48 c = get ctt i 49 if eq c 124 50 w = add w 1 51 else 52 if eq w k 53 ctch c 54 end 55 end 56 end 57 end 58 note %u, and %0Nu with w > 0 59 fn ctdecw v ulong w ulong to void 60 n = ulong 0 61 x = v 62 while true bound 24 63 put ctdig n uchar add rem x 10 48 64 n = add n 1 65 x = div x 10 66 if eq x 0 67 break 68 end 69 end 70 while lt n w bound 24 71 put ctdig n 48 72 n = add n 1 73 end 74 for i ulong n 75 ctch get ctdig sub sub n 1 i 76 end 77 end 78 fn ctdec v ulong to void 79 ctdecw v 0 80 end 81 fn ctsdec v long to void 82 if lt v 0 83 ctch 45 84 ctdec ulong neg v 85 ret 86 end 87 ctdec ulong v 88 end 89 note lowercase hex, zero-padded to w digits 90 fn cthex v ulong w ulong to void 91 n = ulong 0 92 x = v 93 while true bound 24 94 d = uchar rem x 16 95 if lt d 10 96 put ctdig n add d 48 97 else 98 put ctdig n add d 87 99 end 100 n = add n 1 101 x = div x 16 102 if eq x 0 103 break 104 end 105 end 106 while lt n w bound 24 107 put ctdig n 48 108 n = add n 1 109 end 110 for i ulong n 111 ctch get ctdig sub sub n 1 i 112 end 113 end 114 fn ctfnv to ulong 115 h = CTFNVO 116 for a ulong 8192 117 o = mul a 1024 118 for b ulong 1024 119 h = mul xor h ulong get mmwin add o b CTFNVP 120 end 121 end 122 ret h 123 end 124 note "%04u " then the label (printed by the caller); ctend pads it to 24 (%-24s) and ends the line 125 fn ctbeg to void 126 ctdecw get ctstep 0 4 127 put ctstep 0 add get ctstep 0 1 128 ctch 32 129 put ctlab 0 get ctcnt 0 130 end 131 fn ctend rc long to void 132 while lt sub get ctcnt 0 get ctlab 0 24 bound 64 133 ctch 32 134 end 135 ctfrag 21 136 ctsdec rc 137 s = get ctseen 0 138 n = get gsnlog 0 139 while lt s n bound 600 140 ctch 32 141 if ne get gslogw s 0 142 ctch 87 143 else 144 ctch 82 145 end 146 cthex ulong get gslogo s 6 147 ctch 61 148 cthex ulong get gslogv s 8 149 s = add s 1 150 end 151 put ctseen 0 s 152 ctfrag 22 153 ctdec get gsdb 0 154 ctfrag 23 155 cthex ctfnv 16 156 ctch 10 157 ctflush 158 end 159 fn ctline k ulong rc long to void 160 ctbeg 161 ctfrag k 162 ctend rc 163 end 164 fn ctfresh to void 165 for a ulong 8192 166 o = mul a 1024 167 for b ulong 1024 168 put mmwin add o b 165 169 end 170 end 171 r = mmwinit CTPA CTMEM 172 gsinit CTPA CTMEM 173 put mmmode 0 0 174 put ctseen 0 0 175 r1 = mmasinit CTPA 64 176 r2 = long 1 177 if eq r1 MMOK 178 r2 = gminit 10 CTDATA 128 CTVA 179 end 180 if or ne r MMOK or ne r1 MMOK ne r2 GMOK 181 ctfrag 28 182 ctflush 183 exit 1 184 end 185 ctline 0 0 186 end 187 fn main to int 188 chinit 189 ctfresh 190 ctline 1 chcreate 0 4096 1 16 191 ctline 2 chcreate 0 3 127 16 192 ctline 3 chcreate 0 3 1 24 193 ctline 4 chcreate 0 3 1 1 194 ctline 5 chcreate 0 3 1 16 195 ctfrag 24 196 cthex ulong get chtok 0 8 197 ctfrag 25 198 cthex ulong get chrl0 0 8 199 ctch 44 200 cthex ulong get chrl1 0 8 201 ctch 10 202 r = gmalloc 8192 0 GMGPURO 203 pb = get gmout 0 204 ctline 6 r 205 r = gmalloc 4096 1 GMHPOLL 206 sem = get gmout 0 207 ctline 7 r 208 base = get gmbpa pb 209 for i ulong 4096 210 mmwr8 add base i uchar and mul i 7 255 211 end 212 ctline 8 chsubmit 0 pb 2 4 213 ctline 9 chsubmit 0 pb 0 0 214 ctline 10 chsubmit 0 pb 8188 2 215 ctline 11 chsubmit 0 CTFOR 0 4 216 for i uint 300 217 rc = chsubmit 0 pb mul rem i 64 64 add 1 rem i 16 218 ctbeg 219 ctfrag 12 220 ctdec ulong i 221 ctend rc 222 if or eq rc CHEFULL eq rem i 5 4 223 chretire 0 sub get chput 0 rem i 3 224 ctbeg 225 ctfrag 13 226 ctdec ulong get chput 0 227 ctfrag 14 228 ctdec ulong get chret 0 229 ctend 0 230 end 231 end 232 chretire 0 add get chput 0 5 233 ctbeg 234 ctfrag 15 235 ctdec ulong get chret 0 236 ctend 0 237 put chx 0 pb 238 put chx 1 sem 239 ctline 16 chteardown 0 4 2 240 ctline 17 chteardown 0 4 2 241 ctline 18 chsubmit 0 pb 0 4 242 ctfresh 243 ctline 19 chcreate 0 7 2 8 244 r = gmalloc 4096 0 GMGPURO 245 pb = get gmout 0 246 ctline 6 r 247 for i uint 9 248 rc = chsubmit 0 pb 0 8 249 ctbeg 250 ctfrag 12 251 ctdec ulong i 252 ctend rc 253 end 254 put gshang 0 1 255 put chx 0 pb 256 ctline 20 chteardown 0 6 1 257 ctfrag 26 258 ctdec gmcount GMQUAR 259 ctfrag 27 260 ctdec gmcount GMFREE 261 ctch 10 262 ctflush 263 ret 0 264 end