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 / apiviews / ewarg.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Fixed 8-word launch record for the elementwise API. No data view: the caller |
| 3 | note keeps pointer acquisition and the launch. kind 0 is a 1d chunk (n is the |
| 4 | note remaining element count, p0 unused). kind 1 is a rope head chunk (n is the |
| 5 | note remaining head count, p0 is head_dim). kind 2 is an rmsnorm row chunk |
| 6 | note (n is the remaining row count). p0 is eps bits, p1 is dim. |
| 7 | note kind 2 rec 1 is dim/128, rec 2 is the f32 bits of 1/dim, rec 3 eps bits, rec 4 dim. |
| 8 | note WolframLanguageEvaluator: FromDigits[RealDigits[1.0, 2][[1]][[2 ;; 24]], 2] + 127*2^23 -> 1065353216. |
| 9 | note rec 0 count, rec 1 grid or half, rec 2..5 params, rec 6 threads, rec 7 grid. |
| 10 | note Caps: 1024 CTAs, 128 threads, chunk 131072. WolframLanguageEvaluator: 1024*128 -> 131072. |
| 11 | note head_dim is even, 2..2048. |
| 12 | fn av_ewarg kind ulong n ulong p0 ulong p1 ulong rec edit ulong 8 to ulong |
| 13 | if eq n 0 |
| 14 | ret 1 |
| 15 | end |
| 16 | put rec 3 0 |
| 17 | put rec 4 0 |
| 18 | put rec 5 0 |
| 19 | put rec 7 0 |
| 20 | if eq kind 0 |
| 21 | ni = n |
| 22 | if gt ni 131072 |
| 23 | ni = 131072 |
| 24 | end |
| 25 | put rec 0 ni |
| 26 | put rec 1 div add ni 127 128 |
| 27 | put rec 2 ni |
| 28 | put rec 6 128 |
| 29 | ret 0 |
| 30 | end |
| 31 | if eq kind 1 |
| 32 | if lt p0 2 |
| 33 | ret 1 |
| 34 | end |
| 35 | if ne and p0 1 0 |
| 36 | ret 1 |
| 37 | end |
| 38 | if gt p0 2048 |
| 39 | ret 1 |
| 40 | end |
| 41 | nh = n |
| 42 | if gt nh 1024 |
| 43 | nh = 1024 |
| 44 | end |
| 45 | hf = div p0 2 |
| 46 | put rec 0 nh |
| 47 | put rec 1 hf |
| 48 | put rec 2 p0 |
| 49 | put rec 3 hf |
| 50 | put rec 6 hf |
| 51 | put rec 7 nh |
| 52 | ret 0 |
| 53 | end |
| 54 | if eq kind 2 |
| 55 | if eq p1 0 |
| 56 | ret 1 |
| 57 | end |
| 58 | if gt p1 16384 |
| 59 | ret 1 |
| 60 | end |
| 61 | nr = n |
| 62 | if gt nr 1024 |
| 63 | nr = 1024 |
| 64 | end |
| 65 | one = bitcast f32 uint 1065353216 |
| 66 | inv = div f32 one f32 p1 |
| 67 | put rec 0 nr |
| 68 | put rec 1 div p1 128 |
| 69 | put rec 2 ulong bitcast uint inv |
| 70 | put rec 3 p0 |
| 71 | put rec 4 p1 |
| 72 | put rec 6 128 |
| 73 | put rec 7 nr |
| 74 | ret 0 |
| 75 | end |
| 76 | ret 1 |
| 77 | end |