| <?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN" |
| "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd" [ |
| <!ENTITY buildOptionsInc SYSTEM "buildOptionsInc.xml"> |
| ]> |
| |
| <refentry> |
| <refentryinfo> |
| <keywordset> |
| <keyword>clLinkProgram</keyword> |
| </keywordset> |
| </refentryinfo> |
| |
| <refmeta> |
| <refentrytitle> |
| clLinkProgram |
| </refentrytitle> |
| |
| <!-- ******************************************************************************* --> |
| <refmiscinfo> |
| <copyright> |
| <year>2007-2013</year> |
| <holder>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.</holder> |
| </copyright> |
| </refmiscinfo> |
| <manvolnum>3</manvolnum> |
| </refmeta> |
| |
| <!-- ================================ SYNOPSIS --> |
| |
| <refnamediv id="clLinkProgram"> |
| <refname> |
| clLinkProgram |
| </refname> |
| |
| <refpurpose> |
| Links a set of compiled program objects and libraries for all the devices or a specific device(s) in |
| the OpenCL context and creates a library or executable. |
| </refpurpose> |
| </refnamediv> |
| |
| <refsynopsisdiv xmlns:xlink="http://www.w3.org/1999/xlink"><title></title> |
| <funcsynopsis> |
| <funcprototype> |
| <funcdef> |
| <link xlink:href="scalarDataTypes.html">cl_program</link> |
| <function>clLinkProgram</function> |
| </funcdef> |
| <paramdef><link xlink:href="abstractDataTypes.html">cl_context</link><parameter>context</parameter></paramdef> |
| <paramdef><link xlink:href="scalarDataTypes.html">cl_uint</link><parameter>num_devices</parameter></paramdef> |
| <paramdef>const <link xlink:href="abstractDataTypes.html">cl_device_id</link><parameter>*device_list</parameter></paramdef> |
| <paramdef>const <link xlink:href="scalarDataTypes.html">char</link><parameter>*options</parameter></paramdef> |
| <paramdef><link xlink:href="scalarDataTypes.html">cl_uint</link><parameter>num_input_programs</parameter></paramdef> |
| <paramdef>const <link xlink:href="abstractDataTypes.html">cl_program</link><parameter>*input_programs</parameter></paramdef> |
| <paramdef><link xlink:href="scalarDataTypes.html">void</link><parameter>(CL_CALLBACK *pfn_notify) |
| (<link xlink:href="abstractDataTypes.html">cl_program</link> program, <link xlink:href="scalarDataTypes.html">void</link> *user_data)</parameter></paramdef> |
| <paramdef><link xlink:href="scalarDataTypes.html">void</link><parameter>*user_data</parameter></paramdef> |
| <paramdef><link xlink:href="scalarDataTypes.html">cl_int</link><parameter>*errcode_ret</parameter></paramdef> |
| </funcprototype> |
| </funcsynopsis> |
| </refsynopsisdiv> |
| |
| <!-- ================================ PARAMETERS --> |
| |
| <refsect1 id="parameters"> |
| <title>Parameters</title> |
| <variablelist> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| context |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| Must be a valid OpenCL context. |
| </para> |
| </listitem> |
| </varlistentry> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| device_list |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| A pointer to a list of devices that are in <varname>context</varname>. |
| If <varname>device_list</varname> is a NULL value, the link is performed |
| for all devices associated with <varname>context</varname> for which a |
| compiled object is available. If <varname>device_list</varname> is a |
| non-NULL value, the compile is performed for devices specified in this |
| list for which a compiled object is available. |
| </para> |
| </listitem> |
| </varlistentry> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| num_devices |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| The number of devices listed in <varname>device_list</varname>. |
| </para> |
| </listitem> |
| </varlistentry> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| options |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| A pointer to a null-terminated string of characters that describes |
| the link options to be used for building the program executable. See |
| <citerefentry><refentrytitle>clBuildProgram</refentrytitle></citerefentry> |
| for a list of supported compiler and linker options. |
| </para> |
| </listitem> |
| </varlistentry> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| num_input_programs |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| Specifies the number of programs in array referenced by <varname>input_programs</varname>. |
| </para> |
| </listitem> |
| </varlistentry> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| input_programs |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| 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 <varname>device_list</varname> or if <varname>device_list</varname> |
| is NULL the list of devices associated with <varname>context</varname>, |
| the following cases occur: |
| </para> |
| |
| <itemizedlist mark="disc"> |
| <listitem> |
| <para> |
| All programs specified by <varname>input_programs</varname> |
| contain a compiled binary or library for the device. In this case, |
| a link is performed to generate a program executable for this device. |
| </para> |
| </listitem> |
| |
| <listitem> |
| <para> |
| 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. |
| </para> |
| </listitem> |
| |
| <listitem> |
| <para> |
| All other cases will return a |
| <constant>CL_INVALID_OPERATION</constant> error. |
| </para> |
| </listitem> |
| </itemizedlist> |
| </listitem> |
| </varlistentry> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| pfn_notify |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| 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). |
| </para> |
| |
| <para> |
| If <varname>pfn_notify</varname> is not NULL, |
| <function>clLinkProgram</function> 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 <varname>pfn_notify</varname> |
| callback function is called which returns the program object returned |
| by <function>clLinkProgram</function>. 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’s |
| responsibility to ensure that the callback function is thread-safe. |
| </para> |
| |
| <para> |
| If <varname>pfn_notify</varname> is NULL, <function>clLinkProgram</function> |
| does not return until the linker has completed. |
| </para> |
| </listitem> |
| </varlistentry> |
| |
| <varlistentry> |
| <term> |
| <varname> |
| user_data |
| </varname> |
| </term> |
| |
| <listitem> |
| <para> |
| Will be passed as an argument when <varname>pfn_notify</varname> is called. |
| <varname>user_data</varname> can be NULL. |
| </para> |
| </listitem> |
| </varlistentry> |
| </variablelist> |
| </refsect1> |
| |
| <!-- ================================ NOTES --> |
| |
| <refsect1 id="notes"><title>Notes</title> |
| <para> |
| <function>clLinkProgram</function> creates a new program object which |
| contains the library or executable. |
| <citerefentry><refentrytitle>clLinkProgram</refentrytitle></citerefentry> |
| creates a new program object which contains the library or executable. |
| The library or executable binary can be queried using |
| <citerefentry><refentrytitle>clGetProgramInfo</refentrytitle></citerefentry>(<varname>program</varname>, |
| <constant>CL_PROGRAM_BINARIES</constant>, ...) and can be specified to |
| <citerefentry><refentrytitle>clCreateProgramWithBinary</refentrytitle></citerefentry> |
| to create a new program object. |
| </para> |
| |
| <para> |
| The devices associated with the returned program object will be the list of devices |
| specified by <varname>device_list</varname> or if <varname>device_list</varname> |
| is NULL it will be the list of devices associated with <varname>context</varname>. |
| </para> |
| |
| <para> |
| 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, |
| <function>clLinkProgram</function> returns a valid non-zero program object. |
| </para> |
| </refsect1> |
| |
| <!-- ================================ ERRORS --> |
| |
| <refsect1 id="errors"><title>Errors</title> |
| <para> |
| If <varname>pfn_notify</varname> is NULL, the <varname>errcode_ret</varname> will |
| be set to <constant>CL_SUCCESS</constant> if the link operation was successful and |
| <constant>CL_LINK_FAILURE</constant> if there is a failure to link the compiled |
| binaries and/or libraries. |
| </para> |
| |
| <para> |
| If <varname>pfn_notify</varname> is not NULL, <function>clLinkProgram</function> |
| does not have to wait until the linker to complete and can return |
| <constant>CL_SUCCESS</constant> in <varname>errcode_ret</varname> if the linking |
| operation can begin. The <varname>pfn_notify</varname> callback function will |
| return a <constant>CL_SUCCESS</constant> or <constant>CL_LINK_FAILURE</constant> |
| if the linking operation was successful or not. |
| </para> |
| |
| <para> |
| Otherwise <function>clLinkProgram</function> returns a NULL program object with an |
| appropriate error in <varname>errcode_ret</varname>. 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: |
| </para> |
| |
| <itemizedlist mark="disc"> |
| <listitem> |
| <errorname>CL_INVALID_CONTEXT</errorname> if <varname>context</varname> is not a valid context. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_VALUE</errorname> if <varname>device_list</varname> |
| is NULL and <varname>num_devices</varname> is greater than zero, or if |
| <varname>device_list</varname> is not NULL and <varname>num_devices</varname> |
| is zero. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_VALUE</errorname> if <varname>num_input_programs</varname> |
| is zero and <varname>input_programs</varname> is NULL or if |
| <varname>num_input_programs</varname> is zero and <varname>input_programs</varname> |
| is not NULL or if <varname>num_input_programs</varname> is not zero and |
| <varname>input_programs</varname> is NULL. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_PROGRAM</errorname> if programs specified in |
| <varname>input_programs</varname> are not valid program objects. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_VALUE</errorname> if <varname>pfn_notify</varname> is |
| NULL but <varname>user_data</varname> is not NULL. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_DEVICE</errorname> if OpenCL devices listed in |
| <varname>device_list</varname> are not in the list of devices associated with |
| <varname>context</varname>. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_LINKER_OPTIONS</errorname> if the linker options specified by |
| <varname>options</varname> are invalid |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_OPERATION</errorname> if the compilation |
| or build of a program executable for any of the devices |
| listed in <varname>device_list</varname> by a previous call to |
| <citerefentry><refentrytitle>clCompileProgram</refentrytitle></citerefentry> |
| or <citerefentry><refentrytitle>clBuildProgram</refentrytitle></citerefentry> |
| for <varname>program</varname> has not completed. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_OPERATION</errorname> if the rules for devices containing |
| compiled binaries or libraries as described in <varname>input_programs</varname> |
| argument above are not followed. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_INVALID_OPERATION</errorname> if the one or more of the programs specified in |
| <varname>input_programs</varname> requires independent forward progress of |
| sub-groups but one or more of |
| the devices listed in |
| <varname>device_list</varname> does not return |
| <constant>CL_TRUE</constant> for the |
| <constant>CL_DEVICE_SUBGROUP_INDEPENDENT_FORWARD_PROGRESS</constant> query. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_LINKER_NOT_AVAILABLE</errorname> if a linker is not |
| available i.e. <constant>CL_DEVICE_LINKER_AVAILABLE</constant> specified |
| in the table of allowed values for <varname>param_name</varname> for |
| <citerefentry><refentrytitle>clGetDeviceInfo</refentrytitle></citerefentry> |
| is set to <constant>CL_FALSE</constant>. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_LINK_PROGRAM_FAILURE</errorname> if there is a failure to link the |
| compiled binaries and/or libraries. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_OUT_OF_RESOURCES</errorname> if there is a failure to allocate |
| resources required by the OpenCL implementation on the device. |
| </listitem> |
| |
| <listitem> |
| <errorname>CL_OUT_OF_HOST_MEMORY</errorname> if there is a failure to allocate |
| resources required by the OpenCL implementation on the host. |
| </listitem> |
| </itemizedlist> |
| </refsect1> |
| |
| <!-- ================================ EXAMPLE --> |
| <!-- DO NOT DELETE IN CASE AN EXAMPLE IS ADDED IN THE FUTURE --> |
| <!-- |
| <refsect2 id="example1"> |
| <title> |
| Example |
| </title> |
| |
| <informaltable frame="none"> |
| <tgroup cols="1" align="left" colsep="0" rowsep="0"> |
| <colspec colname="col1" colnum="1" /> |
| <tbody> |
| <row> |
| <entry> |
| Example goes here - it will be set in "code" type with white space preserved. |
| </entry> |
| </row> |
| </tbody> |
| </tgroup> |
| </informaltable> |
| </refsect2> |
| --> |
| |
| <!-- ================================ SPECIFICATION --> |
| <!-- Set the "uri" attribute in the <olink /> element to the "named destination" for the PDF page |
| --> |
| <refsect1 id="specification"><title>Specification</title> |
| <para> |
| <imageobject> |
| <imagedata fileref="pdficon_small1.gif" format="gif" /> |
| </imageobject> |
| |
| <olink uri="clLinkProgram">OpenCL Specification</olink> |
| </para> |
| </refsect1> |
| |
| <!-- ================================ ALSO SEE --> |
| |
| <refsect1 id="seealso"><title>Also see</title> |
| <para> |
| <citerefentry><refentrytitle>clGetDeviceInfo</refentrytitle></citerefentry> |
| </para> |
| </refsect1> |
| |
| <!-- ================================ COPYRIGHT --> |
| <!-- Content included from copyright.inc.xsl --> |
| |
| <refsect3 id="Copyright"><title></title> |
| <imageobject> |
| <imagedata fileref="KhronosLogo.jpg" format="jpg" /> |
| </imageobject> |
| <para /> |
| </refsect3> |
| |
| <!-- 27-Oct-2015, API rev. 19 --> |
| </refentry> |
| |