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 / backend / amd / kfd / kernarg.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note vadd kernarg ABI from backend/amd/vadd-gfx1151.s at the parent revision: |
| 3 | note a @0 u64, b @8 u64, c @16 u64, count @24 u32; segment 28, alignment 8. |
| 4 | note amdhsa.version [1,2] is code-object-v5 metadata (LLVM 18.1.3 AMDGPUUsage, Code Object V5 |
| 5 | note Metadata). No explicit .amdhsa_code_object_version appears: LLVM 18 defaults to v5. The gate |
| 6 | note also assembles the oracle and checks ELF ABI 3. Its metadata declares no hidden arguments: |
| 7 | note do not append hidden block-count/group-size fields when no corresponding .args entries exist. |
| 8 | note The same explicit argument ABI can be used by a gfx942 vadd with matching metadata; it does |
| 9 | note not make the gfx1151 kernel executable on gfx942. All AMD hardware NOT_RUN. |
| 10 | note usage: kernarg A B C COUNT [BUFFER_BYTES]; stdout exact 28 bytes; exit 3 short/long buffer |
| 11 | note or count out of u32; 2 number; 64 usage; 74 output. BUFFER_BYTES exists to exercise rejection. |
| 12 | om2 |
| 13 | fn kernarg b edit uchar * a ulong c ulong d ulong n ulong to int |
| 14 | if ne len b 28 |
| 15 | ret 3 |
| 16 | end |
| 17 | if gt n 4294967295 |
| 18 | ret 3 |
| 19 | end |
| 20 | for i ulong 8 |
| 21 | put b i uchar and shr a mul i 8 255 |
| 22 | put b add i 8 uchar and shr c mul i 8 255 |
| 23 | put b add i 16 uchar and shr d mul i 8 255 |
| 24 | end |
| 25 | for i ulong 4 |
| 26 | put b add i 24 uchar and shr n mul i 8 255 |
| 27 | end |
| 28 | ret 0 |
| 29 | end |
| 30 | fn main to int |
| 31 | if or lt argcnt 5 gt argcnt 6 |
| 32 | ret 64 |
| 33 | end |
| 34 | a = argnum 1 |
| 35 | b = argnum 2 |
| 36 | c = argnum 3 |
| 37 | n = argnum 4 |
| 38 | sz = ulong 28 |
| 39 | if eq argcnt 6 |
| 40 | sz = argnum 5 |
| 41 | end |
| 42 | buf = new uchar 28 0 |
| 43 | if gt sz 28 |
| 44 | ret 3 |
| 45 | end |
| 46 | r = kernarg part buf 0 sz a b c n |
| 47 | if ne r 0 |
| 48 | ret r |
| 49 | end |
| 50 | emit buf |
| 51 | ret 0 |
| 52 | end |