 -- 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 =
+mallocHost :: [AllocFlag] -> Int -> IO (Either String (HostPtr a))
+mallocHost flags bytes =
   newHostPtr >>= \hp -> withHostPtr hp $ \p ->
-  cuMemAllocHost p bytes >>= \rv ->
+  cuMemHostAlloc p bytes flags >>= \rv ->
   return $ case nothingIfOk rv of
     Nothing  -> Right hp
     Just err -> Left err
 
-{# fun unsafe cuMemAllocHost
+{# fun unsafe cuMemHostAlloc
   { with'* `Ptr a'
-  ,        `Int'         } -> `Status' cToEnum #}
+  ,        `Int'
+  , combineBitMasks `[AllocFlag]' } -> `Status' cToEnum #}
   where with' = with . castPtr
 
 


module Foreign.CUDA.Driver.Marshal
  (
    DevicePtr, HostPtr,
    malloc, free, mallocHost, freeHost,
    peekArray, peekArrayAsync, pokeArray, pokeArrayAsync, memset
  )
  where


import Control.Monad                            (liftM)
import Unsafe.Coerce

#c
typedef enum CUmemhostalloc_option_enum {
    CU_MEMHOSTALLOC_OPTION_PORTABLE       = CU_MEMHOSTALLOC_PORTABLE,
    CU_MEMHOSTALLOC_OPTION_DEVICE_MAPPED  = CU_MEMHOSTALLOC_DEVICEMAP,
    CU_MEMHOSTALLOC_OPTION_WRITE_COMBINED = CU_MEMHOSTALLOC_WRITECOMBINED
} CUmemhostalloc_option;
#endc

--------------------------------------------------------------------------------
-- Data Types
--------------------------------------------------------------------------------
