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

88 lines · 2140 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Pure decisions. No host words, RM calls, mapping writes or global storage.
3note States: READY BUSY LATCH QUIESCE CHANNEL CONTEXT CLOSED NEWCTX NEWCHAN.
4const READY uint 1
5const BUSY uint 2
6const LATCH uint 3
7const QUIESCE uint 4
8const CHANNEL uint 5
9const CONTEXT uint 6
10const CLOSED uint 7
11const NEWCTX uint 8
12const NEWCHAN uint 9
13const UMAX ulong 18446744073709551615
14note Absolute monotonic deadline: reject zero budget and addition overflow before submit.
15fn omega_c5_deadline start ulong budget ulong to ulong
16if eq budget 0
17ret 0
18end
19if gt start sub UMAX budget
20ret 0
21end
22ret add start budget
23end
24note One deadline for the entire submission, not renewed by progress/marker polling.
25note Result BUSY pending, READY both completion releases, LATCH uncertain completion.
26fn omega_c5_watch now ulong start ulong limit ulong done bool fault bool to uint
27if or fault lt now start
28ret LATCH
29end
30if or eq limit 0 ge now limit
31ret LATCH
32end
33if done
34ret READY
35end
36ret BUSY
37end
38note Caller must present a current process/context token and a completely ready state.
39fn omega_c5_admit state uint epoch ulong token ulong to bool
40ret and eq state READY and ne epoch 0 eq epoch token
41end
42note Per-process handle ownership, context generation and overflow-safe half-open slice.
43fn omega_c5_access pid ulong owner ulong epoch ulong token ulong to bool
44if or eq pid 0 ne pid owner
45ret false
46end
47ret and ne epoch 0 eq epoch token
48end
49fn omega_c5_range capacity ulong off ulong size ulong to bool
50if gt off capacity
51ret false
52end
53ret le size sub capacity off
54end
55fn omega_c5_recover state uint ack bool to uint
56if not ack
57ret state
58end
59if eq state LATCH
60ret QUIESCE
61end
62if eq state QUIESCE
63ret CHANNEL
64end
65if eq state CHANNEL
66ret CONTEXT
67end
68if eq state CONTEXT
69ret CLOSED
70end
71if eq state CLOSED
72ret NEWCTX
73end
74if eq state NEWCTX
75ret NEWCHAN
76end
77if eq state NEWCHAN
78ret READY
79end
80ret state
81end
82note Generation changes only after confirmed context destruction; never wrap to reuse handles.
83fn omega_c5_epoch epoch ulong to ulong
84if or eq epoch 0 eq epoch UMAX
85ret 0
86end
87ret add epoch 1
88end