interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / gpu / nvidia / om / session / admit.om

210 lines · 3279 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Session admission and bookkeeping decisions from src/omega_gpu_session.c.
3note Pure computation: no host words, no platform calls. The C shell keeps the
4note lock, the atomic stores and every dma, queue and sync call. decide is the
5note only export; op selects the decision and a carries the inputs.
6const WMASK ulong 4294967295
7const PAGEMSK ulong 18446744073709547520
8const PAGE ulong 4096
9const EPOCHX ulong 18446744073709551615
10const SIGN ulong 2147483648
11const REFUSED ulong 18446744073709551615
12const HOOKMAX ulong 8
13
14fn roundup v ulong q ulong to ulong
15a = and v WMASK
16b = and q WMASK
17if eq b 0
18ret 0
19end
20ret and mul div add a sub b 1 b b WMASK
21end
22
23fn pageup b ulong to ulong
24r = and add b sub PAGE 1 PAGEMSK
25if lt r PAGE
26ret PAGE
27end
28ret r
29end
30
31fn spinok us ulong mx ulong to ulong
32if gt and us WMASK and mx WMASK
33ret 1
34end
35ret 0
36end
37
38fn gprcount c ulong to ulong
39a = and c WMASK
40if gt a 64
41ret roundup a 8
42end
43ret 64
44end
45
46fn argsoff amp ulong to ulong
47if ne and amp WMASK 0
48ret 352
49end
50ret 896
51end
52
53fn semva amp ulong marker ulong qmd ulong to ulong
54if ne and amp WMASK 0
55ret add marker 32
56end
57ret add qmd 8192
58end
59
60fn scratch o edit ulong 4 bytes ulong cap ulong reserved ulong cpu ulong high ulong to ulong
61b = bytes
62c = cap
63if ne and reserved WMASK 0
64if gt b c
65put o 0 high
66ret 2
67end
68if eq and cpu WMASK 0
69put o 0 high
70ret 2
71end
72end
73if gt b high
74high = b
75end
76put o 0 high
77if ge c b
78if ne and cpu WMASK 0
79ret 0
80end
81end
82ret 1
83end
84
85fn freedec blocked ulong opened ulong plat ulong to ulong
86if ne and blocked WMASK 0
87ret 0
88end
89if eq and opened WMASK 0
90ret 3
91end
92if eq and plat WMASK 0
93ret 3
94end
95ret 2
96end
97
98fn opendec blocked ulong epoch ulong plat ulong opened ulong to ulong
99if ne and blocked WMASK 0
100ret 1
101end
102if ne and opened WMASK 0
103ret 2
104end
105if eq epoch EPOCHX
106ret 3
107end
108if eq and plat WMASK 0
109ret 4
110end
111ret 0
112end
113
114fn platdec opened ulong locked ulong blocked ulong to ulong
115if ne and opened WMASK 0
116ret 1
117end
118if ne and locked WMASK 0
119ret 1
120end
121if ne and blocked WMASK 0
122ret 1
123end
124ret 0
125end
126
127fn recovdec latched ulong opened ulong plat ulong to ulong
128if eq and latched WMASK 0
129ret 2
130end
131if eq and opened WMASK 0
132ret 1
133end
134if eq and plat WMASK 0
135ret 1
136end
137ret 0
138end
139
140fn hookdec nhooks ulong present ulong to ulong
141if ge and nhooks WMASK HOOKMAX
142ret 1
143end
144if eq and present WMASK 0
145ret 1
146end
147ret 0
148end
149
150fn slice left ulong to ulong
151a = and left WMASK
152if lt a 1
153ret a
154end
155ret 1
156end
157
158fn mdone seen ulong want ulong to ulong
159d = and sub seen want WMASK
160if lt d SIGN
161ret 0
162end
163ret 1
164end
165
166fn decide op ulong a view ulong 16 o edit ulong 4 to ulong
167if eq op 0
168ret roundup get a 0 get a 1
169end
170if eq op 1
171ret pageup get a 0
172end
173if eq op 2
174ret spinok get a 0 get a 1
175end
176if eq op 3
177ret gprcount get a 0
178end
179if eq op 4
180ret argsoff get a 0
181end
182if eq op 5
183ret semva get a 0 get a 1 get a 2
184end
185if eq op 6
186ret scratch o get a 0 get a 1 get a 2 get a 3 get a 4
187end
188if eq op 7
189ret freedec get a 0 get a 1 get a 2
190end
191if eq op 8
192ret opendec get a 0 get a 1 get a 2 get a 3
193end
194if eq op 9
195ret platdec get a 0 get a 1 get a 2
196end
197if eq op 10
198ret recovdec get a 0 get a 1 get a 2
199end
200if eq op 11
201ret hookdec get a 0 get a 1
202end
203if eq op 12
204ret slice get a 0
205end
206if eq op 13
207ret mdone get a 0 get a 1
208end
209ret REFUSED
210end