|Home > OpenCL 2.1 > IL programs|
The Intermediate Language (IL) is partly compiled code and enables developers to distribute OpenCL kernel code without distributing the CL source code. IL code is also portable between different OpenCL platforms.
IL code uses the SPIR-V format to store the intermediate form where the compiler has parsed the code and produced a form of "virtual machine code". This "virtual machine code" can be further processed to make real machine code for a specific platform.
To compile the SPIR-V, use a general purpose OpenCL to SPIR-V compiler.
The compiled SPIR-V is stored as a binary file or an array of bytes in the OpenCL
application code to pass to the
Compiling OpenCL to SPIR-V can be done in two ways, either using
clang -Xclang -finclude-default-header -cl-std=CL2.0 --target=spir-unknown-unknown -emit-llvm -c -O0 -o <file.bc> <file.cl> llvm-spirv -o <file.spv> <file.bc>
Or for customers with access to the
mali_clcc offline compiler, by using
mali_clcc -emit=spir-v file.cl
Optionally, use -b32 or -b64 to specify a 32-bit or 64-bit version of the code. Set the -b32 or -b64 option to the same as the OpenCL application code, so a 32-bit application uses 32-bit OpenCL code.
llvm-spirvare available from https://github.com/KhronosGroup/SPIRV-LLVM-Translator.