PDA

View Full Version : How to add header?



dave88
04-19-2010, 09:06 AM
I have a Struct named AES_KEY defined in OpenCL_AES_wrapper.h i use:
cl_program program=clCreateProgramWithSource(context,1,&source,NULL,NULL);
source is:
source="__kernel void encrypt_constant(__global const AES_KEY *key,__global const unsigned int *ivec,unsigned int loop_count,__global unsigned int *device_output)\n"
how to include my header file for recognized the struct type?
thanks in advance.

ibbles
04-19-2010, 12:06 PM
There a basically two ways.



char* sources[2];
sources[0] = readFile("OpenCL_AES_wrapper.h"); // Use whatever you use now to read files
sources[1] = source;
...WithSource(context, 2, sources, ...


and the second is to use build options. See specification 5.4.2 and 5.4.3. In particular 5.4.3.1 (-I) dir.

dave88
04-19-2010, 01:05 PM
the second way is for example:
const char*opt="-I .\my header directory"
sources[0] = "OpenCL_AES_wrapper.h";
sources[1] = source;
with clCreateProgram(context,2,sources
and clBuildProgram (...,opt
or i have to use only
const char*opt="-I .\my header directory"
with clBuildProgram (...,
opt,...);
?

matrem
04-19-2010, 02:50 PM
You can use #include directive in opencl sources.

dave88
04-20-2010, 05:53 AM
thanks i have resolve it with:
const char *options="-I ./lib";//if i don't use it make error
cl_program program=clCreateProgramWithSource(context,1,&source,NULL,NULL);
and

source="#include <aes.h>\n"
"__kernel void encrypt(__global const AES_KEY *key,__global const unsigned int *ivec,unsigned int loop_count,__global unsigned int *device_output)\n"...
this way work correctly
thanks for hint