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 / codegen / cg_pack_len.om

53 lines · 1041 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2note Fixed metadata consumes one native slot. Fields: kind,m,k,mp,kp,n,nt0,nt1,source bytes,destination ushort count,reserved,reserved.
3note Kinds 0 A ushort, 1 row0 ushort, 2 B ushort, 3 A float bits, 4 row0 float bits.
4fn cg_pklen p edit ulong 12 to long
5for i ulong 8
6if gt get p i 4294967295
7ret long -1
8end
9end
10kind = get p 0
11if gt kind 4
12ret long -1
13end
14k = get p 2
15kp = get p 4
16if or gt k kp ne and kp 15 0
17ret long -1
18end
19width = ulong 2
20if ge kind 3
21width = ulong 4
22end
23sn = k
24dn = mul kp 16
25if or eq kind 0 eq kind 3
26m = get p 1
27mp = get p 3
28if or gt m mp ne and mp 15 0
29ret long -1
30end
31sn = mul m k
32dn = mul mp kp
33end
34if eq kind 2
35if lt get p 7 get p 6
36ret long -1
37end
38sn = mul k get p 5
39nj = sub get p 7 get p 6
40if ne kp 0
41if gt nj div div ulong 18446744073709551615 8 kp
42ret long -1
43end
44end
45dn = mul mul nj kp 8
46end
47if or gt sn div ulong 18446744073709551615 width gt dn div ulong 18446744073709551615 2
48ret long -1
49end
50put p 8 mul sn width
51put p 9 dn
52ret long 0
53end