As any other OpenCL objects, cl_mem objects can be queried to return information regarding how they are constructed, their status, reference count, and so on. The OpenCL function clGetMemObjectInfo
helps in this.
cl_int clGetMemObjectInfo (cl_mem memobj,cl_mem_info param_name,size_t param_value_size,void *param_value,size_t *param_value_size_ret)
This function is similar to the clGetDeviceInfo
discussed in Chapter 2, OpenCL Architecture. The param_name
is a parameter specific to this function and is of type cl_mem_info
. It can be used for both image and buffer type cl_mem
objects. The following code snippet shows you how to retrieve the flags associated with a cl_mem
object.
// Create memory buffers on the device for each vector cl_mem A_clmem = clCreateBuffer(context,CL_MEM_READ_ONLY|CL_MEM_USE_HOST_PTR,VECTOR_SIZE * sizeof(float), A_ptr, &clStatus); ... ... ... cl_mem_flags flags; clStatus = clGetMemObjectInfo (A_clmem,CL_MEM_FLAGS,sizeof(cl_mem_flags),&flags...