System.GPU.OpenCL.Memory
Contents
- type CLMem = Ptr ()
- type CLSampler = Ptr ()
- data CLMemFlag
- data CLMemObjectType
- data CLAddressingMode
- data CLFilterMode
- clCreateBuffer :: Integral a => CLContext -> [CLMemFlag] -> (a, Ptr ()) -> IO CLMem
- clRetainMemObject :: CLMem -> IO Bool
- clReleaseMemObject :: CLMem -> IO Bool
- clGetMemType :: CLMem -> IO CLMemObjectType
- clGetMemFlags :: CLMem -> IO [CLMemFlag]
- clGetMemSize :: CLMem -> IO CSize
- clGetMemHostPtr :: CLMem -> IO (Ptr ())
- clGetMemMapCount :: CLMem -> IO CLuint
- clGetMemReferenceCount :: CLMem -> IO CLuint
- clGetMemContext :: CLMem -> IO CLContext
- clCreateSampler :: CLContext -> Bool -> CLAddressingMode -> CLFilterMode -> IO CLSampler
- clRetainSampler :: CLSampler -> IO Bool
- clReleaseSampler :: CLSampler -> IO Bool
- clGetSamplerReferenceCount :: CLSampler -> IO CLuint
- clGetSamplerContext :: CLSampler -> IO CLContext
- clGetSamplerAddressingMode :: CLSampler -> IO CLAddressingMode
- clGetSamplerFilterMode :: CLSampler -> IO CLFilterMode
- clGetSamplerNormalizedCoords :: CLSampler -> IO Bool
Types
-
CL_MEM_READ_WRITE, This flag specifies that the memory object will be read and written by a kernel. This is the default. -
CL_MEM_WRITE_ONLY, This flags specifies that the memory object will be written but not read by a kernel. Reading from a buffer or image object created withCLMEM_WRITE_ONLYinside a kernel is undefined. -
CL_MEM_READ_ONLY, This flag specifies that the memory object is a read-only memory object when used inside a kernel. Writing to a buffer or image object created withCLMEM_READ_ONLYinside a kernel is undefined. -
CL_MEM_USE_HOST_PTR, This flag is valid only if host_ptr is not NULL. If specified, it indicates that the application wants the OpenCL implementation to use memory referenced by host_ptr as the storage bits for the memory object. OpenCL implementations are allowed to cache the buffer contents pointed to by host_ptr in device memory. This cached copy can be used when kernels are executed on a device. The result of OpenCL commands that operate on multiple buffer objects created with the same host_ptr or overlapping host regions is considered to be undefined. -
CL_MEM_ALLOC_HOST_PTR, This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory.CL_MEM_ALLOC_HOST_PTRandCL_MEM_USE_HOST_PTRare mutually exclusive. -
CL_MEM_COPY_HOST_PTR, This flag is valid only if host_ptr 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 host_ptr.CL_MEM_COPY_HOST_PTRandCL_MEM_USE_HOST_PTRare mutually exclusive.CL_MEM_COPY_HOST_PTRcan be used withCL_MEM_ALLOC_HOST_PTRto initialize the contents of the cl_mem object allocated using host-accessible (e.g. PCIe) memory.
data CLMemObjectType Source
-
CL_MEM_OBJECT_BUFFERif memobj is created withclCreateBuffer. -
CL_MEM_OBJECT_IMAGE2Dif memobj is created withclCreateImage2D -
CL_MEM_OBJECT_IMAGE3Dif memobj is created withclCreateImage3D.
Instances
data CLAddressingMode Source
Instances
Memory Functions
clCreateBuffer :: Integral a => CLContext -> [CLMemFlag] -> (a, Ptr ()) -> IO CLMemSource
Creates a buffer object. Returns a valid non-zero buffer object if the
buffer object is created successfully. Otherwise, it throws the CLError:
-
CL_INVALID_CONTEXTif context is not a valid context. -
CL_INVALID_VALUEif values specified in flags are not valid. -
CL_INVALID_BUFFER_SIZEif size is 0 or is greater thanclDeviceMaxMemAllocSizevalue for all devices in context. -
CL_INVALID_HOST_PTRif host_ptr is NULL andCL_MEM_USE_HOST_PTRorCL_MEM_COPY_HOST_PTRare set in flags or if host_ptr is not NULL butCL_MEM_COPY_HOST_PTRorCL_MEM_USE_HOST_PTRare not set in flags. -
CL_MEM_OBJECT_ALLOCATION_FAILUREif there is a failure to allocate memory for buffer object. -
CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
clRetainMemObject :: CLMem -> IO BoolSource
Increments the memory object reference count. returns True if the
function is executed successfully. After the memobj reference count becomes
zero and commands queued for execution on a command-queue(s) that use memobj
have finished, the memory object is deleted. It returns False if memobj is
not a valid memory object.
clReleaseMemObject :: CLMem -> IO BoolSource
Decrements the memory object reference count. After the memobj reference
count becomes zero and commands queued for execution on a command-queue(s)
that use memobj have finished, the memory object is deleted. Returns True
if the function is executed successfully. It returns False if memobj is not
a valid memory object.
clGetMemType :: CLMem -> IO CLMemObjectTypeSource
Returns the mem object type.
This function execute OpenCL clGetMemObjectInfo with CL_MEM_TYPE.
clGetMemFlags :: CLMem -> IO [CLMemFlag]Source
Return the flags argument value specified when memobj was created.
This function execute OpenCL clGetMemObjectInfo with CL_MEM_FLAGS.
clGetMemSize :: CLMem -> IO CSizeSource
Return actual size of memobj in bytes.
This function execute OpenCL clGetMemObjectInfo with CL_MEM_SIZE.
clGetMemHostPtr :: CLMem -> IO (Ptr ())Source
Return the host_ptr argument value specified when memobj is created.
This function execute OpenCL clGetMemObjectInfo with CL_MEM_HOST_PTR.
clGetMemMapCount :: CLMem -> IO CLuintSource
Map count. The map count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for debugging.
This function execute OpenCL clGetMemObjectInfo with CL_MEM_MAP_COUNT.
clGetMemReferenceCount :: CLMem -> IO CLuintSource
Return memobj reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.
This function execute OpenCL clGetMemObjectInfo with CL_MEM_REFERENCE_COUNT.
clGetMemContext :: CLMem -> IO CLContextSource
Return context specified when memory object is created.
This function execute OpenCL clGetMemObjectInfo with CL_MEM_CONTEXT.
Sampler Functions
clCreateSampler :: CLContext -> Bool -> CLAddressingMode -> CLFilterMode -> IO CLSamplerSource
Creates a sampler object. A sampler object describes how to sample an image when the image is read in the kernel. The built-in functions to read from an image in a kernel take a sampler as an argument. The sampler arguments to the image read function can be sampler objects created using OpenCL functions and passed as argument values to the kernel or can be samplers declared inside a kernel. In this section we discuss how sampler objects are created using OpenCL functions.
Returns a valid non-zero sampler object if the sampler object is created
successfully. Otherwise, it throws one of the following CLError exceptions:
-
CL_INVALID_CONTEXTif context is not a valid context. -
CL_INVALID_VALUEif addressing_mode, filter_mode, or normalized_coords or a combination of these argument values are not valid. -
CL_INVALID_OPERATIONif images are not supported by any device associated with context (i.e.CL_DEVICE_IMAGE_SUPPORTspecified in the table of OpenCL Device Queries for clGetDeviceInfo isFalse). -
CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
clRetainSampler :: CLSampler -> IO BoolSource
Increments the sampler reference count. clCreateSampler does an implicit
retain. Returns True if the function is executed successfully. It returns
False if sampler is not a valid sampler object.
clReleaseSampler :: CLSampler -> IO BoolSource
Decrements the sampler reference count. The sampler object is deleted after
the reference count becomes zero and commands queued for execution on a
command-queue(s) that use sampler have finished. clReleaseSampler returns
True if the function is executed successfully. It returns False if
sampler is not a valid sampler object.
clGetSamplerReferenceCount :: CLSampler -> IO CLuintSource
Return the sampler reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.
This function execute OpenCL clGetSamplerInfo with
CL_SAMPLER_REFERENCE_COUNT.
clGetSamplerContext :: CLSampler -> IO CLContextSource
Return the context specified when the sampler is created.
This function execute OpenCL clGetSamplerInfo with CL_SAMPLER_CONTEXT.
clGetSamplerAddressingMode :: CLSampler -> IO CLAddressingModeSource
Return the value specified by addressing_mode argument to clCreateSampler.
This function execute OpenCL clGetSamplerInfo with
CL_SAMPLER_ADDRESSING_MODE.
clGetSamplerFilterMode :: CLSampler -> IO CLFilterModeSource
Return the value specified by filter_mode argument to clCreateSampler.
This function execute OpenCL clGetSamplerInfo with CL_SAMPLER_FILTER_MODE.
clGetSamplerNormalizedCoords :: CLSampler -> IO BoolSource
Return the value specified by normalized_coords argument to clCreateSampler.
This function execute OpenCL clGetSamplerInfo with
CL_SAMPLER_NORMALIZED_COORDS.