cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

billyc59
Journeyman III

device-side enqueue & local memory

I'm trying to use local memory inside a device-side enqueued kernel.

My assumption that any locally-declared array is visible across all work items in the work group.
This is proven to be true when I use local memory on kernels that are called from the host-side, but I'm running into problems when I use a similar setup on device-side enqueued kernels.

Is there something wrong with my assumption?

0 Likes
1 Solution
dipak
Big Boss

Device-side enqueuing requires kernel code to be represented as block syntax. Block syntax allows you to pass arguments declared to be a pointer to local memory. Khronos's OpenCL C spec shows few examples regarding this in the section "Enqueuing Kernels->Arguments that are a pointer type to local address space".

To reuse the kernel code, one can wrap a kernel inside a block and then enqueue the block to the device. However, an interesting point is, you can't wrap a kernel inside a block if the kernel defines some local variables. For more details, you may check this forum thread Device-side enqueue, block syntax, and local kernel variables. On that thread, the user has shared a very good workaround for this problem.

If you are looking for something else, it would be good if you can share some more details in this context. A sample code may be more helpful to discuss.

Regards,

View solution in original post

0 Likes
1 Reply
dipak
Big Boss

Device-side enqueuing requires kernel code to be represented as block syntax. Block syntax allows you to pass arguments declared to be a pointer to local memory. Khronos's OpenCL C spec shows few examples regarding this in the section "Enqueuing Kernels->Arguments that are a pointer type to local address space".

To reuse the kernel code, one can wrap a kernel inside a block and then enqueue the block to the device. However, an interesting point is, you can't wrap a kernel inside a block if the kernel defines some local variables. For more details, you may check this forum thread Device-side enqueue, block syntax, and local kernel variables. On that thread, the user has shared a very good workaround for this problem.

If you are looking for something else, it would be good if you can share some more details in this context. A sample code may be more helpful to discuss.

Regards,

0 Likes