OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1720 Discussions

breakpoints in cl files #included by a another cl file are not hit



my main cl file does not have any kernels, but instead #includes other cl files. This works just fine, except that the debugger will not hit the breakpoints in the #included file. It seems they will only be hit if they are in the top-level cl file, i.e. the file that I provided to clBuildWithSource and as "-s" value to clBuildProgram's build options.

Stepping into a function that resides in a #included file works fine, but in my case the top-level cl file does not have a kernel to begin with. Can you think of a workaround?


0 Kudos
2 Replies
Hi, Yes, I was able to reproduce such behavior. Now I tend to think that this is design limitation, but I will try to analyze it further and I will submit either a bug or feature request. Regarding the workaround. I think you already mentioned it - since the 'step into' works fine, create a kernel function at the top level file and call the one from included file. Thanks, Yuri
0 Kudos


thanks for looking into this.
The reason I stumbled accross this limitation is that I ported CUDA code to OpenCL.
In contrast to OpenCL, CUDA supports template functions.
I am guessing I am not the only one facing this task, so let me make my case:

There is design pattern on how to emulate templates in C, as described here:

For a single templated kernel function, you end up with three files:

//DST and SRC are template parameters, i.e. DST = float, SRC = int
#define someKrnl(DST, SRC) someKrnl_##DST##_##SRC  // becomes someKrnl_float_int
#include "somekrnl.h"
//invoke macro. Compiling by itself only works if DST and SRC are defined with -D, e.g. "-D DST=float -D SRC=int"
__kernel void someKrnl(DST, SRC)(__global DST* dst,  __global DST* src){
// instantiate template with DST=float and SRC=int
#define DST float
#define SRC int
#include "" // produces kernel someKrnl_float_int
#undef DST
#undef SRC

// instantiate template with DST=float2 and SRC=int2
#define DST float2
#define SRC int2
#include "" // produces kernel someKrnl_float2_int2
#undef DST
#undef SRC

The file that I would compile with the offline-compiler or pass to clCreateProgram is Now it would be great if I could also add "-g -s" to the build options and still be able to put my breakpoints into the template kernel.
However, since that's not possible I have to explicitely compile the * file for each template instantiation and define all template parameters with -D. It's doable, but a lot more complicated.


0 Kudos