CLCREATEPROGRAMWITHB(3clc)
π NAME π
clCreateProgramWithBinary β bestie, this is the OpenCL call that makes a program object for a context and loads the binary bits you hand it, specified by binary, straight into that program object. no source code, no compiling from scratch, just vibes and prebuilt bytes. π¦
This page lives in the OpenCL Manual, section 3clc. Pull up a chair, we're getting into it.
β¨ SYNOPSIS β¨
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);
πΈ PARAMETERS πΈ
contextβ has to be a valid OpenCL context, like actually valid, no fake ones. πdevice_listβ a pointer to a list of devices that are incontext.device_listmust be a non-NULL value. The binaries get loaded for the devices in this list, that's the whole point.num_devicesβ the number of devices listed indevice_list.
The devices associated with the program object will be the list of devices specified by device_list. And the list of devices specified by device_list must be devices associated with context. like, they have to actually belong there. π«Ά
lengthsβ an array of the size in bytes of the program binaries to be loaded, for the devices specified bydevice_list.binariesβ an array of pointers to program binaries to be loaded, for the devices specified bydevice_list. For each device given bydevice_list[i], the pointer to the program binary for that device is given bybinaries[i], and the length of this corresponding binary is given bylengths[i].lengths[i]cannot be zero andbinaries[i]cannot be aNULLpointer. periodt.
The program binaries specified by binaries contain the bits that describe one of the following:
- a program executable to be run on the device(s) associated with
context. - a compiled program for device(s) associated with
context. - a library of compiled programs for device(s) associated with
context.
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. it's giving β¨flexibleβ¨.
binary_statusβ returns whether the program binary for each device specified indevice_listwas loaded successfully or not. It's an array ofnum_devicesentries, and it returnsCL_SUCCESSinbinary_status[i]ifbinarywas successfully loaded for the device specified bydevice_list[i]. Otherwise it returnsCL_INVALID_VALUEiflengths[i]is zero or ifbinaries[i]is aNULLvalue, orCL_INVALID_BINARYinbinary_status[i]if the program binary is not a valid binary for the specified device. Ifbinary_statusisNULL, it is ignored. (it's fine, it's just not paying attention π)errcode_retβ returns an appropriate error code. Iferrcode_retisNULL, no error code is returned.
π NOTES π
OpenCL allows applications to create a program object using the program source or binary and build appropriate program executables. And bestie, this is so useful β it lets applications load program source and then compile and link to generate a program executable online on its first instance, for the appropriate OpenCL devices in the system. Those executables can now be queried and cached by the application. So 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. speed. it ate. π₯
π ERRORS π
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_CONTEXTifcontextis not a valid context.CL_INVALID_VALUEifdevice_listisNULLornum_devicesis zero;CL_INVALID_DEVICEif OpenCL devices listed indevice_listare not in the list of devices associated withcontext.CL_INVALID_VALUEif or iflengthsorbinariesareNULLor if any entry inlengths[i]orbinaries[i]isNULL.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.
π SPECIFICATION π
OpenCL Specification[1]
π¦ SEE ALSO π¦
clCreateProgramWithSource(3clc), clReleaseProgram(3clc), clRetainProgram(3clc), classDiagram(3clc)
π AUTHORS π
The Khronos Group
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES π
- OpenCL Specification page 133, section 5.6.1 - Creating Program Objects
okay that's the whole page, bestie, you're officially certified in loading program binaries. slay π β¨
this was brought to you by The Khronos Group, dated 01/14/2021, from the CLCREATEPROGRAMWITHB(3clc) page. mwah. π«Άπ
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms