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