Copyright | (c) [2009..2012] Trevor L. McDonell |
---|---|
License | BSD |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
A common interface for host and device pointers. While it is possible mix the Driver and Runtime environments with CUDA versions >= 3.0, it is still a good idea to pick one interface and stick to it.
- 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
Documentation
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
A reference to page-locked host memory
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
minusHostPtr :: HostPtr a -> HostPtr a -> Int Source
Compute the difference between the second and first argument