'\" t .\" Title: clEnqueueReadImage .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/14/2021 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "CLENQUEUEREADIMAGE" "3clc" "01/14/2021" "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" clEnqueueReadImage \- Enqueue commands to read from an image or image array object to host memory\&. .SH "" .HP \w'cl_int\ clEnqueueReadImage('u .BI "cl_int clEnqueueReadImage(cl_command_queue\ " "command_queue" ", cl_mem\ " "image" ", cl_bool\ " "blocking_read" ", const\ size_t\ *" "origin" ", const\ size_t\ *" "region" ", size_t\ " "row_pitch" ", size_t\ " "slice_pitch" ", 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 read command will be queued\&. \fIcommand_queue\fR and \fIimage\fR must be created with the same OpenCL context\&. .RE .PP \fI image \fR .RS 4 Refers to a valid image or image array object\&. .RE .PP \fI blocking_read \fR .RS 4 Indicates if the read operations are \fIblocking\fR or \fInon\-blocking\fR\&. .sp If \fIblocking_read\fR is \fBCL_TRUE\fR i\&.e\&. the read command is blocking, \fBclEnqueueReadImage\fR does not return until the buffer data has been read and copied into memory pointed to by \fIptr\fR\&. .sp If \fIblocking_read\fR is \fBCL_FALSE\fR i\&.e\&. map operation is non\-blocking, \fBclEnqueueReadImage\fR queues a non\-blocking read command and returns\&. The contents of the buffer that \fIptr\fR points to cannot be used until the read command has completed\&. The \fIevent\fR argument returns an event object which can be used to query the execution status of the read command\&. When the read command has completed, the contents of the buffer that \fIptr\fR points to can be used by the application\&. .RE .PP \fI origin \fR .RS 4 Defines the (\fIx, y, z\fR) offset in pixels in the 1D, 2D, or 3D image, the (\fIx, y\fR) offset and the image index in the image array or the (x) offset and the image index in the 1D image array\&. If \fIimage\fR is a 2D image object, \fIorigin\fR[2] must be 0\&. If \fIimage\fR is a 1D image or 1D image buffer object, \fIorigin\fR[1] and \fIorigin\fR[2] must be 0\&. If \fIimage\fR is a 1D image array object, \fIorigin\fR[2] must be 0\&. If \fIimage\fR is a 1D image array object, \fIorigin\fR[1] describes the image index in the 1D image array\&. If \fIimage\fR is a 2D image array object, \fIorigin\fR[2] describes the image index in the 2D image array\&. .RE .PP \fI region \fR .RS 4 Defines the (\fIwidth, height, depth\fR) in pixels of the 1D, 2D or 3D rectangle, the (\fIwidth, height\fR) in pixels of the 2D rectangle and the number of images of a 2D image array or the (\fIwidth\fR) in pixels of the 1D rectangle and the number of images of a 1D image array\&. If \fIimage\fR is a 2D image object, \fIregion\fR[2] must be 1\&. If \fIimage\fR is a 1D image or 1D image buffer object, \fIregion\fR[1] and \fIregion\fR[2] must be 1\&. If image is a 1D image array object, \fIregion\fR[2] must be 1\&. .RE .PP \fI row_pitch \fR .RS 4 The length of each row in bytes\&. This value must be greater than or equal to the element size in bytes * \fIwidth\fR\&. If \fIrow_pitch\fR is set to 0, the appropriate row pitch is calculated based on the size of each element in bytes multiplied by \fIwidth\fR\&. .RE .PP \fI slice_pitch \fR .RS 4 Size in bytes of the 2D slice of the 3D region of a 3D image or each image of a 1D or 2D image array being read\&. This must be 0 if \fIimage\fR is a 1D or 2D image\&. This value must be greater than or equal to \fIrow_pitch\fR * \fIheight\fR\&. If \fIslice_pitch\fR is set to 0, the appropriate slice pitch is calculated based on the \fIrow_pitch\fR * \fIheight\fR\&. .RE .PP \fI ptr \fR .RS 4 The pointer to a buffer in host memory where image data is to be read from\&. .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 read 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 .SH "NOTES" .PP Calling \fBclEnqueueReadImage\fR to read a region of the \fIimage\fR with the \fIptr\fR argument value set to \fIhost_ptr\fR + (\fIorigin\fR[2] * \fIimage slice pitch\fR + \fIorigin\fR[1] * \fIimage row pitch\fR + \fIorigin\fR[0] * \fIbytes per pixel\fR), where \fIhost_ptr\fR is a pointer to the memory region specified when the \fIimage\fR being read 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 .\} All commands that use this image object have finished execution before the read command begins execution\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The \fIrow_pitch\fR and \fIslice_pitch\fR argument values in \fBclEnqueueReadImage\fR must be set to the image row pitch and slice pitch\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The image object is not mapped\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The image object is not used by any command\-queue until the read command has finished execution\&. .RE .SH "ERRORS" .PP \fBclEnqueueReadImage\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 \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 the region being read specified by \fIorigin\fR and \fIregion\fR is out of bounds or if \fIptr\fR is a NULL value\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if values in \fIorigin\fR and \fIregion\fR do not follow rules described in the argument description for \fIorigin\fR and \fIregion\fR\&. .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_INVALID_IMAGE_SIZE if image dimensions (image width, height, specified or compute row and/or slice pitch) for \fIimage\fR are not supported by 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_INVALID_IMAGE_FORMAT if image format (image channel order and data type) for \fIimage\fR are not supported by 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_MEM_OBJECT_ALLOCATION_FAILURE if there is a failure to allocate memory for data store associated with \fIimage\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if the device associated with \fIcommand_queue\fR does not support images (i\&.e\&. \fBCL_DEVICE_IMAGE_SUPPORT\fR specified in the table of allowed values for \fIparam_name\fR for \fBclGetDeviceInfo\fR(3clc) is \fBCL_FALSE\fR)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if \fBclEnqueueReadImage\fR is called on \fIimage\fR which has been created with \fBCL_MEM_HOST_WRITE_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_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_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 \fBclEnqueueWriteImage\fR(3clc), \fBclEnqueueCopyImage\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 98, section 5.3.3 - Reading, Writing and Copying Image Objects .RE