I am using CUDA-GDB to explore a large CUDA project. I can discover the first CUDA kernel using the following command:
set cuda break_on_launch application
I can then step-debug through the kernel, and GDB's continue
will conveniently take me to the next kernel launch.
As explained here I can also disable these breaks, returning to the default behaviour:
set cuda break_on_launch none
I would like to exit the kernel, and return to the host code. The GDB finish
command doesn't help here, reporting:
(cuda-gdb) finish
"finish" not meaningful in the outermost frame.
Is it possible to exit a CUDA kernel and return to the subsequent line of host code?
I am using CUDA-GDB to explore a large CUDA project. I can discover the first CUDA kernel using the following command:
set cuda break_on_launch application
I can then step-debug through the kernel, and GDB's continue
will conveniently take me to the next kernel launch.
As explained here I can also disable these breaks, returning to the default behaviour:
set cuda break_on_launch none
I would like to exit the kernel, and return to the host code. The GDB finish
command doesn't help here, reporting:
(cuda-gdb) finish
"finish" not meaningful in the outermost frame.
Is it possible to exit a CUDA kernel and return to the subsequent line of host code?
It is possible to switch the focus to any host thread with the thread
command the same way you would do in the original GDB, as mentioned in the docs:
[...] the GDB command to display the host threads and switch to host thread 1 are, respectively:
(cuda-gdb) info threads (cuda-gdb) thread 1
As kernel launches are in general asynchronous, "subsequent line of host code" is not necessarily well defined. But you can set the environment variable CUDA_LAUNCH_BLOCKING
to 1
to get synchronous operation between CPU and GPU which should help exploration (and debugging).
cudaDeviceSynchronize()
call placed immediately after the kernel call. – Robert Crovella Commented Jan 9 at 2:54break_on_launch
as a way to find them, and especially find which ones are called. Once I know where they are, there isn't a problem. – user2023370 Commented Jan 9 at 9:43