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 / api / apish_slot.om

116 lines · 2187 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note FP8 slot step. rec: 0 state, 1 pins, 2 key, 3 version, 4 next_version, 5 mutant, 6 ok.
3note rec 8 loads, 9 load_failures, 10 busy, 11 stale, 12 evictions, 13 pin count, 14 pinned_now, 15 pinned_high.
4note op 1 begin, 2 finish (aux is key), 3 pin, 4 unpin, 5 evict, 6 idle. aux is the version for pin and unpin.
5
6fn bump rec edit ulong 16 i ulong to void
7put rec i add get rec i 1
8end
9
10fn begin rec edit ulong 16 to long
11st = get rec 0
12pins = get rec 1
13if or eq st 1 and ne pins 0 eq get rec 5 0
14bump rec 10
15ret -6
16end
17put rec 0 1
18ret 0
19end
20
21fn finish rec edit ulong 16 key ulong to long
22if ne get rec 0 1
23ret -1
24end
25if ne get rec 6 0
26put rec 0 2
27put rec 2 key
28put rec 3 get rec 4
29put rec 4 add get rec 4 1
30bump rec 8
31ret 0
32end
33put rec 0 0
34put rec 2 0
35bump rec 9
36ret 0
37end
38
39fn pin rec edit ulong 16 ver ulong to long
40if or ne get rec 0 2 or ne get rec 3 ver eq ver 0
41bump rec 11
42ret -7
43end
44note pinned_now is uint32_t in OmegaFp8SlotStats: wrap it at 2^32 before the high-water compare, as the C field
45note does (0xffffffff + 1 is 0, which does not raise pinned_high). pins wraps when om/apirest/slot.om packs it.
46put rec 1 add get rec 1 1
47bump rec 13
48put rec 14 and add get rec 14 1 4294967295
49if gt get rec 14 get rec 15
50put rec 15 get rec 14
51end
52ret 0
53end
54
55fn unpin rec edit ulong 16 ver ulong to long
56if or eq get rec 1 0 and eq get rec 5 0 ne get rec 3 ver
57ret -1
58end
59put rec 1 sub get rec 1 1
60put rec 14 sub get rec 14 1
61ret 0
62end
63
64fn evict rec edit ulong 16 to long
65if or ne get rec 1 0 eq get rec 0 1
66bump rec 10
67ret -6
68end
69if eq get rec 0 2
70bump rec 12
71end
72put rec 0 0
73put rec 2 0
74ret 0
75end
76
77fn idle rec edit ulong 16 to long
78if or eq get rec 0 1 ne get rec 1 0
79ret 0
80end
81ret 1
82end
83fn sentry rec edit ulong 16 ver ulong to long
84if or ne get rec 0 2 or ne get rec 3 ver eq ver 0
85ret -7
86end
87if eq get rec 1 0
88ret -1
89end
90ret 0
91end
92
93fn apishl op ulong aux ulong rec edit ulong 16 to long
94if eq op 1
95ret begin rec
96end
97if eq op 2
98ret finish rec aux
99end
100if eq op 3
101ret pin rec aux
102end
103if eq op 4
104ret unpin rec aux
105end
106if eq op 5
107ret evict rec
108end
109if eq op 6
110ret idle rec
111end
112if eq op 7
113ret sentry rec aux
114end
115ret -1
116end