shawnccx

how to include headers into opencl kernels

Discussion created by shawnccx on Apr 18, 2013
Latest reply on Apr 22, 2013 by LeeHowes

Hi, all,

 

I need to include some .h files into .cl OpenCL kernels but I haven't found a way to solve it.

 

My problem is described as follows:

1.

(1) a kernel in example.cl file:

 

__kernel void example_kernel(length m, length n){

    ....

}

 

(2) type length is defined in test_header.h (in the same directory of all the other files)

 

typedef int length;

 

(3) According to OpenCL Spec, adding -I when building program

 

ciErrNum = clBuildProgram(cpProgram, 0, NULL, "-I ./", NULL, NULL);

 

But this doesn't work, the program got crashed at this line, the log of building program showed:

 

"/tmp/OCLkQF3NK.cl", line 2: error: overloaded function "length" is not a type

          name

  __kernel void example_kernel(length m, length n)

                             ^

 

"/tmp/OCLkQF3NK.cl", line 2: error: overloaded function "length" is not a type

          name

  __kernel void example_kernel(length m, length n)

                                       ^

 

2 errors detected in the compilation of "/tmp/OCLkQF3NK.cl".

 

Internal error: clc compiler invocation failed.

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Previously  I just redefined types and functions as Macros in the kernels to avoid including headers.

 

But now, too many functions from the headers are needed, so I need to find a way to import the headers for kernel.

 

Does anyone have any idea about what could be the problem?

I really need help with this.

 

Thanks,

 

Shawn

Outcomes