Copyright | [2009..2017] Trevor L. McDonell |
---|---|
License | BSD |
Safe Haskell | None |
Language | Haskell98 |
Context management for the low-level driver interface
- newtype Context = Context {
- useContext :: Ptr ()
- data ContextFlag
- create :: Device -> [ContextFlag] -> IO Context
- destroy :: Context -> IO ()
- device :: IO Device
- pop :: IO Context
- push :: Context -> IO ()
- sync :: IO ()
- get :: IO (Maybe Context)
- set :: Context -> IO ()
- attach :: Context -> [ContextFlag] -> IO ()
- detach :: Context -> IO ()
Context Management
A device context
Context | |
|
data ContextFlag Source #
Context creation flags
SchedAuto | |
SchedSpin | |
SchedYield | |
SchedBlockingSync | |
BlockingSync | Deprecated: use SchedBlockingSync instead |
SchedMask | |
MapHost | |
LmemResizeToMax | |
FlagsMask |
create :: Device -> [ContextFlag] -> IO Context Source #
Create a new CUDA context and associate it with the calling thread. The
context is created with a usage count of one, and the caller of create
must call destroy
when done using the context. If a context is already
current to the thread, it is supplanted by the newly created context and
must be restored by a subsequent call to pop
.
destroy :: Context -> IO () Source #
Destroy the specified context, regardless of how many threads it is
current to. The context will be pop
ed from the current thread's
context stack, but if it is current on any other threads it will remain
current to those threads, and attempts to access it will result in an
error.
Return the device of the currently active context
Pop the current CUDA context from the CPU thread. The context may then
be attached to a different CPU thread by calling push
.
push :: Context -> IO () Source #
Push the given context onto the CPU's thread stack of current contexts. The specified context becomes the CPU thread's current context, so all operations that operate on the current context are affected.
Block until the device has completed all preceding requests. If the
context was created with the SchedBlockingSync
flag, the CPU thread
will block until the GPU has finished its work.
get :: IO (Maybe Context) Source #
Return the context bound to the calling CPU thread.
Requires CUDA-4.0.