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 / policy.om

190 lines · 3252 bytes Raw Blame History
1note NVRM decision policy. Omega owns each decision; the raw ioctl call stays in nvrm.c.
2note Every numeric constant below was computed with Wolfram and is quoted in the lane report.
3note Opcode map: 1 nrstat, 2 hnext, 3 vunits, 4 vcover, 5 palign, 6 pspan, 7 pfull,
4note 8 chadm, 9 retry, 10 mthd, 11 gpentry. A result of 0 is a real answer, never an error.
5
6fn nvrm_nrstat st ulong to ulong
7if eq st 0
8ret 0
9end
10if eq st 81
11ret 1
12end
13ret 2
14end
15
16fn nvrm_hnext cls ulong nxt ulong accepted ulong to ulong
17if eq accepted 18446744073709551615
18ret 4294967296
19end
20if eq cls 65
21ret 0
22end
23if eq nxt 4294967295
24ret 4294967296
25end
26ret or nxt 8589934592
27end
28
29fn nvrm_vunits b ulong to ulong
30u = b
31if eq b 0
32u = ulong 1
33end
34s = add u 4294967295
35if lt s u
36ret 0
37end
38ret and s 18446744069414584320
39end
40
41fn nvrm_vcover base ulong vanext ulong endv ulong o edit ulong 4 to ulong
42if eq base 0
43ret 0
44end
45if or lt endv base lt vanext base
46ret 2
47end
48db = sub vanext base
49de = sub endv base
50owned = nvrm_vunits db
51want = nvrm_vunits de
52if or eq owned 0 eq want 0
53ret 2
54end
55if le want owned
56ret 0
57end
58oe = add base owned
59if lt oe base
60ret 2
61end
62we = add base want
63if lt we base
64ret 2
65end
66put o 2 oe
67put o 3 we
68ret 1
69end
70
71fn nvrm_palign base ulong align ulong to ulong
72if or eq align 0 ne and align sub align 1 0
73ret 0
74end
75m = sub align 1
76s = add base m
77if lt s base
78ret 0
79end
80ret and s not m
81end
82
83fn nvrm_pspan off ulong nwords ulong size ulong va ulong to ulong
84if ne and off 3 0
85ret 1
86end
87if eq nwords 0
88ret 1
89end
90if gt nwords 2097151
91ret 1
92end
93bytes = mul nwords 4
94span = add off bytes
95if lt span off
96ret 1
97end
98if gt span size
99ret 1
100end
101limit = sub 18446744073709551615 off
102if gt va limit
103ret 2
104end
105ret 0
106end
107
108fn nvrm_pfull putv ulong retired ulong entries ulong to ulong
109d = and sub putv retired 4294967295
110e = and sub entries 1 4294967295
111if ge d e
112ret 1
113end
114ret 0
115end
116
117fn nvrm_chadm faulted ulong chgroup ulong regd ulong nextra ulong extra ulong maxv ulong to ulong
118if or or or ne faulted 0 ne chgroup 0 ne regd 0 ne nextra 0
119ret 1
120end
121if gt extra maxv
122ret 2
123end
124ret 0
125end
126
127fn nvrm_retry failed ulong tries ulong budget ulong nomem ulong to ulong
128if eq failed 0
129ret 0
130end
131if eq nomem 0
132ret 3
133end
134if ge tries budget
135ret 2
136end
137ret 1
138end
139
140fn nvrm_mthd subc ulong mthd ulong count ulong to ulong
141a = shl ulong 2 28
142b = shl count 16
143c = shl subc 13
144d = shr mthd 2
145ret and or or or a b c d 4294967295
146end
147
148fn nvrm_gpentry va ulong nwords ulong to ulong
149low = and va 18446744073709551612
150nw = and nwords 2097151
151wlen = shl nw 42
152ret or or low wlen 2199023255552
153end
154
155fn nvrm_policy op ulong in view ulong 8 out edit ulong 4 to ulong
156if eq op 1
157ret nvrm_nrstat get in 0
158end
159if eq op 2
160ret nvrm_hnext get in 0 get in 1 get in 2
161end
162if eq op 3
163ret nvrm_vunits get in 0
164end
165if eq op 4
166ret nvrm_vcover get in 0 get in 1 get in 2 out
167end
168if eq op 5
169ret nvrm_palign get in 0 get in 1
170end
171if eq op 6
172ret nvrm_pspan get in 0 get in 1 get in 2 get in 3
173end
174if eq op 7
175ret nvrm_pfull get in 0 get in 1 get in 2
176end
177if eq op 8
178ret nvrm_chadm get in 0 get in 1 get in 2 get in 3 get in 4 get in 5
179end
180if eq op 9
181ret nvrm_retry get in 0 get in 1 get in 2 get in 3
182end
183if eq op 10
184ret nvrm_mthd get in 0 get in 1 get in 2
185end
186if eq op 11
187ret nvrm_gpentry get in 0 get in 1
188end
189ret 0
190end