It seems that I’m facing a problem where NVCC fails to recognize which type of memory to bind to the variable: either constant or global.
The code below:
…
int* memPtr;
if (X==0){
memPtr=constant_array;
}else{
memPtr=_global_array;
}
memPtr[0]=1;
…
works fine in EMU mode and crashes on a real hardware. When I comment either of the “if” statements it works OK.
I realize that it’s impossible to perform this binding in compile time, but what I vote for is to add error message if such problem is detected.
Well, I bumped into the same problem again, and now it’s b/w global and shared memory. Really painful… Maybe someone from NVIDIA can comment:
Here’s the code snippet :
shared int* ptr;
shared int sh_data[2];
global int g_data[2];
if (condition){
ptr=sh_data;
else{
ptr=g_data;
}
int x=ptr[0];
This kernel fails to launch ( unspecified launch failure), while when I comment one of the “if” branches out - it works fine.
Any hope for this to be solved some day?
My own guess is that accesses to different memory types require two different HW ops to be issued, and thus must be resolved at compile time. So unless there’ll be HW support for runtime pointer resolution - no hope for this to work…