Hi all,
I’m a bit confused about all what I read on the program pre-compilation.
Everytime, there is just a part of the code but almost never all the example code.
I’ve seen 3 examples, maybe not complete.
Version 1
a. Use clCreateProgramWithSource and clBuildProgram to compile a program for which the sources are contained into a char*.
b. Use clGetProgramInfo with the option CL_PROGRAM_BINARY_SIZES to generate a string (char*) which contains the program compiled (binary).
c. Keep the string as a variable.
d. Later on, create and compile a new program from the binary (variable in c.) using clCreateProgramWithBinary and clBuildProgram.
Version 2
a. Use clCreateProgramWithSource and clBuildProgram to compile a program for which the sources are contained into a char*.
b. Use clGetProgramInfo with the option CL_PROGRAM_BINARY_SIZES to generate a string (char*) which contains the program compiled (binary).
c. Write the string in an output file.
d. Later on, read the previously generated file and store it into a char*.
e. Create and compile a new program from the binary (char*) using clCreateProgramWithBinary and clBuildProgram.
Version 3
a. Write the kernel into a .cl file.
b. Use XCode to automatically compile the .cl file into a binary file.
c. Later on, create and compile a new program from the binary file using clCreateProgramWithBinary and clBuildProgram.
For the version 3, I guess what I miss is that the compile program is simply read from the binary file and stored into a char *, as for the version 2.
Except their obvious differences, is there any better or worse solution?
Are the versions 1 and 2 similar? It seems that yes and I don’t understand why we should use an external file. I guess that the openCL programs could be compiled the first time the program (main program) is used, and then are never compiled again. But I can’t be sure.
Thanks for your reactions on the subject.
Regards,
Vincent