-- GENERATED by C->Haskell Compiler, version 0.16.5 Crystal Seed, 24 Jan 2009 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Control/Parallel/OpenCL/Query.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 #-}
module Control.Parallel.OpenCL.Query( 
  -- * Types
  CLPlatformInfo(..), CLPlatformID, CLDeviceID, CLDeviceType(..),
  CLDeviceFPConfig(..), CLDeviceExecCapability(..), CLDeviceLocalMemType(..),
  CLDeviceMemCacheType(..),
  -- * Platform Query Functions
  clGetPlatformIDs, clGetPlatformInfo, 
  -- * Device Query Functions
  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 -- expose FFI type constructors, the final imported list
                       -- depends on final architecture
import Foreign.Storable( sizeOf )
import Control.Parallel.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

-- | Obtain the list of platforms available. Returns the list if the function 
-- is executed successfully. Otherwise it returns the empty list.
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
  
-- | Get specific information about the OpenCL platform. It returns Nothing if
-- platform is not a valid platform.
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

-- | Obtain the list of devices available on a platform. Returns the list if 
-- the function is executed successfully. Otherwise it returns the empty list 
-- if platform is not a valid platform or no OpenCL devices that matched 
-- device_type were found.
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)

{-# LINE 256 "src/Control/Parallel/OpenCL/Query.chs" #-}

-- | The default compute device address space size specified as an unsigned 
-- integer value in bits. Currently supported values are 32 or 64 bits.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_ADDRESS_BITS'.
clGetDeviceAddressBits :: CLDeviceID -> IO CLuint
clGetDeviceAddressBits = getDeviceInfoUint . getCLValue $ CL_DEVICE_ADDRESS_BITS

-- | Is 'True' if the device is available and 'False' if the device is not 
-- available.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_AVAILABLE'.
clGetDeviceAvailable :: CLDeviceID -> IO Bool
clGetDeviceAvailable = getDeviceInfoBool . getCLValue $ CL_DEVICE_AVAILABLE

-- | Is 'False' if the implementation does not have a compiler available to 
-- compile the program source. Is 'True' if the compiler is available. This can 
-- be 'False' for the embededed platform profile only.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_COMPILER_AVAILABLE'.
clGetDeviceCompilerAvailable :: CLDeviceID -> IO Bool
clGetDeviceCompilerAvailable = getDeviceInfoBool . getCLValue $ CL_DEVICE_COMPILER_AVAILABLE

-- | Describes the OPTIONAL double precision floating-point capability of the 
-- OpenCL device. This is a bit-field that describes one or more of the 
-- 'CLDeviceFPConfig' values.
-- The mandated minimum double precision floating-point capability is 
-- 'CL_FP_FMA' | 'CL_FP_ROUND_TO_NEAREST' | 'CL_FP_ROUND_TO_ZERO' | 
-- 'CL_FP_ROUND_TO_INF' | 'CL_FP_INF_NAN' | 'CL_FP_DENORM'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_DOUBLE_FP_CONFIG'.
clGetDeviceDoubleFPConfig :: CLDeviceID -> IO [CLDeviceFPConfig]
clGetDeviceDoubleFPConfig = getDeviceInfoFP . getCLValue $ CL_DEVICE_DOUBLE_FP_CONFIG

-- | Is 'True' if the OpenCL device is a little endian device and 'False' 
-- otherwise.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_ENDIAN_LITTLE'.
clGetDeviceEndianLittle :: CLDeviceID -> IO Bool
clGetDeviceEndianLittle = getDeviceInfoBool . getCLValue $ CL_DEVICE_ENDIAN_LITTLE

-- | Is 'True' if the device implements error correction for the memories, 
-- caches, registers etc. in the device. Is 'False' if the device does not 
-- implement error correction. This can be a requirement for certain clients of 
-- OpenCL.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_ERROR_CORRECTION_SUPPORT'.
clGetDeviceErrorCorrectionSupport :: CLDeviceID -> IO Bool
clGetDeviceErrorCorrectionSupport = getDeviceInfoBool . getCLValue $ CL_DEVICE_ERROR_CORRECTION_SUPPORT

-- | Describes the execution capabilities of the device. This is a list that 
-- describes one or more of the 'CLDeviceExecCapability' values.
-- The mandated minimum capability is 'CL_EXEC_KERNEL'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_EXECUTION_CAPABILITIES'.
clGetDeviceExecutionCapabilities :: CLDeviceID -> IO [CLDeviceExecCapability]
clGetDeviceExecutionCapabilities device = do
  flags <- getDeviceInfoUlong (getCLValue CL_DEVICE_EXECUTION_CAPABILITIES) device
  return . bitmaskToExecCapability $ flags

-- | Returns a space separated list of extension names (the extension names 
-- themselves do not contain any spaces). The list of extension names returned 
-- currently can include one or more of the following approved extension names:
--
-- * cl_khr_fp64
--
-- * cl_khr_select_fprounding_mode
--
-- * cl_khr_global_int32_base_atomics
--
-- * cl_khr_global_int32_extended_atomics
--
-- * cl_khr_local_int32_base_atomics
--
-- * cl_khr_local_int32_extended_atomics
--
-- * cl_khr_int64_base_atomics
--
-- * cl_khr_int64_extended_atomics
--
-- * cl_khr_3d_image_writes
--
-- * cl_khr_byte_addressable_store
--
-- * cl_khr_fp16
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_EXTENSIONS'.
clGetDeviceExtensions :: CLDeviceID -> IO String
clGetDeviceExtensions = getDeviceInfoString . getCLValue $ CL_DEVICE_EXTENSIONS

-- | Size of global memory cache in bytes.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_GLOBAL_MEM_CACHE_SIZE'.
clGetDeviceGlobalMemCacheSize :: CLDeviceID -> IO CLulong
clGetDeviceGlobalMemCacheSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_GLOBAL_MEM_CACHE_SIZE

-- | Type of global memory cache supported. Valid values are: 'CL_NONE', 
-- 'CL_READ_ONLY_CACHE', and 'CL_READ_WRITE_CACHE'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_GLOBAL_MEM_CACHE_TYPE'.
clGetDeviceGlobalMemCacheType :: CLDeviceID -> IO CLDeviceMemCacheType
clGetDeviceGlobalMemCacheType device = do
  typ <- getDeviceInfoUint (getCLValue CL_DEVICE_GLOBAL_MEM_CACHE_TYPE) device 
  return . getEnumCL $ typ

-- | Size of global memory cache line in bytes.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE'.
clGetDeviceGlobalMemCachelineSize :: CLDeviceID -> IO CLuint
clGetDeviceGlobalMemCachelineSize = getDeviceInfoUint . getCLValue $ CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE

-- | Size of global device memory in bytes.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_GLOBAL_MEM_SIZE'.
clGetDeviceGlobalMemSize :: CLDeviceID -> IO CLulong
clGetDeviceGlobalMemSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_GLOBAL_MEM_SIZE

-- | Describes the OPTIONAL half precision floating-point capability of the 
-- OpenCL device. This is a bit-field that describes one or more of the 
-- 'CLDeviceFPConfig' values.
-- The required minimum half precision floating-point capability as implemented 
-- by this extension is 'CL_FP_ROUND_TO_ZERO' | 'CL_FP_ROUND_TO_INF' | 
-- 'CL_FP_INF_NAN'.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_HALF_FP_CONFIG'.
clGetDeviceHalfFPConfig :: CLDeviceID -> IO [CLDeviceFPConfig]
clGetDeviceHalfFPConfig = getDeviceInfoFP . getCLValue $ CL_DEVICE_HALF_FP_CONFIG

-- | Is 'True' if images are supported by the OpenCL device and 'False' otherwise.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_IMAGE_SUPPORT'.
clGetDeviceImageSupport :: CLDeviceID -> IO Bool
clGetDeviceImageSupport = getDeviceInfoBool . getCLValue $ CL_DEVICE_IMAGE_SUPPORT

-- | Max height of 2D image in pixels. The minimum value is 8192 if
-- 'clGetDeviceImageSupport' is 'True'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_IMAGE2D_MAX_HEIGHT'.
clGetDeviceImage2DMaxHeight :: CLDeviceID -> IO CSize
clGetDeviceImage2DMaxHeight = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE2D_MAX_HEIGHT

-- | Max width of 2D image in pixels. The minimum value is 8192 if
-- 'clGetDeviceImageSupport' is 'True'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_IMAGE2D_MAX_WIDTH'.
clGetDeviceImage2DMaxWidth :: CLDeviceID -> IO CSize
clGetDeviceImage2DMaxWidth = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE2D_MAX_WIDTH

-- | Max depth of 3D image in pixels. The minimum value is 2048 if 
-- 'clGetDeviceImageSupport' is 'True'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_IMAGE3D_MAX_DEPTH'.
clGetDeviceImage3DMaxDepth :: CLDeviceID -> IO CSize
clGetDeviceImage3DMaxDepth = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE3D_MAX_DEPTH

-- | Max height of 3D image in pixels. The minimum value is 2048 if 
-- 'clGetDeviceImageSupport' is 'True'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_IMAGE3D_MAX_HEIGHT'.
clGetDeviceImage3DMaxHeight :: CLDeviceID -> IO CSize
clGetDeviceImage3DMaxHeight = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE3D_MAX_HEIGHT

-- | Max width of 3D image in pixels. The minimum value is 2048 if 
-- 'clGetDeviceImageSupport' is 'True'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_IMAGE3D_MAX_WIDTH'.
clGetDeviceImage3DMaxWidth :: CLDeviceID -> IO CSize
clGetDeviceImage3DMaxWidth = getDeviceInfoSizet . getCLValue $ CL_DEVICE_IMAGE3D_MAX_WIDTH

-- | Size of local memory arena in bytes. The minimum value is 16 KB.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_LOCAL_MEM_SIZE'.
clGetDeviceLocalMemSize :: CLDeviceID -> IO CLulong
clGetDeviceLocalMemSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_LOCAL_MEM_SIZE

-- | Type of local memory supported. This can be set to 'CL_LOCAL' implying 
-- dedicated local memory storage such as SRAM, or 'CL_GLOBAL'.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_LOCAL_MEM_TYPE'.
clGetDeviceLocalMemType :: CLDeviceID -> IO CLDeviceLocalMemType
clGetDeviceLocalMemType device = do
  typ <- getDeviceInfoUint (getCLValue CL_DEVICE_LOCAL_MEM_TYPE) device 
  return . getEnumCL $ typ

-- | Maximum configured clock frequency of the device in MHz.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_CLOCK_FREQUENCY'.
clGetDeviceMaxClockFrequency :: CLDeviceID -> IO CLuint
clGetDeviceMaxClockFrequency = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_CLOCK_FREQUENCY

-- | The number of parallel compute cores on the OpenCL device. The minimum 
-- value is 1.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_COMPUTE_UNITS'.
clGetDeviceMaxComputeUnits :: CLDeviceID -> IO CLuint
clGetDeviceMaxComputeUnits = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_COMPUTE_UNITS

-- | Max number of arguments declared with the __constant qualifier in a kernel. 
-- The minimum value is 8.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_CONSTANT_ARGS'.
clGetDeviceMaxConstantArgs :: CLDeviceID -> IO CLuint
clGetDeviceMaxConstantArgs = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_CONSTANT_ARGS

-- | Max size in bytes of a constant buffer allocation. The minimum value is 
-- 64 KB.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE'.
clGetDeviceMaxConstantBufferSize :: CLDeviceID -> IO CLulong
clGetDeviceMaxConstantBufferSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE

-- | Max size of memory object allocation in bytes. The minimum value is max 
-- (1/4th of 'clGetDeviceGlobalMemSize', 128*1024*1024)
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_MAX_MEM_ALLOC_SIZE'.
clGetDeviceMaxMemAllocSize :: CLDeviceID -> IO CLulong
clGetDeviceMaxMemAllocSize = getDeviceInfoUlong . getCLValue $ CL_DEVICE_MAX_MEM_ALLOC_SIZE

-- | Max size in bytes of the arguments that can be passed to a kernel. The 
-- minimum value is 256.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_PARAMETER_SIZE'.
clGetDeviceMaxParameterSize :: CLDeviceID -> IO CSize
clGetDeviceMaxParameterSize = getDeviceInfoSizet . getCLValue $ CL_DEVICE_MAX_PARAMETER_SIZE

-- | Max number of simultaneous image objects that can be read by a kernel. The 
-- minimum value is 128 if 'clGetDeviceImageSupport' is 'True'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_READ_IMAGE_ARGS'.
clGetDeviceMaxReadImageArgs :: CLDeviceID -> IO CLuint
clGetDeviceMaxReadImageArgs = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_READ_IMAGE_ARGS

-- | Maximum number of samplers that can be used in a kernel. The minimum value 
-- is 16 if 'clGetDeviceImageSupport' is 'True'. (Also see sampler type.)
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_MAX_SAMPLERS'.
clGetDeviceMaxSamplers :: CLDeviceID -> IO CLuint
clGetDeviceMaxSamplers = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_SAMPLERS

-- | Maximum number of work-items in a work-group executing a kernel using the 
-- data parallel execution model. (Refer to 'clEnqueueNDRangeKernel'). The 
-- minimum value is 1.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_WORK_GROUP_SIZE'.
clGetDeviceMaxWorkGroupSize :: CLDeviceID -> IO CSize
clGetDeviceMaxWorkGroupSize = getDeviceInfoSizet . getCLValue $ CL_DEVICE_MAX_WORK_GROUP_SIZE

-- | Maximum dimensions that specify the global and local work-item IDs used by 
-- the data parallel execution model. (Refer to 'clEnqueueNDRangeKernel'). 
-- The minimum value is 3.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS'.
clGetDeviceMaxWorkItemDimensions :: CLDeviceID -> IO CLuint
clGetDeviceMaxWorkItemDimensions = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS

-- | Maximum number of work-items that can be specified in each dimension of the 
-- work-group to 'clEnqueueNDRangeKernel'.
-- Returns n entries, where n is the value returned by the query for 
-- clDeviceMaxWorkItemDimensions. The minimum value is (1, 1, 1).
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_WORK_ITEM_SIZES'.
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))

-- | Max number of simultaneous image objects that can be written to by a 
-- kernel. The minimum value is 8 if 'clGetDeviceImageSupport' is 'True'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MAX_WRITE_IMAGE_ARGS'.
clGetDeviceMaxWriteImageArgs :: CLDeviceID -> IO CLuint
clGetDeviceMaxWriteImageArgs = getDeviceInfoUint . getCLValue $ CL_DEVICE_MAX_WRITE_IMAGE_ARGS

-- | Describes the alignment in bits of the base address of any allocated 
-- memory object.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MEM_BASE_ADDR_ALIGN'.
clGetDeviceMemBaseAddrAlign :: CLDeviceID -> IO CLuint
clGetDeviceMemBaseAddrAlign = getDeviceInfoUint . getCLValue $ CL_DEVICE_MEM_BASE_ADDR_ALIGN

-- | The smallest alignment in bytes which can be used for any data type.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE'.
clGetDeviceMinDataTypeAlignSize :: CLDeviceID -> IO CLuint
clGetDeviceMinDataTypeAlignSize = getDeviceInfoUint . getCLValue $ CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE

-- | Device name string.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_NAME'.
clGetDeviceName :: CLDeviceID -> IO String
clGetDeviceName = getDeviceInfoString . getCLValue $ CL_DEVICE_NAME

-- | The platform associated with this device.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_PLATFORM'.
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)

-- | Preferred native vector width size for built-in char types that can be put 
-- into vectors. The vector width is defined as the number of scalar elements 
-- that can be stored in the vector.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR'.
clGetDevicePreferredVectorWidthChar :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthChar = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR

-- | Preferred native vector width size for built-in short types that can be put 
-- into vectors. The vector width is defined as the number of scalar elements 
-- that can be stored in the vector.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT'.
clGetDevicePreferredVectorWidthShort :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthShort = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT

-- | Preferred native vector width size for built-in int types that can be put 
-- into vectors. The vector width is defined as the number of scalar elements 
-- that can be stored in the vector.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT'.
clGetDevicePreferredVectorWidthInt :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthInt = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT

-- | Preferred native vector width size for built-in long types that can be put 
-- into vectors. The vector width is defined as the number of scalar elements 
-- that can be stored in the vector.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG'.
clGetDevicePreferredVectorWidthLong :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthLong = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG

-- | Preferred native vector width size for built-in float types that can be put 
-- into vectors. The vector width is defined as the number of scalar elements 
-- that can be stored in the vector.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT'.
clGetDevicePreferredVectorWidthFloat :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthFloat = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT

-- | Preferred native vector width size for built-in double types that can be put 
-- into vectors. The vector width is defined as the number of scalar elements 
-- that can be stored in the vector.
-- | If the cl_khr_fp64 extension is not supported, 
-- 'clGetDevicePreferredVectorWidthDouble' must return 0.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE'.
clGetDevicePreferredVectorWidthDouble :: CLDeviceID -> IO CLuint
clGetDevicePreferredVectorWidthDouble = getDeviceInfoUint . getCLValue $ CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE

-- | OpenCL profile string. Returns the profile name supported by the device 
-- (see note). The profile name returned can be one of the following strings:
-- 
-- * FULL_PROFILE - if the device supports the OpenCL specification 
-- (functionality defined as part of the core specification and does not require 
-- any extensions to be supported).
-- 
-- * EMBEDDED_PROFILE - if the device supports the OpenCL embedded profile.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_PROFILE'.
clGetDeviceProfile :: CLDeviceID -> IO String
clGetDeviceProfile = getDeviceInfoString . getCLValue $ CL_DEVICE_PROFILE

-- | Describes the resolution of device timer. This is measured in nanoseconds.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_PROFILING_TIMER_RESOLUTION'.
clGetDeviceProfilingTimerResolution :: CLDeviceID -> IO CSize
clGetDeviceProfilingTimerResolution = getDeviceInfoSizet . getCLValue $ CL_DEVICE_PROFILING_TIMER_RESOLUTION

-- | Describes the command-queue properties supported by the device. This is a 
-- list that describes one or more of the CLCommandQueueProperty values.
-- These properties are described in the table for 'clCreateCommandQueue'. 
-- The mandated minimum capability is 'CL_QUEUE_PROFILING_ENABLE'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_QUEUE_PROPERTIES'.
clGetDeviceQueueProperties :: CLDeviceID -> IO [CLCommandQueueProperty]
clGetDeviceQueueProperties device = do
  flags <- getDeviceInfoUlong (getCLValue CL_DEVICE_QUEUE_PROPERTIES) device
  return . bitmaskToCommandQueueProperties $ flags
    
-- | Describes single precision floating-point capability of the device. This is 
-- a bit-field that describes one or more of the 'CLDeviceFPConfig' values.
-- The mandated minimum floating-point capability is 'CL_FP_ROUND_TO_NEAREST' | 
-- 'CL_FP_INF_NAN'.
--
-- This function execute OpenCL clGetDeviceInfo with
-- 'CL_DEVICE_SINGLE_FP_CONFIG'.
clGetDeviceSingleFPConfig :: CLDeviceID -> IO [CLDeviceFPConfig]
clGetDeviceSingleFPConfig = getDeviceInfoFP . getCLValue $ CL_DEVICE_SINGLE_FP_CONFIG

-- | The OpenCL device type. Currently supported values are one of or a 
-- combination of: 'CL_DEVICE_TYPE_CPU', 'CL_DEVICE_TYPE_GPU', 
-- 'CL_DEVICE_TYPE_ACCELERATOR', or 'CL_DEVICE_TYPE_DEFAULT'.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_TYPE'.
clGetDeviceType :: CLDeviceID -> IO [CLDeviceType]
clGetDeviceType device = do
  flags <- getDeviceInfoUlong (getCLValue CL_DEVICE_TYPE) device
  return . bitmaskToDeviceTypes $ flags

-- | Vendor name string.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_VENDOR'.
clGetDeviceVendor :: CLDeviceID -> IO String
clGetDeviceVendor = getDeviceInfoString . getCLValue $ CL_DEVICE_VENDOR

-- | A unique device vendor identifier. An example of a unique device identifier 
-- could be the PCIe ID.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_VENDOR_ID'.
clGetDeviceVendorID :: CLDeviceID -> IO CLuint
clGetDeviceVendorID = getDeviceInfoUint . getCLValue $ CL_DEVICE_VENDOR_ID

-- | OpenCL version string. Returns the OpenCL version supported by the device. 
-- This version string has the following format:
-- /OpenCL major_version.minor_version vendor-specific information/
-- The major_version.minor_version value returned will be 1.0.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DEVICE_VERSION'.
clGetDeviceVersion :: CLDeviceID -> IO String
clGetDeviceVersion = getDeviceInfoString . getCLValue $ CL_DEVICE_VERSION

-- | OpenCL software driver version string in the form major_number.minor_number.
--
-- This function execute OpenCL clGetDeviceInfo with 'CL_DRIVER_VERSION'.
clGetDeviceDriverVersion :: CLDeviceID -> IO String
clGetDeviceDriverVersion = getDeviceInfoString . getCLValue $ CL_DRIVER_VERSION

-- -----------------------------------------------------------------------------