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 / backend / amd / kfd / launch / main.om

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