My program has several kernels. I'd like to use offline compiler to compile one kernel into binary. So how can I build my program using other kernels and that one pre-built kernel binary?
2 Answers
You should be able to compile your other kernels using clCreateProgramWithSource and clCompileProgram and load your pre-built kernel with clCreateProgramWithBinary. Then you can link these programs using clLinkProgram to link both of the programs into one new program containing all kernels.
Comments
AFAIK it is not possible or very complicated.
Kernels suppose to be small and modular. Composite kernels is bad practice.
What u can try is Enqueue kernels built from source together with kernels loaded as binary(with/out CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE f.e, with/out blocking or not flag). This way they will run in parallel.
What is left interkernel communication. You can try following:
Simple way: blocking run of kernel A after finishing start from host kernel B.
Complicated way: using
clEnqueueMarkerWithWaitList, clEnqueueBarrierWithWaitList, clEnqueueMarker, clEnqueueWaitLIst, clWaitForEvents, clCreateUserEventclEnqueueBarrierPipes. You can use pipes for it. clCreatePipe I never tried. (OpenCL 2.0)