'\" t .\" Title: clCreateSubBuffer .\" 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 "CLCREATESUBBUFFER" "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" clCreateSubBuffer \- Creates a new buffer object (referred to as a sub\-buffer object) from an existing buffer object\&. .SH "" .HP \w'cl_mem\ clCreateSubBuffer('u .BI "cl_mem clCreateSubBuffer(cl_mem\ " "buffer" ", cl_mem_flags\ " "flags" ", cl_buffer_create_type\ " "buffer_create_type" ", const\ void\ *" "buffer_create_info" ", cl_int\ *" "errcode_ret" ");" .SH "PARAMETERS" .PP \fIbuffer\fR .RS 4 A valid object and cannot be a sub\-buffer object\&. .RE .PP \fIflags\fR .RS 4 A bit\-field that is used to specify allocation and usage information about the sub\-buffer memory object being created and is described in the table below\&. If the \fBCL_MEM_READ_WRITE\fR, \fBCL_MEM_READ_ONLY\fR or \fBCL_MEM_WRITE_ONLY\fR values are not specified in \fIflags\fR, they are inherited from the corresponding memory access qualifers associated with \fIbuffer\fR\&. The \fBCL_MEM_USE_HOST_PTR\fR, \fBCL_MEM_ALLOC_HOST_PTR\fR and \fBCL_MEM_COPY_HOST_PTR\fR values cannot be specified in \fIflags\fR but are inherited from the corresponding memory access qualifiers associated with \fIbuffer\fR\&. If \fBCL_MEM_COPY_HOST_PTR\fR is specified in the memory access qualifier values associated with \fIbuffer\fR it does not imply any additional copies when the sub\-buffer is created from \fIbuffer\fR\&. If the \fBCL_MEM_HOST_WRITE_ONLY\fR, \fBCL_MEM_HOST_READ_ONLY\fR or \fBCL_MEM_HOST_NO_ACCESS\fR values are not specified in \fIflags\fR, they are inherited from the corresponding memory access qualifiers associated with \fIbuffer\fR\&. .TS allbox tab(:); lB lB. T{ cl_mem_flags T}:T{ Description T} .T& l l l l l l l l l l l l l l l l l l. T{ \fBCL_MEM_READ_WRITE\fR T}:T{ This flag specifies that the memory object will be read and written by a kernel\&. This is the default\&. T} T{ \fBCL_MEM_WRITE_ONLY\fR T}:T{ This flags specifies that the memory object will be written but not read by a kernel\&. .sp Reading from a buffer or image object created with \fBCL_MEM_WRITE_ONLY\fR inside a kernel is undefined\&. .sp \fBCL_MEM_READ_WRITE\fR and \fBCL_MEM_WRITE_ONLY\fR are mutually exclusive\&. T} T{ \fBCL_MEM_READ_ONLY\fR T}:T{ This flag specifies that the memory object is a read\-only memory object when used inside a kernel\&. .sp Writing to a buffer or image object created with \fBCL_MEM_READ_ONLY\fR inside a kernel is undefined\&. .sp \fBCL_MEM_READ_WRITE\fR or \fBCL_MEM_WRITE_ONLY\fR and \fBCL_MEM_READ_ONLY\fR are mutually exclusive\&. T} T{ \fBCL_MEM_USE_HOST_PTR\fR T}:T{ This flag is valid only if \fIhost_ptr\fR is not NULL\&. If specified, it indicates that the application wants the OpenCL implementation to use memory referenced by \fIhost_ptr\fR as the storage bits for the memory object\&. .sp OpenCL implementations are allowed to cache the buffer contents pointed to by \fIhost_ptr\fR in device memory\&. This cached copy can be used when kernels are executed on a device\&. .sp The result of OpenCL commands that operate on multiple buffer objects created with the same \fIhost_ptr\fR or overlapping host regions is considered to be undefined\&. .sp Refer to the \fBdataTypes\fR(3clc) for \fIhost_ptr\fR for memory objects (buffer and images) created using \fBCL_MEM_USE_HOST_PTR\fR\&. T} T{ \fBCL_MEM_ALLOC_HOST_PTR\fR T}:T{ This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory\&. .sp \fBCL_MEM_ALLOC_HOST_PTR\fR and \fBCL_MEM_USE_HOST_PTR\fR are mutually exclusive\&. T} T{ \fBCL_MEM_COPY_HOST_PTR\fR T}:T{ This flag is valid only if \fIhost_ptr\fR is not NULL\&. If specified, it indicates that the application wants the OpenCL implementation to allocate memory for the memory object and copy the data from memory referenced by \fIhost_ptr\fR\&. .sp \fBCL_MEM_COPY_HOST_PTR\fR and \fBCL_MEM_USE_HOST_PTR\fR are mutually exclusive\&. .sp \fBCL_MEM_COPY_HOST_PTR\fR can be used with \fBCL_MEM_ALLOC_HOST_PTR\fR to initialize the contents of the \fBcl_mem\fR object allocated using host\-accessible (e\&.g\&. PCIe) memory\&. T} T{ \fBCL_MEM_HOST_WRITE_ONLY\fR T}:T{ This flag specifies that the host will only write to the memory object (using OpenCL APIs that enqueue a write or a map for write)\&. This can be used to optimize write access from the host (e\&.g\&. enable write combined allocations for memory objects for devices that communicate with the host over a system bus such as PCIe)\&. T} T{ \fBCL_MEM_HOST_READ_ONLY\fR T}:T{ This flag specifies that the host will only read the memory object (using OpenCL APIs that enqueue a read or a map for read)\&. .sp \fBCL_MEM_HOST_WRITE_ONLY\fR and \fBCL_MEM_HOST_READ_ONLY\fR are mutually exclusive\&. T} T{ \fBCL_MEM_HOST_NO_ACCESS\fR T}:T{ This flag specifies that the host will not read or write the memory object\&. .sp \fBCL_MEM_HOST_WRITE_ONLY\fR or \fBCL_MEM_HOST_READ_ONLY\fR and \fBCL_MEM_HOST_NO_ACCESS\fR are mutually exclusive\&. T} .TE .sp 1 .RE .PP \fIbuffer_create_type\fR and \fIbuffer_create_info\fR .RS 4 Describes the type of buffer object to be created\&. The list of supported values for \fIbuffer_create_type\fR and corresponding descriptor that \fIbuffer_create_info\fR points to is described below\&. .TS allbox tab(:); lB lB. T{ cl_buffer_create_type T}:T{ Description T} .T& l l. T{ CL_BUFFER_CREATE_TYPE_REGION T}:T{ Create a buffer object that represents a specific region in \fIbuffer\fR\&. .sp \fIbuffer_create_info\fR is a pointer to the following structure: .if n \{\ .RS 4 .\} .nf typedef struct _cl_buffer_region { size_t origin; size_t size; } cl_buffer_region; .fi .if n \{\ .RE .\} .sp (\fIorigin, size\fR) defines the offset and size in bytes in \fIbuffer\fR\&. .sp If \fIbuffer\fR is created with \fBCL_MEM_USE_HOST_PTR\fR, the \fIhost_ptr\fR associated with the buffer object returned is \fIhost_ptr\fR + \fIorigin\fR\&. .sp The buffer object returned references the data store allocated for \fIbuffer\fR and points to a specific region given by (\fIorigin, size\fR) in this data store\&. .sp \fBCL_INVALID_VALUE\fR is returned in \fIerrcode_ret\fR if the region specified by (\fIorigin, size\fR) is out of bounds in \fIbuffer\fR\&. .sp \fBCL_INVALID_BUFFER_SIZE\fR if \fIsize\fR is 0\&. .sp \fBCL_MISALIGNED_SUB_BUFFER_OFFSET\fR is returned in \fIerrcode_ret\fR if there are no devices in context associated with \fIbuffer\fR for which the \fIorigin\fR value is aligned to the \fBCL_DEVICE_MEM_BASE_ADDR_ALIGN\fR value\&. T} .TE .sp 1 .RE .SH "NOTES" .PP Concurrent reading from, writing to and copying between both a buffer object and its sub\-buffer object(s) is undefined\&. Concurrent reading from, writing to and copying between overlapping sub\-buffer objects created with the same buffer object is undefined\&. Only reading from both a buffer object and its sub\-buffer objects or reading from multiple overlapping sub\-buffer objects is defined\&. .SH "ERRORS" .PP Returns a valid non\-zero buffer object and \fIerrcode_ret\fR is set to CL_SUCCESS if the buffer object is created successfully\&. Otherwise, it returns one of the following error in \fIerrcode_ret\fR: .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 or is a sub\-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 \fIbuffer\fR was created with \fBCL_MEM_WRITE_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_READ_WRITE\fR or \fBCL_MEM_READ_ONLY\fR, or if \fIbuffer\fR was created with \fBCL_MEM_READ_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_READ_WRITE\fR or \fBCL_MEM_WRITE_ONLY\fR, or if \fIflags\fR specifies \fBCL_MEM_USE_HOST_PTR\fR or \fBCL_MEM_ALLOC_HOST_PTR\fR or \fBCL_MEM_COPY_HOST_PTR\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if \fIbuffer\fR was created with \fBCL_MEM_HOST_WRITE_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_HOST_READ_ONLY\fR or if \fIbuffer\fR was created with \fBCL_MEM_HOST_READ_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_HOST_WRITE_ONLY\fR, or if \fIbuffer\fR was created with \fBCL_MEM_HOST_NO_ACCESS\fR and \fIflags\fR specifies \fBCL_MEM_HOST_READ_ONLY\fR or \fBCL_MEM_HOST_WRITE_ONLY\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if value specified in \fIbuffer_create_type\fR is not valid\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if value(s) specified in \fIbuffer_create_info\fR (for a given \fIbuffer_create_type\fR) is not valid or if \fIbuffer_create_info\fR is NULL\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_BUFFER_SIZE if size is 0\&. .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 sub\-buffer object\&. .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 \fBclCreateBuffer\fR(3clc), \fBclEnqueueReadBuffer\fR(3clc), \fBclEnqueueWriteBuffer\fR(3clc), \fBclEnqueueCopyBuffer\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 69, section 5.2.1 - Creating Buffer Objects .RE