cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

shawnccx
Journeyman III

how to include headers into opencl kernels

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

0 Likes
2 Replies
himanshu_gautam
Grandmaster

0 Likes

Hmm. I thought I'd locked the duplicate. Let's try that again.

0 Likes