0

I have a problem to debug a cuda kernal. However, the breakpoints in kernal function are never hitted. I tried to delete this project and re-generate using CMake, but it still not work. The kernal code is as follows:

__global__ void testKernel(int val)
{
    printf("[%d, %d]:\t\tValue is:%d\n", \
        blockIdx.y*gridDim.x + blockIdx.x, \
        threadIdx.z*blockDim.x*blockDim.y + threadIdx.y*blockDim.x + threadIdx.x, \
        val);
}

I think the problem is not related with kernal code but with configurations of this project. Because this kernal can be debugged in CUDA Samples projects.

I use Debug->Windows->Modules and find that my target .lib is not loaded. When I select CUDA Thread, the Break Mode shows:

You app has entered a break state, but no code is currently executing that is supported by the selected debug engine (e.g. onley native runtime code is executing).

  • Is this in a .dll? It's possible that the program has not loaded the dll yet - that would result in this error. If so, see [this post](https://stackoverflow.com/questions/2155930/how-do-i-remedy-the-the-breakpoint-will-not-currently-be-hit-no-symbols-have-b). Also, it's possible your source code is out-of-date with the compiled code. Try recompiling, perhaps – alteredinstance Jan 09 '20 at 15:54
  • Sometimes the compiler optimises out what it considers redundant code. So placing a break point there probably won't be hit. This happens when a function is inlined at runtime. – Irelia Jan 09 '20 at 16:03
  • @alteredinstance It's a .lib. I've tried the solution according to [this post](https://stackoverflow.com/questions/2155930/how-do-i-remedy-the-the-breakpoint-will-not-currently-be-hit-no-symbols-have-b?page=1&tab=oldest#tab-top), the .lib is not loaded because it's generated by `nvcc` complier. The problem still exist even though I deleted this project and used cmake to re-generate this project. – Rick Vencent Jan 10 '20 at 02:17

1 Answers1

1

It is because the -g is missing when compile .cu file using nvcc compiler. The original CUDA_NVCC_FLAGS in CMakelists.txt is:

SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-gencode arch=compute_75,code=sm_75;)

After correction:

SET(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -g; -G; -gencode arch=compute_75,code=sm_75;)

Now, we can use Nsight to debug the kernal function.