interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / streams / streams.om

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