offline compilation ?

Hi everybody,
I am currently working on a program using OpenCL (I have previously worked a bit with CUDA), and in all examples included in Nvidia SDK, all kernels are compiled online (during execution).
With CUDA, I work with nvcc and Makefiles for compiling kernels, and I want to know if there is a way to do the same with OpenCL ? Is there already an OpenCL compiler ? How can I compile them offline ?

Thanks in adavance for your replies.

you can compile offline by calling the builtin compiler and store the binaries.
(compilation makes it necessary to specify the graphic card for which you want to create the binaries).

afaik the spec doesnt give any details about an executable of the compiler without using the opencl implementation.

Thanks for your reply :slight_smile:
But i didn’t undestand what you call “builtin compiler”, do you mean clBuildProgram function ?
I haven’t see any binary usable for doing that in SDK…

please have a look at the function clGetProgramInfo with the parameter CL_PROGRAM_BINARIES.

just use your program as usual, read out the kernel binaries after compilation (clBuildProgram) using the above function and store it to a file.
next time you start your program you dont have to compile the kernel again. instead you can use the compiled kernel which you previously stored to the file.

this is what i meant with the builtin compiler cz. the binaries can just be generated with detailed information about your graphic card.

Perfect ! Thanks for your reply, it’s exactly what I want :slight_smile:


but if I want to invoke directly the OpenCL compiler to compile a kernel code, under CUDA toolkit for example, how can I do?