-- GENERATED by C->Haskell Compiler, version 0.16.3 Crystal Seed, 24 Jan 2009 (Haskell)-- Edit the ORIGNAL .chs file instead!{-# LINE 1 "src/System/GPU/OpenCL/Memory.chs" #-}{- Copyright (c) 2011 Luis Cabellos,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-}{-# LANGUAGE ForeignFunctionInterface, ScopedTypeVariables, CPP #-}moduleSystem.GPU.OpenCL.Memory(-- * TypesCLMem,CLSampler,CLMemFlag(..),CLMemObjectType(..),CLAddressingMode(..),CLFilterMode(..),-- * Memory FunctionsclCreateBuffer,clRetainMemObject,clReleaseMemObject,clGetMemType,clGetMemFlags,clGetMemSize,clGetMemHostPtr,clGetMemMapCount,clGetMemReferenceCount,clGetMemContext,-- * Sampler FunctionsclCreateSampler,clRetainSampler,clReleaseSampler,clGetSamplerReferenceCount,clGetSamplerContext,clGetSamplerAddressingMode,clGetSamplerFilterMode,clGetSamplerNormalizedCoords)where-- -----------------------------------------------------------------------------importForeignimportForeign.C.TypesimportSystem.GPU.OpenCL.Types(CLMem,CLContext,CLSampler,CLint,CLuint,CLbool,CLMemFlags_,CLMemInfo_,CLAddressingMode_,CLFilterMode_,CLSamplerInfo_,CLAddressingMode(..),CLFilterMode(..),CLMemFlag(..),CLMemObjectType_,CLMemObjectType(..),wrapPError,wrapCheckSuccess,wrapGetInfo,getEnumCL,bitmaskFromFlags,bitmaskToMemFlags,getCLValue)-- -----------------------------------------------------------------------------foreignimportCALLCONV"clCreateBuffer"raw_clCreateBuffer::CLContext->CLMemFlags_->CSize->Ptr()->PtrCLint->IOCLMem--foreign import CALLCONV "clCreateImage2D" raw_clCreateImage2D :: -- CLContext -> CLMemFlags_ -> CLImageFormat_p -> CSize -> CSize -> CSize -- -> Ptr () -> Ptr CLint -> IO CLMem--foreign import CALLCONV "clCreateImage3D" raw_clCreateImage3D :: -- CLContext -> CLMemFlags_-> CLImageFormat_p -> CSize -> CSize -> CSize -> CSize -- -> CSize -> Ptr () -> Ptr CLint -> IO CLMemforeignimportCALLCONV"clRetainMemObject"raw_clRetainMemObject::CLMem->IOCLintforeignimportCALLCONV"clReleaseMemObject"raw_clReleaseMemObject::CLMem->IOCLint--foreign import CALLCONV "clGetSupportedImageFormats" raw_clGetSupportedImageFormats :: -- CLContext -> CLMemFlags_ -> CLMemObjectType_ -> CLuint -> CLImageFormat_p -- -> Ptr CLuint -> IO CLintforeignimportCALLCONV"clGetMemObjectInfo"raw_clGetMemObjectInfo::CLMem->CLMemInfo_->CSize->Ptr()->PtrCSize->IOCLint--foreign import CALLCONV "clGetImageInfo" raw_clGetImageInfo :: -- CLMem -> CLImageInfo_ -> CSize -> Ptr () -> Ptr CSize -> IO CLintforeignimportCALLCONV"clCreateSampler"raw_clCreateSampler::CLContext->CLbool->CLAddressingMode_->CLFilterMode_->PtrCLint->IOCLSamplerforeignimportCALLCONV"clRetainSampler"raw_clRetainSampler::CLSampler->IOCLintforeignimportCALLCONV"clReleaseSampler"raw_clReleaseSampler::CLSampler->IOCLintforeignimportCALLCONV"clGetSamplerInfo"raw_clGetSamplerInfo::CLSampler->CLSamplerInfo_->CSize->Ptr()->PtrCSize->IOCLint-- -----------------------------------------------------------------------------{-| 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_CONTEXT' if context is not a valid context.
* 'CL_INVALID_VALUE' if values specified in flags are not valid.
* 'CL_INVALID_BUFFER_SIZE' if size is 0 or is greater than
'clDeviceMaxMemAllocSize' value for all devices in context.
* 'CL_INVALID_HOST_PTR' if host_ptr is NULL and 'CL_MEM_USE_HOST_PTR' or
'CL_MEM_COPY_HOST_PTR' are set in flags or if host_ptr is not NULL but
'CL_MEM_COPY_HOST_PTR' or 'CL_MEM_USE_HOST_PTR' are not set in flags.
* 'CL_MEM_OBJECT_ALLOCATION_FAILURE' if there is a failure to allocate memory
for buffer object.
* 'CL_OUT_OF_HOST_MEMORY' if there is a failure to allocate resources required
by the OpenCL implementation on the host.
-}clCreateBuffer::Integrala=>CLContext->[CLMemFlag]->(a,Ptr())->IOCLMemclCreateBufferctxxs(sbuff,buff)=wrapPError$\perr->doraw_clCreateBufferctxflags(fromIntegralsbuff)buffperrwhereflags=bitmaskFromFlagsxs-- | 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.clRetainMemObject::CLMem->IOBoolclRetainMemObjectmem=wrapCheckSuccess$raw_clRetainMemObjectmem-- | 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.clReleaseMemObject::CLMem->IOBoolclReleaseMemObjectmem=wrapCheckSuccess$raw_clReleaseMemObjectmemdataCLMemInfo=CL_MEM_TYPE|CL_MEM_FLAGS|CL_MEM_SIZE|CL_MEM_HOST_PTR|CL_MEM_MAP_COUNT|CL_MEM_REFERENCE_COUNT|CL_MEM_CONTEXTinstanceEnumCLMemInfowherefromEnumCL_MEM_TYPE=4352fromEnumCL_MEM_FLAGS=4353fromEnumCL_MEM_SIZE=4354fromEnumCL_MEM_HOST_PTR=4355fromEnumCL_MEM_MAP_COUNT=4356fromEnumCL_MEM_REFERENCE_COUNT=4357fromEnumCL_MEM_CONTEXT=4358toEnum4352=CL_MEM_TYPEtoEnum4353=CL_MEM_FLAGStoEnum4354=CL_MEM_SIZEtoEnum4355=CL_MEM_HOST_PTRtoEnum4356=CL_MEM_MAP_COUNTtoEnum4357=CL_MEM_REFERENCE_COUNTtoEnum4358=CL_MEM_CONTEXTtoEnumunmatched=error("CLMemInfo.toEnum: Cannot match "++showunmatched){-# LINE 143 "src/System/GPU/OpenCL/Memory.chs" #-}-- | Returns the mem object type.---- This function execute OpenCL clGetMemObjectInfo with 'CL_MEM_TYPE'.clGetMemType::CLMem->IOCLMemObjectTypeclGetMemTypemem=wrapGetInfo(\(dat::PtrCLMemObjectType_)->raw_clGetMemObjectInfomeminfoidsize(castPtrdat))getEnumCLwhereinfoid=getCLValueCL_MEM_TYPEsize=fromIntegral$sizeOf(0::CLMemObjectType_)-- | Return the flags argument value specified when memobj was created.---- This function execute OpenCL clGetMemObjectInfo with 'CL_MEM_FLAGS'.clGetMemFlags::CLMem->IO[CLMemFlag]clGetMemFlagsmem=wrapGetInfo(\(dat::PtrCLMemFlags_)->raw_clGetMemObjectInfomeminfoidsize(castPtrdat))bitmaskToMemFlagswhereinfoid=getCLValueCL_MEM_FLAGSsize=fromIntegral$sizeOf(0::CLMemFlags_)-- | Return actual size of memobj in bytes.---- This function execute OpenCL clGetMemObjectInfo with 'CL_MEM_SIZE'.clGetMemSize::CLMem->IOCSizeclGetMemSizemem=wrapGetInfo(\(dat::PtrCSize)->raw_clGetMemObjectInfomeminfoidsize(castPtrdat))idwhereinfoid=getCLValueCL_MEM_SIZEsize=fromIntegral$sizeOf(0::CSize)-- | Return the host_ptr argument value specified when memobj is created.---- This function execute OpenCL clGetMemObjectInfo with 'CL_MEM_HOST_PTR'.clGetMemHostPtr::CLMem->IO(Ptr())clGetMemHostPtrmem=wrapGetInfo(\(dat::Ptr(Ptr()))->raw_clGetMemObjectInfomeminfoidsize(castPtrdat))idwhereinfoid=getCLValueCL_MEM_HOST_PTRsize=fromIntegral$sizeOf(nullPtr::Ptr())-- | 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'.clGetMemMapCount::CLMem->IOCLuintclGetMemMapCountmem=wrapGetInfo(\(dat::PtrCLuint)->raw_clGetMemObjectInfomeminfoidsize(castPtrdat))idwhereinfoid=getCLValueCL_MEM_MAP_COUNTsize=fromIntegral$sizeOf(0::CLuint)-- | 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'.clGetMemReferenceCount::CLMem->IOCLuintclGetMemReferenceCountmem=wrapGetInfo(\(dat::PtrCLuint)->raw_clGetMemObjectInfomeminfoidsize(castPtrdat))idwhereinfoid=getCLValueCL_MEM_REFERENCE_COUNTsize=fromIntegral$sizeOf(0::CLuint)-- | Return context specified when memory object is created.---- This function execute OpenCL clGetMemObjectInfo with 'CL_MEM_CONTEXT'.clGetMemContext::CLMem->IOCLContextclGetMemContextmem=wrapGetInfo(\(dat::PtrCLContext)->raw_clGetMemObjectInfomeminfoidsize(castPtrdat))idwhereinfoid=getCLValueCL_MEM_CONTEXTsize=fromIntegral$sizeOf(0::CLuint)-- -----------------------------------------------------------------------------{-| 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_CONTEXT' if context is not a valid context.
* 'CL_INVALID_VALUE' if addressing_mode, filter_mode, or normalized_coords or a
combination of these argument values are not valid.
* 'CL_INVALID_OPERATION' if images are not supported by any device associated
with context (i.e. 'CL_DEVICE_IMAGE_SUPPORT' specified in the table of OpenCL
Device Queries for clGetDeviceInfo is 'False').
* 'CL_OUT_OF_HOST_MEMORY' if there is a failure to allocate resources required
by the OpenCL implementation on the host.
-}clCreateSampler::CLContext->Bool->CLAddressingMode->CLFilterMode->IOCLSamplerclCreateSamplerctxnormamfm=wrapPError$\perr->doraw_clCreateSamplerctx(fromBoolnorm)(getCLValueam)(getCLValuefm)perr-- | 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.clRetainSampler::CLSampler->IOBoolclRetainSamplermem=wrapCheckSuccess$raw_clRetainSamplermem-- | 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.clReleaseSampler::CLSampler->IOBoolclReleaseSamplermem=wrapCheckSuccess$raw_clReleaseSamplermemdataCLSamplerInfo=CL_SAMPLER_REFERENCE_COUNT|CL_SAMPLER_CONTEXT|CL_SAMPLER_ADDRESSING_MODE|CL_SAMPLER_FILTER_MODE|CL_SAMPLER_NORMALIZED_COORDSinstanceEnumCLSamplerInfowherefromEnumCL_SAMPLER_REFERENCE_COUNT=4432fromEnumCL_SAMPLER_CONTEXT=4433fromEnumCL_SAMPLER_ADDRESSING_MODE=4435fromEnumCL_SAMPLER_FILTER_MODE=4436fromEnumCL_SAMPLER_NORMALIZED_COORDS=4434toEnum4432=CL_SAMPLER_REFERENCE_COUNTtoEnum4433=CL_SAMPLER_CONTEXTtoEnum4435=CL_SAMPLER_ADDRESSING_MODEtoEnum4436=CL_SAMPLER_FILTER_MODEtoEnum4434=CL_SAMPLER_NORMALIZED_COORDStoEnumunmatched=error("CLSamplerInfo.toEnum: Cannot match "++showunmatched){-# LINE 278 "src/System/GPU/OpenCL/Memory.chs" #-}-- | 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'.clGetSamplerReferenceCount::CLSampler->IOCLuintclGetSamplerReferenceCountsam=wrapGetInfo(\(dat::PtrCLuint)->raw_clGetSamplerInfosaminfoidsize(castPtrdat))idwhereinfoid=getCLValueCL_SAMPLER_REFERENCE_COUNTsize=fromIntegral$sizeOf(0::CLuint)-- | Return the context specified when the sampler is created.---- This function execute OpenCL clGetSamplerInfo with 'CL_SAMPLER_CONTEXT'.clGetSamplerContext::CLSampler->IOCLContextclGetSamplerContextsam=wrapGetInfo(\(dat::PtrCLContext)->raw_clGetSamplerInfosaminfoidsize(castPtrdat))idwhereinfoid=getCLValueCL_SAMPLER_CONTEXTsize=fromIntegral$sizeOf(nullPtr::CLContext)-- | Return the value specified by addressing_mode argument to clCreateSampler.---- This function execute OpenCL clGetSamplerInfo with-- 'CL_SAMPLER_ADDRESSING_MODE'.clGetSamplerAddressingMode::CLSampler->IOCLAddressingModeclGetSamplerAddressingModesam=wrapGetInfo(\(dat::PtrCLAddressingMode_)->raw_clGetSamplerInfosaminfoidsize(castPtrdat))getEnumCLwhereinfoid=getCLValueCL_SAMPLER_ADDRESSING_MODEsize=fromIntegral$sizeOf(0::CLAddressingMode_)-- | Return the value specified by filter_mode argument to clCreateSampler.---- This function execute OpenCL clGetSamplerInfo with 'CL_SAMPLER_FILTER_MODE'.clGetSamplerFilterMode::CLSampler->IOCLFilterModeclGetSamplerFilterModesam=wrapGetInfo(\(dat::PtrCLFilterMode_)->raw_clGetSamplerInfosaminfoidsize(castPtrdat))getEnumCLwhereinfoid=getCLValueCL_SAMPLER_FILTER_MODEsize=fromIntegral$sizeOf(0::CLFilterMode_)-- | Return the value specified by normalized_coords argument to-- clCreateSampler.---- This function execute OpenCL clGetSamplerInfo with-- 'CL_SAMPLER_NORMALIZED_COORDS'.clGetSamplerNormalizedCoords::CLSampler->IOBoolclGetSamplerNormalizedCoordssam=wrapGetInfo(\(dat::PtrCLbool)->raw_clGetSamplerInfosaminfoidsize(castPtrdat))(/=0)whereinfoid=getCLValueCL_SAMPLER_NORMALIZED_COORDSsize=fromIntegral$sizeOf(0::CLbool)-- -----------------------------------------------------------------------------