简体   繁体   English

如何在混合cuda C ++程序中调试主机代码?

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

My work platforms are VS2010 and Nsight 3.1. 我的工作平台是VS2010和Nsight 3.1。

With Nsight, breakpoints can be set in cuda kernel and the debugger works well. 使用Nsight,可以在cuda内核中设置断点,并且调试器运行良好。 If the breakpoints are set in host code, Nsight just ignores them. 如果断点在主机代码中设置,则Nsight只会忽略它们。

I don't know if it is possible to set breakpoints in host code and use the debugger provided by VS2010. 我不知道是否可以在主机代码中设置断点并使用VS2010提供的调试器。 I tried, but the program stops when it meets the first cudaMalloc function. 我试过了,但程序在遇到第一个cudaMalloc函数时停止了。 Could someone please tell me how to debug host code in a mixed cuda and c++ program? 有人可以告诉我如何在混合cuda和c ++程序中调试主机代码吗?

Thanks a lot. 非常感谢。

I'm afraid you could not debug both CUDA and c++ program in on VS. 我担心你无法在VS上调试CUDA和c ++程序。 Here is a workaround. 这是一个解决方法。 Hope it could help you 希望它可以帮到你

  1. Launch a Windows command line. 启动Windows命令行。 Set NSIGHT_CUDA_DEBUGGER=1 设置NSIGHT_CUDA_DEBUGGER = 1
  2. In this command line, execute your CUDA application (Here I suppose it's a long-term execution). 在此命令行中,执行您的CUDA应用程序(这里我认为这是一个长期执行)。
  3. Open a VS. 打开VS. Tools menu ->Attach to Process. 工具菜单 - >附加到流程。 Choose transport as Nsight CPU Debugger and attach to your application. 选择传输为Nsight CPU Debugger并附加到您的应用程序。 Then you could debug CUDA code 然后你可以调试CUDA代码
  4. Open another VS. 打开另一个VS. Choose transport as Default. 选择transport作为Default。 Attach to the application then you could debug C++ code 附加到应用程序然后您可以调试C ++代码
  5. Please pay attention, if the application is suspended by a VS, it could not be debugged by the other VS. 请注意,如果应用程序被VS暂停,则其他VS无法调试。 You must resume current one and then switch to the other. 您必须恢复当前的一个,然后切换到另一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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