Avoid host allocations for by-offload arguments to GPU kernels #24970
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses a performance issue first noted by @stonea in the context of Coral. Today, I had a chat with @Guillaume-Helbecque who was also suffering partly from it.
This issue arises when:
When (2), we pass arrays by offload -- we copy the record onto GPU memory and pass that record as an argument to the kernel. This involves allocating memory for the record on device-accessible memory. Now, most likely because oversight (on my part), that allocation is done on page-locked host memory instead. (Probably because I was thinking that object instances should be host-accessible so that they can be initialized, but we're talking about an already initialized record that we'll bit-copy anyways).
Page-locked allocations are globally synchronous. In other words, they will block all other GPUs, or be blocked until all other GPUs are free. That is why this is especially problematic with (1).
This PR adjusts the memory allocation to be on device memory proper.
Resolves #24936
Test: