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 / core / ampack.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Copyright 2026 Drake Stapleton |
| 3 | note Ampere host packing. C still reads the IR struct (pointer I/O). This unit sign-extends |
| 4 | note the low 32 bits and packs imm/control plus the flag word. WolframLanguageEvaluator: |
| 5 | note 2^64 - 2^32 -> 18446744069414584320; 2^31 -> 2147483648. |
| 6 | note mode 0 packs one instruction from src[16] into dst[0..7]. |
| 7 | note mode 1 sign-extends all 16 slots (the physical-register chunks). |
| 8 | fn sext32 v ulong to ulong |
| 9 | v = and v 4294967295 |
| 10 | if ne and v 2147483648 0 |
| 11 | ret or v ulong 18446744069414584320 |
| 12 | end |
| 13 | ret v |
| 14 | end |
| 15 | fn ampack mode ulong src view ulong 16 dst edit ulong 16 to void |
| 16 | if eq mode 0 |
| 17 | put dst 0 sext32 get src 0 |
| 18 | put dst 1 sext32 get src 1 |
| 19 | put dst 2 sext32 get src 2 |
| 20 | put dst 3 sext32 get src 3 |
| 21 | put dst 4 sext32 get src 4 |
| 22 | put dst 5 sext32 get src 5 |
| 23 | imm = and get src 6 4294967295 |
| 24 | ctl = and get src 7 4294967295 |
| 25 | put dst 6 or imm shl ctl 32 |
| 26 | f = ulong get src 8 |
| 27 | f = or f shl get src 9 1 |
| 28 | f = or f shl get src 10 2 |
| 29 | f = or f shl get src 15 8 |
| 30 | f = or f shl get src 11 16 |
| 31 | f = or f shl get src 12 24 |
| 32 | f = or f shl get src 13 32 |
| 33 | f = or f shl get src 14 40 |
| 34 | put dst 7 f |
| 35 | else |
| 36 | for i ulong 16 |
| 37 | put dst i sext32 get src i |
| 38 | end |
| 39 | end |
| 40 | end |