user1200759
user1200759

Reputation: 101

Can OpenCL build program from .cl source code together with a pre-built binary kernel?

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?

Upvotes: 1

Views: 274

Answers (2)

Jan-Gerd
Jan-Gerd

Reputation: 1289

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.

Upvotes: 2

Boris Ivanov
Boris Ivanov

Reputation: 4254

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:

  1. Simple way: blocking run of kernel A after finishing start from host kernel B.

  2. Complicated way: using clEnqueueMarkerWithWaitList, clEnqueueBarrierWithWaitList, clEnqueueMarker, clEnqueueWaitLIst, clWaitForEvents, clCreateUserEventclEnqueueBarrier

  3. Pipes. You can use pipes for it. clCreatePipe I never tried. (OpenCL 2.0)

Upvotes: 1

Related Questions