Memory objects are encapsulated by cl_mem
data structure. The two important functions to create a memory object are as follows:
cl_mem clCreateBuffer (cl_context context,cl_mem_flags flags,size_t size,void *host_ptr,cl_int *errcode_ret) cl_mem clCreateImage (cl_context context,cl_mem_flags flags,const cl_image_format *image_format,const cl_image_desc *image_desc,void *host_ptr,cl_int *errcode_ret)
Note that both the buffer and image data objects are of type cl_mem
and these objects form the most important basic component in OpenCL. Both these functions return the cl_mem
objects and the type of memory is specified by the flags variable of type cl_mem_flags
. For comparison purpose the clCreateImage
function is shown here. More details of this will be discussed in the next chapter. The possible values for the cl_mem_flags
flags are shown in the following table: