Using cuda-gdb

I would like to use cuda-gdb for debugging, but as you can see the device and kernel information are not available although I have set a breakpoint at the kernel.


$ cuda-gdb --args vec_add 1 128
...
Reading symbols from vec_add...
(cuda-gdb) list increment
12	  std::cout << "\n";
13	}
14	
15	
16	__global__ void increment( int *a, int N )
17	{
18	  int i = threadIdx.x;
19	  if ( i < N )
20	    a[ i ] = a[ i ] + 1;
21	}
(cuda-gdb) break increment
Breakpoint 1 at 0xb498: file vec_add.cu, line 17.
(cuda-gdb) info cuda devices
No CUDA devices.
(cuda-gdb) info cuda kernels
No CUDA kernels.
(cuda-gdb)

Any idea about that? nvidia-smi command works fine, so the device is working properly.

I suggest asking cuda-gdb questions on the cuda-gdb forum.

Moved…

It appears that while you’ve set the breakpoint, you haven’t started the program, so CUDA isn’t yet initialized. Can you:

  • set the breakpoint
  • run to the breakpoint
  • retry the CUDA commands

Please let us know if you’re still encountering issues after following the above steps.

Right. Thank you very much.

@steveu May I ask one more question?
As you can see below, I set a breakpoint at the kernel name and the instructions following the pc are like this:

(cuda-gdb) list increment
12	  std::cout << "\n";
13	}
14	
15	
16	__global__ void increment( int *a, int N )
17	{
18	  int i = threadIdx.x;
19	  if ( i < N )
20	    a[ i ] = a[ i ] + 1;
21	}
(cuda-gdb) break increment
Breakpoint 1 at 0xb498: file vec_add.cu, line 17.
(cuda-gdb) r
...
Thread 1 "vec_add" hit Breakpoint 1, increment<<<(1,1,1),(1024,1,1)>>> (a=0x7fffd7a00000, N=1024) at vec_add.cu:18
18	  int i = threadIdx.x;
cuda-gdb) x/10i $pc
=> 0x555555b3abf0 <_Z9incrementPii+240>:	S2R R3, SR_TID.X 
   0x555555b3ac00 <_Z9incrementPii+256>:	MOV R3, R3 
   0x555555b3ac10 <_Z9incrementPii+272>:	MOV R3, R3 
   0x555555b3ac20 <_Z9incrementPii+288>:	MOV R3, R3 
   0x555555b3ac30 <_Z9incrementPii+304>:	ISETP.LT.AND P0, PT, R3, R4, PT 
...

However, using cuobjdump, shows that there are more instructions before S2R.

		Function : _Z9incrementPii
	.headerflags    @"EF_CUDA_SM86 EF_CUDA_PTX_SM(EF_CUDA_SM86)"
        /*0000*/                   MOV R1, c[0x0][0x28] ;                    /* 0x00000a0000017a02 */
                                                                             /* 0x003fde0000000f00 */
        /*0010*/                   MOV R8, c[0x0][0x118] ;                   /* 0x0000460000087a02 */
                                                                             /* 0x003fde0000000f00 */
        /*0020*/                   MOV R9, c[0x0][0x11c] ;                   /* 0x0000470000097a02 */
                                                                             /* 0x003fde0000000f00 */
        /*0030*/                   MOV R2, 0x160 ;                           /* 0x0000016000027802 */
                                                                             /* 0x003fde0000000f00 */
        /*0040*/                   LDC.64 R2, c[0x0][R2] ;                   /* 0x0000000002027b82 */
                                                                             /* 0x00321e0000000a00 */
        /*0050*/                   MOV R0, R2 ;                              /* 0x0000000200007202 */
                                                                             /* 0x003fde0000000f00 */
        /*0060*/                   MOV R4, R3 ;                              /* 0x0000000300047202 */
                                                                             /* 0x003fde0000000f00 */
        /*0070*/                   MOV R2, R0 ;                              /* 0x0000000000027202 */
                                                                             /* 0x003fde0000000f00 */
        /*0080*/                   MOV R4, R4 ;                              /* 0x0000000400047202 */
                                                                             /* 0x003fde0000000f00 */
        /*0090*/                   MOV R0, 0x168 ;                           /* 0x0000016800007802 */
                                                                             /* 0x003fde0000000f00 */
        /*00a0*/                   LDC R0, c[0x0][R0] ;                      /* 0x0000000000007b82 */
                                                                             /* 0x00321e0000000800 */
        /*00b0*/                   MOV R3, R0 ;                              /* 0x0000000000037202 */
                                                                             /* 0x003fde0000000f00 */
        /*00c0*/                   MOV R2, R2 ;                              /* 0x0000000200027202 */
                                                                             /* 0x003fde0000000f00 */
        /*00d0*/                   MOV R0, R4 ;                              /* 0x0000000400007202 */
                                                                             /* 0x003fde0000000f00 */
        /*00e0*/                   MOV R4, R3 ;                              /* 0x0000000300047202 */
                                                                             /* 0x003fde0000000f00 */
        /*00f0*/                   S2R R3, SR_TID.X ;                        /* 0x0000000000037919 */
                                                                             /* 0x00321e0000002100 */
        /*0100*/                   MOV R3, R3 ;                              /* 0x0000000300037202 */

So, I want to know what happened to those instructions. Are they executed so far?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.