Enqueues a command to map a region of the buffer object given by buffer into the host address space and returns a pointer to this mapped region.
command_queue
Must be a valid command-queue.
blocking_map
Indicates if the map operation is blocking or non-blocking.
If blocking_map is CL_TRUE, clEnqueueMapBuffer does not return until the specified region in buffer can be mapped.
If blocking_map is CL_FALSE i.e. map operation is non-blocking, the pointer to the mapped region returned by clEnqueueMapBuffer cannot be used until the map command has completed. The event argument returns an event object which can be used to query the execution status of the map command. When the map command is completed, the application can access the contents of the mapped region using the pointer returned by clEnqueueMapBuffer.
map_flags
Is a bit-field and can be set to CL_MAP_READ to indicate that the region specified by (offset, cb) in the buffer object is being mapped for reading, and/or CL_MAP_WRITE to indicate that the region specified by (offset, cb) in the buffer object is being mapped for writing.
buffer
A valid buffer object. The OpenCL context associated with command_queue and buffer must be the same.
offset,
cb
The offset in bytes and the size of the region in the buffer object that is being mapped.
event_wait_list,
num_events_in_wait_list
Specify events that need to complete before this
particular command can be executed. If event_wait_list is NULL, then this particular command
does not wait on any event to complete. If event_wait_list is NULL, num_events_in_wait_list
must be 0. If event_wait_list is not NULL, the list of events pointed to by event_wait_list must
be valid and num_events_in_wait_list must be greater than 0. The events specified in
event_wait_list act as synchronization points. The context associated with events in
event_wait_list and command_queue must be the same.
event
Returns an event object that identifies this particular copy command and can be used to query or queue a wait for this particular command to complete. event can be NULL in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete.
errcode_ret
Returns an appropriate error code. If errcode_ret is NULL, no error code is returned.
If the buffer object is created with CL_MEM_USE_HOST_PTR set in mem_flags, the host_ptr specified in clCreateBuffer is guaranteed to contain the latest bits in the region being mapped when the clEnqueueMapBuffer command has completed; and the pointer value returned by clEnqueueMapBuffer will be derived from the host_ptr specified when the buffer object is created.
Mapped buffer objects are unmapped using clEnqueueUnmapMemObject.
The contents of the regions of a memory object mapped for writing (i.e. CL_MAP_WRITE is set in map_flags argument to clEnqueueMapBuffer or clEnqueueMapImage) are considered to be undefined until this region is unmapped. Reads and writes by a kernel executing on a device to a memory region(s) mapped for writing are undefined.
Multiple command-queues can map a region or overlapping regions of a memory object for
reading (i.e. map_flags = CL_MAP_READ). The contents of the regions of a memory object mapped for reading can also be read by kernels executing on a device(s). The behavior of writes by a kernel executing on a device to a mapped region of a memory object is undefined. Mapping (and unmapping) overlapped regions of a buffer or image memory object for writing is undefined.
The behavior of OpenCL function calls that enqueue commands that write or copy to regions of a memory object that are mapped is undefined.
The pointer returned maps a region starting at offset and is at least cb bytes in size. The result of a memory access outside this region is undefined.
clEnqueueMapBuffer will return a pointer to the mapped region if the function is executed successfully. The errcode_ret is set to CL_SUCCESS.
A NULL pointer is returned otherwise with one of the following error values returned in errcode_ret:
command_queue is not a valid command-queue.
command_queue and buffer are not the
same or if the context associated with
command_queue and events
in event_wait_list are not the same.
buffer is not a valid buffer object.
offset, cb) is out of bounds or if
values specified in map_flags are not valid
event_wait_list is NULL and
num_events_in_wait_list greater than 0, or event_wait_list is not NULL and
num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
event_wait_list is a negative integer value.
buffer is a sub-buffer object and
offset specified when the sub-buffer object is created is not aligned to CL_DEVICE_MEM_BASE_ADDR_ALIGN
value for device associated with queue.
CL_MEM_USE_HOST_PTR
or CL_MEM_ALLOC_HOST_PTR.
buffer.
Copyright © 2007-2010 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.