Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CUDA][HIP] Fix kernel arguments being overwritten when added out of order #2559

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

fabiomestre
Copy link
Contributor

@fabiomestre fabiomestre commented Jan 14, 2025

In the Cuda and Hip adapter, when kernel arguments are added out of order (e.g. argument at index 1 is added before argument at index 0), the existing arguments are currently being overwritten. This happens because some of the argument sizes might not be known when adding them out of order and the code relies on those sizes to choose where to store the argument.

This PR avoids this issue by storing the arguments in the same order that they are added and accessing them using pointer offsets.

intel/llvm: intel/llvm#16733

@fabiomestre fabiomestre force-pushed the fix_kernel_arg_indices branch from 4400095 to 7ca2133 Compare January 14, 2025 13:25
@github-actions github-actions bot added the cuda CUDA adapter specific issues label Jan 14, 2025
@fabiomestre fabiomestre force-pushed the fix_kernel_arg_indices branch 3 times, most recently from ccccf85 to 0a071be Compare January 14, 2025 15:25
@github-actions github-actions bot added the hip HIP adapter specific issues label Jan 14, 2025
@fabiomestre fabiomestre changed the title Fix kernel argument indices bug [CUDA][HIP] Fix kernel arguments being overriden when added out of order Jan 14, 2025
Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add CTS tests for this? Probably in test/conformance/exp_command_buffer/update/local_memory_update.cpp & test/conformance/kernel/urKernelSetArgLocal.cpp

Might make it easier if we want to merge this fix earlier than the intel/llvm#16573 feature

@github-actions github-actions bot added the conformance Conformance test suite issues. label Jan 15, 2025
@fabiomestre fabiomestre force-pushed the fix_kernel_arg_indices branch from 86885a1 to bf6b6f9 Compare January 15, 2025 14:57
@fabiomestre fabiomestre marked this pull request as ready for review January 15, 2025 14:58
@fabiomestre fabiomestre requested review from a team as code owners January 15, 2025 14:58
@fabiomestre fabiomestre requested review from reble and npmiller January 15, 2025 14:58
source/adapters/cuda/kernel.hpp Outdated Show resolved Hide resolved
source/adapters/hip/kernel.hpp Outdated Show resolved Hide resolved
@fabiomestre fabiomestre changed the title [CUDA][HIP] Fix kernel arguments being overriden when added out of order [CUDA][HIP] Fix kernel arguments being overwritten when added out of order Jan 15, 2025
In the Cuda and Hip adapter, when kernel arguments are added out of order
(e.g. argument at index 1 is added before argument at index 0), the
existing arguments are currently being overwritten. This happens because
some of the argument sizes might not be known when adding them out of
order and the code relies on those sizes to choose where to store the
argument.

This commit avoids this issue by storing the arguments in the same order that
they are added and accessing them using pointer offsets.
@github-actions github-actions bot added the command-buffer Command Buffer feature addition/changes/specification label Jan 21, 2025
@fabiomestre fabiomestre force-pushed the fix_kernel_arg_indices branch from 27a3561 to e3dcfc3 Compare January 21, 2025 14:23
@fabiomestre fabiomestre force-pushed the fix_kernel_arg_indices branch from a6c39c4 to f98229f Compare January 22, 2025 14:02
source/adapters/cuda/enqueue.cpp Outdated Show resolved Hide resolved
@fabiomestre fabiomestre added the ready to merge Added to PR's which are ready to merge label Jan 22, 2025
@kbenzie kbenzie merged commit b841691 into oneapi-src:main Jan 23, 2025
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
command-buffer Command Buffer feature addition/changes/specification conformance Conformance test suite issues. cuda CUDA adapter specific issues hip HIP adapter specific issues ready to merge Added to PR's which are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants