C Specification

To creates a program object for a context and load code in an intermediate language into that object, call the function

cl_program clCreateProgramWithIL(
    cl_context context,
    const void* il,
    size_t length,
    cl_int* errcode_ret);


  • context must be a valid OpenCL context.

  • il is a pointer to a length-byte block of memory containing SPIR-V or an implementation-defined intermediate language.

  • errcode_ret will return an appropriate error code. If errcode_ret is NULL, no error code is returned.


The IL pointed to by il and with length in bytes length will be loaded into the program object. The devices associated with the program object are the devices associated with context.

clCreateProgramWithIL returns a valid non-zero program object and errcode_ret is set to CL_​SUCCESS if the program object is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:

  • CL_​INVALID_​CONTEXT if context is not a valid context.

  • CL_​INVALID_​VALUE if il is NULL or if length is zero.

  • CL_​INVALID_​VALUE if the length-byte memory pointed to by il does not contain well-formed intermediate language input that can be consumed by the OpenCL runtime.

  • CL_​OUT_​OF_​RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_​OUT_​OF_​HOST_​MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

See Also

Document Notes

For more information, see the OpenCL Specification

This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.