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/om/platform-linux/plat_policy.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 / om / platform-linux / plat_policy.om` 281 lines · 4052 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note Linux platform policy. Effectful nvrm and m16 calls stay in C. 3 note WolframLanguageEvaluator: IntegerString[{BitOr[BitShiftLeft[2, 28], BitShiftLeft[4, 16], BitShiftRight[40, 2]], BitShiftLeft[17, 27], `18446744073709547520`, `1844674407370955161`, `18446744073709551615`}, 16] -> `2004000a`, `88000000`, `fffffffffffff000`, `1999999999999999`, ffffffffffffffff 4 note m[0] selects the decision. q is cleared by the caller. Return 0 means refuse or not-found where the op says so. 5 fn plat_byte m view ulong 16 idx ulong to ulong 6 word = div idx 8 7 shift = mul rem idx 8 8 8 ret and shr get m add 2 word shift 255 9 end 10 fn plat_l2 q edit ulong 16 to ulong 11 put q 0 `537133066` 12 put q 1 0 13 put q 2 0 14 put q 3 0 15 put q 4 `2281701376` 16 ret 5 17 end 18 fn plat_chan m view ulong 16 to ulong 19 if or eq get m 1 0 gt get m 1 1 20 ret 1 21 end 22 b0 = get m 2 23 if or lt b0 50 gt b0 52 24 ret 1 25 end 26 if ne get m 3 0 27 ret 1 28 end 29 ret sub b0 48 30 end 31 fn plat_range m view ulong 16 to ulong 32 nbytes = get m 3 33 off = get m 2 34 size = get m 1 35 if eq nbytes 0 36 ret 7 37 end 38 if gt off size 39 ret 7 40 end 41 if gt nbytes sub size off 42 ret 7 43 end 44 ret 0 45 end 46 fn plat_alloc m view ulong 16 q edit ulong 16 to ulong 47 if ne get m 5 0 48 put q 0 get m 5 49 ret 1 50 end 51 discrete = get m 1 52 kind = get m 2 53 rights = get m 3 54 cached = get m 4 55 local = ulong 0 56 if and and ne discrete 0 ne kind 4 eq and rights 32 0 57 local = 1 58 end 59 if and ne local 0 ne cached 0 60 put q 0 10 61 ret 1 62 end 63 if ne cached 0 64 if or ne kind 2 ne and rights 33 0 65 put q 0 10 66 ret 1 67 end 68 end 69 put q 0 0 70 put q 1 local 71 put q 2 cached 72 if ne local 0 73 put q 3 1 74 else 75 if ne cached 0 76 put q 3 2 77 else 78 put q 3 3 79 end 80 end 81 ret 1 82 end 83 fn plat_page m view ulong 16 q edit ulong 16 to ulong 84 bytes = get m 1 85 if eq bytes 0 86 ret 0 87 end 88 if gt bytes `18446744073709547520` 89 ret 0 90 end 91 put q 0 and add bytes 4095 `18446744073709547520` 92 ret 1 93 end 94 fn plat_fit m view ulong 16 to ulong 95 nwords = get m 1 96 prefix = get m 2 97 ring = get m 3 98 if eq nwords 0 99 ret 7 100 end 101 if gt nwords sub `18446744073709551615` prefix 102 ret 7 103 end 104 words = add nwords prefix 105 if gt words `4611686018427387903` 106 ret 7 107 end 108 if gt mul words 4 ring 109 ret 7 110 end 111 ret 0 112 end 113 fn plat_xq m view ulong 16 to ulong 114 nchan = get m 1 115 if lt nchan 2 116 ret 0 117 end 118 for i ulong 3 119 if ge add i 1 nchan 120 break 121 end 122 gen = get m add 5 mul i 2 123 if eq gen 0 124 else 125 if and eq get m add 4 mul i 2 get m 2 eq gen get m 3 126 ret add i 1 127 end 128 end 129 end 130 ret 0 131 end 132 fn plat_acc m view ulong 16 start ulong stop ulong out edit ulong 1 to ulong 133 acc = ulong 0 134 for i ulong 32 135 if ge add start i stop 136 break 137 end 138 d = plat_byte m add start i 139 if or lt d 48 gt d 57 140 ret 0 141 end 142 dig = sub d 48 143 if gt acc `1844674407370955161` 144 ret 0 145 end 146 acc = mul acc 10 147 if gt acc sub `18446744073709551615` dig 148 ret 0 149 end 150 acc = add acc dig 151 end 152 if eq start stop 153 ret 0 154 end 155 put out 0 acc 156 ret 1 157 end 158 fn plat_sp c ulong to ulong 159 if eq c 32 160 ret 1 161 end 162 if eq c 9 163 ret 1 164 end 165 if eq c 10 166 ret 1 167 end 168 if eq c 11 169 ret 1 170 end 171 if eq c 12 172 ret 1 173 end 174 if eq c 13 175 ret 1 176 end 177 ret 0 178 end 179 fn plat_min m view ulong 16 q edit ulong 16 to ulong 180 n = get m 1 181 if or eq n 0 gt n 32 182 ret 0 183 end 184 if eq plat_byte m 0 45 185 ret 0 186 end 187 i = ulong 0 188 for k ulong 32 189 if ge i n 190 break 191 end 192 c = plat_byte m i 193 if eq plat_sp c 1 194 i = add i 1 195 else 196 break 197 end 198 end 199 sign = ulong 0 200 if lt i n 201 c = plat_byte m i 202 if eq c 43 203 i = add i 1 204 end 205 if eq c 45 206 sign = 1 207 i = add i 1 208 end 209 end 210 got = new ulong 1 0 211 if eq plat_acc m i n got 0 212 ret 0 213 end 214 v = get got 0 215 if ne sign 0 216 v = sub 0 v 217 end 218 put q 0 v 219 ret 1 220 end 221 fn plat_sm m view ulong 16 to ulong 222 if eq get m 1 0 223 ret 0 224 end 225 if eq get m 2 0 226 ret 121 227 end 228 ret get m 2 229 end 230 fn plat_policy m view ulong 16 q edit ulong 16 to ulong 231 op = get m 0 232 if eq op 1 233 ret plat_l2 q 234 end 235 if eq op 2 236 ret plat_chan m 237 end 238 if eq op 3 239 ret plat_range m 240 end 241 if eq op 4 242 ret plat_alloc m q 243 end 244 if eq op 5 245 ret plat_page m q 246 end 247 if eq op 7 248 ret plat_min m q 249 end 250 if eq op 8 251 if ge get m 1 get m 2 252 ret 12 253 end 254 ret 0 255 end 256 if eq op 9 257 ret plat_fit m 258 end 259 if eq op 10 260 if eq and get m 1 32 0 261 ret 8 262 end 263 if ne and get m 2 3 0 264 ret 1 265 end 266 ret 0 267 end 268 if eq op 12 269 ret plat_xq m 270 end 271 if eq op 13 272 if and ne get m 1 0 ne get m 2 0 273 ret 1 274 end 275 ret 0 276 end 277 if eq op 14 278 ret plat_sm m 279 end 280 ret 0 281 end