Question

I went through some tutorials to optimize kernal invocation using binary files. I refered the link below,

http://www.fixstars.com/en/opencl/book/OpenCLProgrammingBook/online-offline-compilation/

There it is mentioned that if we use binary files , we don't have to build the created program. I tried that. But it doesn't work as it mentions. When I insert "clBuildProgram(program, 0, NULL, NULL, NULL, NULL)" after the line of creating program from binary files, the program works.

I also went through other references also. Some of them mention we have to insert the "build" line there. I also went through all related questions in this site. But i couldn't get any clear idea about this.

I feel if we really avoid the "build" part, we can reduce the time taken to execution.

If we have to use the "build" part, then my other question is what is the benifit of using binary instead of source.

Thanks in advance.

Was it helpful?

Solution

The specification is your friend. https://www.khronos.org/registry/cl/specs/opencl-1.2.pdf

. clBuildProgram must be called for program created using either clCreateProgramWithSource or clCreateProgramWithBinary to build the program executable for one or more devices associated with program.

So it's explicitly said that you must call the buildprogram even if you are using binary programs.

In most cases the buildprogram is faster for binaryprograms than what they are for text programs. So there is marginal speed benefit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top