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 / codegen / cg_em.om

127 lines · 1968 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Pure decisions from omega_bw_em.h and omega_bw_em_q.h. C owns IR records and append.
3note w: pending, held, control, unused. All control arithmetic has C uint32 wrap.
4fn em_cw st uint wb uint rb uint wt uint to uint
5ret or or or shl st 9 shl wb 14 shl rb 17 shl wt 20
6end
7fn em_emit k long pred long w edit ulong 4 to long
8wt = uint get w 0
9pn = wt
10cw = uint 0
11if or eq k 0 eq k 6
12cw = em_cw 6 7 7 wt
13pn = uint 0
14else
15if eq k 1
16cw = em_cw 14 7 7 wt
17pn = uint 0
18else
19if or eq k 2 eq k 3
20if eq k 3
21wt = and wt 2
22pn = or pn 3
23else
24pn = uint 3
25end
26cw = or em_cw 4 0 1 wt 8192
27else
28if eq k 4
29cw = or em_cw 4 2 7 wt 8192
30pn = uint 4
31else
32if eq k 5
33cw = or em_cw 4 7 1 wt 8192
34pn = uint 2
35else
36if or eq k 7 eq k 8
37cw = em_cw 5 7 7 wt
38if eq pred 0
39pn = uint 0
40end
41else
42if eq k 9
43cw = or em_cw 1 7 7 wt 8192
44pn = uint 0
45else
46if eq k 10
47cw = or em_cw 5 7 7 wt 8192
48pn = uint 0
49else
50ret -1
51end
52end
53end
54end
55end
56end
57end
58end
59put w 0 ulong pn
60put w 2 ulong cw
61ret 0
62end
63fn em_log v ulong to long
64l = ulong 0
65while lt shl ulong 1 l v bound 32
66l = add l 1
67end
68if eq shl ulong 1 l v
69ret long l
70end
71ret -1
72end
73fn cg_em act ulong a long b long c long w edit ulong 4 to long
74if eq act 0
75ret em_emit a b w
76end
77if eq act 1
78sb = uint a
79put w 2 ulong or em_cw 4 sb 1 and uint get w 0 2 8192
80put w 0 or get w 0 2
81put w 1 or get w 1 ulong shl uint 1 sb
82ret 0
83end
84if eq act 2
85mk = ulong shl uint 1 uint a
86put w 0 or get w 0 and get w 1 mk
87put w 1 and get w 1 xor mk 4294967295
88ret 0
89end
90if eq act 3
91if ge a 4
92ret -1
93end
94ret add a 1
95end
96if eq act 4
97if le a 0
98ret -1
99end
100ret sub a 1
101end
102if eq act 5
103endval = long get w 3
104if ge endval 2147483648
105endval = sub endval 4294967296
106end
107if and and ge a 0 lt a b and ge c b lt c endval
108ret endval
109end
110ret c
111end
112if eq act 6
113ret em_log ulong a
114end
115if eq act 7
116put w 2 ulong em_cw uint a 7 7 uint get w 0
117put w 0 0
118ret 0
119end
120if eq act 8
121ret sub a b
122end
123if eq act 9
124ret and a 31
125end
126ret -1
127end