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_pfhost_emit.om

130 lines · 3274 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Seeded e5b32567. Tape ABI from omega_gpu_om_ir.h; scheduling mirrors omega_bw_em.h.
3note st: count,pending,held; record scratch at 8..15. Helpers never retain per-record allocations.
4const PHNONE ulong 18446744073709551615
5fn ph_base st edit ulong 16 op ulong d ulong a ulong b ulong to void
6put st 8 op
7put st 9 d
8put st 10 a
9put st 11 b
10put st 12 PHNONE
11put st 13 PHNONE
12put st 14 0
13put st 15 0
14end
15fn ph_emit ins edit ulong 8192 st edit ulong 16 kind ulong to void
16waits = get st 1
17ctl = or or shl ulong 6 9 shl ulong 7 14 shl ulong 7 17
18if eq kind 1
19ctl = or or shl ulong 14 9 shl ulong 7 14 shl ulong 7 17
20end
21if or eq kind 2 eq kind 3
22ctl = or or shl ulong 4 9 shl ulong 1 17 8192
23end
24if eq kind 3
25waits = and waits 2
26end
27if eq kind 4
28ctl = or or or shl ulong 4 9 shl ulong 2 14 shl ulong 7 17 8192
29end
30if eq kind 5
31ctl = or or or shl ulong 4 9 shl ulong 7 14 shl ulong 1 17 8192
32end
33if eq kind 7
34ctl = or or shl ulong 5 9 shl ulong 7 14 shl ulong 7 17
35end
36if eq kind 11
37ctl = or or or shl ulong 4 9 shl ulong 3 14 shl ulong 1 17 8192
38waits = and waits 2
39end
40ctl = or ctl shl waits 20
41n = mul get st 0 8
42for j ulong 8
43put ins add n j get st add j 8
44end
45put ins add n 6 or get st 14 shl ctl 32
46put st 0 add get st 0 1
47if or eq kind 0 eq kind 1
48put st 1 0
49end
50if eq kind 2
51put st 1 3
52end
53if eq kind 3
54put st 1 or get st 1 3
55end
56if eq kind 4
57put st 1 4
58end
59if eq kind 5
60put st 1 2
61end
62if eq kind 7
63if eq and get st 15 2 0
64put st 1 0
65end
66end
67if eq kind 11
68put st 1 or get st 1 2
69put st 2 or get st 2 8
70end
71end
72fn ph_imm ins edit ulong 8192 st edit ulong 16 op ulong d ulong imm ulong kind ulong to void
73ph_base st op d PHNONE PHNONE
74put st 14 imm
75if eq op 7
76put st 15 1
77end
78ph_emit ins st kind
79end
80fn ph_imad ins edit ulong 8192 st edit ulong 16 d ulong a ulong imm ulong c ulong to void
81ph_base st 8 d a PHNONE
82put st 12 c
83put st 14 imm
84ph_emit ins st 0
85end
86fn ph_wide ins edit ulong 8192 st edit ulong 16 d ulong a ulong imm ulong c ulong to void
87ph_base st 9 d a PHNONE
88put st 12 c
89put st 14 imm
90ph_emit ins st 0
91end
92fn ph_load ins edit ulong 8192 st edit ulong 16 d ulong a ulong imm ulong kind ulong to void
93ph_base st 57 d a PHNONE
94put st 13 0
95put st 14 imm
96ph_emit ins st kind
97end
98fn ph_consume st edit ulong 16 to void
99put st 1 or get st 1 and get st 2 8
100put st 2 and get st 2 not ulong 8
101end
102fn ph_tail ins edit ulong 8192 st edit ulong 16 to void
103ph_imm ins st 45 PHNONE 0 7
104ph_base st 46 PHNONE PHNONE PHNONE
105ph_emit ins st 7
106put ins sub mul get st 0 8 2 shl ulong 1032192 32
107end
108fn ph_branch ins edit ulong 8192 st edit ulong 16 target ulong to void
109ph_base st 46 PHNONE PHNONE PHNONE
110put st 14 and sub target get st 0 4294967295
111put st 15 2
112ph_emit ins st 7
113end
114note args: destination and source subregisters travel packed in flags scratch cfg[8..13].
115fn ph_muladd ins edit ulong 8192 st edit ulong 16 cf view ulong 64 to void
116ph_base st 32 get cf 10 get cf 11 get cf 12
117put st 15 or shl get cf 13 24 shl get cf 14 32
118if eq get cf 3 1
119put st 8 33
120put st 9 get cf 8
121put st 12 get cf 8
122put st 15 or get st 15 or shl get cf 9 16 shl get cf 9 40
123ph_emit ins st 0
124else
125ph_emit ins st 0
126ph_base st 30 get cf 8 get cf 8 get cf 10
127put st 15 or shl get cf 9 16 shl get cf 9 24
128ph_emit ins st 0
129end
130end