I got some weird results back from func1 (although func2 was never executed).
I tried to comment func2 and smem2 out and then func1 worked properly. I tried to figure out what caused the problem but after commenting in func2 and smem2 it still worked and I don’t have any idea what caused the problem.
It is a memory problem “both arrays are starting in the same memory address!!”
See Variable Type Qualifiers (shared) section 4.2.2.3 on pages 19,20 in the CUDA_Programming_Guide_0.8.pdf for details about how to define arrays in shared memory without having this problem.
This is not correct. Please read section 4.2.2.3 carefully again. Shared arrays with specified dimension are always disjoint. You only need to calculate offsets for extern shared arrays (where the size is specified on kernel invocation).
I don’t know, what you say is correct, but may be there is a memory initialization or something like that the runs in parallel with the kernel and corrupts your calculations!
let’s try at first to do the correct allocation and if the problem still there, then we think!!
Sorry, I didn’t notice that our case is static allocation!!
I tried the example with 2 statically allocated arrays and 2 kernels, and I called only one kernel… everything was OK and no data corruption happened!!!
please check your main program, sure there is something wrong in your code!!