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/apiviews/hostrest.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 / apiviews / hostrest.om` 394 lines · 6272 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 note FP8/GDN host-only policy; effect acquisition remains in the C caller. 3 fn ah_flag c ulong tail ulong dflt ulong to ulong 4 if eq tail 0 5 if eq c 48 6 ret 0 7 end 8 if eq c 49 9 ret 1 10 end 11 end 12 ret dflt 13 end 14 fn ah_var c ulong tail ulong to ulong 15 if and eq c 50 eq tail 0 16 ret 2 17 end 18 ret 1 19 end 20 fn ah_shape k uint over uint kind uint to uint 21 if ne over 0 22 ret over 23 end 24 if eq kind 0 25 if eq rem k 512 0 26 ret 16 27 end 28 ret 8 29 end 30 if eq kind 1 31 ret 1 32 end 33 ret 8 34 end 35 fn ah_reg threads ulong decl ulong to ulong 36 if le mul threads decl 65536 37 ret 1 38 end 39 ret 0 40 end 41 fn ah_group groups uint forced uint wave ulong to uint 42 if and gt forced 0 le forced 256 43 ret forced 44 end 45 if or eq wave 0 eq groups 0 46 ret 6 47 end 48 n = div uint 48 groups 49 if eq n 0 50 ret 1 51 end 52 if lt n 6 53 ret n 54 end 55 ret 6 56 end 57 fn ah_digit n uint c uint to ulong 58 if or lt c 48 gt c 57 59 ret `4294967296` 60 end 61 if ge n 1000 62 ret `4294967296` 63 end 64 ret ulong add mul n 10 sub c 48 65 end 66 fn ah_warps k uint groups uint over uint bigk ulong variant ulong to uint 67 if ne over 0 68 ret over 69 end 70 if eq variant 2 71 ret 16 72 end 73 if gt groups 1 74 ret 32 75 end 76 if and and eq groups 1 gt k 4096 ne bigk 0 77 ret 16 78 end 79 ret 8 80 end 81 fn ah_coal on ulong warps uint rows uint to uint 82 if and ne on 0 le mul warps rows 32 83 ret 1 84 end 85 ret 0 86 end 87 fn ah_depth k uint lb uint rows uint warps uint groups uint bigk ulong to ulong 88 ks = div k mul uint 32 lb 89 partial = false 90 if gt mul mul ks rows lb 128 91 if gt k 4096 92 if eq groups 1 93 partial = ne bigk 0 94 end 95 end 96 end 97 if partial 98 full = ks 99 ks = sub ks 1 100 while gt ks 1 101 if eq rem full ks 0 102 if le mul mul ks rows lb 128 103 break 104 end 105 end 106 ks = sub ks 1 107 end 108 if lt ks 2 109 ret 0 110 end 111 end 112 if gt mul mul ks rows lb 128 113 ret 0 114 end 115 if ne rem k mul uint 32 warps 0 116 ret 0 117 end 118 if gt k mul uint 512 warps 119 ret 0 120 end 121 if partial 122 ret or ulong ks `4294967296` 123 end 124 ret ulong ks 125 end 126 fn ah_refuse n uint rows uint support ulong to ulong 127 if ne rem n rows 0 128 ret 1 129 end 130 if eq support 0 131 ret 1 132 end 133 ret 0 134 end 135 fn ah_grid n uint rows uint warps uint budget uint bigk ulong to uint 136 rg = div n rows 137 gx = div add rg sub warps 1 warps 138 if ne bigk 0 139 waves = div add gx 383 384 140 if lt waves 2 141 waves = 2 142 end 143 gx = div add gx sub waves 1 waves 144 budget = gx 145 end 146 if gt gx budget 147 gx = budget 148 end 149 if eq gx 0 150 gx = 1 151 end 152 ret gx 153 end 154 fn ah_cache valid ulong equal ulong rec ulong to ulong 155 if and ne valid 0 ne equal 0 156 ret 1 157 end 158 if and ne valid 0 ne rec 0 159 ret 2 160 end 161 ret 0 162 end 163 fn ah_move kind ulong dst ulong bytes ulong per ulong to ulong 164 if or or or and ne kind 4 ne kind 5 eq dst 0 eq bytes 0 ne rem bytes per 0 165 ret 0 166 end 167 if gt div bytes per `2147483647` 168 ret 0 169 end 170 ret div bytes per 171 end 172 fn ah_tokens layer uint layers uint t uint low uint high uint to ulong 173 if or or ge layer layers lt t low gt t high 174 ret 0 175 end 176 ret 1 177 end 178 fn ah_scratch rec ulong present ulong cap ulong bytes ulong to ulong 179 if and ne rec 0 or eq present 0 lt cap bytes 180 ret 0 181 end 182 ret 1 183 end 184 fn ah_pfgx t uint prep uint ratio uint stage uint to uint 185 if eq stage 0 186 ret div add t sub prep 1 prep 187 end 188 if eq stage 1 189 ret ratio 190 end 191 ret t 192 end 193 fn ah_dcall p view ulong 16 to ulong 194 a = uint get p 0 195 b = uint get p 1 196 c = uint get p 2 197 d = uint get p 3 198 e = uint get p 4 199 f = get p 5 200 ret ah_depth a b c d e f 201 end 202 fn ah_tcall p view ulong 16 to ulong 203 a = uint get p 0 204 b = uint get p 1 205 c = uint get p 2 206 d = uint get p 3 207 e = uint get p 4 208 ret ah_tokens a b c d e 209 end 210 fn ah_admit p view ulong 16 to ulong 211 if eq get p 0 0 212 if ne get p 1 0 213 if or or eq get p 2 0 eq get p 3 0 eq get p 4 0 214 ret 0 215 end 216 end 217 ret 1 218 end 219 if eq get p 0 1 220 if eq get p 1 0 221 ret 0 222 end 223 if and eq get p 2 0 eq get p 3 0 224 ret 0 225 end 226 if and and eq get p 4 0 eq get p 5 0 eq get p 6 0 227 ret 0 228 end 229 if and eq get p 7 0 eq get p 8 0 230 ret 0 231 end 232 ret 1 233 end 234 if ne get p 1 0 235 if or or eq get p 2 0 eq get p 3 0 eq get p 4 0 236 ret 0 237 end 238 else 239 if or or or eq get p 5 0 eq get p 6 0 eq get p 7 0 eq get p 8 0 240 ret 0 241 end 242 end 243 ret 1 244 end 245 note op 25 ragged k: p0 k, p1 lane_bytes, p2 ragged allowed, p3 variant, p4 depth. 1 when the call may use a ragged-k kernel 246 note (omega_blackwell_codegen_fp8_gemv_ragged_prog): variant 1, step-by-step kernel (depth 0), k a multiple of 128 and not of 247 note 32 * lane_bytes. Everything else, including every k the plain kernels take, answers 0. 248 fn ah_ragged p view ulong 16 to ulong 249 if or eq get p 2 0 ne get p 3 1 250 ret 0 251 end 252 if or eq get p 1 0 ne get p 4 0 253 ret 0 254 end 255 w = mul ulong 32 get p 1 256 if eq rem get p 0 w 0 257 ret 0 258 end 259 if ne rem get p 0 128 0 260 ret 0 261 end 262 ret 1 263 end 264 fn ah_extra op ulong p view ulong 16 to ulong 265 if eq op 25 266 ret ah_ragged p 267 end 268 if eq op 24 269 k = uint get p 0 270 lb = uint get p 1 271 r = uint get p 2 272 ks = div k mul uint 32 lb 273 if gt mul mul ks r lb 128 274 if and gt k 4096 eq get p 3 1 275 ret 1 276 end 277 end 278 ret 0 279 end 280 if eq op 23 281 ret ah_admit p 282 end 283 if eq op 16 284 for i ulong 8 285 if ne get p i 0 286 ret 0 287 end 288 end 289 ret 1 290 end 291 if eq op 17 292 if eq get p 0 0 293 ret 0 294 end 295 if or eq get p 1 1 eq get p 1 get p 0 296 ret 1 297 end 298 ret 0 299 end 300 if eq op 18 301 if ne get p 0 0 302 ret get p 1 303 end 304 if gt get p 2 1 305 if eq get p 3 2 306 ret 12 307 end 308 ret get p 4 309 end 310 ret 256 311 end 312 if eq op 19 313 if ne get p 0 0 314 ret 0 315 end 316 if ne get p 1 1 317 ret 0 318 end 319 if le get p 2 4096 320 ret 0 321 end 322 ret get p 3 323 end 324 if eq op 20 325 if ne get p 0 1 326 ret 0 327 end 328 if eq get p 1 0 329 ret 0 330 end 331 if gt get p 2 get p 3 332 ret 0 333 end 334 ret 1 335 end 336 if eq op 21 337 if gt get p 0 get p 1 338 ret 1 339 end 340 ret 0 341 end 342 ret div get p 0 get p 1 343 end 344 fn ah_rest op ulong p view ulong 16 to ulong 345 if ge op 16 346 ret ah_extra op p 347 end 348 if eq op 0 349 ret ah_flag get p 0 get p 1 get p 2 350 end 351 if eq op 1 352 ret ah_var get p 0 get p 1 353 end 354 if eq op 2 355 ret ulong ah_shape uint get p 0 uint get p 1 uint get p 2 356 end 357 if eq op 3 358 ret ah_reg get p 0 get p 1 359 end 360 if eq op 4 361 ret ulong ah_group uint get p 0 uint get p 1 get p 2 362 end 363 if eq op 5 364 ret ah_digit uint get p 0 uint get p 1 365 end 366 if eq op 6 367 ret ulong ah_warps uint get p 0 uint get p 1 uint get p 2 get p 3 get p 4 368 end 369 if eq op 7 370 ret ulong ah_coal get p 0 uint get p 1 uint get p 2 371 end 372 if eq op 8 373 ret ah_dcall p 374 end 375 if eq op 9 376 ret ah_refuse uint get p 0 uint get p 1 get p 2 377 end 378 if eq op 10 379 ret ulong ah_grid uint get p 0 uint get p 1 uint get p 2 uint get p 3 get p 4 380 end 381 if eq op 11 382 ret ah_cache get p 0 get p 1 get p 2 383 end 384 if eq op 12 385 ret ah_move get p 0 get p 1 get p 2 get p 3 386 end 387 if eq op 13 388 ret ah_tcall p 389 end 390 if eq op 14 391 ret ah_scratch get p 0 get p 1 get p 2 get p 3 392 end 393 ret ulong ah_pfgx uint get p 0 uint get p 1 uint get p 2 uint get p 3 394 end