cuda-gdb在__global__函数的另一行设置断点



问题

我在CUDA中有一个__global__函数,我想使用cuda-gdb调试它,但我不能在内核中设置断点,它指向另一行。这是我的代码

// include stuff
// ...
#define blockNUM 1
#define threadNUM 1
// ...
int main() {
// ... (define d_R_0, d_R_1, d_R_2, and d_H)
cudaSetDevice(0);
dim3 threadsPerBlock(threadNUM);
dim3 numBlocks(blockNUM);
decode<<<numBlocks,threadsPerBlock>>>(d_R_0, d_R_1, d_R_2, d_H);
// ... (other codes go here)
}
__global__ void decode(uint *d_R_0, uint *d_R_1, uint *d_R_2, uint *d_H) {
uint idx = (blockIdx.x * blockDim.x + threadIdx.x); // --> I want to set breakpoint here! (line 197) <--
// ... (implementation of the function)
} // --> But the cuda-gdb set the breakpoint here! (line 288) <--

这是cuda gdb

(cuda-gdb) break 197
Breakpoint 1 at 0xa7f6: file /home/matin/main.cu, line 288.

额外信息

我使用以下命令编译main.cu

$ nvcc -g -G main.cu

我对Nvidia网站上的第一个CUDA C程序片段也有同样的问题


规格:

  • GNU gdb(gdb)10.1
  • NVIDIA(R)CUDA调试器:11.5版本
  • CUDA版本:12.0
  • Ubuntu版本:22.04

在更新我的Nvidia驱动程序后,我遇到了同样的问题。我希望这个解决方案也适用于你。

您必须使用内核函数名设置断点。例如,对于第一个CUDA C程序,您应该遵循以下步骤:

  1. 使用内核函数名设置断点
(cuda-gdb) b saxpy
Breakpoint 1 at 0x338: file /home/nahid/temp/saxpy.cu, line 5.
  1. 运行以到达断点
(cuda-gdb) r
  1. 最后,将断点设置为所需的行
(cuda-gdb) b 7
Breakpoint 2 at 0xfffe3258e10: file saxpy.cu, line 7

最新更新