interplane.Get Omega
Read in your language

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

branch main Branches Tags History

CUDApp / om / apiviews / ewarg.om

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