The cl_mem type is a handle to the "Memory Object" (as described in Section 3.5 of the OpenCL 1.1 Spec ). These are essentially inputs and outputs for OpenCL cores and are returned from OpenCL API calls to host code such as clCreateBuffer
cl_mem clCreateBuffer (cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_int *errcode_ret)
In the presented memory areas, various access patterns may be allowed, for example. Only reading or allocating in different memory areas depending on the flags set in the buffer creation calls.
Typically, the handle is stored to allow a later call to free memory, for example:
cl_int clReleaseMemObject (cl_mem memobj)
In short, it provides an abstraction over where the memory actually resides: you can copy data to the appropriate memory or return via the OpenCL API clEnqueueWriteBuffer and clEnqueueReadBuffer, but the OpenCL implementation can allocate the space in which it wants.
source share