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