blob: af287c23f945e9e18ee5464968414d9645ec58ee [file] [log] [blame]
Jon Leech932ed552016-12-09 04:38:24 -08001<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4
5<refentry>
6 <refentryinfo>
7 <keywordset>
8 <keyword>clCreateProgramWithBinary</keyword>
9 </keywordset>
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>
14 clCreateProgramWithBinary
15 </refentrytitle>
16
17 <refmiscinfo>
18 <copyright>
19 <year>2007-2013</year>
20 <holder>The Khronos Group Inc.
21 Permission is hereby granted, free of charge, to any person obtaining a
22copy of this software and/or associated documentation files (the
23"Materials"), to deal in the Materials without restriction, including
24without limitation the rights to use, copy, modify, merge, publish,
25distribute, sublicense, and/or sell copies of the Materials, and to
26permit persons to whom the Materials are furnished to do so, subject to
27the condition that this copyright notice and permission notice shall be included
28in all copies or substantial portions of the Materials.</holder>
29 </copyright>
30 </refmiscinfo>
31 <manvolnum>3</manvolnum>
32 </refmeta>
33
34<!-- ================================ SYNOPSIS -->
35
36 <refnamediv id="clCreateProgramWithBinary">
37 <refname>
38 clCreateProgramWithBinary
39 </refname>
40
41 <refpurpose>
42 Creates a program object for a context, and loads the binary bits specified by
43 <varname>binary</varname> into the program object.
44 </refpurpose>
45 </refnamediv>
46
47 <refsynopsisdiv xmlns:xlink="http://www.w3.org/1999/xlink"><title></title>
48 <funcsynopsis>
49 <funcprototype>
50 <funcdef>
51 <link xlink:href="abstractDataTypes.html">cl_program</link> <function>clCreateProgramWithBinary</function>
52 </funcdef>
53 <paramdef><link xlink:href="abstractDataTypes.html">cl_context</link><parameter>context</parameter></paramdef>
54 <paramdef><link xlink:href="scalarDataTypes.html">cl_uint</link><parameter>num_devices</parameter></paramdef>
55 <paramdef>const <link xlink:href="abstractDataTypes.html">cl_device_id</link><parameter>*device_list</parameter></paramdef>
56 <paramdef>const <link xlink:href="scalarDataTypes.html">size_t</link><parameter>*lengths</parameter></paramdef>
57 <paramdef>const <link xlink:href="scalarDataTypes.html">unsigned char</link><parameter>**binaries</parameter></paramdef>
58 <paramdef><link xlink:href="scalarDataTypes.html">cl_int</link><parameter>*binary_status</parameter></paramdef>
59 <paramdef><link xlink:href="scalarDataTypes.html">cl_int</link><parameter>*errcode_ret</parameter></paramdef>
60 </funcprototype>
61 </funcsynopsis>
62 </refsynopsisdiv>
63
64<!-- ================================ PARAMETERS -->
65
66 <refsect1 id="parameters">
67 <title>Parameters</title>
68 <variablelist>
69
70 <varlistentry>
71 <term> <varname> context </varname> </term>
72 <listitem>
73 <para>
74 Must be a valid OpenCL context.
75 </para>
76 </listitem>
77 </varlistentry>
78
79 <varlistentry>
80 <term> <varname> device_list </varname> </term>
81 <listitem>
82 <para>
83 A pointer to a list of devices that are in <varname>context</varname>.
84 <varname>device_list</varname> must be a non-NULL
85 value. The binaries are loaded for devices specified in this list.
86 </para>
87 </listitem>
88 </varlistentry>
89
90 <varlistentry>
91 <term> <varname> num_devices </varname> </term>
92 <listitem>
93 <para>
94 The number of devices listed in <varname>device_list</varname>.
95 </para>
96
97 <para>
98 The devices associated with the program object
99 will be the list of devices specified by
100 <varname>device_list</varname>. The list of devices
101 specified by <varname>device_list</varname>
102 must be devices associated with <varname>context</varname>.
103 </para>
104 </listitem>
105 </varlistentry>
106
107 <varlistentry>
108 <term> <varname> lengths </varname> </term>
109 <listitem>
110 <para>
111 An array of the size in bytes of the program binaries
112 to be loaded for devices specified by <varname>device_list</varname>.
113 </para>
114
115 </listitem>
116 </varlistentry>
117
118 <varlistentry>
119 <term> <varname> binaries </varname> </term>
120 <listitem>
121 <para>
122 An array of pointers to program binaries to be loaded for devices
123 specified by <varname>device_list</varname>. For each device given
124 by <varname>device_list</varname>[i], the pointer to the program
125 binary for that device is given by <varname>binaries</varname>[i]
126 and the length of this corresponding binary is given by
127 <varname>lengths</varname>[i]. <varname>lengths</varname>[i] cannot be
128 zero and <varname>binaries</varname>[i] cannot be a NULL pointer.
129 </para>
130
131 <para>
132 The program binaries specified by <varname>binaries</varname>
133 contain the bits that describe one of the following:
134
135 <itemizedlist mark="disc">
136 <listitem>
137 a program executable to be run on the device(s) associated
138 with <varname>context</varname>,
139 </listitem>
140
141 <listitem>
142 a compiled program for device(s) associated
143 with <varname>context</varname>, or
144 </listitem>
145
146 <listitem>
147 a library of compiled programs for device(s) associated with
148 <varname>context</varname>.
149 </listitem>
150 </itemizedlist>
151 </para>
152
153 <para>
154 The program binary can consist of either or both of device-specific
155 code and/or implementation-specific intermediate representation (IR)
156 which will be converted to the device-specific code.
157 </para>
158 </listitem>
159 </varlistentry>
160
161 <varlistentry>
162 <term> <varname> binary_status </varname> </term>
163 <listitem>
164 <para>
165 Returns whether the program binary for each device specified
166 in <varname>device_list</varname> was loaded successfully
167 or not. It is an array of <varname>num_devices</varname>
168 entries and returns <constant>CL_SUCCESS</constant> in
169 <varname>binary_status</varname>[i] if binary was successfully
170 loaded for device specified by <varname>device_list</varname>[i];
171 otherwise returns <constant>CL_INVALID_VALUE</constant> if
172 <varname>lengths</varname>[i] is zero or if <varname>binaries</varname>[i]
173 is a NULL value or <constant>CL_INVALID_BINARY</constant> in
174 <varname>binary_status</varname>[i] if program binary is not a valid
175 binary for the specified device. If <varname>binary_status</varname>
176 is NULL, it is ignored.
177 </para>
178 </listitem>
179 </varlistentry>
180
181 <varlistentry>
182 <term> <varname> errcode_ret </varname> </term>
183 <listitem>
184 <para>
185 Returns an appropriate error code. If <varname>errcode_ret</varname>
186 is NULL, no error code is returned.
187 </para>
188 </listitem>
189 </varlistentry>
190 </variablelist>
191 </refsect1>
192
193<!-- ================================ NOTES -->
194
195 <refsect1 id="notes"><title>Notes</title>
196 <para>
197 OpenCL allows applications to create a program object using the program source or
198 binary and build appropriate program executables. This can be very useful as it
199 allows applications to load program source and then compile and link to generate a
200 program executable online on its first instance for appropriate OpenCL devices in
201 the system. These executables can now be queried and cached by the application.
202 Future instances of the application launching will no longer need to compile and
203 link the program executables. The cached executables can be read and loaded by the
204 application, which can help significantly reduce the application initialization time.
205 </para>
206 </refsect1>
207
208<!-- ================================ ERRORS -->
209
210 <refsect1 id="errors"><title>Errors</title>
211 <para>
212 Returns a valid non-zero program object and <varname>errcode_ret</varname> is set to
213 <errorname>CL_SUCCESS</errorname> if the program object is created successfully.
214 Otherwise, it returns a NULL value with one of the following error values returned in
215 <varname>errcode_ret</varname>:
216 </para>
217
218 <itemizedlist mark="disc">
219 <listitem>
220 <errorname>CL_INVALID_CONTEXT</errorname> if <varname>context</varname> is not
221 a valid context.
222 </listitem>
223
224 <listitem>
225 <errorname>CL_INVALID_VALUE</errorname> if <varname>device_list</varname> is NULL
226 or <varname>num_devices</varname> is zero.
227 </listitem>
228
229 <listitem>
230 <errorname>CL_INVALID_DEVICE</errorname> if OpenCL devices listed in
231 <varname>device_list</varname> are not in the list of devices associated with
232 <varname>context</varname>.
233 </listitem>
234
235 <listitem>
236 <errorname>CL_INVALID_VALUE</errorname> if or if <varname>lengths</varname> or
237 <varname>binaries</varname> are NULL or if any entry in <varname>lengths</varname>[i]
238 or <varname>binaries</varname>[i] is NULL.
239 </listitem>
240
241 <listitem>
242 <errorname>CL_INVALID_BINARY</errorname> if an invalid program binary was encountered
243 for any device. <varname>binary_status</varname> will return specific status for
244 each device.
245 </listitem>
246
247 <listitem>
248 <errorname>CL_OUT_OF_RESOURCES</errorname> if there is a failure to allocate
249 resources required by the OpenCL implementation on the device.
250 </listitem>
251
252 <listitem>
253 <errorname>CL_OUT_OF_HOST_MEMORY</errorname> if there is a failure to allocate
254 resources required by the OpenCL implementation on the host.
255 </listitem>
256 </itemizedlist>
257 </refsect1>
258
259<!-- ================================ EXAMPLE -->
260<!-- DO NOT DELETE IN CASE AN EXAMPLE IS ADDED IN THE FUTURE -->
261<!--
262 <refsect2 id="example1">
263 <title>
264 Example
265 </title>
266
267 <informaltable frame="none">
268 <tgroup cols="1" align="left" colsep="0" rowsep="0">
269 <colspec colname="col1" colnum="1" />
270 <tbody>
271 <row>
272 <entry>
273 Example goes here - it will be set in "code" type with white space preserved.
274 </entry>
275 </row>
276 </tbody>
277 </tgroup>
278 </informaltable>
279 </refsect2>
280-->
281
282<!-- ================================ SPECIFICATION -->
283<!-- Set the "uri" attribute in the <olink /> element to the "named destination" for the PDF page
284-->
285 <refsect1 id="specification"><title>Specification</title>
286 <para>
287 <imageobject>
288 <imagedata fileref="pdficon_small1.gif" format="gif" />
289 </imageobject>
290
291 <olink uri="clCreateProgramWithBinary">OpenCL Specification</olink>
292 </para>
293 </refsect1>
294
295<!-- ================================ ALSO SEE -->
296
297 <refsect1 id="seealso"><title>Also see</title>
298 <para>
299 <citerefentry><refentrytitle>clCreateProgramWithSource</refentrytitle></citerefentry>,
300 <citerefentry><refentrytitle>clCreateProgramWithBuiltInKernels</refentrytitle></citerefentry>,
301 <citerefentry><refentrytitle>clReleaseProgram</refentrytitle></citerefentry>,
302 <citerefentry><refentrytitle>clRetainProgram</refentrytitle></citerefentry>,
303 <citerefentry href="classDiagram"><refentrytitle>Cardinality Diagram</refentrytitle></citerefentry>
304 </para>
305 </refsect1>
306
307<!-- ================================ COPYRIGHT -->
308<!-- Content included from copyright.inc.xsl -->
309
310 <refsect3 id="Copyright"><title></title>
311 <imageobject>
312 <imagedata fileref="KhronosLogo.jpg" format="jpg" />
313 </imageobject>
314 <para />
315 </refsect3>
316
317<!-- 22-Oct-2015, API rev. 19 -->
318</refentry>
319