Copyright | [2009..2023] Trevor L. McDonell |
---|---|
License | BSD |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Context management for the low-level driver interface
Synopsis
- 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
data ContextFlag Source #
Context creation flags
SchedAuto | |
SchedSpin | |
SchedYield | |
SchedBlockingSync | |
BlockingSync | Deprecated: use SchedBlockingSync instead |
SchedMask | |
MapHost | |
LmemResizeToMax | |
FlagsMask |
Instances
Bounded ContextFlag Source # | |
Defined in Foreign.CUDA.Driver.Context.Base minBound :: ContextFlag # maxBound :: ContextFlag # | |
Enum ContextFlag Source # | |
Defined in Foreign.CUDA.Driver.Context.Base succ :: ContextFlag -> ContextFlag # pred :: ContextFlag -> ContextFlag # toEnum :: Int -> ContextFlag # fromEnum :: ContextFlag -> Int # enumFrom :: ContextFlag -> [ContextFlag] # enumFromThen :: ContextFlag -> ContextFlag -> [ContextFlag] # enumFromTo :: ContextFlag -> ContextFlag -> [ContextFlag] # enumFromThenTo :: ContextFlag -> ContextFlag -> ContextFlag -> [ContextFlag] # | |
Show ContextFlag Source # | |
Defined in Foreign.CUDA.Driver.Context.Base showsPrec :: Int -> ContextFlag -> ShowS # show :: ContextFlag -> String # showList :: [ContextFlag] -> ShowS # | |
Eq ContextFlag Source # | |
Defined in Foreign.CUDA.Driver.Context.Base (==) :: ContextFlag -> ContextFlag -> Bool # (/=) :: ContextFlag -> ContextFlag -> Bool # |
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.