Hi everyone,
I have a question concerning the shared memory in combination with syncthreads.
When i need to load some data into shared memory or initialize it, i use for example:
[font=“Courier New”]
int threadNo = blockDim.x * blockIdx.x + threadIdx.x;
if(particleNo < sharedMemValues)
{
sharedPotentials[threadNo] = 0.0f;
}
__syncthreads();
[/font]
With the “syncthreads” command to ensure that all values are set before the programm continues.
The cuda manual says, “syncthreads” means, that all threads of that block wait at that line. But I have more than one block, isn’t it possible that that other blocks acces the shared memory, before “block 0” is finished with the setting of the shared memory, or even that block 2 is executed before block 0 and the shared memory isn’t set?
I hope you can understand what I mean! → What am I supposed to do?
Thx,
Philipp.