Copyright | [2009..2017] Trevor L. McDonell |
---|---|
License | BSD |
Safe Haskell | Safe |
Language | Haskell98 |
Data pointers on the host and device. These can be shared freely between the CUDA runtime and Driver APIs.
- newtype DevicePtr a = DevicePtr {
- useDevicePtr :: Ptr a
- withDevicePtr :: DevicePtr a -> (Ptr a -> IO b) -> IO b
- devPtrToWordPtr :: DevicePtr a -> WordPtr
- wordPtrToDevPtr :: WordPtr -> DevicePtr a
- nullDevPtr :: DevicePtr a
- castDevPtr :: DevicePtr a -> DevicePtr b
- plusDevPtr :: DevicePtr a -> Int -> DevicePtr a
- alignDevPtr :: DevicePtr a -> Int -> DevicePtr a
- minusDevPtr :: DevicePtr a -> DevicePtr a -> Int
- advanceDevPtr :: Storable a => DevicePtr a -> Int -> DevicePtr a
- newtype HostPtr a = HostPtr {
- useHostPtr :: Ptr a
- withHostPtr :: HostPtr a -> (Ptr a -> IO b) -> IO b
- nullHostPtr :: HostPtr a
- castHostPtr :: HostPtr a -> HostPtr b
- plusHostPtr :: HostPtr a -> Int -> HostPtr a
- alignHostPtr :: HostPtr a -> Int -> HostPtr a
- minusHostPtr :: HostPtr a -> HostPtr a -> Int
- advanceHostPtr :: Storable a => HostPtr a -> Int -> HostPtr a
Device pointers
A reference to data stored on the device.
DevicePtr | |
|
withDevicePtr :: DevicePtr a -> (Ptr a -> IO b) -> IO b Source #
Look at the contents of device memory. This takes an IO action that will be applied to that pointer, the result of which is returned. It would be silly to return the pointer from the action.
devPtrToWordPtr :: DevicePtr a -> WordPtr Source #
Return a unique handle associated with the given device pointer
wordPtrToDevPtr :: WordPtr -> DevicePtr a Source #
Return a device pointer from the given handle
nullDevPtr :: DevicePtr a Source #
The constant nullDevPtr
contains the distinguished memory location that is
not associated with a valid memory location
castDevPtr :: DevicePtr a -> DevicePtr b Source #
Cast a device pointer from one type to another
plusDevPtr :: DevicePtr a -> Int -> DevicePtr a Source #
Advance the pointer address by the given offset in bytes.
alignDevPtr :: DevicePtr a -> Int -> DevicePtr a Source #
Given an alignment constraint, align the device pointer to the next highest address satisfying the constraint
minusDevPtr :: DevicePtr a -> DevicePtr a -> Int Source #
Compute the difference between the second and first argument. This fulfils the relation
p2 == p1 `plusDevPtr` (p2 `minusDevPtr` p1)
advanceDevPtr :: Storable a => DevicePtr a -> Int -> DevicePtr a Source #
Advance a pointer into a device array by the given number of elements
Host pointers
A reference to page-locked host memory.
A HostPtr
is just a plain Ptr
, but the memory has been allocated by CUDA
into page locked memory. This means that the data can be copied to the GPU
via DMA (direct memory access). Note that the use of the system function
mlock
is not sufficient here --- the CUDA version ensures that the
physical address stays this same, not just the virtual address.
To copy data into a HostPtr
array, you may use for example withHostPtr
together with copyArray
or
moveArray
.
HostPtr | |
|
withHostPtr :: HostPtr a -> (Ptr a -> IO b) -> IO b Source #
Apply an IO action to the memory reference living inside the host pointer
object. All uses of the pointer should be inside the withHostPtr
bracket.
nullHostPtr :: HostPtr a Source #
The constant nullHostPtr
contains the distinguished memory location that is
not associated with a valid memory location
castHostPtr :: HostPtr a -> HostPtr b Source #
Cast a host pointer from one type to another
plusHostPtr :: HostPtr a -> Int -> HostPtr a Source #
Advance the pointer address by the given offset in bytes
alignHostPtr :: HostPtr a -> Int -> HostPtr a Source #
Given an alignment constraint, align the host pointer to the next highest address satisfying the constraint