The output w/ and w/o debug mode differs


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

nvcc -g -G -o lookup.o

The program gives the desired output.

But when compiled without debug mode

nvcc -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.

db.txt (1.04 KB) (7.12 KB)