5

I am using visual studio 2010, parallel nsight 2.2 and cuda 4.2 for learning. My system is Windows 8 pro x64. I opened the radix sort project which included by cuda computing SDK in VS, and compiled it with no error. The sort code uses thrust library:

if(keysOnly)
    thrust::sort(d_keys.begin(), d_keys.end());
else 
    thrust::sort_by_key(d_keys.begin(), d_keys.end(), d_values.begin());

I want to know how thrust dispatch the sort function to cuda kernels, so I tried to add breakpoints in front of lines above and compiled the project in debug mode. But when I use parallel nsight for cuda debugging, there are always errors that "no source correspondence for breakpoint".

So, my problems are:

  1. How to debug cuda thrust programs in visual studio with parallel nsight?
  2. Or is there anyone can instruct me using another way to know how cuda thrust dipatch functions to cuda kernels or other functions?

Any advise will be appreciated!

Miles Xu
  • 51
  • 1
  • 4

1 Answers1

2

Normally, to debug device code in CUDA, it's necessary to pass the:

-G -g

switches to nvcc. However this modality is not supported with thrust code. You can get an idea of how thrust code gets dispatched to the device by following the structure in the thrust include files. Since thrust is entirely templatized code, there are no libraries to worry about. However that's a challenging proposition. You can also tell the compiler to generate ptx:

-ptx

which is one of the intermediate code types that cuda code gets compiled to. However that is not a trivial thing to parse either. This link gives some alternate ideas for debugging with Thrust.

Robert Crovella
  • 120,849
  • 8
  • 160
  • 206
  • Thank you Robert, I've read the thrust wiki on debugging already. But I think its contents are not very usable to my problems. I just want to know the details of decision processes in thrust library. So I was trying to read the source code and may also try to read ptx code. Thank you! – Miles Xu Nov 17 '12 at 00:47