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

Copyright[2009..2014] Trevor L. McDonell
Safe HaskellNone




Context management for low-level driver interface


Context Management

newtype Context Source

A device context




useContext :: Ptr ()


data ContextFlag Source

Context creation flags



Deprecated: use SchedBlockingSync instead


create :: Device -> [ContextFlag] -> IO Context Source

Create a new CUDA context and associate it with the calling thread

attach :: Context -> [ContextFlag] -> IO () Source

Deprecated: deprecated as of CUDA-4.0

Increments the usage count of the context. API: no context flags are currently supported, so this parameter must be empty.

detach :: Context -> IO () Source

Deprecated: deprecated as of CUDA-4.0

Detach the context, and destroy if no longer used

destroy :: Context -> IO () Source

Destroy the specified context. This fails if the context is more than a single attachment (including that from initial creation).

device :: IO Device Source

Return the device of the currently active context

pop :: IO Context Source

Pop the current CUDA context from the CPU thread. The context must have a single usage count (matching calls to attach and detach). If successful, the new context is returned, and the old may be attached to a different CPU.

push :: Context -> IO () Source

Push the given context onto the CPU's thread stack of current contexts. The context must be floating (via pop), i.e. not attached to any thread.

sync :: IO () Source

Block until the device has completed all preceding requests

get :: IO Context Source

Return the context bound to the calling CPU thread. Requires cuda-4.0.

set :: Context -> IO () Source

Bind the specified context to the calling thread. Requires cuda-4.0.

Peer Access

data PeerFlag Source

Possible option values for direct peer memory access


accessible :: Device -> Device -> IO Bool Source

Queries if the first device can directly access the memory of the second. If direct access is possible, it can then be enabled with add. Requires cuda-4.0.

add :: Context -> [PeerFlag] -> IO () Source

If the devices of both the current and supplied contexts support unified addressing, then enable allocations in the supplied context to be accessible by the current context. Requires cuda-4.0.

remove :: Context -> IO () Source

Disable direct memory access from the current context to the supplied context. Requires cuda-4.0.

Cache Configuration

data Cache Source

Device cache configuration preference


getLimit :: Limit -> IO Int Source

Query compute 2.0 call stack limits. Requires cuda-3.1.

setLimit :: Limit -> Int -> IO () Source

Specify the size of the call stack, for compute 2.0 devices. Requires cuda-3.1.

setCacheConfig :: Cache -> IO () Source

On devices where the L1 cache and shared memory use the same hardware resources, this sets the preferred cache configuration for the current context. This is only a preference. Requires cuda-3.2.