Creates a program object for a context, and loads the binary bits specified by
binary into the program object.
cl_program clCreateProgramWithBinary(cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_int *errcode_ret)
Must be a valid OpenCL context.
A pointer to a list of devices that are in
device_listmust be a non-NULL value. The binaries are loaded for devices specified in this list.
The number of devices listed in
The devices associated with the program object will be the list of devices specified by
device_list. The list of devices specified by
device_listmust be devices associated with
An array of the size in bytes of the program binaries to be loaded for devices specified by
An array of pointers to program binaries to be loaded for devices specified by
device_list. For each device given by
device_list[i], the pointer to the program binary for that device is given by
binaries[i] and the length of this corresponding binary is given by
lengths[i] cannot be zero and
binaries[i] cannot be a NULL pointer.
The program binaries specified by
binariescontain the bits that describe one of the following:
a program executable to be run on the device(s) associated with
a compiled program for device(s) associated with
a library of compiled programs for device(s) associated with
The program binary can consist of either or both of device-specific code and/or implementation-specific intermediate representation (IR) which will be converted to the device-specific code.
Returns whether the program binary for each device specified in
device_listwas loaded successfully or not. It is an array of
num_devicesentries and returns
binary_status[i] if binary was successfully loaded for device specified by
device_list[i]; otherwise returns
lengths[i] is zero or if
binaries[i] is a NULL value or
binary_status[i] if program binary is not a valid binary for the specified device. If
binary_statusis NULL, it is ignored.
Returns an appropriate error code. If
errcode_retis NULL, no error code is returned.
OpenCL allows applications to create a program object using the program source or binary and build appropriate program executables. This can be very useful as it allows applications to load program source and then compile and link to generate a program executable online on its first instance for appropriate OpenCL devices in the system. These executables can now be queried and cached by the application. Future instances of the application launching will no longer need to compile and link the program executables. The cached executables can be read and loaded by the application, which can help significantly reduce the application initialization time.
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
contextis not a valid context.
device_listis NULL or
CL_INVALID_DEVICEif OpenCL devices listed in
device_listare not in the list of devices associated with
CL_INVALID_VALUEif or if
binariesare NULL or if any entry in
binaries[i] is NULL.
CL_INVALID_BINARYif an invalid program binary was encountered for any device.
binary_statuswill return specific status for each device.
CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.
CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.