~ubuntu-branches/ubuntu/trusty/khronos-opencl-man/trusty

« back to all changes in this revision

Viewing changes to clEnqueueMapBuffer.xml

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-05-21 18:06:15 UTC
  • Revision ID: package-import@ubuntu.com-20130521180615-6e0s2n3pai95ip2f
Tags: upstream-1.0~svn21772
ImportĀ upstreamĀ versionĀ 1.0~svn21772

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?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>clEnqueueMapBuffer</keyword>
 
9
        </keywordset>
 
10
    </refentryinfo>
 
11
 
 
12
    <refmeta>
 
13
        <refentrytitle>
 
14
            clEnqueueMapBuffer
 
15
        </refentrytitle>
 
16
 
 
17
        <refmiscinfo>
 
18
            <copyright>
 
19
                <year>2007-2011</year>
 
20
                <holder>The Khronos Group Inc.
 
21
 Permission is hereby granted, free of charge, to any person obtaining a
 
22
copy of this software and/or associated documentation files (the
 
23
"Materials"), to deal in the Materials without restriction, including
 
24
without limitation the rights to use, copy, modify, merge, publish,
 
25
distribute, sublicense, and/or sell copies of the Materials, and to
 
26
permit persons to whom the Materials are furnished to do so, subject to
 
27
the condition that this copyright notice and permission notice shall be included
 
28
in 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="clEnqueueMapBuffer">
 
37
        <refname>
 
38
            clEnqueueMapBuffer
 
39
        </refname>
 
40
 
 
41
        <refpurpose>
 
42
            Enqueues a command to map a region of the buffer object given by <varname>buffer</varname>
 
43
            into the host address space and returns a pointer to this mapped region.
 
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="scalarDataTypes.html">void</link> * <function>clEnqueueMapBuffer</function>
 
52
                </funcdef>
 
53
                    <paramdef><link xlink:href="abstractDataTypes.html">cl_command_queue</link><parameter>command_queue</parameter></paramdef>
 
54
                    <paramdef><link xlink:href="abstractDataTypes.html">cl_mem</link><parameter>buffer</parameter></paramdef>
 
55
                    <paramdef><link xlink:href="enums.html#cl_bool">cl_bool</link><parameter>blocking_map</parameter></paramdef>
 
56
                    <paramdef><link xlink:href="enums.html#cl_map_flags">cl_map_flags</link><parameter>map_flags</parameter></paramdef>
 
57
                    <paramdef><link xlink:href="scalarDataTypes.html">size_t</link><parameter>offset</parameter></paramdef>
 
58
                    <paramdef><link xlink:href="scalarDataTypes.html">size_t</link><parameter>size</parameter></paramdef>
 
59
                    <paramdef><link xlink:href="scalarDataTypes.html">cl_uint</link><parameter>num_events_in_wait_list</parameter></paramdef>
 
60
                    <paramdef>const <link xlink:href="abstractDataTypes.html">cl_event</link><parameter>*event_wait_list</parameter></paramdef>
 
61
                    <paramdef><link xlink:href="abstractDataTypes.html">cl_event</link><parameter>*event</parameter></paramdef>
 
62
                    <paramdef><link xlink:href="scalarDataTypes.html">cl_int</link><parameter>*errcode_ret</parameter></paramdef>
 
63
            </funcprototype>
 
64
        </funcsynopsis>
 
65
    </refsynopsisdiv>
 
66
 
 
67
<!-- ================================ PARAMETERS -->
 
68
 
 
69
    <refsect1 id="parameters">
 
70
        <title>Parameters</title>
 
71
        <variablelist>
 
72
 
 
73
            <varlistentry>
 
74
                <term> <varname> command_queue </varname> </term>
 
75
                <listitem>
 
76
                    <para>
 
77
                        Must be a valid command-queue.
 
78
                    </para>
 
79
               </listitem>
 
80
            </varlistentry>
 
81
 
 
82
            <varlistentry>
 
83
                <term> <varname> blocking_map </varname> </term>
 
84
                <listitem>
 
85
                    <para>
 
86
                      Indicates if the map operation is <varname>blocking</varname> or
 
87
                      <varname>non-blocking</varname>.
 
88
                    </para>
 
89
 
 
90
                    <para>
 
91
                      If <varname>blocking_map</varname> is <constant>CL_TRUE</constant>,
 
92
                      <function>clEnqueueMapBuffer</function> does not return until the specified
 
93
                      region in <varname>buffer</varname> is mapped into the host address space
 
94
                      and the application can access the contents of the mapped region using
 
95
                      the pointer returned by <function>clEnqueueMapBuffer</function>.
 
96
                    </para>
 
97
 
 
98
                    <para>
 
99
                      If <varname>blocking_map</varname> is <constant>CL_FALSE</constant>
 
100
                      i.e. map operation is non-blocking, the pointer to the mapped region
 
101
                      returned by <function>clEnqueueMapBuffer</function> cannot be used until
 
102
                      the map command has completed. The <varname>event</varname> argument
 
103
                      returns an event object which can be used to query the execution status
 
104
                      of the map command. When the map command is completed, the application
 
105
                      can access the contents of the mapped region using the pointer returned
 
106
                      by <function>clEnqueueMapBuffer</function>.
 
107
                    </para>
 
108
                </listitem>
 
109
            </varlistentry>
 
110
 
 
111
<!-- ================================ PARAMETER TABLE (OPTIONAL) -->
 
112
<!-- DELETE IF NOT NEEDED -->
 
113
<!-- Use this if parameter information requires a table. Adjust the number of columns by adjusting
 
114
<colspec /> tags. Column header goes in the <thead /> section. Delte the section if no column head needed.
 
115
-->
 
116
            <varlistentry>
 
117
                <term><varname>map_flags</varname></term>
 
118
                <listitem>
 
119
                    <para>
 
120
                        A bit-bield with the following supported values.
 
121
                    </para>
 
122
 
 
123
                        <!-- table 5.5, also applies to clEnqueueMapImage.xml -->
 
124
                        <informaltable frame="all"><tgroup cols="2" align="left" colsep="1" rowsep="1">
 
125
                            <colspec colname="col1" colnum="1" />
 
126
                            <colspec colname="col2" colnum="2" />
 
127
                            <thead>
 
128
                                <row>
 
129
                                <entry>cl_map_flags</entry>
 
130
                                <entry>Description</entry>
 
131
                                </row>
 
132
                            </thead>
 
133
 
 
134
                            <tbody>
 
135
                                <row>
 
136
                                    <entry><constant>CL_MAP_READ</constant></entry>
 
137
                                    <entry>
 
138
                                        <para>
 
139
                                            This flag specifies that the region being mapped in the memory
 
140
                                            object is being mapped for reading.
 
141
                                        </para>
 
142
 
 
143
                                        <para>
 
144
                                            The pointer returned by <function>clEnqueueMapBuffer</function> or
 
145
                                            <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>
 
146
                                            is guaranteed to contain
 
147
                                            the latest bits in the region being
 
148
                                            mapped when the <function>clEnqueueMapBuffer</function> or
 
149
                                            <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>
 
150
                                            command has completed.
 
151
                                        </para>
 
152
                                    </entry>
 
153
                                </row>
 
154
 
 
155
                                <row>
 
156
                                    <entry><constant>CL_MAP_WRITE</constant></entry>
 
157
                                    <entry>
 
158
                                        <para>
 
159
                                            This flag specifies that the region being mapped in the memory
 
160
                                            object is being mapped for writing.
 
161
                                        </para>
 
162
 
 
163
                                        <para>
 
164
                                            The pointer returned by <function>clEnqueueMapBuffer</function> or
 
165
                                           <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>
 
166
                                            is guaranteed to contain the latest bits in
 
167
                                            the region being mapped when the <function>clEnqueueMapBuffer</function> or
 
168
                                            <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>
 
169
                                            command has completed.
 
170
                                        </para>
 
171
                                    </entry>
 
172
                                </row>
 
173
 
 
174
                                <row>
 
175
                                    <entry><constant>CL_MAP_WRITE_INVALIDATE_REGION</constant></entry>
 
176
                                    <entry>
 
177
                                        <para>
 
178
                                            This flag specifies that the region being mapped in the memory
 
179
                                            object is being mapped for writing.
 
180
                                        </para>
 
181
 
 
182
                                        <para>
 
183
                                            The contents of the region being mapped are to be discarded.
 
184
                                            This is typically the case
 
185
                                            when the region being mapped is overwritten by the host. This
 
186
                                            flag allows the implementation
 
187
                                            to no longer guarantee that the pointer returned by
 
188
                                             <function>clEnqueueMapBuffer</function> or
 
189
                                            <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>
 
190
                                            contains the latest bits in the region being
 
191
                                            mapped which can be a significant performance enhancement.
 
192
                                        </para>
 
193
 
 
194
                                        <para>
 
195
                                            <constant>CL_MAP_READ</constant> or <constant>CL_MAP_WRITE</constant>
 
196
                                            and <constant> CL_MAP_WRITE_INVALIDATE_REGION</constant>
 
197
                                            are mutually exclusive.
 
198
                                        </para>
 
199
                                    </entry>
 
200
                                </row>
 
201
                            </tbody>
 
202
                        </tgroup></informaltable>
 
203
                </listitem>
 
204
            </varlistentry>
 
205
 
 
206
<!-- ================================ END PARAMETER TABLE  -->
 
207
 
 
208
            <varlistentry>
 
209
                <term> <varname> buffer </varname> </term>
 
210
                <listitem>
 
211
                    <para>
 
212
                        A valid buffer object. The OpenCL context associated with <varname>command_queue</varname>
 
213
                        and <varname>buffer</varname> must be the same.
 
214
                    </para>
 
215
               </listitem>
 
216
            </varlistentry>
 
217
 
 
218
            <varlistentry>
 
219
                <term>
 
220
                    <varname>
 
221
                        offset,
 
222
                    </varname>
 
223
                    <varname>
 
224
                        size
 
225
                    </varname>
 
226
                </term>
 
227
 
 
228
                <listitem>
 
229
                    <para>
 
230
                        The offset in bytes and the size of the region in the buffer object that is being mapped.
 
231
                    </para>
 
232
               </listitem>
 
233
            </varlistentry>
 
234
 
 
235
            <varlistentry>
 
236
                <term>
 
237
                    <varname>
 
238
                        event_wait_list,
 
239
                    </varname>
 
240
                    <varname>
 
241
                        num_events_in_wait_list
 
242
                    </varname>
 
243
                </term>
 
244
 
 
245
                <listitem>
 
246
                    <para>
 
247
                      Specify events that need to complete before this particular
 
248
                      command can be executed. If <varname>event_wait_list</varname>
 
249
                      is NULL, then this particular command does not wait on any
 
250
                      event to complete. If <varname>event_wait_list</varname> is
 
251
                      NULL, <varname>num_events_in_wait_list</varname> must be 0. If
 
252
                      <varname>event_wait_list</varname> is not NULL, the list of events
 
253
                      pointed to by <varname>event_wait_list</varname> must be valid
 
254
                      and <varname>num_events_in_wait_list</varname> must be greater
 
255
                      than 0. The events specified in <varname>event_wait_list</varname>
 
256
                      act as synchronization points. The context associated with events in
 
257
                      <varname>event_wait_list</varname> and <varname>command_queue</varname> must
 
258
                      be the same.  The memory associated with <varname>event_wait_list</varname>
 
259
                      can be reused or freed after the function returns.
 
260
                    </para>
 
261
               </listitem>
 
262
            </varlistentry>
 
263
 
 
264
            <varlistentry>
 
265
                <term> <varname> event </varname> </term>
 
266
                <listitem>
 
267
                    <para>
 
268
                      Returns an event object that identifies this particular copy command
 
269
                      and can be used to query or queue a wait for this particular command
 
270
                      to complete. <varname>event</varname> can be NULL in which case
 
271
                      it will not be possible for the application to query the status of
 
272
                      this command or queue a wait for this command to complete.  If the
 
273
                      <varname>event_wait_list</varname> and the <varname>event</varname>
 
274
                      arguments are not NULL, the <varname>event</varname> argument should not
 
275
                      refer to an element of the <varname>event_wait_list</varname> array.
 
276
                    </para>
 
277
                </listitem>
 
278
            </varlistentry>
 
279
 
 
280
            <varlistentry>
 
281
                <term> <varname> errcode_ret </varname> </term>
 
282
                <listitem>
 
283
                    <para>
 
284
                      Returns an appropriate error code. If <varname>errcode_ret</varname>
 
285
                      is NULL, no error code is returned.
 
286
                    </para>
 
287
                </listitem>
 
288
            </varlistentry>
 
289
        </variablelist>
 
290
    </refsect1>
 
291
 
 
292
<!-- ================================ NOTES  -->
 
293
 
 
294
    <refsect1 id="notes"><title>Notes</title>
 
295
        <para>
 
296
          The returned pointer maps a region starting at <varname>offset</varname> and is at
 
297
          least <varname>size</varname> bytes in size. The result of a memory access outside
 
298
          this region is undefined.
 
299
        </para>
 
300
 
 
301
        <para>
 
302
          If the buffer object is created with <constant>CL_MEM_USE_HOST_PTR</constant> set in
 
303
          <varname>mem_flags</varname>, the following will be true:
 
304
        </para>
 
305
 
 
306
        <itemizedlist mark="disc">
 
307
            <listitem>
 
308
              The <varname>host_ptr</varname> specified in
 
309
              <citerefentry><refentrytitle>clCreateBuffer</refentrytitle></citerefentry>
 
310
              is guaranteed to contain the latest bits in the region being mapped when the
 
311
              <function>clEnqueueMapBuffer</function> command has completed.
 
312
            </listitem>
 
313
 
 
314
            <listitem>
 
315
              The pointer value returned by <function>clEnqueueMapBuffer</function> will be derived
 
316
              from the <varname>host_ptr</varname> specified when the buffer object is created.
 
317
            </listitem>
 
318
        </itemizedlist>
 
319
 
 
320
        <para>
 
321
          Mapped buffer objects are unmapped using
 
322
          <citerefentry><refentrytitle>clEnqueueUnmapMemObject</refentrytitle></citerefentry>.
 
323
        </para>
 
324
 
 
325
        <para>
 
326
          <!-- core spec p. 120, section 5.4.2 --> <function>clEnqueueMapBuffer</function>
 
327
          and <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>
 
328
          increment the mapped count of the memory object. The initial mapped count value of a
 
329
          memory object is zero. Multiple calls to <function>clEnqueueMapBuffer</function> or
 
330
          <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry> on the
 
331
          same memory object will increment this mapped count by appropriate number of calls.
 
332
          <citerefentry><refentrytitle>clEnqueueUnmapMemObject</refentrytitle></citerefentry>
 
333
          decrements the mapped count of the memory object.
 
334
        </para>
 
335
 
 
336
        <para>
 
337
          <!-- core spec p. 120, section 5.4.2 --> <function>clEnqueueMapBuffer</function>
 
338
          and <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>
 
339
          act as synchronization points for a region of the buffer object being mapped.
 
340
        </para>
 
341
    </refsect1>
 
342
 
 
343
<!-- ================================ ERRORS  -->
 
344
 
 
345
    <refsect1 id="errors"><title>Errors</title>
 
346
        <para>
 
347
          <function>clEnqueueMapBuffer</function> will return a pointer to the mapped region
 
348
          if the function is executed successfully.  The <varname>errcode_ret</varname> is set
 
349
          to <errorname>CL_SUCCESS</errorname>.
 
350
        </para>
 
351
 
 
352
        <para>
 
353
          A NULL pointer is returned otherwise with one of the following error values returned
 
354
          in <varname>errcode_ret</varname>:
 
355
        </para>
 
356
 
 
357
        <itemizedlist mark="disc">
 
358
            <listitem>
 
359
                <errorname>CL_INVALID_COMMAND_QUEUE</errorname> if <varname>command_queue</varname>
 
360
                is not a valid command-queue.
 
361
            </listitem>
 
362
 
 
363
            <listitem>
 
364
                <errorname>CL_INVALID_CONTEXT</errorname> if the context associated with
 
365
                <varname>command_queue</varname> and <varname>image</varname>
 
366
                are not the same or if the context associated with <varname>command_queue</varname>
 
367
                and events in <varname>event_wait_list</varname> are not the same.
 
368
            </listitem>
 
369
 
 
370
            <listitem>
 
371
                <errorname>CL_INVALID_MEM_OBJECT</errorname> if <varname>image</varname> is not a valid image object.
 
372
            </listitem>
 
373
 
 
374
            <listitem>
 
375
                <errorname>CL_INVALID_VALUE</errorname> if region being mapped given by
 
376
                (<varname>offset</varname>, <varname>size</varname>)
 
377
                is out of bounds or if <varname>size</varname> is 0 or values specified in
 
378
                <varname>map_flags</varname> are not valid.
 
379
            </listitem>
 
380
 
 
381
            <listitem>
 
382
              <errorname>CL_INVALID_EVENT_WAIT_LIST</errorname>
 
383
              if <varname>event_wait_list</varname> is NULL and
 
384
              <varname>num_events_in_wait_list</varname> &gt; 0,
 
385
              or <varname>event_wait_list</varname> is not NULL and
 
386
              <varname>num_events_in_wait_list</varname> is 0, or if event objects in
 
387
              <varname>event_wait_list</varname> are not valid events.
 
388
            </listitem>
 
389
 
 
390
            <listitem>
 
391
              <errorname>CL_MISALIGNED_SUB_BUFFER_OFFSET</errorname> if
 
392
              <varname>buffer</varname> is a sub-buffer object and <varname>offset</varname>
 
393
              specified when the sub-buffer object is created is not aligned to
 
394
              <constant>CL_DEVICE_MEM_BASE_ADDR_ALIGN</constant> value for device associated
 
395
              with <varname>queue</varname>.
 
396
            </listitem>
 
397
 
 
398
            <listitem>
 
399
              <errorname>CL_MAP_FAILURE</errorname> if there is a failure to map the
 
400
              requested region into the host address space. This error cannot occur for
 
401
              image objects created with <constant>CL_MEM_USE_HOST_PTR</constant> or
 
402
              <constant>CL_MEM_ALLOC_HOST_PTR</constant>.
 
403
            </listitem>
 
404
 
 
405
            <listitem>
 
406
              <errorname>CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST</errorname> if the
 
407
              map operation is blocking and the execution status of any of the events in
 
408
              <varname>event_wait_list</varname> is a negative integer value.
 
409
            </listitem>
 
410
 
 
411
            <listitem>
 
412
              <errorname>CL_MEM_OBJECT_ALLOCATION_FAILURE</errorname> if there is a failure to
 
413
              allocate memory for data store associated with <varname>buffer</varname>.
 
414
            </listitem>
 
415
 
 
416
            <listitem>
 
417
              <errorname>CL_INVALID_OPERATION</errorname> if <varname>buffer</varname>
 
418
              has been created with <constant>CL_MEM_HOST_WRITE_ONLY</constant> or
 
419
              <constant>CL_MEM_HOST_NO_ACCESS</constant> and <constant>CL_MAP_READ</constant>
 
420
              is set in <varname>map_flags</varname> or if <varname>buffer</varname>
 
421
              has been created with <constant>CL_MEM_HOST_READ_ONL</constant> or
 
422
              <constant>CL_MEM_HOST_NO_ACCESS</constant> and <constant>CL_MAP_WRITE</constant>
 
423
              or <constant>CL_MAP_WRITE_INVALIDATE_REGION</constant> is set in
 
424
              <varname>map_flags</varname>.
 
425
            </listitem>
 
426
 
 
427
            <listitem>
 
428
              <errorname>CL_OUT_OF_RESOURCES</errorname> if there is a failure to allocate
 
429
              resources required by the OpenCL implementation on the device.
 
430
            </listitem>
 
431
 
 
432
            <listitem>
 
433
              <errorname>CL_OUT_OF_HOST_MEMORY</errorname> if there is a failure to allocate
 
434
              resources required by the OpenCL implementation on the host.
 
435
            </listitem>
 
436
        </itemizedlist>
 
437
    </refsect1>
 
438
 
 
439
<!-- ================================ EXAMPLE  -->
 
440
<!-- DO NOT DELETE IN CASE AN EXAMPLE IS ADDED IN THE FUTURE -->
 
441
<!--
 
442
    <refsect2 id="example1">
 
443
        <title>
 
444
            Example
 
445
        </title>
 
446
 
 
447
        <informaltable frame="none">
 
448
            <tgroup cols="1" align="left" colsep="0" rowsep="0">
 
449
                <colspec colname="col1" colnum="1" />
 
450
                <tbody>
 
451
                    <row>
 
452
                        <entry>
 
453
                            Example goes here - it will be set in "code" type with white space preserved.
 
454
                        </entry>
 
455
                    </row>
 
456
                </tbody>
 
457
            </tgroup>
 
458
        </informaltable>
 
459
    </refsect2>
 
460
-->
 
461
 
 
462
<!-- ================================ SPECIFICATION  -->
 
463
<!-- Set the "uri" attribute in the <olink /> element to the "named destination" for the PDF page
 
464
-->
 
465
    <refsect1 id="specification"><title>Specification</title>
 
466
        <para>
 
467
            <imageobject>
 
468
                <imagedata fileref="pdficon_small1.gif" format="gif" />
 
469
            </imageobject>
 
470
 
 
471
            <olink uri="clEnqueueMapBuffer">OpenCL Specification</olink>
 
472
        </para>
 
473
    </refsect1>
 
474
 
 
475
<!-- ================================ ALSO SEE  -->
 
476
 
 
477
    <refsect1 id="seealso"><title>Also see</title>
 
478
        <para>
 
479
            <citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>,
 
480
            <citerefentry><refentrytitle>clEnqueueUnmapMemObject</refentrytitle></citerefentry>
 
481
        </para>
 
482
    </refsect1>
 
483
 
 
484
<!-- ================================ COPYRIGHT  -->
 
485
<!-- Content included from copyright.inc.xsl -->
 
486
 
 
487
    <refsect3 id="Copyright"><title></title>
 
488
        <imageobject>
 
489
                <imagedata fileref="KhronosLogo.jpg" format="jpg" />
 
490
        </imageobject>
 
491
        <para />
 
492
    </refsect3>
 
493
 
 
494
<!-- 18-Oct-2011 -->
 
495
</refentry>
 
496