interplane.Get Omega
Read in your language

omega-gpu-driver

aien-dev/omega-gpu-driver

Brought by drakestapleton

branch main Branches Tags History

omega-gpu-driver / tests / chan_trace.om

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