Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCL, include files

Following the post , if I have header file,which has some functions implementations in it and should be included in several kernels(I mean these function are auxilary in all kernels and I don`t want to duplicate the code)

How I make this inclusion - can I keep the functions in header?Will the kernels and the header functions be compiled?

Can you specify (maybe by example) how I use the "-I" option in these case? I am using VS2010(if its matter at all)

Note:Each kernel runs in different program

like image 776
Yakov Avatar asked Jul 26 '11 14:07

Yakov


1 Answers

Yes, you can use headers in OpenCL for exactly what you are suggesting. Each kernel file will include the header and compile it.

The "-I" option is only used to specify the path for includes. If your includes are in your working directory it is not necessary. Here is an example:

/////////////////////////////////////////////////////////////////
// Load CL file, build CL program object, create CL kernel object
/////////////////////////////////////////////////////////////////
std::string  sourceStr = FileToString(params.kernelFile);

cl::Program::Sources sources(1, std::make_pair(sourceStr.c_str(), sourceStr.length()));
cl::Program program = cl::Program(oclHandles.context, sources);

program.build(oclHandles.devices,"-I c:/Includes/");
like image 184
Nigel Avatar answered Sep 28 '22 19:09

Nigel