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