简体   繁体   中英

How to debug host code in mixed cuda C++ program?

My work platforms are VS2010 and Nsight 3.1.

With Nsight, breakpoints can be set in cuda kernel and the debugger works well. If the breakpoints are set in host code, Nsight just ignores them.

I don't know if it is possible to set breakpoints in host code and use the debugger provided by VS2010. I tried, but the program stops when it meets the first cudaMalloc function. Could someone please tell me how to debug host code in a mixed cuda and c++ program?

Thanks a lot.

I'm afraid you could not debug both CUDA and c++ program in on VS. Here is a workaround. Hope it could help you

  1. Launch a Windows command line. Set NSIGHT_CUDA_DEBUGGER=1
  2. In this command line, execute your CUDA application (Here I suppose it's a long-term execution).
  3. Open a VS. Tools menu ->Attach to Process. Choose transport as Nsight CPU Debugger and attach to your application. Then you could debug CUDA code
  4. Open another VS. Choose transport as Default. Attach to the application then you could debug C++ code
  5. Please pay attention, if the application is suspended by a VS, it could not be debugged by the other VS. You must resume current one and then switch to the other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM