'\" t .\" Title: clLinkProgram .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 02/03/2019 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "CLLINKPROGRAM" "3clc" "02/03/2019" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" clLinkProgram \- Links a set of compiled program objects and libraries for all the devices or a specific device(s) in the OpenCL context and creates an executable\&. .SH "" .HP \w'cl_program\ clLinkProgram('u .BI "cl_program clLinkProgram(cl_context\ " "context" ", cl_uint\ " "num_devices" ", const\ cl_device_id\ *" "device_list" ", const\ char\ *" "options" ", cl_uint\ " "num_input_programs" ", const\ cl_program\ *" "input_programs" ", void\ " "(CL_CALLBACK\ *pfn_notify)\ (cl_program\ program,\ void\ *user_data)" ", void\ *" "user_data" ", cl_int\ *" "errcode_ret" ");" .SH "PARAMETERS" .PP \fI context \fR .RS 4 Must be a valid OpenCL context\&. .RE .PP \fI device_list \fR .RS 4 A pointer to a list of devices that are in \fIcontext\fR\&. If \fIdevice_list\fR is a NULL value, the link is performed for all devices associated with \fIcontext\fR for which a compiled object is available\&. If \fIdevice_list\fR is a non\-NULL value, the compile is performed for devices specified in this list for which a source has been loaded\&. .RE .PP \fI num_devices \fR .RS 4 The number of devices listed in \fIdevice_list\fR\&. .RE .PP \fI options \fR .RS 4 A pointer to a null\-terminated string of characters that describes the link options to be used for building the program executable\&. See \fBclBuildProgram\fR(3clc) for a list of supported compiler and linker options\&. .RE .PP \fI num_input_programs \fR .RS 4 Specifies the number of programs in array referenced by \fIinput_programs\fR\&. .RE .PP \fI input_programs \fR .RS 4 An array of program objects that are compiled binaries or libraries that are to be linked to create the program executable\&. For each device in \fIdevice_list\fR or if \fIdevice_list\fR is NULL the list of devices associated with \fIcontext\fR, the following cases occur: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} All programs specified by \fIinput_programs\fR contain a compiled binary or library for the device\&. In this case, a link is performed to generate a program executable for this device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} None of the programs contain a compiled binary or library for that device\&. In this case, no link is performed and there will be no program executable generated for this device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} All other cases will return a \fBCL_INVALID_OPERATION\fR error\&. .RE .RE .PP \fI pfn_notify \fR .RS 4 A function pointer to a notification routine\&. The notification routine is a callback function that an application can register and which will be called when the program executable has been built (successfully or unsuccessfully)\&. .sp If \fIpfn_notify\fR is not NULL, \fBclLinkProgram\fR does not need to wait for the linker to complete and can return immediately once the linking operation can begin\&. Once the linker has completed, the \fIpfn_notify\fR callback function is called which returns the program object returned by \fBclLinkProgram\fR\&. The application can query the link status and log for this program object\&. This callback function may be called asynchronously by the OpenCL implementation\&. It is the application\(cqs responsibility to ensure that the callback function is thread\-safe\&. .sp If \fIpfn_notify\fR is NULL, \fBclLinkProgram\fR does not return until the linker has completed\&. .RE .PP \fI user_data \fR .RS 4 Will be passed as an argument when \fIpfn_notify\fR is called\&. \fIuser_data\fR can be NULL\&. .RE .SH "NOTES" .PP \fBclLinkProgram\fR creates a new program object which contains this executable\&. The executable binary can be queried using \fBclGetProgramInfo\fR(3clc)(program, \fBCL_PROGRAM_BINARIES\fR, \&.\&.\&.) and can be specified to \fBclCreateProgramWithBinary\fR(3clc) to create a new program object\&. .PP The devices associated with the returned program object will be the list of devices specified by \fIdevice_list\fR or if \fIdevice_list\fR is NULL it will be the list of devices associated with \fIcontext\fR\&. .PP The linking operation can begin if the context, list of devices, input programs and linker options specified are all valid and appropriate host and device resources needed to perform the link are available\&. If the linking operation can begin, \fBclLinkProgram\fR returns a valid non\-zero program object\&. .SH "ERRORS" .PP If \fIpfn_notify\fR is NULL, the \fIerrcode_ret\fR will be set to \fBCL_SUCCESS\fR if the link operation was successful and \fBCL_LINK_FAILURE\fR if there is a failure to link the compiled binaries and/or libraries\&. .PP If \fIpfn_notify\fR is not NULL, \fBclLinkProgram\fR does not have to wait until the linker to complete and can return \fBCL_SUCCESS\fR in \fIerrcode_ret\fR if the linking operation can begin\&. The \fIpfn_notify\fR callback function will return a \fBCL_SUCCESS\fR or \fBCL_LINK_FAILURE\fR if the linking operation was successful or not\&. .PP Otherwise \fBclLinkProgram\fR returns a NULL program object with an appropriate error in \fIerrcode_ret\fR\&. The application should query the linker status of this program object to check if the link was successful or not\&. The list of errors that can be returned are: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_CONTEXT if \fIcontext\fR is not a valid context\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if \fIdevice_list\fR is NULL and \fInum_devices\fR is greater than zero, or if \fIdevice_list\fR is not NULL and \fInum_devices\fR is zero\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if \fInum_input_programs\fR is zero and \fIinput_programs\fR is NULL or if \fInum_input_programs\fR is zero and \fIinput_programs\fR is not NULL or if \fInum_input_programs\fR is not zero and \fIinput_programs\fR is NULL\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_PROGRAM if programs specified in \fIinput_programs\fR are not valid program objects\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if \fIpfn_notify\fR is NULL but user_data is not NULL\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_DEVICE if OpenCL devices listed in \fIdevice_list\fR are not in the list of devices associated with \fIcontext\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_LINKER_OPTIONS if the linker options specified by \fIoptions\fR are invalid .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if the compilation or build of a program executable for any of the devices listed in \fIdevice_list\fR by a previous call to \fBclCompileProgram\fR(3clc) or \fBclBuildProgram\fR(3clc) for program has not completed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if the rules for devices containing compiled binaries or libraries as described in \fIinput_programs\fR argument above are not followed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_LINKER_NOT_AVAILABLE if a linker is not available i\&.e\&. \fBCL_DEVICE_LINKER_AVAILABLE\fR specified in the table of allowed values for \fIparam_name\fR for \fBclGetDeviceInfo\fR(3clc) is set to \fBCL_FALSE\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_LINK_PROGRAM_FAILURE if there is a failure to link the compiled binaries and/or libraries\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host\&. .RE .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBclGetDeviceInfo\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br 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. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 142, section 5.6.3 - Separate Compilation and Linking of Programs .RE