1: Create the cache object
cl_mem clCreateBuffer(
cl_context context, // context
cl_mem_flags flags, // memory property of the object tag
size_t size, // size
void * host_ptr, // host address
cl_int * errcode_ret // error code
)
Nature Tags:
CL_MEM_READ_WRITE specified kernel object to read and write by the kernel
CL_MEM_WRITE_ONLY specified kernel object only by the kernel to write
CL_MEM_READ_ONLY specified kernel object read-only by the kernel
CL_MEM_ALLOC_HOST_PTR specified buffer should be allocated in memory accessible by the host, can not be used with the next properties
Memory bit CL_MEM_USE_HOST_PTR implemented using host_ptr referenced memory as memory objects
CL_MEM_COPY_HOST_PTR memory allocation of memory to achieve the object, and copy data to hst_ptr referenced from, and not be used with the one property. Can CL_MEM_ALLOC_HOST_PTR, initialize the contents of these objects. And host_ptr is not NULL
2: Creating a sub-cache object
cl_mem clCreateSubBuffer(
cl_mem buffer, // cache object
cl_mem_flags flags, // property of the object
cl_buffer_create_type buffer_create_type,//CL_BUFFER_CREATE_TYPE_ORGIN
const void * buffer_create_info, // cache data creation information
cl_int * errcode_ret // Error Codes
)
Creating cache data structure: (buffer_create_info)
typedef struct _cl_buffer_region{
size_t origin;
size_t size;
}cl_buffer_region;
3: Get information about the object cache
cl_int clGetMemObjectInfo(
cl_mem memobj, // cache object
cl_mem_info param_name, // Information Type Name
size_t param_value_size, // size to obtain relevant information
void * param_value, // cache information storage address
size_t param_value_size_ret // get the actual size of the information
)