Skip to content

Is there any example for passing a map array to a cuda kernel? #493

Answered by sleeepyjack
wangzilu asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @wangzilu,

There are multiple ways to achieve this. I just put together a simple example here.
The idea is to emplace the map objects into a host vector and then create non-owning reference objects for each map that can be placed into a device vector and then later be used in the kernel.

The downside of this approach is that each map will allocate its own storage, which can lead to overheads during allocation/initialization (plain cudaMalloc is a blocking operation).
Instead, it is also possible to allocate a single storage array first and then subdivide it into multiple maps.
This approach is a bit more complex. We have an example here.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PointKernel
Comment options

Answer selected by PointKernel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants