The output w/ and w/o debug mode differs

Hi,

I have this code(attached in the file). The problem with the code is that when compiled in debug mode

nvcc -g -G table_lookup.cu -o lookup.o
./lookup.o

The program gives the desired output.

But when compiled without debug mode

nvcc table_lookup.cu -o lookup.o
./lookup.o

The program gives the incorrect result.

I have debugged the program using cuda-gdb which seems to work properly and gives the correct result. I do not understand why would setting debug mode change the output. I mean what else is going on in debug mode that is not happening in normal mode. I wish I could go inside those GPU cores and see what they are actually doing.

I have already spent hours to figure out the problem. I would spent more hours to debug it using cuda-gdb but this is not working properly .I would really appreciate if someone suggest some approach to debug it now.

Thanks.
db.txt (1.04 KB)
table_lookup.cu (7.12 KB)