cuda-0.10.1.0: FFI binding to the CUDA interface for programming NVIDIA GPUs

Copyright[2009..2018] Trevor L. McDonell
LicenseBSD
Safe HaskellSafe
LanguageHaskell98

Foreign.CUDA.Ptr

Contents

Description

Data pointers on the host and device. These can be shared freely between the CUDA runtime and Driver APIs.

Synopsis

Device pointers

newtype DevicePtr a Source #

A reference to data stored on the device.

Constructors

DevicePtr 

Fields

Instances
Eq (DevicePtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Methods

(==) :: DevicePtr a -> DevicePtr a -> Bool #

(/=) :: DevicePtr a -> DevicePtr a -> Bool #

Ord (DevicePtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Show (DevicePtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Storable (DevicePtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Methods

sizeOf :: DevicePtr a -> Int #

alignment :: DevicePtr a -> Int #

peekElemOff :: Ptr (DevicePtr a) -> Int -> IO (DevicePtr a) #

pokeElemOff :: Ptr (DevicePtr a) -> Int -> DevicePtr a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (DevicePtr a) #

pokeByteOff :: Ptr b -> Int -> DevicePtr a -> IO () #

peek :: Ptr (DevicePtr a) -> IO (DevicePtr a) #

poke :: Ptr (DevicePtr a) -> DevicePtr a -> IO () #

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

newtype HostPtr a Source #

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.

Constructors

HostPtr 

Fields

Instances
Eq (HostPtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Methods

(==) :: HostPtr a -> HostPtr a -> Bool #

(/=) :: HostPtr a -> HostPtr a -> Bool #

Ord (HostPtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Methods

compare :: HostPtr a -> HostPtr a -> Ordering #

(<) :: HostPtr a -> HostPtr a -> Bool #

(<=) :: HostPtr a -> HostPtr a -> Bool #

(>) :: HostPtr a -> HostPtr a -> Bool #

(>=) :: HostPtr a -> HostPtr a -> Bool #

max :: HostPtr a -> HostPtr a -> HostPtr a #

min :: HostPtr a -> HostPtr a -> HostPtr a #

Show (HostPtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Methods

showsPrec :: Int -> HostPtr a -> ShowS #

show :: HostPtr a -> String #

showList :: [HostPtr a] -> ShowS #

Storable (HostPtr a) Source # 
Instance details

Defined in Foreign.CUDA.Ptr

Methods

sizeOf :: HostPtr a -> Int #

alignment :: HostPtr a -> Int #

peekElemOff :: Ptr (HostPtr a) -> Int -> IO (HostPtr a) #

pokeElemOff :: Ptr (HostPtr a) -> Int -> HostPtr a -> IO () #

peekByteOff :: Ptr b -> Int -> IO (HostPtr a) #

pokeByteOff :: Ptr b -> Int -> HostPtr a -> IO () #

peek :: Ptr (HostPtr a) -> IO (HostPtr a) #

poke :: Ptr (HostPtr a) -> HostPtr a -> IO () #

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

advanceHostPtr :: Storable a => HostPtr a -> Int -> HostPtr a Source #

Advance a pointer into a host array by a given number of elements