{-# LINE 1 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_HADDOCK prune #-}
module Foreign.CUDA.Driver.Marshal (
AllocFlag(..),
mallocHostArray, mallocHostForeignPtr, freeHost,
registerArray, unregisterArray,
mallocArray, allocaArray, free,
AttachFlag(..),
mallocManagedArray,
prefetchArrayAsync,
attachArrayAsync,
peekArray, peekArrayAsync, peekArray2D, peekArray2DAsync, peekListArray,
pokeArray, pokeArrayAsync, pokeArray2D, pokeArray2DAsync, pokeListArray,
copyArray, copyArrayAsync, copyArray2D, copyArray2DAsync,
copyArrayPeer, copyArrayPeerAsync,
newListArray, newListArrayLen,
withListArray, withListArrayLen,
memset, memsetAsync,
getDevicePtr, getBasePtr, getMemInfo,
useDeviceHandle, peekDeviceHandle
) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.Ptr as C2HSImp
{-# LINE 55 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
import Foreign.CUDA.Ptr
import Foreign.CUDA.Driver.Device
import Foreign.CUDA.Driver.Error
import Foreign.CUDA.Driver.Stream ( Stream(..), defaultStream )
import Foreign.CUDA.Driver.Context.Base ( Context(..) )
import Foreign.CUDA.Internal.C2HS
import Data.Int
import Data.Maybe
import Data.Word
import Unsafe.Coerce
import Control.Applicative
import Control.Exception
import Prelude
import Foreign.C
import Foreign.Ptr
import Foreign.ForeignPtr
import Foreign.Storable
import qualified Foreign.Marshal as F
import GHC.Ptr
import GHC.Word
import GHC.Base
data AllocFlag = Portable
| DeviceMapped
| WriteCombined
deriving (AllocFlag -> AllocFlag -> Bool
(AllocFlag -> AllocFlag -> Bool)
-> (AllocFlag -> AllocFlag -> Bool) -> Eq AllocFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllocFlag -> AllocFlag -> Bool
$c/= :: AllocFlag -> AllocFlag -> Bool
== :: AllocFlag -> AllocFlag -> Bool
$c== :: AllocFlag -> AllocFlag -> Bool
Eq,Int -> AllocFlag -> ShowS
[AllocFlag] -> ShowS
AllocFlag -> String
(Int -> AllocFlag -> ShowS)
-> (AllocFlag -> String)
-> ([AllocFlag] -> ShowS)
-> Show AllocFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AllocFlag] -> ShowS
$cshowList :: [AllocFlag] -> ShowS
show :: AllocFlag -> String
$cshow :: AllocFlag -> String
showsPrec :: Int -> AllocFlag -> ShowS
$cshowsPrec :: Int -> AllocFlag -> ShowS
Show,AllocFlag
AllocFlag -> AllocFlag -> Bounded AllocFlag
forall a. a -> a -> Bounded a
maxBound :: AllocFlag
$cmaxBound :: AllocFlag
minBound :: AllocFlag
$cminBound :: AllocFlag
Bounded)
instance Enum AllocFlag where
succ :: AllocFlag -> AllocFlag
succ AllocFlag
Portable = AllocFlag
DeviceMapped
succ AllocFlag
DeviceMapped = AllocFlag
WriteCombined
succ AllocFlag
WriteCombined = String -> AllocFlag
forall a. HasCallStack => String -> a
error String
"AllocFlag.succ: WriteCombined has no successor"
pred :: AllocFlag -> AllocFlag
pred AllocFlag
DeviceMapped = AllocFlag
Portable
pred AllocFlag
WriteCombined = AllocFlag
DeviceMapped
pred AllocFlag
Portable = String -> AllocFlag
forall a. HasCallStack => String -> a
error String
"AllocFlag.pred: Portable has no predecessor"
enumFromTo :: AllocFlag -> AllocFlag -> [AllocFlag]
enumFromTo AllocFlag
from AllocFlag
to = AllocFlag -> [AllocFlag]
forall t. Enum t => t -> [t]
go AllocFlag
from
where
end :: Int
end = AllocFlag -> Int
forall a. Enum a => a -> Int
fromEnum AllocFlag
to
go :: t -> [t]
go t
v = case Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (t -> Int
forall a. Enum a => a -> Int
fromEnum t
v) Int
end of
Ordering
LT -> t
v t -> [t] -> [t]
forall a. a -> [a] -> [a]
: t -> [t]
go (t -> t
forall a. Enum a => a -> a
succ t
v)
Ordering
EQ -> [t
v]
Ordering
GT -> []
enumFrom :: AllocFlag -> [AllocFlag]
enumFrom AllocFlag
from = AllocFlag -> AllocFlag -> [AllocFlag]
forall a. Enum a => a -> a -> [a]
enumFromTo AllocFlag
from AllocFlag
WriteCombined
fromEnum :: AllocFlag -> Int
fromEnum AllocFlag
Portable = Int
1
fromEnum AllocFlag
DeviceMapped = Int
2
fromEnum AllocFlag
WriteCombined = Int
4
toEnum 1 = Portable
toEnum 2 = DeviceMapped
toEnum 4 = WriteCombined
toEnum unmatched = error ("AllocFlag.toEnum: Cannot match " ++ show unmatched)
{-# LINE 101 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE mallocHostArray #-}
mallocHostArray :: Storable a => [AllocFlag] -> Int -> IO (HostPtr a)
mallocHostArray !flags = doMalloc undefined
where
doMalloc :: Storable a' => a' -> Int -> IO (HostPtr a')
doMalloc x !n = resultIfOk =<< cuMemHostAlloc (n * sizeOf x) flags
{-# INLINEABLE mallocHostForeignPtr #-}
{-# SPECIALISE mallocHostForeignPtr :: [AllocFlag] -> Int -> IO (ForeignPtr Word8) #-}
mallocHostForeignPtr :: Storable a => [AllocFlag] -> Int -> IO (ForeignPtr a)
mallocHostForeignPtr :: [AllocFlag] -> Int -> IO (ForeignPtr a)
mallocHostForeignPtr ![AllocFlag]
flags !Int
size = do
HostPtr Ptr a
ptr <- [AllocFlag] -> Int -> IO (HostPtr a)
forall a. Storable a => [AllocFlag] -> Int -> IO (HostPtr a)
mallocHostArray [AllocFlag]
flags Int
size
FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
newForeignPtr FinalizerPtr a
forall a. FinalizerPtr a
finalizerMemFreeHost Ptr a
ptr
{-# INLINE cuMemHostAlloc #-}
cuMemHostAlloc :: (Int) -> ([AllocFlag]) -> IO ((Status), (HostPtr a))
cuMemHostAlloc :: Int -> [AllocFlag] -> IO (Status, HostPtr a)
cuMemHostAlloc Int
a2 [AllocFlag]
a3 =
(Ptr (Ptr ()) -> IO (Status, HostPtr a)) -> IO (Status, HostPtr a)
forall b b. (Ptr b -> IO b) -> IO b
alloca' ((Ptr (Ptr ()) -> IO (Status, HostPtr a))
-> IO (Status, HostPtr a))
-> (Ptr (Ptr ()) -> IO (Status, HostPtr a))
-> IO (Status, HostPtr a)
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr ())
a1' ->
let {a2' :: CULong
a2' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = [AllocFlag] -> CUInt
forall a b. (Enum a, Num b, Bits b) => [a] -> b
combineBitMasks [AllocFlag]
a3} in
Ptr (Ptr ()) -> CULong -> CUInt -> IO CInt
cuMemHostAlloc'_ Ptr (Ptr ())
a1' CULong
a2' CUInt
a3' IO CInt
-> (CInt -> IO (Status, HostPtr a)) -> IO (Status, HostPtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Ptr (Ptr ()) -> IO (HostPtr a)
forall a a. Ptr (Ptr a) -> IO (HostPtr a)
peekHP Ptr (Ptr ())
a1'IO (HostPtr a)
-> (HostPtr a -> IO (Status, HostPtr a)) -> IO (Status, HostPtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \HostPtr a
a1'' ->
(Status, HostPtr a) -> IO (Status, HostPtr a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res', HostPtr a
a1'')
{-# LINE 141 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
alloca' !f = F.alloca $ \ !p -> poke p nullPtr >> f (castPtr p)
peekHP !p = HostPtr . castPtr <$> peek p
foreign import ccall "&cuMemFreeHost" finalizerMemFreeHost :: FinalizerPtr a
{-# INLINEABLE freeHost #-}
freeHost :: HostPtr a -> IO ()
freeHost :: HostPtr a -> IO ()
freeHost !HostPtr a
p = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HostPtr a -> IO Status
forall a. HostPtr a -> IO Status
cuMemFreeHost HostPtr a
p
{-# INLINE cuMemFreeHost #-}
cuMemFreeHost :: (HostPtr a) -> IO ((Status))
cuMemFreeHost :: HostPtr a -> IO Status
cuMemFreeHost HostPtr a
a1 =
let {a1' :: Ptr b
a1' = HostPtr a -> Ptr b
forall a b. HostPtr a -> Ptr b
useHP HostPtr a
a1} in
Ptr () -> IO CInt
cuMemFreeHost'_ Ptr ()
forall b. Ptr b
a1' IO CInt -> (CInt -> IO Status) -> IO Status
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 163 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
useHP = castPtr . useHostPtr
{-# INLINEABLE registerArray #-}
registerArray :: Storable a => [AllocFlag] -> Int -> Ptr a -> IO (HostPtr a)
registerArray :: [AllocFlag] -> Int -> Ptr a -> IO (HostPtr a)
registerArray ![AllocFlag]
flags !Int
n = a -> Ptr a -> IO (HostPtr a)
forall b. Storable b => b -> Ptr b -> IO (HostPtr b)
go a
forall a. HasCallStack => a
undefined
where
go :: Storable b => b -> Ptr b -> IO (HostPtr b)
go :: b -> Ptr b -> IO (HostPtr b)
go b
x !Ptr b
p = do
Status
status <- Ptr b -> Int -> [AllocFlag] -> IO Status
forall a. Ptr a -> Int -> [AllocFlag] -> IO Status
cuMemHostRegister Ptr b
p (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* b -> Int
forall a. Storable a => a -> Int
sizeOf b
x) [AllocFlag]
flags
(Status, HostPtr b) -> IO (HostPtr b)
forall a. (Status, a) -> IO a
resultIfOk (Status
status,Ptr b -> HostPtr b
forall a. Ptr a -> HostPtr a
HostPtr Ptr b
p)
{-# INLINE cuMemHostRegister #-}
cuMemHostRegister :: (Ptr a) -> (Int) -> ([AllocFlag]) -> IO ((Status))
cuMemHostRegister :: Ptr a -> Int -> [AllocFlag] -> IO Status
cuMemHostRegister Ptr a
a1 Int
a2 [AllocFlag]
a3 =
let {a1' :: Ptr b
a1' = Ptr a -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr a
a1} in
let {a2' :: CULong
a2' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = [AllocFlag] -> CUInt
forall a b. (Enum a, Num b, Bits b) => [a] -> b
combineBitMasks [AllocFlag]
a3} in
Ptr () -> CULong -> CUInt -> IO CInt
cuMemHostRegister'_ Ptr ()
forall b. Ptr b
a1' CULong
a2' CUInt
a3' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 204 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE unregisterArray #-}
unregisterArray :: HostPtr a -> IO (Ptr a)
unregisterArray :: HostPtr a -> IO (Ptr a)
unregisterArray (HostPtr !Ptr a
p) = do
Status
status <- Ptr a -> IO Status
forall a. Ptr a -> IO Status
cuMemHostUnregister Ptr a
p
(Status, Ptr a) -> IO (Ptr a)
forall a. (Status, a) -> IO a
resultIfOk (Status
status,Ptr a
p)
{-# INLINE cuMemHostUnregister #-}
cuMemHostUnregister :: (Ptr a) -> IO ((Status))
cuMemHostUnregister :: Ptr a -> IO Status
cuMemHostUnregister Ptr a
a1 =
let {a1' :: Ptr b
a1' = Ptr a -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr a
a1} in
Ptr () -> IO CInt
cuMemHostUnregister'_ Ptr ()
forall b. Ptr b
a1' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 226 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE mallocArray #-}
mallocArray :: Storable a => Int -> IO (DevicePtr a)
mallocArray :: Int -> IO (DevicePtr a)
mallocArray = a -> Int -> IO (DevicePtr a)
forall a'. Storable a' => a' -> Int -> IO (DevicePtr a')
doMalloc a
forall a. HasCallStack => a
undefined
where
doMalloc :: Storable a' => a' -> Int -> IO (DevicePtr a')
doMalloc :: a' -> Int -> IO (DevicePtr a')
doMalloc a'
x !Int
n = (Status, DevicePtr a') -> IO (DevicePtr a')
forall a. (Status, a) -> IO a
resultIfOk ((Status, DevicePtr a') -> IO (DevicePtr a'))
-> IO (Status, DevicePtr a') -> IO (DevicePtr a')
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Int -> IO (Status, DevicePtr a')
forall a. Int -> IO (Status, DevicePtr a)
cuMemAlloc (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x)
{-# INLINE cuMemAlloc #-}
cuMemAlloc :: (Int) -> IO ((Status), (DevicePtr a))
cuMemAlloc :: Int -> IO (Status, DevicePtr a)
cuMemAlloc Int
a2 =
(Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall b b. (Ptr b -> IO b) -> IO b
alloca' ((Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a))
-> (Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall a b. (a -> b) -> a -> b
$ \Ptr CULLong
a1' ->
let {a2' :: CULong
a2' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
Ptr CULLong -> CULong -> IO CInt
cuMemAlloc'_ Ptr CULLong
a1' CULong
a2' IO CInt
-> (CInt -> IO (Status, DevicePtr a)) -> IO (Status, DevicePtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Ptr CULLong -> IO (DevicePtr a)
forall a. Ptr CULLong -> IO (DevicePtr a)
peekDeviceHandle Ptr CULLong
a1'IO (DevicePtr a)
-> (DevicePtr a -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \DevicePtr a
a1'' ->
(Status, DevicePtr a) -> IO (Status, DevicePtr a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res', DevicePtr a
a1'')
{-# LINE 250 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
alloca' !f = F.alloca $ \ !p -> poke p nullPtr >> f (castPtr p)
{-# INLINEABLE allocaArray #-}
allocaArray :: Storable a => Int -> (DevicePtr a -> IO b) -> IO b
allocaArray :: Int -> (DevicePtr a -> IO b) -> IO b
allocaArray !Int
n = IO (DevicePtr a)
-> (DevicePtr a -> IO ()) -> (DevicePtr a -> IO b) -> IO b
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (DevicePtr a)
forall a. Storable a => Int -> IO (DevicePtr a)
mallocArray Int
n) DevicePtr a -> IO ()
forall a. DevicePtr a -> IO ()
free
{-# INLINEABLE free #-}
free :: DevicePtr a -> IO ()
free :: DevicePtr a -> IO ()
free !DevicePtr a
dp = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> IO Status
forall a. DevicePtr a -> IO Status
cuMemFree DevicePtr a
dp
{-# INLINE cuMemFree #-}
cuMemFree :: (DevicePtr a) -> IO ((Status))
cuMemFree :: DevicePtr a -> IO Status
cuMemFree DevicePtr a
a1 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
CULLong -> IO CInt
cuMemFree'_ CULLong
a1' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 281 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
data AttachFlag = CuMemAttachGlobal
| CuMemAttachHost
| CuMemAttachSingle
deriving (AttachFlag -> AttachFlag -> Bool
(AttachFlag -> AttachFlag -> Bool)
-> (AttachFlag -> AttachFlag -> Bool) -> Eq AttachFlag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachFlag -> AttachFlag -> Bool
$c/= :: AttachFlag -> AttachFlag -> Bool
== :: AttachFlag -> AttachFlag -> Bool
$c== :: AttachFlag -> AttachFlag -> Bool
Eq,Int -> AttachFlag -> ShowS
[AttachFlag] -> ShowS
AttachFlag -> String
(Int -> AttachFlag -> ShowS)
-> (AttachFlag -> String)
-> ([AttachFlag] -> ShowS)
-> Show AttachFlag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachFlag] -> ShowS
$cshowList :: [AttachFlag] -> ShowS
show :: AttachFlag -> String
$cshow :: AttachFlag -> String
showsPrec :: Int -> AttachFlag -> ShowS
$cshowsPrec :: Int -> AttachFlag -> ShowS
Show,AttachFlag
AttachFlag -> AttachFlag -> Bounded AttachFlag
forall a. a -> a -> Bounded a
maxBound :: AttachFlag
$cmaxBound :: AttachFlag
minBound :: AttachFlag
$cminBound :: AttachFlag
Bounded)
instance Enum AttachFlag where
succ :: AttachFlag -> AttachFlag
succ AttachFlag
CuMemAttachGlobal = AttachFlag
CuMemAttachHost
succ AttachFlag
CuMemAttachHost = AttachFlag
CuMemAttachSingle
succ AttachFlag
CuMemAttachSingle = String -> AttachFlag
forall a. HasCallStack => String -> a
error String
"AttachFlag.succ: CuMemAttachSingle has no successor"
pred :: AttachFlag -> AttachFlag
pred AttachFlag
CuMemAttachHost = AttachFlag
CuMemAttachGlobal
pred AttachFlag
CuMemAttachSingle = AttachFlag
CuMemAttachHost
pred AttachFlag
CuMemAttachGlobal = String -> AttachFlag
forall a. HasCallStack => String -> a
error String
"AttachFlag.pred: CuMemAttachGlobal has no predecessor"
enumFromTo :: AttachFlag -> AttachFlag -> [AttachFlag]
enumFromTo AttachFlag
from AttachFlag
to = AttachFlag -> [AttachFlag]
forall t. Enum t => t -> [t]
go AttachFlag
from
where
end :: Int
end = AttachFlag -> Int
forall a. Enum a => a -> Int
fromEnum AttachFlag
to
go :: t -> [t]
go t
v = case Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (t -> Int
forall a. Enum a => a -> Int
fromEnum t
v) Int
end of
Ordering
LT -> t
v t -> [t] -> [t]
forall a. a -> [a] -> [a]
: t -> [t]
go (t -> t
forall a. Enum a => a -> a
succ t
v)
Ordering
EQ -> [t
v]
Ordering
GT -> []
enumFrom :: AttachFlag -> [AttachFlag]
enumFrom AttachFlag
from = AttachFlag -> AttachFlag -> [AttachFlag]
forall a. Enum a => a -> a -> [a]
enumFromTo AttachFlag
from AttachFlag
CuMemAttachSingle
fromEnum :: AttachFlag -> Int
fromEnum AttachFlag
CuMemAttachGlobal = Int
1
fromEnum AttachFlag
CuMemAttachHost = Int
2
fromEnum AttachFlag
CuMemAttachSingle = Int
4
toEnum :: Int -> AttachFlag
toEnum Int
1 = AttachFlag
CuMemAttachGlobal
toEnum Int
2 = AttachFlag
CuMemAttachHost
toEnum Int
4 = AttachFlag
CuMemAttachSingle
toEnum unmatched = error ("AttachFlag.toEnum: Cannot match " ++ show unmatched)
{-# LINE 297 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE mallocManagedArray #-}
mallocManagedArray :: Storable a => [AttachFlag] -> Int -> IO (DevicePtr a)
mallocManagedArray !flags = doMalloc undefined
where
doMalloc :: Storable a' => a' -> Int -> IO (DevicePtr a')
doMalloc x !n = resultIfOk =<< cuMemAllocManaged (n * sizeOf x) flags
{-# INLINE cuMemAllocManaged #-}
cuMemAllocManaged :: (Int) -> ([AttachFlag]) -> IO ((Status), (DevicePtr a))
cuMemAllocManaged :: Int -> [AttachFlag] -> IO (Status, DevicePtr a)
cuMemAllocManaged Int
a2 [AttachFlag]
a3 =
(Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall b b. (Ptr b -> IO b) -> IO b
alloca' ((Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a))
-> (Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall a b. (a -> b) -> a -> b
$ \Ptr CULLong
a1' ->
let {a2' :: CULong
a2' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = [AttachFlag] -> CUInt
forall a b. (Enum a, Num b, Bits b) => [a] -> b
combineBitMasks [AttachFlag]
a3} in
Ptr CULLong -> CULong -> CUInt -> IO CInt
cuMemAllocManaged'_ Ptr CULLong
a1' CULong
a2' CUInt
a3' IO CInt
-> (CInt -> IO (Status, DevicePtr a)) -> IO (Status, DevicePtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Ptr CULLong -> IO (DevicePtr a)
forall a. Ptr CULLong -> IO (DevicePtr a)
peekDeviceHandle Ptr CULLong
a1'IO (DevicePtr a)
-> (DevicePtr a -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \DevicePtr a
a1'' ->
(Status, DevicePtr a) -> IO (Status, DevicePtr a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res', a1'')
{-# LINE 335 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
alloca' !f = F.alloca $ \ !p -> poke p nullPtr >> f (castPtr p)
prefetchArrayAsync :: Storable a => DevicePtr a -> Int -> Maybe Device -> Maybe Stream -> IO ()
prefetchArrayAsync :: DevicePtr a -> Int -> Maybe Device -> Maybe Stream -> IO ()
prefetchArrayAsync DevicePtr a
ptr Int
n Maybe Device
mdev Maybe Stream
mst = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
go a
forall a. HasCallStack => a
undefined DevicePtr a
ptr
where
go :: Storable a' => a' -> DevicePtr a' -> IO ()
go :: a' -> DevicePtr a' -> IO ()
go a'
x DevicePtr a'
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> Int -> CInt -> Stream -> IO Status
forall a. DevicePtr a -> Int -> CInt -> Stream -> IO Status
cuMemPrefetchAsync DevicePtr a
ptr (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x) (CInt -> (Device -> CInt) -> Maybe Device -> CInt
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (-CInt
1) Device -> CInt
useDevice Maybe Device
mdev) (Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst)
{-# INLINE cuMemPrefetchAsync #-}
cuMemPrefetchAsync :: (DevicePtr a) -> (Int) -> (CInt) -> (Stream) -> IO ((Status))
cuMemPrefetchAsync :: DevicePtr a -> Int -> CInt -> Stream -> IO Status
cuMemPrefetchAsync DevicePtr a
a1 Int
a2 CInt
a3 Stream
a4 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: CULong
a2' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CInt
a3' = CInt -> CInt
forall a. a -> a
id CInt
a3} in
let {a4' :: Ptr ()
a4' = Stream -> Ptr ()
useStream Stream
a4} in
CULLong -> CULong -> CInt -> Ptr () -> IO CInt
cuMemPrefetchAsync'_ CULLong
a1' CULong
a2' CInt
a3' Ptr ()
a4' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 367 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE attachArrayAsync #-}
attachArrayAsync :: forall a. Storable a => [AttachFlag] -> Stream -> DevicePtr a -> Int -> IO ()
attachArrayAsync :: [AttachFlag] -> Stream -> DevicePtr a -> Int -> IO ()
attachArrayAsync ![AttachFlag]
flags !Stream
stream !DevicePtr a
ptr !Int
n = Stream -> DevicePtr a -> Int -> [AttachFlag] -> IO ()
cuStreamAttachMemAsync Stream
stream DevicePtr a
ptr (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a -> Int
forall a. Storable a => a -> Int
sizeOf (a
forall a. HasCallStack => a
undefined::a)) [AttachFlag]
flags
where
cuStreamAttachMemAsync :: (Stream) -> (DevicePtr a) -> (Int) -> ([AttachFlag]) -> IO ()
cuStreamAttachMemAsync :: Stream -> DevicePtr a -> Int -> [AttachFlag] -> IO ()
cuStreamAttachMemAsync Stream
a1 DevicePtr a
a2 Int
a3 [AttachFlag]
a4 =
let {a1' :: Ptr ()
a1' = Stream -> Ptr ()
useStream Stream
a1} in
let {a2' :: CULLong
a2' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: CUInt
a4' = [AttachFlag] -> CUInt
forall a b. (Enum a, Num b, Bits b) => [a] -> b
combineBitMasks [AttachFlag]
a4} in
Ptr () -> CULLong -> CULong -> CUInt -> IO CInt
cuStreamAttachMemAsync'_ Ptr ()
a1' CULLong
a2' CULong
a3' CUInt
a4' IO CInt -> (CInt -> IO ()) -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
CInt -> IO ()
checkStatus CInt
res IO () -> IO () -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
{-# LINE 386 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE peekArray #-}
peekArray :: Storable a => Int -> DevicePtr a -> Ptr a -> IO ()
peekArray :: Int -> DevicePtr a -> Ptr a -> IO ()
peekArray !Int
n !DevicePtr a
dptr !Ptr a
hptr = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doPeek a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
doPeek :: Storable a' => a' -> DevicePtr a' -> IO ()
doPeek :: a' -> DevicePtr a' -> IO ()
doPeek a'
x DevicePtr a'
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr a -> DevicePtr a -> Int -> IO Status
forall a. Ptr a -> DevicePtr a -> Int -> IO Status
cuMemcpyDtoH Ptr a
hptr DevicePtr a
dptr (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x)
{-# INLINE cuMemcpyDtoH #-}
cuMemcpyDtoH :: (Ptr a) -> (DevicePtr a) -> (Int) -> IO ((Status))
cuMemcpyDtoH :: Ptr a -> DevicePtr a -> Int -> IO Status
cuMemcpyDtoH Ptr a
a1 DevicePtr a
a2 Int
a3 =
let {a1' :: Ptr b
a1' = Ptr a -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr a
a1} in
let {a2' :: CULLong
a2' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
Ptr () -> CULLong -> CULong -> IO CInt
cuMemcpyDtoH'_ Ptr ()
forall b. Ptr b
a1' CULLong
a2' CULong
a3' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 413 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE peekArrayAsync #-}
peekArrayAsync :: Storable a => Int -> DevicePtr a -> HostPtr a -> Maybe Stream -> IO ()
peekArrayAsync :: Int -> DevicePtr a -> HostPtr a -> Maybe Stream -> IO ()
peekArrayAsync !Int
n !DevicePtr a
dptr !HostPtr a
hptr !Maybe Stream
mst = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doPeek a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
doPeek :: Storable a' => a' -> DevicePtr a' -> IO ()
doPeek :: a' -> DevicePtr a' -> IO ()
doPeek a'
x DevicePtr a'
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HostPtr a -> DevicePtr a -> Int -> Stream -> IO Status
forall a. HostPtr a -> DevicePtr a -> Int -> Stream -> IO Status
cuMemcpyDtoHAsync HostPtr a
hptr DevicePtr a
dptr (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x) (Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst)
{-# INLINE cuMemcpyDtoHAsync #-}
cuMemcpyDtoHAsync :: (HostPtr a) -> (DevicePtr a) -> (Int) -> (Stream) -> IO ((Status))
cuMemcpyDtoHAsync :: HostPtr a -> DevicePtr a -> Int -> Stream -> IO Status
cuMemcpyDtoHAsync HostPtr a
a1 DevicePtr a
a2 Int
a3 Stream
a4 =
let {a1' :: Ptr b
a1' = HostPtr a -> Ptr b
forall a b. HostPtr a -> Ptr b
useHP HostPtr a
a1} in
let {a2' :: CULLong
a2' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: Ptr ()
a4' = Stream -> Ptr ()
useStream Stream
a4} in
Ptr () -> CULLong -> CULong -> Ptr () -> IO CInt
cuMemcpyDtoHAsync'_ Ptr ()
forall b. Ptr b
a1' CULLong
a2' CULong
a3' Ptr ()
a4' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 434 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
useHP = castPtr . useHostPtr
{-# INLINEABLE peekArray2D #-}
peekArray2D
:: Storable a
=> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Ptr a
-> Int
-> Int
-> Int
-> IO ()
peekArray2D :: Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Ptr a
-> Int
-> Int
-> Int
-> IO ()
peekArray2D !Int
w !Int
h !DevicePtr a
dptr !Int
dw !Int
dx !Int
dy !Ptr a
hptr !Int
hw !Int
hx !Int
hy = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doPeek a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
doPeek :: Storable a' => a' -> DevicePtr a' -> IO ()
doPeek :: a' -> DevicePtr a' -> IO ()
doPeek a'
x DevicePtr a'
_ =
let bytes :: Int
bytes = a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x
w' :: Int
w' = Int
w Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hw' :: Int
hw' = Int
hw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hx' :: Int
hx' = Int
hx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dw' :: Int
dw' = Int
dw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dx' :: Int
dx' = Int
dx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
in
Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Ptr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
forall a.
Ptr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
cuMemcpy2DDtoH Ptr a
hptr Int
hw' Int
hx' Int
hy DevicePtr a
dptr Int
dw' Int
dx' Int
dy Int
w' Int
h
{-# INLINE cuMemcpy2DDtoH #-}
cuMemcpy2DDtoH :: (Ptr a) -> (Int) -> (Int) -> (Int) -> (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((Status))
cuMemcpy2DDtoH :: Ptr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
cuMemcpy2DDtoH Ptr a
a1 Int
a2 Int
a3 Int
a4 DevicePtr a
a5 Int
a6 Int
a7 Int
a8 Int
a9 Int
a10 =
let {a1' :: Ptr b
a1' = Ptr a -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr a
a1} in
let {a2' :: CUInt
a2' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: CUInt
a4' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a4} in
let {a5' :: CULLong
a5' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a5} in
let {a6' :: CUInt
a6' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a6} in
let {a7' :: CUInt
a7' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a7} in
let {a8' :: CUInt
a8' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in
let {a9' :: CUInt
a9' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a9} in
let {a10' :: CUInt
a10' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a10} in
Ptr ()
-> CUInt
-> CUInt
-> CUInt
-> CULLong
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> IO CInt
cuMemcpy2DDtoH'_ Ptr ()
forall b. Ptr b
a1' CUInt
a2' CUInt
a3' CUInt
a4' CULLong
a5' CUInt
a6' CUInt
a7' CUInt
a8' CUInt
a9' CUInt
a10' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 484 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE peekArray2DAsync #-}
peekArray2DAsync
:: Storable a
=> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> HostPtr a
-> Int
-> Int
-> Int
-> Maybe Stream
-> IO ()
peekArray2DAsync :: Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> HostPtr a
-> Int
-> Int
-> Int
-> Maybe Stream
-> IO ()
peekArray2DAsync !Int
w !Int
h !DevicePtr a
dptr !Int
dw !Int
dx !Int
dy !HostPtr a
hptr !Int
hw !Int
hx !Int
hy !Maybe Stream
mst = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doPeek a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
doPeek :: Storable a' => a' -> DevicePtr a' -> IO ()
doPeek :: a' -> DevicePtr a' -> IO ()
doPeek a'
x DevicePtr a'
_ =
let bytes :: Int
bytes = a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x
w' :: Int
w' = Int
w Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hw' :: Int
hw' = Int
hw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hx' :: Int
hx' = Int
hx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dw' :: Int
dw' = Int
dw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dx' :: Int
dx' = Int
dx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
st :: Stream
st = Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst
in
Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HostPtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
forall a.
HostPtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
cuMemcpy2DDtoHAsync HostPtr a
hptr Int
hw' Int
hx' Int
hy DevicePtr a
dptr Int
dw' Int
dx' Int
dy Int
w' Int
h Stream
st
{-# INLINE cuMemcpy2DDtoHAsync #-}
cuMemcpy2DDtoHAsync :: (HostPtr a) -> (Int) -> (Int) -> (Int) -> (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (Int) -> (Int) -> (Stream) -> IO ((Status))
cuMemcpy2DDtoHAsync :: HostPtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
cuMemcpy2DDtoHAsync HostPtr a
a1 Int
a2 Int
a3 Int
a4 DevicePtr a
a5 Int
a6 Int
a7 Int
a8 Int
a9 Int
a10 Stream
a11 =
let {a1' :: Ptr b
a1' = HostPtr a -> Ptr b
forall a b. HostPtr a -> Ptr b
useHP HostPtr a
a1} in
let {a2' :: CUInt
a2' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: CUInt
a4' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a4} in
let {a5' :: CULLong
a5' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a5} in
let {a6' :: CUInt
a6' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a6} in
let {a7' :: CUInt
a7' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a7} in
let {a8' :: CUInt
a8' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in
let {a9' :: CUInt
a9' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a9} in
let {a10' :: CUInt
a10' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a10} in
let {a11' :: Ptr ()
a11' = Stream -> Ptr ()
useStream Stream
a11} in
Ptr ()
-> CUInt
-> CUInt
-> CUInt
-> CULLong
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> Ptr ()
-> IO CInt
cuMemcpy2DDtoHAsync'_ Ptr ()
forall b. Ptr b
a1' CUInt
a2' CUInt
a3' CUInt
a4' CULLong
a5' CUInt
a6' CUInt
a7' CUInt
a8' CUInt
a9' CUInt
a10' Ptr ()
a11' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 537 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
useHP = castPtr . useHostPtr
{-# INLINEABLE peekListArray #-}
peekListArray :: Storable a => Int -> DevicePtr a -> IO [a]
peekListArray :: Int -> DevicePtr a -> IO [a]
peekListArray !Int
n !DevicePtr a
dptr =
Int -> (Ptr a -> IO [a]) -> IO [a]
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
F.allocaArray Int
n ((Ptr a -> IO [a]) -> IO [a]) -> (Ptr a -> IO [a]) -> IO [a]
forall a b. (a -> b) -> a -> b
$ \Ptr a
p -> do
Int -> DevicePtr a -> Ptr a -> IO ()
forall a. Storable a => Int -> DevicePtr a -> Ptr a -> IO ()
peekArray Int
n DevicePtr a
dptr Ptr a
p
Int -> Ptr a -> IO [a]
forall a. Storable a => Int -> Ptr a -> IO [a]
F.peekArray Int
n Ptr a
p
{-# INLINEABLE pokeArray #-}
pokeArray :: Storable a => Int -> Ptr a -> DevicePtr a -> IO ()
pokeArray :: Int -> Ptr a -> DevicePtr a -> IO ()
pokeArray !Int
n !Ptr a
hptr !DevicePtr a
dptr = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doPoke a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
doPoke :: Storable a' => a' -> DevicePtr a' -> IO ()
doPoke :: a' -> DevicePtr a' -> IO ()
doPoke a'
x DevicePtr a'
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> Ptr a -> Int -> IO Status
forall a. DevicePtr a -> Ptr a -> Int -> IO Status
cuMemcpyHtoD DevicePtr a
dptr Ptr a
hptr (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x)
{-# INLINE cuMemcpyHtoD #-}
cuMemcpyHtoD :: (DevicePtr a) -> (Ptr a) -> (Int) -> IO ((Status))
cuMemcpyHtoD :: DevicePtr a -> Ptr a -> Int -> IO Status
cuMemcpyHtoD DevicePtr a
a1 Ptr a
a2 Int
a3 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: Ptr b
a2' = Ptr a -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
CULLong -> Ptr () -> CULong -> IO CInt
cuMemcpyHtoD'_ CULLong
a1' Ptr ()
forall b. Ptr b
a2' CULong
a3' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 574 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE pokeArrayAsync #-}
pokeArrayAsync :: Storable a => Int -> HostPtr a -> DevicePtr a -> Maybe Stream -> IO ()
pokeArrayAsync :: Int -> HostPtr a -> DevicePtr a -> Maybe Stream -> IO ()
pokeArrayAsync !Int
n !HostPtr a
hptr !DevicePtr a
dptr !Maybe Stream
mst = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
dopoke a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
dopoke :: Storable a' => a' -> DevicePtr a' -> IO ()
dopoke :: a' -> DevicePtr a' -> IO ()
dopoke a'
x DevicePtr a'
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> HostPtr a -> Int -> Stream -> IO Status
forall a. DevicePtr a -> HostPtr a -> Int -> Stream -> IO Status
cuMemcpyHtoDAsync DevicePtr a
dptr HostPtr a
hptr (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x) (Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst)
{-# INLINE cuMemcpyHtoDAsync #-}
cuMemcpyHtoDAsync :: (DevicePtr a) -> (HostPtr a) -> (Int) -> (Stream) -> IO ((Status))
cuMemcpyHtoDAsync :: DevicePtr a -> HostPtr a -> Int -> Stream -> IO Status
cuMemcpyHtoDAsync DevicePtr a
a1 HostPtr a
a2 Int
a3 Stream
a4 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: Ptr b
a2' = HostPtr a -> Ptr b
forall a b. HostPtr a -> Ptr b
useHP HostPtr a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: Ptr ()
a4' = Stream -> Ptr ()
useStream Stream
a4} in
CULLong -> Ptr () -> CULong -> Ptr () -> IO CInt
cuMemcpyHtoDAsync'_ CULLong
a1' Ptr ()
forall b. Ptr b
a2' CULong
a3' Ptr ()
a4' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 595 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
useHP = castPtr . useHostPtr
{-# INLINEABLE pokeArray2D #-}
pokeArray2D
:: Storable a
=> Int
-> Int
-> Ptr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> IO ()
pokeArray2D :: Int
-> Int
-> Ptr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> IO ()
pokeArray2D !Int
w !Int
h !Ptr a
hptr !Int
hw !Int
hx !Int
hy !DevicePtr a
dptr !Int
dw !Int
dx !Int
dy = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doPoke a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
doPoke :: Storable a' => a' -> DevicePtr a' -> IO ()
doPoke :: a' -> DevicePtr a' -> IO ()
doPoke a'
x DevicePtr a'
_ =
let bytes :: Int
bytes = a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x
w' :: Int
w' = Int
w Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hw' :: Int
hw' = Int
hw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hx' :: Int
hx' = Int
hx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dw' :: Int
dw' = Int
dw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dx' :: Int
dx' = Int
dx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
in
Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a
-> Int
-> Int
-> Int
-> Ptr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
forall a.
DevicePtr a
-> Int
-> Int
-> Int
-> Ptr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
cuMemcpy2DHtoD DevicePtr a
dptr Int
dw' Int
dx' Int
dy Ptr a
hptr Int
hw' Int
hx' Int
hy Int
w' Int
h
{-# INLINE cuMemcpy2DHtoD #-}
cuMemcpy2DHtoD :: (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (Ptr a) -> (Int) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((Status))
cuMemcpy2DHtoD :: DevicePtr a
-> Int
-> Int
-> Int
-> Ptr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
cuMemcpy2DHtoD DevicePtr a
a1 Int
a2 Int
a3 Int
a4 Ptr a
a5 Int
a6 Int
a7 Int
a8 Int
a9 Int
a10 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: CUInt
a2' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: CUInt
a4' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a4} in
let {a5' :: Ptr b
a5' = Ptr a -> Ptr b
forall a b. Ptr a -> Ptr b
castPtr Ptr a
a5} in
let {a6' :: CUInt
a6' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a6} in
let {a7' :: CUInt
a7' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a7} in
let {a8' :: CUInt
a8' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in
let {a9' :: CUInt
a9' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a9} in
let {a10' :: CUInt
a10' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a10} in
CULLong
-> CUInt
-> CUInt
-> CUInt
-> Ptr ()
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> IO CInt
cuMemcpy2DHtoD'_ CULLong
a1' CUInt
a2' CUInt
a3' CUInt
a4' Ptr ()
forall b. Ptr b
a5' CUInt
a6' CUInt
a7' CUInt
a8' CUInt
a9' CUInt
a10' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 645 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE pokeArray2DAsync #-}
pokeArray2DAsync
:: Storable a
=> Int
-> Int
-> HostPtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Maybe Stream
-> IO ()
pokeArray2DAsync :: Int
-> Int
-> HostPtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Maybe Stream
-> IO ()
pokeArray2DAsync !Int
w !Int
h !HostPtr a
hptr !Int
hw !Int
hx !Int
hy !DevicePtr a
dptr !Int
dw !Int
dx !Int
dy !Maybe Stream
mst = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doPoke a
forall a. HasCallStack => a
undefined DevicePtr a
dptr
where
doPoke :: Storable a' => a' -> DevicePtr a' -> IO ()
doPoke :: a' -> DevicePtr a' -> IO ()
doPoke a'
x DevicePtr a'
_ =
let bytes :: Int
bytes = a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x
w' :: Int
w' = Int
w Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hw' :: Int
hw' = Int
hw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hx' :: Int
hx' = Int
hx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dw' :: Int
dw' = Int
dw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dx' :: Int
dx' = Int
dx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
st :: Stream
st = Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst
in
Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a
-> Int
-> Int
-> Int
-> HostPtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
forall a.
DevicePtr a
-> Int
-> Int
-> Int
-> HostPtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
cuMemcpy2DHtoDAsync DevicePtr a
dptr Int
dw' Int
dx' Int
dy HostPtr a
hptr Int
hw' Int
hx' Int
hy Int
w' Int
h Stream
st
{-# INLINE cuMemcpy2DHtoDAsync #-}
cuMemcpy2DHtoDAsync :: (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (HostPtr a) -> (Int) -> (Int) -> (Int) -> (Int) -> (Int) -> (Stream) -> IO ((Status))
cuMemcpy2DHtoDAsync :: DevicePtr a
-> Int
-> Int
-> Int
-> HostPtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
cuMemcpy2DHtoDAsync DevicePtr a
a1 Int
a2 Int
a3 Int
a4 HostPtr a
a5 Int
a6 Int
a7 Int
a8 Int
a9 Int
a10 Stream
a11 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: CUInt
a2' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: CUInt
a4' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a4} in
let {a5' :: Ptr b
a5' = HostPtr a -> Ptr b
forall a b. HostPtr a -> Ptr b
useHP HostPtr a
a5} in
let {a6' :: CUInt
a6' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a6} in
let {a7' :: CUInt
a7' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a7} in
let {a8' :: CUInt
a8' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in
let {a9' :: CUInt
a9' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a9} in
let {a10' :: CUInt
a10' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a10} in
let {a11' :: Ptr ()
a11' = Stream -> Ptr ()
useStream Stream
a11} in
CULLong
-> CUInt
-> CUInt
-> CUInt
-> Ptr ()
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> Ptr ()
-> IO CInt
cuMemcpy2DHtoDAsync'_ CULLong
a1' CUInt
a2' CUInt
a3' CUInt
a4' Ptr ()
forall b. Ptr b
a5' CUInt
a6' CUInt
a7' CUInt
a8' CUInt
a9' CUInt
a10' Ptr ()
a11' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 698 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
useHP = castPtr . useHostPtr
{-# INLINEABLE pokeListArray #-}
pokeListArray :: Storable a => [a] -> DevicePtr a -> IO ()
pokeListArray :: [a] -> DevicePtr a -> IO ()
pokeListArray ![a]
xs !DevicePtr a
dptr = [a] -> (Int -> Ptr a -> IO ()) -> IO ()
forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
F.withArrayLen [a]
xs ((Int -> Ptr a -> IO ()) -> IO ())
-> (Int -> Ptr a -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ !Int
len !Ptr a
p -> Int -> Ptr a -> DevicePtr a -> IO ()
forall a. Storable a => Int -> Ptr a -> DevicePtr a -> IO ()
pokeArray Int
len Ptr a
p DevicePtr a
dptr
{-# INLINEABLE copyArray #-}
copyArray :: Storable a => Int -> DevicePtr a -> DevicePtr a -> IO ()
copyArray :: Int -> DevicePtr a -> DevicePtr a -> IO ()
copyArray !Int
n = a -> DevicePtr a -> DevicePtr a -> IO ()
forall a'.
Storable a' =>
a' -> DevicePtr a' -> DevicePtr a' -> IO ()
docopy a
forall a. HasCallStack => a
undefined
where
docopy :: Storable a' => a' -> DevicePtr a' -> DevicePtr a' -> IO ()
docopy :: a' -> DevicePtr a' -> DevicePtr a' -> IO ()
docopy a'
x DevicePtr a'
src DevicePtr a'
dst = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a' -> DevicePtr a' -> Int -> IO Status
forall a. DevicePtr a -> DevicePtr a -> Int -> IO Status
cuMemcpyDtoD DevicePtr a'
dst DevicePtr a'
src (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x)
{-# INLINE cuMemcpyDtoD #-}
cuMemcpyDtoD :: (DevicePtr a) -> (DevicePtr a) -> (Int) -> IO ((Status))
cuMemcpyDtoD :: DevicePtr a -> DevicePtr a -> Int -> IO Status
cuMemcpyDtoD DevicePtr a
a1 DevicePtr a
a2 Int
a3 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: CULLong
a2' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
CULLong -> CULLong -> CULong -> IO CInt
cuMemcpyDtoD'_ CULLong
a1' CULLong
a2' CULong
a3' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 735 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE copyArrayAsync #-}
copyArrayAsync :: Storable a => Int -> DevicePtr a -> DevicePtr a -> Maybe Stream -> IO ()
copyArrayAsync :: Int -> DevicePtr a -> DevicePtr a -> Maybe Stream -> IO ()
copyArrayAsync !Int
n !DevicePtr a
src !DevicePtr a
dst !Maybe Stream
mst = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
docopy a
forall a. HasCallStack => a
undefined DevicePtr a
src
where
docopy :: Storable a' => a' -> DevicePtr a' -> IO ()
docopy :: a' -> DevicePtr a' -> IO ()
docopy a'
x DevicePtr a'
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> DevicePtr a -> Int -> Stream -> IO Status
forall a. DevicePtr a -> DevicePtr a -> Int -> Stream -> IO Status
cuMemcpyDtoDAsync DevicePtr a
dst DevicePtr a
src (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x) (Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst)
{-# INLINE cuMemcpyDtoDAsync #-}
cuMemcpyDtoDAsync :: (DevicePtr a) -> (DevicePtr a) -> (Int) -> (Stream) -> IO ((Status))
cuMemcpyDtoDAsync :: DevicePtr a -> DevicePtr a -> Int -> Stream -> IO Status
cuMemcpyDtoDAsync DevicePtr a
a1 DevicePtr a
a2 Int
a3 Stream
a4 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: CULLong
a2' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: Ptr ()
a4' = Stream -> Ptr ()
useStream Stream
a4} in
CULLong -> CULLong -> CULong -> Ptr () -> IO CInt
cuMemcpyDtoDAsync'_ CULLong
a1' CULLong
a2' CULong
a3' Ptr ()
a4' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 758 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE copyArray2D #-}
copyArray2D
:: Storable a
=> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> IO ()
copyArray2D :: Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> IO ()
copyArray2D !Int
w !Int
h !DevicePtr a
src !Int
hw !Int
hx !Int
hy !DevicePtr a
dst !Int
dw !Int
dx !Int
dy = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doCopy a
forall a. HasCallStack => a
undefined DevicePtr a
dst
where
doCopy :: Storable a' => a' -> DevicePtr a' -> IO ()
doCopy :: a' -> DevicePtr a' -> IO ()
doCopy a'
x DevicePtr a'
_ =
let bytes :: Int
bytes = a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x
w' :: Int
w' = Int
w Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hw' :: Int
hw' = Int
hw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hx' :: Int
hx' = Int
hx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dw' :: Int
dw' = Int
dw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dx' :: Int
dx' = Int
dx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
in
Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
forall a.
DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
cuMemcpy2DDtoD DevicePtr a
dst Int
dw' Int
dx' Int
dy DevicePtr a
src Int
hw' Int
hx' Int
hy Int
w' Int
h
{-# INLINE cuMemcpy2DDtoD #-}
cuMemcpy2DDtoD :: (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (Int) -> (Int) -> IO ((Status))
cuMemcpy2DDtoD :: DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> IO Status
cuMemcpy2DDtoD DevicePtr a
a1 Int
a2 Int
a3 Int
a4 DevicePtr a
a5 Int
a6 Int
a7 Int
a8 Int
a9 Int
a10 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: CUInt
a2' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: CUInt
a4' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a4} in
let {a5' :: CULLong
a5' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a5} in
let {a6' :: CUInt
a6' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a6} in
let {a7' :: CUInt
a7' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a7} in
let {a8' :: CUInt
a8' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in
let {a9' :: CUInt
a9' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a9} in
let {a10' :: CUInt
a10' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a10} in
CULLong
-> CUInt
-> CUInt
-> CUInt
-> CULLong
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> IO CInt
cuMemcpy2DDtoD'_ CULLong
a1' CUInt
a2' CUInt
a3' CUInt
a4' CULLong
a5' CUInt
a6' CUInt
a7' CUInt
a8' CUInt
a9' CUInt
a10' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 809 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE copyArray2DAsync #-}
copyArray2DAsync
:: Storable a
=> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Maybe Stream
-> IO ()
copyArray2DAsync :: Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Maybe Stream
-> IO ()
copyArray2DAsync !Int
w !Int
h !DevicePtr a
src !Int
hw !Int
hx !Int
hy !DevicePtr a
dst !Int
dw !Int
dx !Int
dy !Maybe Stream
mst = a -> DevicePtr a -> IO ()
forall a'. Storable a' => a' -> DevicePtr a' -> IO ()
doCopy a
forall a. HasCallStack => a
undefined DevicePtr a
dst
where
doCopy :: Storable a' => a' -> DevicePtr a' -> IO ()
doCopy :: a' -> DevicePtr a' -> IO ()
doCopy a'
x DevicePtr a'
_ =
let bytes :: Int
bytes = a' -> Int
forall a. Storable a => a -> Int
sizeOf a'
x
w' :: Int
w' = Int
w Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hw' :: Int
hw' = Int
hw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
hx' :: Int
hx' = Int
hx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dw' :: Int
dw' = Int
dw Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
dx' :: Int
dx' = Int
dx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
bytes
st :: Stream
st = Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst
in
Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
forall a.
DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
cuMemcpy2DDtoDAsync DevicePtr a
dst Int
dw' Int
dx' Int
dy DevicePtr a
src Int
hw' Int
hx' Int
hy Int
w' Int
h Stream
st
{-# INLINE cuMemcpy2DDtoDAsync #-}
cuMemcpy2DDtoDAsync :: (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (DevicePtr a) -> (Int) -> (Int) -> (Int) -> (Int) -> (Int) -> (Stream) -> IO ((Status))
cuMemcpy2DDtoDAsync :: DevicePtr a
-> Int
-> Int
-> Int
-> DevicePtr a
-> Int
-> Int
-> Int
-> Int
-> Int
-> Stream
-> IO Status
cuMemcpy2DDtoDAsync DevicePtr a
a1 Int
a2 Int
a3 Int
a4 DevicePtr a
a5 Int
a6 Int
a7 Int
a8 Int
a9 Int
a10 Stream
a11 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: CUInt
a2' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a2} in
let {a3' :: CUInt
a3' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: CUInt
a4' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a4} in
let {a5' :: CULLong
a5' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a5} in
let {a6' :: CUInt
a6' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a6} in
let {a7' :: CUInt
a7' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a7} in
let {a8' :: CUInt
a8' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a8} in
let {a9' :: CUInt
a9' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a9} in
let {a10' :: CUInt
a10' = Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a10} in
let {a11' :: Ptr ()
a11' = Stream -> Ptr ()
useStream Stream
a11} in
CULLong
-> CUInt
-> CUInt
-> CUInt
-> CULLong
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> CUInt
-> Ptr ()
-> IO CInt
cuMemcpy2DDtoDAsync'_ CULLong
a1' CUInt
a2' CUInt
a3' CUInt
a4' CULLong
a5' CUInt
a6' CUInt
a7' CUInt
a8' CUInt
a9' CUInt
a10' Ptr ()
a11' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 863 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE copyArrayPeer #-}
copyArrayPeer :: Storable a
=> Int
-> DevicePtr a -> Context
-> DevicePtr a -> Context
-> IO ()
copyArrayPeer :: Int -> DevicePtr a -> Context -> DevicePtr a -> Context -> IO ()
copyArrayPeer !Int
n !DevicePtr a
src !Context
srcCtx !DevicePtr a
dst !Context
dstCtx = a -> DevicePtr a -> DevicePtr a -> IO ()
forall a'.
Storable a' =>
a' -> DevicePtr a' -> DevicePtr a' -> IO ()
go a
forall a. HasCallStack => a
undefined DevicePtr a
src DevicePtr a
dst
where
go :: Storable b => b -> DevicePtr b -> DevicePtr b -> IO ()
go :: b -> DevicePtr b -> DevicePtr b -> IO ()
go b
x DevicePtr b
_ DevicePtr b
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a
-> Context -> DevicePtr a -> Context -> Int -> IO Status
forall a.
DevicePtr a
-> Context -> DevicePtr a -> Context -> Int -> IO Status
cuMemcpyPeer DevicePtr a
dst Context
dstCtx DevicePtr a
src Context
srcCtx (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* b -> Int
forall a. Storable a => a -> Int
sizeOf b
x)
{-# INLINE cuMemcpyPeer #-}
cuMemcpyPeer :: (DevicePtr a) -> (Context) -> (DevicePtr a) -> (Context) -> (Int) -> IO ((Status))
cuMemcpyPeer :: DevicePtr a
-> Context -> DevicePtr a -> Context -> Int -> IO Status
cuMemcpyPeer DevicePtr a
a1 Context
a2 DevicePtr a
a3 Context
a4 Int
a5 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: Ptr ()
a2' = Context -> Ptr ()
useContext Context
a2} in
let {a3' :: CULLong
a3' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a3} in
let {a4' :: Ptr ()
a4' = Context -> Ptr ()
useContext Context
a4} in
let {a5' :: CULong
a5' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a5} in
CULLong -> Ptr () -> CULLong -> Ptr () -> CULong -> IO CInt
cuMemcpyPeer'_ CULLong
a1' Ptr ()
a2' CULLong
a3' Ptr ()
a4' CULong
a5' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 902 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE copyArrayPeerAsync #-}
copyArrayPeerAsync :: Storable a
=> Int
-> DevicePtr a -> Context
-> DevicePtr a -> Context
-> Maybe Stream
-> IO ()
copyArrayPeerAsync :: Int
-> DevicePtr a
-> Context
-> DevicePtr a
-> Context
-> Maybe Stream
-> IO ()
copyArrayPeerAsync !Int
n !DevicePtr a
src !Context
srcCtx !DevicePtr a
dst !Context
dstCtx !Maybe Stream
st = a -> DevicePtr a -> DevicePtr a -> IO ()
forall a'.
Storable a' =>
a' -> DevicePtr a' -> DevicePtr a' -> IO ()
go a
forall a. HasCallStack => a
undefined DevicePtr a
src DevicePtr a
dst
where
go :: Storable b => b -> DevicePtr b -> DevicePtr b -> IO ()
go :: b -> DevicePtr b -> DevicePtr b -> IO ()
go b
x DevicePtr b
_ DevicePtr b
_ = Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a
-> Context -> DevicePtr a -> Context -> Int -> Stream -> IO Status
forall a.
DevicePtr a
-> Context -> DevicePtr a -> Context -> Int -> Stream -> IO Status
cuMemcpyPeerAsync DevicePtr a
dst Context
dstCtx DevicePtr a
src Context
srcCtx (Int
n Int -> Int -> Int
forall a. Num a => a -> a -> a
* b -> Int
forall a. Storable a => a -> Int
sizeOf b
x) Stream
stream
stream :: Stream
stream = Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
st
{-# INLINE cuMemcpyPeerAsync #-}
cuMemcpyPeerAsync :: (DevicePtr a) -> (Context) -> (DevicePtr a) -> (Context) -> (Int) -> (Stream) -> IO ((Status))
cuMemcpyPeerAsync :: DevicePtr a
-> Context -> DevicePtr a -> Context -> Int -> Stream -> IO Status
cuMemcpyPeerAsync DevicePtr a
a1 Context
a2 DevicePtr a
a3 Context
a4 Int
a5 Stream
a6 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: Ptr ()
a2' = Context -> Ptr ()
useContext Context
a2} in
let {a3' :: CULLong
a3' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a3} in
let {a4' :: Ptr ()
a4' = Context -> Ptr ()
useContext Context
a4} in
let {a5' :: CULong
a5' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a5} in
let {a6' :: Ptr ()
a6' = Stream -> Ptr ()
useStream Stream
a6} in
CULLong
-> Ptr () -> CULLong -> Ptr () -> CULong -> Ptr () -> IO CInt
cuMemcpyPeerAsync'_ CULLong
a1' Ptr ()
a2' CULLong
a3' Ptr ()
a4' CULong
a5' Ptr ()
a6' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 938 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE newListArrayLen #-}
newListArrayLen :: Storable a => [a] -> IO (DevicePtr a, Int)
newListArrayLen :: [a] -> IO (DevicePtr a, Int)
newListArrayLen [a]
xs =
[a]
-> (Int -> Ptr a -> IO (DevicePtr a, Int)) -> IO (DevicePtr a, Int)
forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
F.withArrayLen [a]
xs ((Int -> Ptr a -> IO (DevicePtr a, Int)) -> IO (DevicePtr a, Int))
-> (Int -> Ptr a -> IO (DevicePtr a, Int)) -> IO (DevicePtr a, Int)
forall a b. (a -> b) -> a -> b
$ \Int
len Ptr a
p ->
IO (DevicePtr a)
-> (DevicePtr a -> IO ())
-> (DevicePtr a -> IO (DevicePtr a, Int))
-> IO (DevicePtr a, Int)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracketOnError (Int -> IO (DevicePtr a)
forall a. Storable a => Int -> IO (DevicePtr a)
mallocArray Int
len) DevicePtr a -> IO ()
forall a. DevicePtr a -> IO ()
free ((DevicePtr a -> IO (DevicePtr a, Int)) -> IO (DevicePtr a, Int))
-> (DevicePtr a -> IO (DevicePtr a, Int)) -> IO (DevicePtr a, Int)
forall a b. (a -> b) -> a -> b
$ \DevicePtr a
d_xs -> do
Int -> Ptr a -> DevicePtr a -> IO ()
forall a. Storable a => Int -> Ptr a -> DevicePtr a -> IO ()
pokeArray Int
len Ptr a
p DevicePtr a
d_xs
(DevicePtr a, Int) -> IO (DevicePtr a, Int)
forall (m :: * -> *) a. Monad m => a -> m a
return (DevicePtr a
d_xs, Int
len)
{-# INLINEABLE newListArray #-}
newListArray :: Storable a => [a] -> IO (DevicePtr a)
newListArray :: [a] -> IO (DevicePtr a)
newListArray [a]
xs = (DevicePtr a, Int) -> DevicePtr a
forall a b. (a, b) -> a
fst ((DevicePtr a, Int) -> DevicePtr a)
-> IO (DevicePtr a, Int) -> IO (DevicePtr a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` [a] -> IO (DevicePtr a, Int)
forall a. Storable a => [a] -> IO (DevicePtr a, Int)
newListArrayLen [a]
xs
{-# INLINEABLE withListArray #-}
withListArray :: Storable a => [a] -> (DevicePtr a -> IO b) -> IO b
withListArray :: [a] -> (DevicePtr a -> IO b) -> IO b
withListArray [a]
xs = [a] -> (Int -> DevicePtr a -> IO b) -> IO b
forall a b.
Storable a =>
[a] -> (Int -> DevicePtr a -> IO b) -> IO b
withListArrayLen [a]
xs ((Int -> DevicePtr a -> IO b) -> IO b)
-> ((DevicePtr a -> IO b) -> Int -> DevicePtr a -> IO b)
-> (DevicePtr a -> IO b)
-> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DevicePtr a -> IO b) -> Int -> DevicePtr a -> IO b
forall a b. a -> b -> a
const
{-# INLINEABLE withListArrayLen #-}
withListArrayLen :: Storable a => [a] -> (Int -> DevicePtr a -> IO b) -> IO b
withListArrayLen :: [a] -> (Int -> DevicePtr a -> IO b) -> IO b
withListArrayLen [a]
xs Int -> DevicePtr a -> IO b
f =
IO (DevicePtr a, Int)
-> ((DevicePtr a, Int) -> IO ())
-> ((DevicePtr a, Int) -> IO b)
-> IO b
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket ([a] -> IO (DevicePtr a, Int)
forall a. Storable a => [a] -> IO (DevicePtr a, Int)
newListArrayLen [a]
xs) (DevicePtr a -> IO ()
forall a. DevicePtr a -> IO ()
free (DevicePtr a -> IO ())
-> ((DevicePtr a, Int) -> DevicePtr a)
-> (DevicePtr a, Int)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DevicePtr a, Int) -> DevicePtr a
forall a b. (a, b) -> a
fst) ((DevicePtr a -> Int -> IO b) -> (DevicePtr a, Int) -> IO b
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((DevicePtr a -> Int -> IO b) -> (DevicePtr a, Int) -> IO b)
-> ((Int -> DevicePtr a -> IO b) -> DevicePtr a -> Int -> IO b)
-> (Int -> DevicePtr a -> IO b)
-> (DevicePtr a, Int)
-> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int -> DevicePtr a -> IO b) -> DevicePtr a -> Int -> IO b
forall a b c. (a -> b -> c) -> b -> a -> c
flip ((Int -> DevicePtr a -> IO b) -> (DevicePtr a, Int) -> IO b)
-> (Int -> DevicePtr a -> IO b) -> (DevicePtr a, Int) -> IO b
forall a b. (a -> b) -> a -> b
$ Int -> DevicePtr a -> IO b
f)
{-# INLINEABLE memset #-}
memset :: Storable a => DevicePtr a -> Int -> a -> IO ()
memset :: DevicePtr a -> Int -> a -> IO ()
memset !DevicePtr a
dptr !Int
n !a
val = case a -> Int
forall a. Storable a => a -> Int
sizeOf a
val of
Int
1 -> Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> a -> Int -> IO Status
forall a. DevicePtr a -> a -> Int -> IO Status
cuMemsetD8 DevicePtr a
dptr a
val Int
n
Int
2 -> Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> a -> Int -> IO Status
forall a. DevicePtr a -> a -> Int -> IO Status
cuMemsetD16 DevicePtr a
dptr a
val Int
n
Int
4 -> Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> a -> Int -> IO Status
forall a. DevicePtr a -> a -> Int -> IO Status
cuMemsetD32 DevicePtr a
dptr a
val Int
n
Int
_ -> String -> IO ()
forall a. String -> IO a
cudaErrorIO String
"can only memset 8-, 16-, and 32-bit values"
{-# INLINE cuMemsetD8 #-}
cuMemsetD8 :: (DevicePtr a) -> (a) -> (Int) -> IO ((Status))
cuMemsetD8 :: DevicePtr a -> a -> Int -> IO Status
cuMemsetD8 DevicePtr a
a1 a
a2 Int
a3 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: b
a2' = a -> b
forall a b. a -> b
unsafeCoerce a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
CULLong -> CUChar -> CULong -> IO CInt
cuMemsetD8'_ CULLong
a1' CUChar
forall b. b
a2' CULong
a3' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 1028 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINE cuMemsetD16 #-}
cuMemsetD16 :: (DevicePtr a) -> (a) -> (Int) -> IO ((Status))
cuMemsetD16 a1 a2 a3 =
let {a1' = useDeviceHandle a1} in
let {a2' = unsafeCoerce a2} in
let {a3' = fromIntegral a3} in
cuMemsetD16'_ a1' a2' a3' >>= \res ->
let {res' = cToEnum res} in
return (res')
{-# LINE 1034 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINE cuMemsetD32 #-}
cuMemsetD32 :: (DevicePtr a) -> (a) -> (Int) -> IO ((Status))
cuMemsetD32 a1 a2 a3 =
let {a1' = useDeviceHandle a1} in
let {a2' = unsafeCoerce a2} in
let {a3' = fromIntegral a3} in
cuMemsetD32'_ a1' a2' a3' >>= \res ->
let {res' = cToEnum res} in
return (res')
{-# LINE 1040 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE memsetAsync #-}
memsetAsync :: Storable a => DevicePtr a -> Int -> a -> Maybe Stream -> IO ()
memsetAsync :: DevicePtr a -> Int -> a -> Maybe Stream -> IO ()
memsetAsync !DevicePtr a
dptr !Int
n !a
val !Maybe Stream
mst = case a -> Int
forall a. Storable a => a -> Int
sizeOf a
val of
Int
1 -> Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> a -> Int -> Stream -> IO Status
forall a. DevicePtr a -> a -> Int -> Stream -> IO Status
cuMemsetD8Async DevicePtr a
dptr a
val Int
n Stream
stream
Int
2 -> Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> a -> Int -> Stream -> IO Status
forall a. DevicePtr a -> a -> Int -> Stream -> IO Status
cuMemsetD16Async DevicePtr a
dptr a
val Int
n Stream
stream
Int
4 -> Status -> IO ()
nothingIfOk (Status -> IO ()) -> IO Status -> IO ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< DevicePtr a -> a -> Int -> Stream -> IO Status
forall a. DevicePtr a -> a -> Int -> Stream -> IO Status
cuMemsetD32Async DevicePtr a
dptr a
val Int
n Stream
stream
Int
_ -> String -> IO ()
forall a. String -> IO a
cudaErrorIO String
"can only memset 8-, 16-, and 32-bit values"
where
stream :: Stream
stream = Stream -> Maybe Stream -> Stream
forall a. a -> Maybe a -> a
fromMaybe Stream
defaultStream Maybe Stream
mst
{-# INLINE cuMemsetD8Async #-}
cuMemsetD8Async :: (DevicePtr a) -> (a) -> (Int) -> (Stream) -> IO ((Status))
cuMemsetD8Async :: DevicePtr a -> a -> Int -> Stream -> IO Status
cuMemsetD8Async DevicePtr a
a1 a
a2 Int
a3 Stream
a4 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: b
a2' = a -> b
forall a b. a -> b
unsafeCoerce a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: Ptr ()
a4' = Stream -> Ptr ()
useStream Stream
a4} in
CULLong -> CUChar -> CULong -> Ptr () -> IO CInt
cuMemsetD8Async'_ CULLong
a1' CUChar
forall b. b
a2' CULong
a3' Ptr ()
a4' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 1074 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINE cuMemsetD16Async #-}
cuMemsetD16Async :: (DevicePtr a) -> (a) -> (Int) -> (Stream) -> IO ((Status))
cuMemsetD16Async :: DevicePtr a -> a -> Int -> Stream -> IO Status
cuMemsetD16Async DevicePtr a
a1 a
a2 Int
a3 Stream
a4 =
let {a1' :: CULLong
a1' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a1} in
let {a2' :: b
a2' = a -> b
forall a b. a -> b
unsafeCoerce a
a2} in
let {a3' :: CULong
a3' = Int -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
a3} in
let {a4' :: Ptr ()
a4' = Stream -> Ptr ()
useStream Stream
a4} in
CULLong -> CUShort -> CULong -> Ptr () -> IO CInt
cuMemsetD16Async'_ CULLong
a1' CUShort
forall b. b
a2' CULong
a3' Ptr ()
a4' IO CInt -> (CInt -> IO Status) -> IO Status
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Status -> IO Status
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res')
{-# LINE 1081 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINE cuMemsetD32Async #-}
cuMemsetD32Async :: (DevicePtr a) -> (a) -> (Int) -> (Stream) -> IO ((Status))
cuMemsetD32Async a1 a2 a3 a4 =
let {a1' = useDeviceHandle a1} in
let {a2' = unsafeCoerce a2} in
let {a3' = fromIntegral a3} in
let {a4' = useStream a4} in
cuMemsetD32Async'_ a1' a2' a3' a4' >>= \res ->
let {res' = cToEnum res} in
return (res')
{-# LINE 1089 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINEABLE getDevicePtr #-}
getDevicePtr :: [AllocFlag] -> HostPtr a -> IO (DevicePtr a)
getDevicePtr :: [AllocFlag] -> HostPtr a -> IO (DevicePtr a)
getDevicePtr ![AllocFlag]
flags !HostPtr a
hp = (Status, DevicePtr a) -> IO (DevicePtr a)
forall a. (Status, a) -> IO a
resultIfOk ((Status, DevicePtr a) -> IO (DevicePtr a))
-> IO (Status, DevicePtr a) -> IO (DevicePtr a)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HostPtr a -> [AllocFlag] -> IO (Status, DevicePtr a)
forall a. HostPtr a -> [AllocFlag] -> IO (Status, DevicePtr a)
cuMemHostGetDevicePointer HostPtr a
hp [AllocFlag]
flags
{-# INLINE cuMemHostGetDevicePointer #-}
cuMemHostGetDevicePointer :: (HostPtr a) -> ([AllocFlag]) -> IO ((Status), (DevicePtr a))
cuMemHostGetDevicePointer :: HostPtr a -> [AllocFlag] -> IO (Status, DevicePtr a)
cuMemHostGetDevicePointer HostPtr a
a2 [AllocFlag]
a3 =
(Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall b. (Ptr CULLong -> IO b) -> IO b
alloca' ((Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a))
-> (Ptr CULLong -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall a b. (a -> b) -> a -> b
$ \Ptr CULLong
a1' ->
let {a2' :: Ptr b
a2' = HostPtr a -> Ptr b
forall a b. HostPtr a -> Ptr b
useHP HostPtr a
a2} in
let {a3' :: CUInt
a3' = [AllocFlag] -> CUInt
forall a b. (Enum a, Num b, Bits b) => [a] -> b
combineBitMasks [AllocFlag]
a3} in
Ptr CULLong -> Ptr () -> CUInt -> IO CInt
cuMemHostGetDevicePointer'_ Ptr CULLong
a1' Ptr ()
forall b. Ptr b
a2' CUInt
a3' IO CInt
-> (CInt -> IO (Status, DevicePtr a)) -> IO (Status, DevicePtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Ptr CULLong -> IO (DevicePtr a)
forall a. Ptr CULLong -> IO (DevicePtr a)
peekDeviceHandle Ptr CULLong
a1'IO (DevicePtr a)
-> (DevicePtr a -> IO (Status, DevicePtr a))
-> IO (Status, DevicePtr a)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \DevicePtr a
a1'' ->
(Status, DevicePtr a) -> IO (Status, DevicePtr a)
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res', DevicePtr a
a1'')
{-# LINE 1108 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
alloca' = F.alloca
useHP = castPtr . useHostPtr
{-# INLINEABLE getBasePtr #-}
getBasePtr :: DevicePtr a -> IO (DevicePtr a, Int64)
getBasePtr :: DevicePtr a -> IO (DevicePtr a, Int64)
getBasePtr !DevicePtr a
dptr = do
(Status
status,DevicePtr a
base,Int64
size) <- DevicePtr a -> IO (Status, DevicePtr a, Int64)
forall a. DevicePtr a -> IO (Status, DevicePtr a, Int64)
cuMemGetAddressRange DevicePtr a
dptr
(Status, (DevicePtr a, Int64)) -> IO (DevicePtr a, Int64)
forall a. (Status, a) -> IO a
resultIfOk (Status
status, (DevicePtr a
base,Int64
size))
{-# INLINE cuMemGetAddressRange #-}
cuMemGetAddressRange :: (DevicePtr a) -> IO ((Status), (DevicePtr a), (Int64))
cuMemGetAddressRange :: DevicePtr a -> IO (Status, DevicePtr a, Int64)
cuMemGetAddressRange DevicePtr a
a3 =
(Ptr CULLong -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca' ((Ptr CULLong -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64))
-> (Ptr CULLong -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64)
forall a b. (a -> b) -> a -> b
$ \Ptr CULLong
a1' ->
(Ptr CULong -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64)
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca' ((Ptr CULong -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64))
-> (Ptr CULong -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64)
forall a b. (a -> b) -> a -> b
$ \Ptr CULong
a2' ->
let {a3' :: CULLong
a3' = DevicePtr a -> CULLong
forall a. DevicePtr a -> CULLong
useDeviceHandle DevicePtr a
a3} in
Ptr CULLong -> Ptr CULong -> CULLong -> IO CInt
cuMemGetAddressRange'_ Ptr CULLong
a1' Ptr CULong
a2' CULLong
a3' IO CInt
-> (CInt -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = cToEnum CInt
res} in
Ptr CULLong -> IO (DevicePtr a)
forall a. Ptr CULLong -> IO (DevicePtr a)
peekDeviceHandle Ptr CULLong
a1'IO (DevicePtr a)
-> (DevicePtr a -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \DevicePtr a
a1'' ->
Ptr CULong -> IO Int64
forall a b. (Storable a, Integral a, Integral b) => Ptr a -> IO b
peekIntConv Ptr CULong
a2'IO Int64
-> (Int64 -> IO (Status, DevicePtr a, Int64))
-> IO (Status, DevicePtr a, Int64)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int64
a2'' ->
(Status, DevicePtr a, Int64) -> IO (Status, DevicePtr a, Int64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res', DevicePtr a
a1'', Int64
a2'')
{-# LINE 1129 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
alloca' :: Storable a => (Ptr a -> IO b) -> IO b
alloca' = F.alloca
{-# INLINEABLE getMemInfo #-}
getMemInfo :: IO (Int64, Int64)
getMemInfo :: IO (Int64, Int64)
getMemInfo = do
(!Status
status,!Int64
f,!Int64
t) <- IO (Status, Int64, Int64)
cuMemGetInfo
(Status, (Int64, Int64)) -> IO (Int64, Int64)
forall a. (Status, a) -> IO a
resultIfOk (Status
status,(Int64
f,Int64
t))
{-# INLINE cuMemGetInfo #-}
cuMemGetInfo :: IO ((Status), (Int64), (Int64))
cuMemGetInfo :: IO (Status, Int64, Int64)
cuMemGetInfo =
(Ptr CULong -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64)
forall b. (Ptr CULong -> IO b) -> IO b
alloca' ((Ptr CULong -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64))
-> (Ptr CULong -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64)
forall a b. (a -> b) -> a -> b
$ \Ptr CULong
a1' ->
(Ptr CULong -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64)
forall b. (Ptr CULong -> IO b) -> IO b
alloca' ((Ptr CULong -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64))
-> (Ptr CULong -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64)
forall a b. (a -> b) -> a -> b
$ \Ptr CULong
a2' ->
Ptr CULong -> Ptr CULong -> IO CInt
cuMemGetInfo'_ Ptr CULong
a1' Ptr CULong
a2' IO CInt
-> (CInt -> IO (Status, Int64, Int64)) -> IO (Status, Int64, Int64)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \CInt
res ->
let {res' :: Status
res' = CInt -> Status
forall i e. (Integral i, Enum e) => i -> e
cToEnum CInt
res} in
Ptr CULong -> IO Int64
forall a b. (Storable a, Integral a, Integral b) => Ptr a -> IO b
peekIntConv Ptr CULong
a1'IO Int64
-> (Int64 -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int64
a1'' ->
Ptr CULong -> IO Int64
forall a b. (Storable a, Integral a, Integral b) => Ptr a -> IO b
peekIntConv Ptr CULong
a2'IO Int64
-> (Int64 -> IO (Status, Int64, Int64))
-> IO (Status, Int64, Int64)
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Int64
a2'' ->
(Status, Int64, Int64) -> IO (Status, Int64, Int64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Status
res', Int64
a1'', Int64
a2'')
{-# LINE 1149 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
where
alloca' = F.alloca
type DeviceHandle = (C2HSImp.CULLong)
{-# LINE 1158 "src/Foreign/CUDA/Driver/Marshal.chs" #-}
{-# INLINE peekDeviceHandle #-}
peekDeviceHandle :: Ptr DeviceHandle -> IO (DevicePtr a)
peekDeviceHandle :: Ptr CULLong -> IO (DevicePtr a)
peekDeviceHandle !Ptr CULLong
p = do
CULLong (W64# Word#
w#) <- Ptr CULLong -> IO CULLong
forall a. Storable a => Ptr a -> IO a
peek Ptr CULLong
p
DevicePtr a -> IO (DevicePtr a)
forall (m :: * -> *) a. Monad m => a -> m a
return (DevicePtr a -> IO (DevicePtr a))
-> DevicePtr a -> IO (DevicePtr a)
forall a b. (a -> b) -> a -> b
$! Ptr a -> DevicePtr a
forall a. Ptr a -> DevicePtr a
DevicePtr (Addr# -> Ptr a
forall a. Addr# -> Ptr a
Ptr (Int# -> Addr#
int2Addr# (Word# -> Int#
word2Int# Word#
w#)))
{-# INLINE useDeviceHandle #-}
useDeviceHandle :: DevicePtr a -> DeviceHandle
useDeviceHandle :: DevicePtr a -> CULLong
useDeviceHandle (DevicePtr (Ptr Addr#
addr#)) =
Word64 -> CULLong
CULLong (Word# -> Word64
W64# (Int# -> Word#
int2Word# (Addr# -> Int#
addr2Int# Addr#
addr#)))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemHostAlloc"
cuMemHostAlloc'_ :: ((C2HSImp.Ptr (C2HSImp.Ptr ())) -> (C2HSImp.CULong -> (C2HSImp.CUInt -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemFreeHost"
cuMemFreeHost'_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemHostRegister"
cuMemHostRegister'_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> (C2HSImp.CUInt -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemHostUnregister"
cuMemHostUnregister'_ :: ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemAlloc"
cuMemAlloc'_ :: ((C2HSImp.Ptr C2HSImp.CULLong) -> (C2HSImp.CULong -> (IO C2HSImp.CInt)))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemFree"
cuMemFree'_ :: (C2HSImp.CULLong -> (IO C2HSImp.CInt))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemAllocManaged"
cuMemAllocManaged'_ :: ((C2HSImp.Ptr C2HSImp.CULLong) -> (C2HSImp.CULong -> (C2HSImp.CUInt -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemPrefetchAsync"
cuMemPrefetchAsync'_ :: (C2HSImp.CULLong -> (C2HSImp.CULong -> (C2HSImp.CInt -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuStreamAttachMemAsync"
cuStreamAttachMemAsync'_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CULLong -> (C2HSImp.CULong -> (C2HSImp.CUInt -> (IO C2HSImp.CInt)))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyDtoH"
cuMemcpyDtoH'_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CULLong -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyDtoHAsync"
cuMemcpyDtoHAsync'_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CULLong -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpy2DDtoH"
cuMemcpy2DDtoH'_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (IO C2HSImp.CInt)))))))))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpy2DDtoHAsync"
cuMemcpy2DDtoHAsync'_ :: ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))))))))))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyHtoD"
cuMemcpyHtoD'_ :: (C2HSImp.CULLong -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyHtoDAsync"
cuMemcpyHtoDAsync'_ :: (C2HSImp.CULLong -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpy2DHtoD"
cuMemcpy2DHtoD'_ :: (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (IO C2HSImp.CInt)))))))))))
foreign import ccall safe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpy2DHtoDAsync"
cuMemcpy2DHtoDAsync'_ :: (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))))))))))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyDtoD"
cuMemcpyDtoD'_ :: (C2HSImp.CULLong -> (C2HSImp.CULLong -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyDtoDAsync"
cuMemcpyDtoDAsync'_ :: (C2HSImp.CULLong -> (C2HSImp.CULLong -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpy2DDtoD"
cuMemcpy2DDtoD'_ :: (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (IO C2HSImp.CInt)))))))))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpy2DDtoDAsync"
cuMemcpy2DDtoDAsync'_ :: (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt))))))))))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyPeer"
cuMemcpyPeer'_ :: (C2HSImp.CULLong -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULLong -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemcpyPeerAsync"
cuMemcpyPeerAsync'_ :: (C2HSImp.CULLong -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULLong -> ((C2HSImp.Ptr ()) -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemsetD8"
cuMemsetD8'_ :: (C2HSImp.CULLong -> (C2HSImp.CUChar -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemsetD16"
cuMemsetD16'_ :: (C2HSImp.CULLong -> (C2HSImp.CUShort -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemsetD32"
cuMemsetD32'_ :: (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CULong -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemsetD8Async"
cuMemsetD8Async'_ :: (C2HSImp.CULLong -> (C2HSImp.CUChar -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemsetD16Async"
cuMemsetD16Async'_ :: (C2HSImp.CULLong -> (C2HSImp.CUShort -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemsetD32Async"
cuMemsetD32Async'_ :: (C2HSImp.CULLong -> (C2HSImp.CUInt -> (C2HSImp.CULong -> ((C2HSImp.Ptr ()) -> (IO C2HSImp.CInt)))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemHostGetDevicePointer"
cuMemHostGetDevicePointer'_ :: ((C2HSImp.Ptr C2HSImp.CULLong) -> ((C2HSImp.Ptr ()) -> (C2HSImp.CUInt -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemGetAddressRange"
cuMemGetAddressRange'_ :: ((C2HSImp.Ptr C2HSImp.CULLong) -> ((C2HSImp.Ptr C2HSImp.CULong) -> (C2HSImp.CULLong -> (IO C2HSImp.CInt))))
foreign import ccall unsafe "Foreign/CUDA/Driver/Marshal.chs.h cuMemGetInfo"
cuMemGetInfo'_ :: ((C2HSImp.Ptr C2HSImp.CULong) -> ((C2HSImp.Ptr C2HSImp.CULong) -> (IO C2HSImp.CInt)))