CUDA __shared__ memory corruption problem with CUDA shared memory ..

Hi All,

I tried to used shared memory by declaring it outside the routine scope to use it from multiple device routines in the same file scope.

shared int my_buffer[512];

global void myroutine()
there are some other shared buffers here too
shared flags[20];
//ldo something with my_buffer and flags here

//call the other routine


device void otherroutine()
// do something with my_buffer here

This works well in most of the cases earlier and i was really happy about it. unfortunately i ran into some unknown behavior lately. My investigation reveals the memory is getting corrupted and i’m not getting right result. However if i comment out some code it works fine ( even though the commented code area is not reachable in the tests i run). This problme is probably introduced in the compile time.

I’m wondering if this is due to wrong usage of shared memory ( as i havent seen any declarion outside routine). BTW i also get a bunch of warnings in building like " Advisory: Cannot tell what pointer points to, assuming global memory". It’ll be great if someone in the forum can throw some light regarding this.