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 / native / nvrm / wire.om

107 lines · 1980 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note NVIDIA580.173.02 nvos.h NVOS00/21/33/46/47/54 and Unix NVOS33 fd wrapper.
3note Scalars are ordered exactly as fields in the vendor declaration, excluding padding.
4note No native struct representation is used. All padding and initial status bytes are zero.
5fn nvrm_wire_store b edit uchar 64 off ulong v ulong n ulong to void
6for i ulong n
7put b add off i uchar and shr v mul i 8 255
8end
9end
10fn nvrm_pack op ulong a view ulong 16 b edit uchar 64 to ulong
11for i ulong 64
12put b i 0
13end
14if or eq op 1 eq op 2
15for i ulong 4
16nvrm_wire_store b mul i 4 get a i 4
17end
18nvrm_wire_store b 16 get a 4 8
19nvrm_wire_store b 24 get a 5 4
20ret 32
21end
22if eq op 3
23for i ulong 3
24nvrm_wire_store b mul i 4 get a i 4
25end
26ret 16
27end
28if eq op 4
29for i ulong 3
30nvrm_wire_store b mul i 4 get a i 4
31end
32for i ulong 3
33nvrm_wire_store b add 16 mul i 8 get a add i 3 8
34end
35nvrm_wire_store b 44 get a 6 4
36nvrm_wire_store b 48 get a 7 4
37ret 56
38end
39if eq op 5
40for i ulong 4
41nvrm_wire_store b mul i 4 get a i 4
42end
43nvrm_wire_store b 16 get a 4 8
44nvrm_wire_store b 24 get a 5 8
45for i ulong 3
46nvrm_wire_store b add 32 mul i 4 get a add i 6 4
47end
48nvrm_wire_store b 48 get a 9 8
49ret 64
50end
51if eq op 6
52for i ulong 5
53nvrm_wire_store b mul i 4 get a i 4
54end
55nvrm_wire_store b 24 get a 5 8
56nvrm_wire_store b 32 get a 6 8
57ret 48
58end
59if eq op 7
60nvrm_wire_store b 0 get a 0 4
61ret 4
62end
63ret 0
64end
65fn nvrm_wire_load b view uchar 64 off ulong n ulong to ulong
66v = ulong 0
67for i ulong n
68v = or v shl ulong get b add off i mul i 8
69end
70ret v
71end
72fn nvrm_wire_reply op ulong b view uchar 64 r edit ulong 2 to ulong
73at = ulong 0
74if or eq op 1 eq op 2
75at = 28
76else
77if eq op 3
78at = 12
79else
80if eq op 4
81at = 40
82else
83if eq op 5
84at = 56
85else
86if eq op 6
87at = 40
88else
89ret 1
90end
91end
92end
93end
94end
95put r 0 nvrm_wire_load b at 4
96put r 1 0
97if eq op 1
98put r 1 nvrm_wire_load b 8 4
99end
100if eq op 4
101put r 1 nvrm_wire_load b 32 8
102end
103if eq op 5
104put r 1 nvrm_wire_load b 48 8
105end
106ret 0
107end