From the programming guide, “shared and constant variables have implied static storage”. my understandings from C, “static” means the memory persist across multiple function calls.
If I declare a shared array, initialize it with one global kernel, and run another global kernel to read/write to this memory, will the values of the shared memory consistant across muliple calls?
here is an example to illustrate my question (taken from this thread)
__shared__ uint g_seeds[N];
__global__ void mt_rand_init(void) {
// initialize g_seeds[idx] here ...
}
__global__ void genrand(float2 result[]){
// take g_seeds[] values, do some math
// and save back to g_seeds[]
}
main(){
...
mt_rand_init<<<gridsize,blocksize>>>();
for(i=0;i<10;i++){
genrand<<<gridsize,blocksize>>>(res);
}
...
}
if I initialize g_seeds in mt_rand_init(), shall I expect to see the same values in genrand()? and across the multiple calls of genrand()?
what would happen if gridsize/blocksize are different for mt_rand_init and genrand?