PDA

View Full Version : Header files for Kernels



clint3112
02-01-2013, 01:06 AM
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

matthiasv
02-01-2013, 01:56 AM
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.

clint3112
02-01-2013, 03:31 AM
First problem, its on windows.
But is there an openCL preprocessor available?

matthiasv
02-01-2013, 03:36 AM
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.

clint3112
02-01-2013, 04:27 AM
so, the compiler will delete the unused functions from the header files? then, a simple copy would be enough.

clint3112
02-01-2013, 04:33 AM
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