Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CUDA: Using shared memory across different kernels

Is this possible?
I am trying to define a shared memory array in one kernel and then I need to use those values in a different kernel.

I tried declaring the

extern __shared__ float sharedMem[];

outside all functions and then wrote to it in one kernel and tried to access it in a different kernel. The sharedMem array is written to properly in the first kernel, but when I try to access it in the second kernel, the values are all 0. So I am guessing this won't work or I am doing something wrong.

Can someone please help me out on this?

like image 206
lokstok Avatar asked Jun 12 '26 10:06

lokstok


1 Answers

You are correct, shared memory does not persist across kernel calls. Instead you must use global memory (or texture memory) and load it into shared memory in each kernel call.

like image 75
jmilloy Avatar answered Jun 14 '26 00:06

jmilloy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!