'\" t .\" Title: clCreateBuffer .\" 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 "CLCREATEBUFFER" "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" clCreateBuffer \- Creates a buffer object\&. .SH "" .HP \w'cl_mem\ clCreateBuffer('u .BI "cl_mem clCreateBuffer(cl_context\ " "context" ", cl_mem_flags\ " "flags" ", size_t\ " "size" ", void\ *" "host_ptr" ", cl_int\ *" "errcode_ret" ");" .SH "PARAMETERS" .PP \fIcontext\fR .RS 4 A valid OpenCL context used to create the buffer object\&. .RE .PP \fIflags\fR .RS 4 A bit\-field that is used to specify allocation and usage information such as the memory arena that should be used to allocate the buffer object and how it will be used\&. The following table describes the possible values for \fIflags\fR\&. If value specified for \fIflags\fR is 0, the default is used which is \fBCL_MEM_READ_WRITE\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 \fIsize\fR .RS 4 The size in bytes of the buffer memory object to be allocated\&. .RE .PP \fIhost_ptr\fR .RS 4 A pointer to the buffer data that may already be allocated by the application\&. The size of the buffer that \fIhost_ptr\fR points to must be ≥ \fIsize\fR bytes\&. .RE .PP \fIerrcode_ret\fR .RS 4 Returns an appropriate error code\&. If \fIerrcode_ret\fR is NULL, no error code is returned\&. .RE .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 a NULL value 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_CONTEXT if \fIcontext\fR is not a valid context\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if values specified in \fIflags\fR are not valid as defined in the table above\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_BUFFER_SIZE if \fIsize\fR is 0\&. Implementations may return \fBCL_INVALID_BUFFER_SIZE\fR if size is greater than the \fBCL_DEVICE_MAX_MEM_ALLOC_SIZE\fR value specified in the table of allowed values for \fIparam_name\fR for \fBclGetDeviceInfo\fR(3clc) for all devices in context\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_HOST_PTR if \fIhost_ptr\fR is NULL and \fBCL_MEM_USE_HOST_PTR\fR or \fBCL_MEM_COPY_HOST_PTR\fR are set in \fIflags\fR or if \fIhost_ptr\fR is not NULL but \fBCL_MEM_COPY_HOST_PTR\fR or \fBCL_MEM_USE_HOST_PTR\fR are not set in \fIflags\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 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 \fBclEnqueueReadBuffer\fR(3clc), \fBclEnqueueWriteBuffer\fR(3clc), \fBclEnqueueCopyBuffer\fR(3clc), \fBclCreateSubBuffer\fR(3clc), \fBclassDiagram\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 66, section 5.2.1 - Creating Buffer Objects .RE