module System.GPU.OpenCL.Query(
CLPlatformInfo(..), CLPlatformID, CLDeviceID, CLDeviceType(..),
CLDeviceFPConfig(..), CLDeviceExecCapability(..), CLDeviceLocalMemType(..),
CLDeviceMemCacheType(..),
clGetPlatformIDs, clGetPlatformInfo,
clGetDeviceIDs, clGetDeviceExecutionCapabilities,
clGetDeviceAddressBits, clGetDeviceAvailable, clGetDeviceCompilerAvailable,
clGetDeviceEndianLittle, clGetDeviceErrorCorrectionSupport,
clGetDeviceExtensions, clGetDeviceGlobalMemCacheSize,
clGetDeviceGlobalMemCachelineSize, clGetDeviceGlobalMemSize,
clGetDeviceImageSupport, clGetDeviceImage2DMaxHeight,
clGetDeviceImage2DMaxWidth, clGetDeviceImage3DMaxDepth,
clGetDeviceImage3DMaxHeight, clGetDeviceImage3DMaxWidth,
clGetDeviceLocalMemSize, clGetDeviceMaxClockFrequency,
clGetDeviceMaxComputeUnits, clGetDeviceMaxConstantArgs,
clGetDeviceMaxConstantBufferSize, clGetDeviceMaxMemAllocSize,
clGetDeviceMaxParameterSize, clGetDeviceMaxReadImageArgs,
clGetDeviceMaxSamplers, clGetDeviceMaxWorkGroupSize,
clGetDeviceMaxWorkItemDimensions, clGetDeviceMaxWorkItemSizes,
clGetDeviceMaxWriteImageArgs, clGetDeviceMemBaseAddrAlign,
clGetDeviceMinDataTypeAlignSize, clGetDeviceName, clGetDevicePlatform,
clGetDevicePreferredVectorWidthChar, clGetDevicePreferredVectorWidthShort,
clGetDevicePreferredVectorWidthInt, clGetDevicePreferredVectorWidthLong,
clGetDevicePreferredVectorWidthFloat, clGetDevicePreferredVectorWidthDouble,
clGetDeviceProfile, clGetDeviceProfilingTimerResolution, clGetDeviceVendor,
clGetDeviceVendorID, clGetDeviceVersion, clGetDeviceDriverVersion,
clGetDeviceSingleFPConfig, clGetDeviceDoubleFPConfig,
clGetDeviceHalfFPConfig, clGetDeviceLocalMemType,
clGetDeviceGlobalMemCacheType, clGetDeviceQueueProperties, clGetDeviceType )
where
import Foreign( Ptr, nullPtr, castPtr, alloca, allocaArray, peek, peekArray )
import Foreign.C.String( CString, peekCString )
import Foreign.C.Types( CSize )
import Foreign.Storable( sizeOf )
import System.GPU.OpenCL.Types(
CLbool, CLint, CLuint, CLulong, CLPlatformInfo_, CLDeviceType_,
CLDeviceInfo_, CLDeviceFPConfig(..), CLDeviceExecCapability(..),
CLDeviceLocalMemType(..), CLDeviceMemCacheType(..), CLPlatformInfo(..),
CLPlatformID, CLDeviceID, CLDeviceType(..), CLCommandQueueProperty,
getCLValue, getEnumCL, bitmaskToDeviceTypes, bitmaskToCommandQueueProperties,
whenSuccess, bitmaskToFPConfig, bitmaskToExecCapability )
foreign import CALLCONV "clGetPlatformIDs" raw_clGetPlatformIDs ::
CLuint -> Ptr CLPlatformID -> Ptr CLuint -> IO CLint
foreign import CALLCONV "clGetPlatformInfo" raw_clGetPlatformInfo ::
CLPlatformID -> CLPlatformInfo_ -> CSize -> Ptr () -> Ptr CSize -> IO CLint
foreign import CALLCONV "clGetDeviceIDs" raw_clGetDeviceIDs ::
CLPlatformID -> CLDeviceType_ -> CLuint -> Ptr CLDeviceID -> Ptr CLuint -> IO CLint
foreign import CALLCONV "clGetDeviceInfo" raw_clGetDeviceInfo ::
CLDeviceID -> CLDeviceInfo_ -> CSize -> Ptr () -> Ptr CSize -> IO CLint
getNumPlatforms :: IO CLuint
getNumPlatforms = alloca $ \(num_platforms :: Ptr CLuint) -> do
whenSuccess (raw_clGetPlatformIDs 0 nullPtr num_platforms)
$ peek num_platforms
clGetPlatformIDs :: IO [CLPlatformID]
clGetPlatformIDs = do
nplats <- getNumPlatforms
allocaArray (fromIntegral nplats) $ \(plats :: Ptr CLPlatformID) -> do
whenSuccess (raw_clGetPlatformIDs nplats plats nullPtr)
$ peekArray (fromIntegral nplats) plats
getPlatformInfoSize :: CLPlatformID -> CLuint -> IO CSize
getPlatformInfoSize platform infoid = alloca $ \(value_size :: Ptr CSize) -> do
whenSuccess (raw_clGetPlatformInfo platform infoid 0 nullPtr value_size)
$ peek value_size
clGetPlatformInfo :: CLPlatformID -> CLPlatformInfo -> IO String
clGetPlatformInfo platform infoid = do
sval <- getPlatformInfoSize platform infocl
allocaArray (fromIntegral sval) $ \(buff :: CString) -> do
whenSuccess (raw_clGetPlatformInfo platform infocl sval (castPtr buff) nullPtr)
$ peekCString buff
where
infocl = getCLValue infoid
getNumDevices :: CLPlatformID -> CLDeviceType_ -> IO CLuint
getNumDevices platform dtype = alloca $ \(num_devices :: Ptr CLuint) -> do
whenSuccess (raw_clGetDeviceIDs platform dtype 0 nullPtr num_devices)
$ peek num_devices
clGetDeviceIDs :: CLPlatformID -> CLDeviceType -> IO [CLDeviceID]
clGetDeviceIDs platform dtype = do
ndevs <- getNumDevices platform dval
allocaArray (fromIntegral ndevs) $ \(devs :: Ptr CLDeviceID) -> do
whenSuccess (raw_clGetDeviceIDs platform dval ndevs devs nullPtr)
$ peekArray (fromIntegral ndevs) devs
where
dval = getCLValue dtype
getDeviceInfoSize :: CLDeviceID -> CLDeviceInfo_ -> IO CSize
getDeviceInfoSize device infoid = alloca $ \(value_size :: Ptr CSize) -> do
whenSuccess (raw_clGetDeviceInfo device infoid 0 nullPtr value_size)
$ peek value_size
getDeviceInfoString :: CLDeviceInfo_ -> CLDeviceID -> IO String
getDeviceInfoString infoid device = do
n <- getDeviceInfoSize device infoid
allocaArray (fromIntegral n) $ \(buff :: CString) -> do
whenSuccess (raw_clGetDeviceInfo device infoid n (castPtr buff) nullPtr)
$ peekCString buff
getDeviceInfoUint :: CLDeviceInfo_ -> CLDeviceID -> IO CLuint
getDeviceInfoUint infoid device = alloca $ \(dat :: Ptr CLuint) -> do
whenSuccess (raw_clGetDeviceInfo device infoid size (castPtr dat) nullPtr)
$ peek dat
where
size = fromIntegral $ sizeOf (0::CLuint)
getDeviceInfoUlong :: CLDeviceInfo_ -> CLDeviceID -> IO CLulong
getDeviceInfoUlong infoid device = alloca $ \(dat :: Ptr CLulong) -> do
whenSuccess (raw_clGetDeviceInfo device infoid size (castPtr dat) nullPtr)
$ peek dat
where
size = fromIntegral $ sizeOf (0::CLulong)
getDeviceInfoSizet :: CLDeviceInfo_ -> CLDeviceID -> IO CSize
getDeviceInfoSizet infoid device = alloca $ \(dat :: Ptr CSize) -> do
whenSuccess (raw_clGetDeviceInfo device infoid size (castPtr dat) nullPtr)
$ peek dat
where
size = fromIntegral $ sizeOf (0::CSize)
getDeviceInfoBool :: CLDeviceInfo_ -> CLDeviceID -> IO Bool
getDeviceInfoBool infoid device = alloca $ \(dat :: Ptr CLbool) -> do
whenSuccess (raw_clGetDeviceInfo device infoid size (castPtr dat) nullPtr)
$ peek dat >>= return . (/=0)
where
size = fromIntegral $ sizeOf (0::CLbool)
getDeviceInfoFP :: CLDeviceInfo_ -> CLDeviceID -> IO [CLDeviceFPConfig]
getDeviceInfoFP infoid device = do
flags <- getDeviceInfoUlong infoid device
return . bitmaskToFPConfig $ flags
data CLDeviceInfo = CL_DEVICE_ADDRESS_BITS
| CL_DEVICE_AVAILABLE
| CL_DEVICE_COMPILER_AVAILABLE
| CL_DEVICE_DOUBLE_FP_CONFIG
| CL_DEVICE_ENDIAN_LITTLE
| CL_DEVICE_ERROR_CORRECTION_SUPPORT
| CL_DEVICE_EXECUTION_CAPABILITIES
| CL_DEVICE_EXTENSIONS
| CL_DEVICE_GLOBAL_MEM_CACHE_SIZE
| CL_DEVICE_GLOBAL_MEM_CACHE_TYPE
| CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE
| CL_DEVICE_GLOBAL_MEM_SIZE
| CL_DEVICE_HALF_FP_CONFIG
| CL_DEVICE_IMAGE_SUPPORT
| CL_DEVICE_IMAGE2D_MAX_HEIGHT
| CL_DEVICE_IMAGE2D_MAX_WIDTH
| CL_DEVICE_IMAGE3D_MAX_DEPTH
| CL_DEVICE_IMAGE3D_MAX_HEIGHT
| CL_DEVICE_IMAGE3D_MAX_WIDTH
| CL_DEVICE_LOCAL_MEM_SIZE
| CL_DEVICE_LOCAL_MEM_TYPE
| CL_DEVICE_MAX_CLOCK_FREQUENCY
| CL_DEVICE_MAX_COMPUTE_UNITS
| CL_DEVICE_MAX_CONSTANT_ARGS
| CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE
| CL_DEVICE_MAX_MEM_ALLOC_SIZE
| CL_DEVICE_MAX_PARAMETER_SIZE
| CL_DEVICE_MAX_READ_IMAGE_ARGS
| CL_DEVICE_MAX_SAMPLERS
| CL_DEVICE_MAX_WORK_GROUP_SIZE
| CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
| CL_DEVICE_MAX_WORK_ITEM_SIZES
| CL_DEVICE_MAX_WRITE_IMAGE_ARGS
| CL_DEVICE_MEM_BASE_ADDR_ALIGN
| CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE
| CL_DEVICE_NAME
| CL_DEVICE_PLATFORM
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT
| CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE
| CL_DEVICE_PROFILE
| CL_DEVICE_PROFILING_TIMER_RESOLUTION
| CL_DEVICE_QUEUE_PROPERTIES
| CL_DEVICE_SINGLE_FP_CONFIG
| CL_DEVICE_TYPE
| CL_DEVICE_VENDOR
| CL_DEVICE_VENDOR_ID
| CL_DEVICE_VERSION
| CL_DRIVER_VERSION
instance Enum CLDeviceInfo where
fromEnum CL_DEVICE_ADDRESS_BITS = 4109
fromEnum CL_DEVICE_AVAILABLE = 4135
fromEnum CL_DEVICE_COMPILER_AVAILABLE = 4136
fromEnum CL_DEVICE_DOUBLE_FP_CONFIG = 4146
fromEnum CL_DEVICE_ENDIAN_LITTLE = 4134
fromEnum CL_DEVICE_ERROR_CORRECTION_SUPPORT = 4132
fromEnum CL_DEVICE_EXECUTION_CAPABILITIES = 4137
fromEnum CL_DEVICE_EXTENSIONS = 4144
fromEnum CL_DEVICE_GLOBAL_MEM_CACHE_SIZE = 4126
fromEnum CL_DEVICE_GLOBAL_MEM_CACHE_TYPE = 4124
fromEnum CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE = 4125
fromEnum CL_DEVICE_GLOBAL_MEM_SIZE = 4127
fromEnum CL_DEVICE_HALF_FP_CONFIG = 4147
fromEnum CL_DEVICE_IMAGE_SUPPORT = 4118
fromEnum CL_DEVICE_IMAGE2D_MAX_HEIGHT = 4114
fromEnum CL_DEVICE_IMAGE2D_MAX_WIDTH = 4113
fromEnum CL_DEVICE_IMAGE3D_MAX_DEPTH = 4117
fromEnum CL_DEVICE_IMAGE3D_MAX_HEIGHT = 4116
fromEnum CL_DEVICE_IMAGE3D_MAX_WIDTH = 4115
fromEnum CL_DEVICE_LOCAL_MEM_SIZE = 4131
fromEnum CL_DEVICE_LOCAL_MEM_TYPE = 4130
fromEnum CL_DEVICE_MAX_CLOCK_FREQUENCY = 4108
fromEnum CL_DEVICE_MAX_COMPUTE_UNITS = 4098
fromEnum CL_DEVICE_MAX_CONSTANT_ARGS = 4129
fromEnum CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 4128
fromEnum CL_DEVICE_MAX_MEM_ALLOC_SIZE = 4112
fromEnum CL_DEVICE_MAX_PARAMETER_SIZE = 4119
fromEnum CL_DEVICE_MAX_READ_IMAGE_ARGS = 4110
fromEnum CL_DEVICE_MAX_SAMPLERS = 4120
fromEnum CL_DEVICE_MAX_WORK_GROUP_SIZE = 4100
fromEnum CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = 4099
fromEnum CL_DEVICE_MAX_WORK_ITEM_SIZES = 4101
fromEnum CL_DEVICE_MAX_WRITE_IMAGE_ARGS = 4111
fromEnum CL_DEVICE_MEM_BASE_ADDR_ALIGN = 4121
fromEnum CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE = 4122
fromEnum CL_DEVICE_NAME = 4139
fromEnum CL_DEVICE_PLATFORM = 4145
fromEnum CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR = 4102
fromEnum CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT = 4103
fromEnum CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT = 4104
fromEnum CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG = 4105
fromEnum CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT = 4106
fromEnum CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE = 4107
fromEnum CL_DEVICE_PROFILE = 4142
fromEnum CL_DEVICE_PROFILING_TIMER_RESOLUTION = 4133
fromEnum CL_DEVICE_QUEUE_PROPERTIES = 4138
fromEnum CL_DEVICE_SINGLE_FP_CONFIG = 4123
fromEnum CL_DEVICE_TYPE = 4096
fromEnum CL_DEVICE_VENDOR = 4140
fromEnum CL_DEVICE_VENDOR_ID = 4097
fromEnum CL_DEVICE_VERSION = 4143
fromEnum CL_DRIVER_VERSION = 4141
toEnum 4109 = CL_DEVICE_ADDRESS_BITS
toEnum 4135 = CL_DEVICE_AVAILABLE
toEnum 4136 = CL_DEVICE_COMPILER_AVAILABLE
toEnum 4146 = CL_DEVICE_DOUBLE_FP_CONFIG
toEnum 4134 = CL_DEVICE_ENDIAN_LITTLE
toEnum 4132 = CL_DEVICE_ERROR_CORRECTION_SUPPORT
toEnum 4137 = CL_DEVICE_EXECUTION_CAPABILITIES
toEnum 4144 = CL_DEVICE_EXTENSIONS
toEnum 4126 = CL_DEVICE_GLOBAL_MEM_CACHE_SIZE
toEnum 4124 = CL_DEVICE_GLOBAL_MEM_CACHE_TYPE
toEnum 4125 = CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE
toEnum 4127 = CL_DEVICE_GLOBAL_MEM_SIZE
toEnum 4147 = CL_DEVICE_HALF_FP_CONFIG
toEnum 4118 = CL_DEVICE_IMAGE_SUPPORT
toEnum 4114 = CL_DEVICE_IMAGE2D_MAX_HEIGHT
toEnum 4113 = CL_DEVICE_IMAGE2D_MAX_WIDTH
toEnum 4117 = CL_DEVICE_IMAGE3D_MAX_DEPTH
toEnum 4116 = CL_DEVICE_IMAGE3D_MAX_HEIGHT
toEnum 4115 = CL_DEVICE_IMAGE3D_MAX_WIDTH
toEnum 4131 = CL_DEVICE_LOCAL_MEM_SIZE
toEnum 4130 = CL_DEVICE_LOCAL_MEM_TYPE
toEnum 4108 = CL_DEVICE_MAX_CLOCK_FREQUENCY
toEnum 4098 = CL_DEVICE_MAX_COMPUTE_UNITS
toEnum 4129 = CL_DEVICE_MAX_CONSTANT_ARGS
toEnum 4128 = CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE
toEnum 4112 = CL_DEVICE_MAX_MEM_ALLOC_SIZE
toEnum 4119 = CL_DEVICE_MAX_PARAMETER_SIZE
toEnum 4110 = CL_DEVICE_MAX_READ_IMAGE_ARGS
toEnum 4120 = CL_DEVICE_MAX_SAMPLERS
toEnum 4100 = CL_DEVICE_MAX_WORK_GROUP_SIZE
toEnum 4099 = CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
toEnum 4101 = CL_DEVICE_MAX_WORK_ITEM_SIZES
toEnum 4111 = CL_DEVICE_MAX_WRITE_IMAGE_ARGS
toEnum 4121 = CL_DEVICE_MEM_BASE_ADDR_ALIGN
toEnum 4122 = CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE
toEnum 4139 = CL_DEVICE_NAME
toEnum 4145 = CL_DEVICE_PLATFORM
toEnum 4102 = CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR
toEnum 4103 = CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT
toEnum 4104 = CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT
toEnum 4105 = CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG
toEnum 4106 = CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT
toEnum 4107 = CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE
toEnum 4142 = CL_DEVICE_PROFILE
toEnum 4133 = CL_DEVICE_PROFILING_TIMER_RESOLUTION
toEnum 4138 = CL_DEVICE_QUEUE_PROPERTIES
toEnum 4123 = CL_DEVICE_SINGLE_FP_CONFIG
toEnum 4096 = CL_DEVICE_TYPE
toEnum 4140 = CL_DEVICE_VENDOR
toEnum 4097 = CL_DEVICE_VENDOR_ID
toEnum 4143 = CL_DEVICE_VERSION
toEnum 4141 = CL_DRIVER_VERSION
toEnum unmatched = error ("CLDeviceInfo.toEnum: Cannot match " ++ show unmatched)
clGetDeviceAddressBits :: CLDeviceID -> IO CLuint
clGetDeviceAddressBits = getDeviceInfoUint . getCLValue $ CL_DEVICE_ADDRESS_BITS
clGetDeviceAvailable :: CLDeviceID -> IO Bool
clGetDeviceAvailable = getDeviceInfoBool . getCLValue $ CL_DEVICE_AVAILABLE
clGetDeviceCompilerAvailable :: CLDeviceID -> IO Bool
clGetDeviceCompilerAvailable = getDeviceInfoBool . getCLValue $ CL_DEVICE_COMPILER_AVAILABLE
clGetDeviceDoubleFPConfig :: CLDeviceID -> IO [CLDeviceFPConfig]
clGetDeviceDoubleFPConfig = getDeviceInfoFP . getCLValue $ CL_DEVICE_DOUBLE_FP_CONFIG
clGetDeviceEndianLittle :: CLDeviceID -> IO Bool
clGetDeviceEndianLittle = getDeviceInfoBool . getCLValue $ CL_DEVICE_ENDIAN_LITTLE
clGetDeviceErrorCorrectionSupport :: CLDeviceID -> IO Bool
clGetDeviceErrorCorrectionSupport = getDeviceInfoBool . getCLValue $ CL_DEVICE_ERROR_CORRECTION_SUPPORT
clGetDeviceExecutionCapabilities :: CLDeviceID -> IO [CLDeviceExecCapability]
clGetDeviceExecutionCapabilities device = do
flags <- getDeviceInfoUlong (getCLValue CL_DEVICE_EXECUTION_CAPABILITIES) device
return . bitmaskToExecCapability $ flags
clGetDeviceExtensions :: CLDeviceID -> IO String
clGetDeviceExtensions = getDeviceInfoString . getCLValue $ CL_DEVICE_EXTENSIONS
clGetDeviceGlobalMemCacheSize :: CLDeviceID -> IO CLulong
clGetDeviceGlobalMemCacheSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_GLOBAL_MEM_CACHE_SIZE
clGetDeviceGlobalMemCacheType :: CLDeviceID -> IO CLDeviceMemCacheType
clGetDeviceGlobalMemCacheType device = do
typ <- getDeviceInfoUint (getCLValue CL_DEVICE_GLOBAL_MEM_CACHE_TYPE) device
return . getEnumCL $ typ
clGetDeviceGlobalMemCachelineSize :: CLDeviceID -> IO CLuint
clGetDeviceGlobalMemCachelineSize = getDeviceInfoUint . getCLValue $ CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE
clGetDeviceGlobalMemSize :: CLDeviceID -> IO CLulong
clGetDeviceGlobalMemSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_GLOBAL_MEM_SIZE
clGetDeviceHalfFPConfig :: CLDeviceID -> IO [CLDeviceFPConfig]
clGetDeviceHalfFPConfig = getDeviceInfoFP . getCLValue $ CL_DEVICE_HALF_FP_CONFIG
clGetDeviceImageSupport :: CLDeviceID -> IO Bool
clGetDeviceImageSupport = getDeviceInfoBool . getCLValue $ CL_DEVICE_IMAGE_SUPPORT
clGetDeviceImage2DMaxHeight :: CLDeviceID -> IO CSize
clGetDeviceImage2DMaxHeight = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE2D_MAX_HEIGHT
clGetDeviceImage2DMaxWidth :: CLDeviceID -> IO CSize
clGetDeviceImage2DMaxWidth = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE2D_MAX_WIDTH
clGetDeviceImage3DMaxDepth :: CLDeviceID -> IO CSize
clGetDeviceImage3DMaxDepth = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE3D_MAX_DEPTH
clGetDeviceImage3DMaxHeight :: CLDeviceID -> IO CSize
clGetDeviceImage3DMaxHeight = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE3D_MAX_HEIGHT
clGetDeviceImage3DMaxWidth :: CLDeviceID -> IO CSize
clGetDeviceImage3DMaxWidth = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE3D_MAX_WIDTH
clGetDeviceLocalMemSize :: CLDeviceID -> IO CLulong
clGetDeviceLocalMemSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_LOCAL_MEM_SIZE
clGetDeviceLocalMemType :: CLDeviceID -> IO CLDeviceLocalMemType
clGetDeviceLocalMemType device = do
typ <- getDeviceInfoUint (getCLValue CL_DEVICE_LOCAL_MEM_TYPE) device
return . getEnumCL $ typ
clGetDeviceMaxClockFrequency :: CLDeviceID -> IO CLuint
clGetDeviceMaxClockFrequency = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_CLOCK_FREQUENCY
clGetDeviceMaxComputeUnits :: CLDeviceID -> IO CLuint
clGetDeviceMaxComputeUnits = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_COMPUTE_UNITS
clGetDeviceMaxConstantArgs :: CLDeviceID -> IO CLuint
clGetDeviceMaxConstantArgs = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_CONSTANT_ARGS
clGetDeviceMaxConstantBufferSize :: CLDeviceID -> IO CLulong
clGetDeviceMaxConstantBufferSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE
clGetDeviceMaxMemAllocSize :: CLDeviceID -> IO CLulong
clGetDeviceMaxMemAllocSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_MAX_MEM_ALLOC_SIZE
clGetDeviceMaxParameterSize :: CLDeviceID -> IO CSize
clGetDeviceMaxParameterSize = getDeviceInfoSizet . getCLValue $ CL_DEVICE_MAX_PARAMETER_SIZE
clGetDeviceMaxReadImageArgs :: CLDeviceID -> IO CLuint
clGetDeviceMaxReadImageArgs = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_READ_IMAGE_ARGS
clGetDeviceMaxSamplers :: CLDeviceID -> IO CLuint
clGetDeviceMaxSamplers = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_SAMPLERS
clGetDeviceMaxWorkGroupSize :: CLDeviceID -> IO CSize
clGetDeviceMaxWorkGroupSize = getDeviceInfoSizet . getCLValue $ CL_DEVICE_MAX_WORK_GROUP_SIZE
clGetDeviceMaxWorkItemDimensions :: CLDeviceID -> IO CLuint
clGetDeviceMaxWorkItemDimensions = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
clGetDeviceMaxWorkItemSizes :: CLDeviceID -> IO [CSize]
clGetDeviceMaxWorkItemSizes device = do
n <- clGetDeviceMaxWorkItemDimensions device
allocaArray (fromIntegral n) $ \(buff :: Ptr CSize) -> do
whenSuccess (raw_clGetDeviceInfo device infoid (size n) (castPtr buff) nullPtr)
$ peekArray (fromIntegral n) buff
where
infoid = getCLValue CL_DEVICE_MAX_WORK_ITEM_SIZES
size n = fromIntegral $ (fromIntegral n) * (sizeOf (0::CSize))
clGetDeviceMaxWriteImageArgs :: CLDeviceID -> IO CLuint
clGetDeviceMaxWriteImageArgs = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_WRITE_IMAGE_ARGS
clGetDeviceMemBaseAddrAlign :: CLDeviceID -> IO CLuint
clGetDeviceMemBaseAddrAlign = getDeviceInfoUint . getCLValue $ CL_DEVICE_MEM_BASE_ADDR_ALIGN
clGetDeviceMinDataTypeAlignSize :: CLDeviceID -> IO CLuint
clGetDeviceMinDataTypeAlignSize = getDeviceInfoUint . getCLValue $ CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE
clGetDeviceName :: CLDeviceID -> IO String
clGetDeviceName = getDeviceInfoString . getCLValue $ CL_DEVICE_NAME
clGetDevicePlatform :: CLDeviceID -> IO CLPlatformID
clGetDevicePlatform device = alloca $ \(dat :: Ptr CLPlatformID) -> do
whenSuccess (raw_clGetDeviceInfo device infoid size (castPtr dat) nullPtr)
$ peek dat
where
infoid = getCLValue CL_DEVICE_PLATFORM
size = fromIntegral $ sizeOf (nullPtr :: CLPlatformID)
clGetDevicePreferredVectorWidthChar :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthChar = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR
clGetDevicePreferredVectorWidthShort :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthShort = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT
clGetDevicePreferredVectorWidthInt :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthInt = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT
clGetDevicePreferredVectorWidthLong :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthLong = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG
clGetDevicePreferredVectorWidthFloat :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthFloat = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT
clGetDevicePreferredVectorWidthDouble :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthDouble = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE
clGetDeviceProfile :: CLDeviceID -> IO String
clGetDeviceProfile = getDeviceInfoString . getCLValue $ CL_DEVICE_PROFILE
clGetDeviceProfilingTimerResolution :: CLDeviceID -> IO CSize
clGetDeviceProfilingTimerResolution = getDeviceInfoSizet . getCLValue $ CL_DEVICE_PROFILING_TIMER_RESOLUTION
clGetDeviceQueueProperties :: CLDeviceID -> IO [CLCommandQueueProperty]
clGetDeviceQueueProperties device = do
flags <- getDeviceInfoUlong (getCLValue CL_DEVICE_QUEUE_PROPERTIES) device
return . bitmaskToCommandQueueProperties $ flags
clGetDeviceSingleFPConfig :: CLDeviceID -> IO [CLDeviceFPConfig]
clGetDeviceSingleFPConfig = getDeviceInfoFP . getCLValue $ CL_DEVICE_SINGLE_FP_CONFIG
clGetDeviceType :: CLDeviceID -> IO [CLDeviceType]
clGetDeviceType device = do
flags <- getDeviceInfoUlong (getCLValue CL_DEVICE_TYPE) device
return . bitmaskToDeviceTypes $ flags
clGetDeviceVendor :: CLDeviceID -> IO String
clGetDeviceVendor = getDeviceInfoString . getCLValue $ CL_DEVICE_VENDOR
clGetDeviceVendorID :: CLDeviceID -> IO CLuint
clGetDeviceVendorID = getDeviceInfoUint . getCLValue $ CL_DEVICE_VENDOR_ID
clGetDeviceVersion :: CLDeviceID -> IO String
clGetDeviceVersion = getDeviceInfoString . getCLValue $ CL_DEVICE_VERSION
clGetDeviceDriverVersion :: CLDeviceID -> IO String
clGetDeviceDriverVersion = getDeviceInfoString . getCLValue $ CL_DRIVER_VERSION