Header files for Kernels

Hi again,

I’m still sitting on my abstraction layer and got the next problem with the kernelsources. My problem:


#include "inc.h"

__kernel foo(int arg)
{
  bar(arg); //contained in inc.h
}

I nearly found a solution for all the sourcecodes (hiding them in a Database, containing binaries in the future maybe) but this will not help in case of kernel files with includes.

Does anyone know a way how to solve the inclusion problem when you don’t want to have a file on your disk?
I haven’t seen a method like “clAddIncludeFromSource()”. So the only way is to forbid includes with all of their problem (code dublication, etc) or scan for includes in the source an manually add all of the included source into the file. But in that solution, you would have all methods from a header in your kernel, not only the ones you are using.

Thanks in advance,
clint3112

Probably the best solution would be to run the pre-processor cpp (assuming you are running some UNIXy OS) yourself somewhere in your build process. This will include the definitions and get rid of the include statement.

First problem, its on windows.
But is there an openCL preprocessor available?

A pre-processor is nothing magical but just replacing text strings by other text strings that you #defined before doing any actual compilation. Moreover, OpenCL C is an extended version of C99, therefore you could easily re-use any C pre-processor.

so, the compiler will delete the unused functions from the header files? then, a simple copy would be enough.

An what you advice would be a prebuild step. My code is in a db that is queried at runtime. So calling an external program wouldnt be the best idea i think