Skip to content

Convert kernel arguments without map over the argument tuple - #788

Open
maleadt wants to merge 1 commit into
mainfrom
alloc
Open

maleadt wants to merge 1 commit into
mainfrom
alloc

Conversation

@maleadt

@maleadt maleadt commented Dec 2, 2026

Copy link
Copy Markdown
Member

Fixes #769.

map over a tuple of 32 or more elements isn't inferred, so launching a kernel with that many arguments (31 through KernelAbstractions, which adds its context) converted each argument through a dynamic call and allocated 10–40 KB on the host. The arguments are now converted with an unrolled ntuple, as onecall already sets them, both when @oneapi compiles the kernel and in launch_managed. KernelAbstractions and KernelInterface already convert their arguments this way, so this was the remaining map.

Bytes allocated per launch with the reproducer from the issue, on an Arc A770 (Julia 1.13.4):

arguments @oneapi, before → after KernelAbstractions, before → after
24 3464 → 3464 3539 → 3539
31 3953 → 3952 16307 → 4028
32 10542 → 3999 16685 → 4078
56 20493 → 9357 43030 → 9350

The remaining cost per argument is unchanged from below 32 arguments: mostly the closure passed to with_ownership, which holds the converted arguments, and the growth of the refs vector.

The "inference" testset now also checks a launch with 40 arguments, which fails without this change.

`map` over a tuple of 32 or more elements isn't inferred, so launching a
kernel with that many arguments (31 through KernelAbstractions, which adds
its context) dispatched for every argument and allocated 10-40 KB on the
host instead of a few hundred bytes per argument. Convert the arguments
with an unrolled `ntuple`, as `onecall` already sets them, both when
`@oneapi` compiles the kernel and when it is launched.

Fixes #769.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Launching a kernel with 32 or more arguments allocates 10–40 KB on the host

1 participant