I am developing a high level OpenCL binding in Haskell, and I need peer-review and testing. It currently only gets platform and device info from OpenCL.
I have lots of functions that only change the returned type and the size of the type passed to the C library, but I don't know how to fix it.
getDeviceInfoUlong :: CLDeviceInfo_ -> CLDeviceID -> IO (Either CLError 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 (Either CLError 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)