I’m using version 4.1 in Visual Studio 2013.
I have a fairly simple CUDA kernel with some loops and conditions. Nothing too fancy.
Yet, the value of some variables cannot always be displayed in the Watch/WarpWatch windows or ScreenTip.
I must note that when stepping through the code, the value of all variables is traceable
immediately after assignment, but it goes ‘out of scope’ at some point, probably due to some compiler optimization indicating the variable is not used from that point onward.
The workaround is simple: assigning the value to a temp variable at the end of the inspected code segment, tricking the compiler to thinking the value is still required,
but I imagine there is a more elegant way to approach this.
You are likely right in that the variables have been ‘optimized out’ at certain points. Once the variables no longer exist on the device it is impossible to read them. Presumably you are running a full Release build with optimizations turned on?
The cleanest way is probably to do your investigative work with a ‘Debug’ build (optimizations off, host AND device debug enabled). Then once you have ensured that it is working as intended, repeat a test with a Release build to ensure consistency between your Release and Debug builds. Note that a Debug build of device code adds extra hidden lines of code and will run significantly slower than a Release build.
i have had mixed results tracing local variables, regardless of the build, and even with later cuda versions such as 6/ 6.5
the cleanest debugging for me is normally to dump to shared memory, particularly around a hot spot; shared memory is guaranteed ito debugging in my experience
I am using Debug build. Verified that ‘CUDA C/C++/Host’ optimization is turned off.
Not sure how to configure such optimization flag on the device.
Both Host/Device have debug information enabled.