'\" t .\" Title: clEnqueueWriteBuffer .\" 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 "CLENQUEUEWRITEBUFFER" "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" clEnqueueWriteBuffer \- Enqueue commands to write to a buffer object from host memory\&. .SH "" .HP \w'cl_int\ clEnqueueWriteBuffer('u .BI "cl_int clEnqueueWriteBuffer(cl_command_queue\ " "command_queue" ", cl_mem\ " "buffer" ", cl_bool\ " "blocking_write" ", size_t\ " "offset" ", size_t\ " "size" ", const\ void\ *" "ptr" ", cl_uint\ " "num_events_in_wait_list" ", const\ cl_event\ *" "event_wait_list" ", cl_event\ *" "event" ");" .SH "PARAMETERS" .PP \fI command_queue \fR .RS 4 Refers to the command\-queue in which the write command will be queued\&. \fIcommand_queue\fR and \fIbuffer\fR must be created with the same OpenCL context\&. .RE .PP \fI buffer \fR .RS 4 Refers to a valid buffer object\&. .RE .PP \fI blocking_write \fR .RS 4 Indicates if the write operations are \fIblocking\fR or \fInonblocking\fR\&. .sp If \fIblocking_write\fR is \fBCL_TRUE\fR, the OpenCL implementation copies the data referred to by \fIptr\fR and enqueues the write operation in the command\-queue\&. The memory pointed to by \fIptr\fR can be reused by the application after the \fBclEnqueueWriteBuffer\fR call returns\&. .sp If \fIblocking_write\fR is \fBCL_FALSE\fR, the OpenCL implementation will use \fIptr\fR to perform a nonblocking write\&. As the write is non\-blocking the implementation can return immediately\&. The memory pointed to by \fIptr\fR cannot be reused by the application after the call returns\&. The \fIevent\fR argument returns an event object which can be used to query the execution status of the write command\&. When the write command has completed, the memory pointed to by \fIptr\fR can then be reused by the application\&. .RE .PP \fI offset \fR .RS 4 The offset in bytes in the buffer object to write to\&. .RE .PP \fI size \fR .RS 4 The size in bytes of data being written\&. .RE .PP \fI ptr \fR .RS 4 The pointer to buffer in host memory where data is to be written from\&. .RE .PP \fI \fR\fI\fR\fI event_wait_list \fR, \fI \fR\fI\fR\fI num_events_in_wait_list \fR .RS 4 \fIevent_wait_list\fR and \fInum_events_in_wait_list\fR 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 write 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\&. .RE .SH "NOTES" .PP Calling \fBclEnqueueWriteBuffer\fR to update the latest bits in a region of the buffer object with the \fIptr\fR argument value set to \fIhost_ptr\fR + \fIoffset\fR, where \fIhost_ptr\fR is a pointer to the memory region specified when the buffer object being written is created with \fBCL_MEM_USE_HOST_PTR\fR, must meet the following requirements in order to avoid undefined behavior: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The host memory region given by \fI(host_ptr + offset, cb)\fR contains the latest bits when the enqueued write command begins execution\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The buffer object or memory objects created from this buffer object are not mapped\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The buffer object or memory objects created from this buffer object are not used by any command\-queue until the read command has finished execution\&. .RE .SH "ERRORS" .PP \fBclEnqueueWriteBuffer\fR returns CL_SUCCESS if the function is executed successfully\&. Otherwise, it returns one of the following errors: .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 \fIbuffer\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 \fIbuffer\fR is not a valid buffer object\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if the region being written specified by (\fIoffset\fR, \fIsize\fR) is out of bounds or if \fIptr\fR is a NULL value or if size is 0\&. .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 greater than 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_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST if the read and write operations are 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 \fBclEnqueueWriteBuffer\fR(3clc) is called on \fIbuffer\fR which has been created with \fBCL_MEM_HOST_READ_ONLY\fR or \fBCL_MEM_HOST_NO_ACCESS\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 \fBclEnqueueCopyBuffer\fR(3clc), \fBclEnqueueReadBuffer\fR(3clc), \fBclEnqueueReadBufferRect\fR(3clc), \fBclEnqueueWriteBufferRect\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 72, section 5.2.2 - Reading, Writing, Copying Buffer Objects .RE