     _ -> return $ Just "can only memset 8-, 16-, and 32-bit values"
 
 --
--- We use unsafe coerce below to reinterpret the bits of the value to memset
--- into the required integer type.
+-- We use unsafe coerce below to reinterpret the bits of the value to memset as,
+-- into the integer type required by the setting functions.
 --
 {# fun unsafe cuMemsetD8
   { useDevicePtr `DevicePtr a'

-- memory is thusly reduced, overall system performance may suffer. This is best
-- used sparingly to allocate staging areas for data exchange.
--
mallocHost :: Int -> IO (Either String (HostPtr a))
mallocHost bytes =
  newHostPtr >>= \hp -> withHostPtr hp $ \p ->
  cuMemAllocHost p bytes >>= \rv ->
  return $ case nothingIfOk rv of
    Nothing  -> Right hp
    Just err -> Left err

{# fun unsafe cuMemAllocHost
  { with'* `Ptr a'
  ,        `Int'         } -> `Status' cToEnum #}
  where with' = with . castPtr



  , unsafeCoerce `a'
  ,              `Int'         } -> `Status' cToEnum #}


-- |
-- Return the device pointer associated with a mapped, pinned host buffer, which
-- was allocated with the DEVICE_MAPPED option.
--
-- Currently, no options are supported and this must be empty.
--
getDevicePtr :: [AllocFlag] -> HostPtr a -> IO (Either String (DevicePtr a))
getDevicePtr flags hptr = withHostPtr hptr $ \hp -> (resultIfOk `fmap` cuMemHostGetDevicePointer hp flags)

{# fun unsafe cuMemHostGetDevicePointer
  { alloca-         `DevicePtr a' dptr*
  , castPtr         `Ptr a'
  , combineBitMasks `[AllocFlag]'       } -> `Status' cToEnum #}
  where dptr = liftM DevicePtr . peekIntConv

