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