Conditional Breakpoints on Work Items
Setting Conditional Breakpoints
- Place a breakpoint at a work item on dimension zero with global ID value equal to two:(gdb) break kernel.cl:3 if (__ocl_dbg_gid0 == 2)
- Answer yes (y) when you see the following message, because at this moment, a kernel code does not exist, and it will be generated only after you run an application:Make breakpoint pending on future shared library load? (y or [n]) yExpected output for this example:Breakpoint 3 (kernel.cl:3 if (__ocl_dbg_gid0 == 2)) pending.
- Run the application:(gdb) runIf the application successfully stopped on the breakpoint, you will see the following message with a status of the application and a line where the breakpoint was placed:[Switching to Thread 0x7fffcffff700 (LWP 26115)] Thread 20 "host_program" hit Breakpoint 1, main_kernel (buf_in=0x1834280 "", buf_out=0x186c880 "") at kernel.cl:3 3 size_t workdim = get_work_dim();
- You can use the__ocl_dbg_gid0variable to identify a global ID for a specified NDRange dimension. To print the global ID, use the following command:(gdb) print __ocl_dbg_gid0Expected output for this example:$0 = 2