2

I am getting a very frustrating error where a variable in my code does "not have a value". Here is a picture of my code with the debugger information at the bottom.

My original code only has the red squares, but I added in the blue square "Xmax = 40" just to see if i could force a value into the variable. Obviously you can see there is still a problem. Any insight into why I am getting this error?

enter image description here

Shawn Tabrizi
  • 12,206
  • 1
  • 38
  • 69
  • If you want to work around the life range optimization of the compiler, you can _read_ the variable the end of your kernel (in a way that cannot be optimized away by the compiler, e.g. modifying a global variable) instead of _writing_ to it. – tera Dec 16 '12 at 10:35

1 Answers1

4

The problem that you are experiencing is very likely due to the live range of the variable. Most compilers when compiling code for debugging extend the live range of variables to be equal to the scope of the variables.

The NVCC compiler does not extend the live range of the variables. Furthermore, NVCC compiler performs some optimizations even when optimizations flags are not specified. This can lead to elimination of user specified variables. Extending the live range of the variables is one of the top items on the CUDA debugger feature request list but I cannot tell you in what release this issue will be resolved.

I recommend that you submit a bug on the issue through the CUDA Registered Developer Program.

Greg Smith
  • 11,007
  • 2
  • 36
  • 37