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 / backend / amd / kfd / kernarg.om

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