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

142 lines · 3057 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Deterministic RM/channel simulator, not a hardware executor or SASS simulator.
3note Two modeled process identities and two private eight-word mappings at the same VA.
4global states uint 2
5global epochs ulong 2
6global starts ulong 2
7global limits ulong 2
8global kinds uint 2
9global cursors ulong 2
10global chans uint 2
11global ctxs uint 2
12global maps uint 2
13global memory ulong 16
14fn model_init to void
15for p ulong 2
16put states p READY
17put epochs p 1
18put chans p 1
19put ctxs p 1
20put maps p 1
21put cursors p 0
22end
23for i ulong 16
24put memory i 0
25end
26end
27note Buffer handle is (owner process, context generation); address/offset alone is not a handle.
28fn model_store p ulong owner ulong token ulong off ulong value ulong to bool
29if ge p 2
30ret false
31end
32if not omega_c5_access add p 1 owner get epochs p token
33ret false
34end
35if not omega_c5_range 8 off 1
36ret false
37end
38if ne get maps p 1
39ret false
40end
41put memory add mul p 8 off value
42ret true
43end
44fn model_load p ulong owner ulong token ulong off ulong to ulong
45if ge p 2
46ret UMAX
47end
48if not omega_c5_access add p 1 owner get epochs p token
49ret UMAX
50end
51if not omega_c5_range 8 off 1
52ret UMAX
53end
54if ne get maps p 1
55ret UMAX
56end
57ret get memory add mul p 8 off
58end
59fn model_submit p ulong token ulong now ulong budget ulong kind uint to bool
60if ge p 2
61ret false
62end
63if not omega_c5_admit get states p get epochs p token
64ret false
65end
66if or ne get chans p 1 or ne get ctxs p 1 ne get maps p 1
67ret false
68end
69limit = omega_c5_deadline now budget
70if eq limit 0
71ret false
72end
73put states p BUSY
74put starts p now
75put limits p limit
76put kinds p kind
77put cursors p 0
78ret true
79end
80note kind zero simulates a kernel with a back edge and no completion release.
81note Work emits eight stores then two completion markers. Both share the original deadline.
82fn model_tick p ulong token ulong now ulong fault bool to uint
83if ne get states p BUSY
84ret get states p
85end
86if ne token get epochs p
87ret BUSY
88end
89next = omega_c5_watch now get starts p get limits p false fault
90if eq next LATCH
91put states p LATCH
92ret LATCH
93end
94if ne get kinds p 0
95pos = get cursors p
96if lt pos 8
97ok = model_store p add p 1 token pos add mul add p 1 100 pos
98if not ok
99put states p LATCH
100ret LATCH
101end
102end
103put cursors p add pos 1
104next = omega_c5_watch now get starts p get limits p ge get cursors p 10 false
105put states p next
106end
107ret next
108end
109note Acknowledgements stand for successful RM actions, not attempted calls.
110note No grid/mapping release until channel destruction; no epoch change before context destruction.
111fn model_recover p ulong ack bool to uint
112state = get states p
113next = omega_c5_recover state ack
114if eq state next
115ret state
116end
117if eq state CHANNEL
118put chans p 0
119end
120if eq state CONTEXT
121put ctxs p 0
122put maps p 0
123put epochs p omega_c5_epoch get epochs p
124for i ulong 8
125put memory add mul p 8 i 0
126end
127end
128if eq state CLOSED
129if eq get epochs p 0
130ret state
131end
132put ctxs p 1
133end
134if eq state NEWCTX
135put chans p 1
136end
137if eq state NEWCHAN
138put maps p 1
139end
140put states p next
141ret next
142end