3
votes

how do I prevent cuda-gdb from optimizing out any value ( whether device or host, local or global )? I have checked nvidia forums but most of them are years old and there seems to be not a solution for old cuda versions, but is there one for the newest one (cuda 9.2 and sm 61)?

I am using flags described in nvidia's documentation:

-g - "Generate debug information for host code."

-G - "Generate debug information for device code. Turns off all optimizations. Don't use for profiling; use -lineinfo instead."

1
The only thing that should be necessary is a debug build. However, you will still need to inspect the variable when it is actually in scope. It is not necessarily in scope from the point at which it is declared. You may have to step forward until the variable is actually used in a meaningful way. - Robert Crovella
@RobertCrovella I have built using nvcc and and -g -G flags. Also, I have made sure i am in scope. Are there any other possible flags to turn off optimization? - Cucumber Mellon U.
none that I am aware of - Robert Crovella

1 Answers

1
votes

how do I prevent cuda-gdb from optimizing out any value

The cuda-gdb is not optimizing anything; it is just interpreting the debug info that the compiler (nvcc) put into the binary.

If the compiler chose not to describe location of some variable, then there is nothing cuda-gdb can do to recover that info. This would generally be a quality of debugging info issue with nvcc.

It's possible that nvcc did describe the location you are after, but cuda-gdb is failing to handle that description, in which case it's a bug in cuda-gdb.

In either case, you can't really do anything about it, other than complaining to NVidia.