initializing shared memory

It seems that when the same shared memory is used by two kernels (both kernels are in the same .cu file, and at least in emulation mode), the shared memory is not reinitialized when the second kernel gets invoked (so it still contains the values set by kernel 1). Does this mean that the second kernel should initialize it (each thread initializing a portion), or would moving the second kernel to its own .cu file fix this problem?


With any memory an any hardware architecture (disclaimer: that I know of), it is never safe to assume that memory has been initialized for you. You should initialize it yourself.