'\" t .\" Title: clEnqueueMapBuffer .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 02/03/2019 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "CLENQUEUEMAPBUFFER" "3clc" "02/03/2019" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" clEnqueueMapBuffer \- 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\&. .SH "" .HP \w'void\ *\ clEnqueueMapBuffer('u .BI "void * clEnqueueMapBuffer(cl_command_queue\ " "command_queue" ", cl_mem\ " "buffer" ", cl_bool\ " "blocking_map" ", cl_map_flags\ " "map_flags" ", size_t\ " "offset" ", size_t\ " "size" ", cl_uint\ " "num_events_in_wait_list" ", const\ cl_event\ *" "event_wait_list" ", cl_event\ *" "event" ", cl_int\ *" "errcode_ret" ");" .SH "PARAMETERS" .PP \fI command_queue \fR .RS 4 Must be a valid command\-queue\&. .RE .PP \fI blocking_map \fR .RS 4 Indicates if the map operation is \fIblocking\fR or \fInon\-blocking\fR\&. .sp If \fIblocking_map\fR is \fBCL_TRUE\fR, \fBclEnqueueMapBuffer\fR does not return until the specified region in \fIbuffer\fR is mapped into the host address space and the application can access the contents of the mapped region using the pointer returned by \fBclEnqueueMapBuffer\fR\&. .sp If \fIblocking_map\fR is \fBCL_FALSE\fR i\&.e\&. map operation is non\-blocking, the pointer to the mapped region returned by \fBclEnqueueMapBuffer\fR cannot be used until the map command has completed\&. The \fIevent\fR 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 \fBclEnqueueMapBuffer\fR\&. .RE .PP \fImap_flags\fR .RS 4 A bit\-bield with the following supported values\&. .TS allbox tab(:); lB lB. T{ cl_map_flags T}:T{ Description T} .T& l l l l l l. T{ \fBCL_MAP_READ\fR T}:T{ This flag specifies that the region being mapped in the memory object is being mapped for reading\&. .sp The pointer returned by \fBclEnqueueMapBuffer\fR or \fBclEnqueueMapImage\fR(3clc) is guaranteed to contain the latest bits in the region being mapped when the \fBclEnqueueMapBuffer\fR or \fBclEnqueueMapImage\fR(3clc) command has completed\&. T} T{ \fBCL_MAP_WRITE\fR T}:T{ This flag specifies that the region being mapped in the memory object is being mapped for writing\&. .sp The pointer returned by \fBclEnqueueMapBuffer\fR or \fBclEnqueueMapImage\fR(3clc) is guaranteed to contain the latest bits in the region being mapped when the \fBclEnqueueMapBuffer\fR or \fBclEnqueueMapImage\fR(3clc) command has completed\&. T} T{ \fBCL_MAP_WRITE_INVALIDATE_REGION\fR T}:T{ This flag specifies that the region being mapped in the memory object is being mapped for writing\&. .sp The contents of the region being mapped are to be discarded\&. This is typically the case when the region being mapped is overwritten by the host\&. This flag allows the implementation to no longer guarantee that the pointer returned by \fBclEnqueueMapBuffer\fR or \fBclEnqueueMapImage\fR(3clc) contains the latest bits in the region being mapped which can be a significant performance enhancement\&. .sp \fBCL_MAP_READ\fR or \fBCL_MAP_WRITE\fR and \fB CL_MAP_WRITE_INVALIDATE_REGION\fR are mutually exclusive\&. T} .TE .sp 1 .RE .PP \fI buffer \fR .RS 4 A valid buffer object\&. The OpenCL context associated with \fIcommand_queue\fR and \fIbuffer\fR must be the same\&. .RE .PP \fI offset, \fR \fI size \fR .RS 4 The offset in bytes and the size of the region in the buffer object that is being mapped\&. .RE .PP \fI event_wait_list, \fR \fI num_events_in_wait_list \fR .RS 4 Specify events that need to complete before this particular command can be executed\&. If \fIevent_wait_list\fR is NULL, then this particular command does not wait on any event to complete\&. If \fIevent_wait_list\fR is NULL, \fInum_events_in_wait_list\fR must be 0\&. If \fIevent_wait_list\fR is not NULL, the list of events pointed to by \fIevent_wait_list\fR must be valid and \fInum_events_in_wait_list\fR must be greater than 0\&. The events specified in \fIevent_wait_list\fR act as synchronization points\&. The context associated with events in \fIevent_wait_list\fR and \fIcommand_queue\fR must be the same\&. The memory associated with \fIevent_wait_list\fR can be reused or freed after the function returns\&. .RE .PP \fI event \fR .RS 4 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\&. \fIevent\fR 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\&. If the \fIevent_wait_list\fR and the \fIevent\fR arguments are not NULL, the \fIevent\fR argument should not refer to an element of the \fIevent_wait_list\fR array\&. .RE .PP \fI errcode_ret \fR .RS 4 Returns an appropriate error code\&. If \fIerrcode_ret\fR is NULL, no error code is returned\&. .RE .SH "NOTES" .PP The returned pointer maps a region starting at \fIoffset\fR and is at least \fIsize\fR bytes in size\&. The result of a memory access outside this region is undefined\&. .PP If the buffer object is created with \fBCL_MEM_USE_HOST_PTR\fR set in \fImem_flags\fR, the following will be true: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The \fIhost_ptr\fR specified in \fBclCreateBuffer\fR(3clc) is guaranteed to contain the latest bits in the region being mapped when the \fBclEnqueueMapBuffer\fR command has completed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The pointer value returned by \fBclEnqueueMapBuffer\fR will be derived from the \fIhost_ptr\fR specified when the buffer object is created\&. .RE .PP Mapped buffer objects are unmapped using \fBclEnqueueUnmapMemObject\fR(3clc)\&. .PP \fBclEnqueueMapBuffer\fR and \fBclEnqueueMapImage\fR(3clc) increment the mapped count of the memory object\&. The initial mapped count value of a memory object is zero\&. Multiple calls to \fBclEnqueueMapBuffer\fR or \fBclEnqueueMapImage\fR(3clc) on the same memory object will increment this mapped count by appropriate number of calls\&. \fBclEnqueueUnmapMemObject\fR(3clc) decrements the mapped count of the memory object\&. .PP \fBclEnqueueMapBuffer\fR and \fBclEnqueueMapImage\fR(3clc) act as synchronization points for a region of the buffer object being mapped\&. .SH "ERRORS" .PP \fBclEnqueueMapBuffer\fR will return a pointer to the mapped region if the function is executed successfully\&. The \fIerrcode_ret\fR is set to CL_SUCCESS\&. .PP A NULL pointer is returned otherwise with one of the following error values returned in \fIerrcode_ret\fR: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_COMMAND_QUEUE if \fIcommand_queue\fR is not a valid command\-queue\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_CONTEXT if the context associated with \fIcommand_queue\fR and \fIimage\fR are not the same or if the context associated with \fIcommand_queue\fR and events in \fIevent_wait_list\fR are not the same\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_MEM_OBJECT if \fIimage\fR is not a valid image object\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if region being mapped given by (\fIoffset\fR, \fIsize\fR) is out of bounds or if \fIsize\fR is 0 or values specified in \fImap_flags\fR are not valid\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_EVENT_WAIT_LIST if \fIevent_wait_list\fR is NULL and \fInum_events_in_wait_list\fR > 0, or \fIevent_wait_list\fR is not NULL and \fInum_events_in_wait_list\fR is 0, or if event objects in \fIevent_wait_list\fR are not valid events\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_MISALIGNED_SUB_BUFFER_OFFSET if \fIbuffer\fR is a sub\-buffer object and \fIoffset\fR specified when the sub\-buffer object is created is not aligned to \fBCL_DEVICE_MEM_BASE_ADDR_ALIGN\fR value for device associated with \fIqueue\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_MAP_FAILURE if there is a failure to map the requested region into the host address space\&. This error cannot occur for image objects created with \fBCL_MEM_USE_HOST_PTR\fR or \fBCL_MEM_ALLOC_HOST_PTR\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST if the map operation is blocking and the execution status of any of the events in \fIevent_wait_list\fR is a negative integer value\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_MEM_OBJECT_ALLOCATION_FAILURE if there is a failure to allocate memory for data store associated with \fIbuffer\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if \fIbuffer\fR has been created with \fBCL_MEM_HOST_WRITE_ONLY\fR or \fBCL_MEM_HOST_NO_ACCESS\fR and \fBCL_MAP_READ\fR is set in \fImap_flags\fR or if \fIbuffer\fR has been created with \fBCL_MEM_HOST_READ_ONL\fR or \fBCL_MEM_HOST_NO_ACCESS\fR and \fBCL_MAP_WRITE\fR or \fBCL_MAP_WRITE_INVALIDATE_REGION\fR is set in \fImap_flags\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host\&. .RE .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBclEnqueueMapImage\fR(3clc), \fBclEnqueueUnmapMemObject\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br 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. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 86, section 5.2.3 - Mapping Buffer Objects .RE