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

Copyright(c) [2009..2012] Trevor L. McDonell
LicenseBSD
Safe HaskellSafe-Inferred
LanguageHaskell98

Foreign.CUDA.Ptr

Description

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.

Synopsis

Documentation

newtype DevicePtr a Source

A reference to data stored on the device.

Constructors

DevicePtr 

Fields

useDevicePtr :: Ptr a
 

Instances

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

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 the CUDA runtime 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 addresses stay 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

useHostPtr :: Ptr a
 

Instances

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