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">
8
<keyword>clEnqueueMapBuffer</keyword>
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>
31
<manvolnum>3</manvolnum>
34
<!-- ================================ SYNOPSIS -->
36
<refnamediv id="clEnqueueMapBuffer">
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.
47
<refsynopsisdiv xmlns:xlink="http://www.w3.org/1999/xlink"><title></title>
51
<link xlink:href="scalarDataTypes.html">void</link> * <function>clEnqueueMapBuffer</function>
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>
67
<!-- ================================ PARAMETERS -->
69
<refsect1 id="parameters">
70
<title>Parameters</title>
74
<term> <varname> command_queue </varname> </term>
77
Must be a valid command-queue.
83
<term> <varname> blocking_map </varname> </term>
86
Indicates if the map operation is <varname>blocking</varname> or
87
<varname>non-blocking</varname>.
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>.
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>.
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.
117
<term><varname>map_flags</varname></term>
120
A bit-bield with the following supported values.
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" />
129
<entry>cl_map_flags</entry>
130
<entry>Description</entry>
136
<entry><constant>CL_MAP_READ</constant></entry>
139
This flag specifies that the region being mapped in the memory
140
object is being mapped for reading.
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.
156
<entry><constant>CL_MAP_WRITE</constant></entry>
159
This flag specifies that the region being mapped in the memory
160
object is being mapped for writing.
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.
175
<entry><constant>CL_MAP_WRITE_INVALIDATE_REGION</constant></entry>
178
This flag specifies that the region being mapped in the memory
179
object is being mapped for writing.
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.
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.
202
</tgroup></informaltable>
206
<!-- ================================ END PARAMETER TABLE -->
209
<term> <varname> buffer </varname> </term>
212
A valid buffer object. The OpenCL context associated with <varname>command_queue</varname>
213
and <varname>buffer</varname> must be the same.
230
The offset in bytes and the size of the region in the buffer object that is being mapped.
241
num_events_in_wait_list
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.
265
<term> <varname> event </varname> </term>
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.
281
<term> <varname> errcode_ret </varname> </term>
284
Returns an appropriate error code. If <varname>errcode_ret</varname>
285
is NULL, no error code is returned.
292
<!-- ================================ NOTES -->
294
<refsect1 id="notes"><title>Notes</title>
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.
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:
306
<itemizedlist mark="disc">
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.
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.
321
Mapped buffer objects are unmapped using
322
<citerefentry><refentrytitle>clEnqueueUnmapMemObject</refentrytitle></citerefentry>.
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.
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.
343
<!-- ================================ ERRORS -->
345
<refsect1 id="errors"><title>Errors</title>
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>.
353
A NULL pointer is returned otherwise with one of the following error values returned
354
in <varname>errcode_ret</varname>:
357
<itemizedlist mark="disc">
359
<errorname>CL_INVALID_COMMAND_QUEUE</errorname> if <varname>command_queue</varname>
360
is not a valid command-queue.
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.
371
<errorname>CL_INVALID_MEM_OBJECT</errorname> if <varname>image</varname> is not a valid image object.
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.
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> > 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.
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>.
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>.
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.
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>.
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>.
428
<errorname>CL_OUT_OF_RESOURCES</errorname> if there is a failure to allocate
429
resources required by the OpenCL implementation on the device.
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.
439
<!-- ================================ EXAMPLE -->
440
<!-- DO NOT DELETE IN CASE AN EXAMPLE IS ADDED IN THE FUTURE -->
442
<refsect2 id="example1">
447
<informaltable frame="none">
448
<tgroup cols="1" align="left" colsep="0" rowsep="0">
449
<colspec colname="col1" colnum="1" />
453
Example goes here - it will be set in "code" type with white space preserved.
462
<!-- ================================ SPECIFICATION -->
463
<!-- Set the "uri" attribute in the <olink /> element to the "named destination" for the PDF page
465
<refsect1 id="specification"><title>Specification</title>
468
<imagedata fileref="pdficon_small1.gif" format="gif" />
471
<olink uri="clEnqueueMapBuffer">OpenCL Specification</olink>
475
<!-- ================================ ALSO SEE -->
477
<refsect1 id="seealso"><title>Also see</title>
479
<citerefentry><refentrytitle>clEnqueueMapImage</refentrytitle></citerefentry>,
480
<citerefentry><refentrytitle>clEnqueueUnmapMemObject</refentrytitle></citerefentry>
484
<!-- ================================ COPYRIGHT -->
485
<!-- Content included from copyright.inc.xsl -->
487
<refsect3 id="Copyright"><title></title>
489
<imagedata fileref="KhronosLogo.jpg" format="jpg" />