开发者

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


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/");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜