Copyright | [2016..2020] The Accelerate Team |
---|---|
License | BSD3 |
Maintainer | Trevor L. McDonell <trevor.mcdonell@gmail.com> |
Stability | experimental |
Portability | non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data ForeignAcc f where
- ForeignAcc :: String -> (a -> Par Native (Future b)) -> ForeignAcc (a -> b)
- data ForeignExp f where
- ForeignExp :: String -> IRFun1 Native () (x -> y) -> ForeignExp (x -> y)
- data LLVM target a
- data Native = Native {}
- liftIO :: MonadIO m => IO a -> m a
- module Data.Array.Accelerate.LLVM.Array.Data
- cloneArray :: ArrayR (Array sh e) -> Array sh e -> LLVM Native (Array sh e)
- class Monad (Par arch) => Async arch where
- data Par arch :: Type -> Type
- type FutureR arch :: Type -> Type
- new :: HasCallStack => Par arch (FutureR arch a)
- put :: HasCallStack => FutureR arch a -> a -> Par arch ()
- get :: HasCallStack => FutureR arch a -> Par arch a
- fork :: Par arch () -> Par arch ()
- liftPar :: HasCallStack => LLVM arch a -> Par arch a
- block :: HasCallStack => FutureR arch a -> Par arch a
- spawn :: HasCallStack => Par arch a -> Par arch a
- newFull :: HasCallStack => a -> Par arch (FutureR arch a)
- data Future a = Future !(IORef (IVar a))
- data IVar a
- getArrays :: Async arch => ArraysR a -> FutureArraysR arch a -> Par arch a
- evalPar :: Par Native a -> LLVM Native a
- putIO :: HasCallStack => Workers -> Future a -> a -> IO ()
Documentation
data ForeignAcc f where Source #
ForeignAcc :: String -> (a -> Par Native (Future b)) -> ForeignAcc (a -> b) |
Instances
Foreign ForeignAcc Source # | |
Defined in Data.Array.Accelerate.LLVM.Native.Foreign strForeign :: ForeignAcc args -> String liftForeign :: HasCallStack => ForeignAcc args -> Q (TExp (ForeignAcc args)) |
data ForeignExp f where Source #
ForeignExp :: String -> IRFun1 Native () (x -> y) -> ForeignExp (x -> y) |
Instances
Foreign ForeignExp Source # | |
Defined in Data.Array.Accelerate.LLVM.Native.Foreign strForeign :: ForeignExp args -> String liftForeign :: HasCallStack => ForeignExp args -> Q (TExp (ForeignExp args)) |
The LLVM monad, for executing array computations. This consists of a stack
for the LLVM execution context as well as the per-execution target specific
state target
.
Instances
MonadState target (LLVM target) | |
Monad (LLVM target) | |
Functor (LLVM target) | |
Applicative (LLVM target) | |
Defined in Data.Array.Accelerate.LLVM.State | |
MonadIO (LLVM target) | |
Defined in Data.Array.Accelerate.LLVM.State | |
MonadMask (LLVM target) | |
Defined in Data.Array.Accelerate.LLVM.State mask :: ((forall a. LLVM target a -> LLVM target a) -> LLVM target b) -> LLVM target b # uninterruptibleMask :: ((forall a. LLVM target a -> LLVM target a) -> LLVM target b) -> LLVM target b # generalBracket :: LLVM target a -> (a -> ExitCase b -> LLVM target c) -> (a -> LLVM target b) -> LLVM target (b, c) # | |
MonadCatch (LLVM target) | |
MonadThrow (LLVM target) | |
Defined in Data.Array.Accelerate.LLVM.State |
Native machine code JIT execution target
Instances
Skeleton Native | |
Defined in Data.Array.Accelerate.LLVM.Native.CodeGen generate :: UID -> Gamma aenv -> ArrayR (Array sh e) -> IRFun1 Native aenv (sh -> e) -> CodeGen Native (IROpenAcc Native aenv (Array sh e)) transform :: UID -> Gamma aenv -> ArrayR (Array sh a) -> ArrayR (Array sh' b) -> IRFun1 Native aenv (sh' -> sh) -> IRFun1 Native aenv (a -> b) -> CodeGen Native (IROpenAcc Native aenv (Array sh' b)) map :: UID -> Gamma aenv -> ArrayR (Array sh a) -> TypeR b -> IRFun1 Native aenv (a -> b) -> CodeGen Native (IROpenAcc Native aenv (Array sh b)) fold :: UID -> Gamma aenv -> ArrayR (Array sh e) -> IRFun2 Native aenv (e -> e -> e) -> Maybe (IRExp Native aenv e) -> MIRDelayed Native aenv (Array (sh, Int) e) -> CodeGen Native (IROpenAcc Native aenv (Array sh e)) foldSeg :: UID -> Gamma aenv -> ArrayR (Array (sh, Int) e) -> IntegralType i -> IRFun2 Native aenv (e -> e -> e) -> Maybe (IRExp Native aenv e) -> MIRDelayed Native aenv (Array (sh, Int) e) -> MIRDelayed Native aenv (Segments i) -> CodeGen Native (IROpenAcc Native aenv (Array (sh, Int) e)) scan :: UID -> Gamma aenv -> ArrayR (Array (sh, Int) e) -> Direction -> IRFun2 Native aenv (e -> e -> e) -> Maybe (IRExp Native aenv e) -> MIRDelayed Native aenv (Array (sh, Int) e) -> CodeGen Native (IROpenAcc Native aenv (Array (sh, Int) e)) scan' :: UID -> Gamma aenv -> ArrayR (Array (sh, Int) e) -> Direction -> IRFun2 Native aenv (e -> e -> e) -> IRExp Native aenv e -> MIRDelayed Native aenv (Array (sh, Int) e) -> CodeGen Native (IROpenAcc Native aenv (Array (sh, Int) e, Array sh e)) permute :: UID -> Gamma aenv -> ArrayR (Array sh e) -> ShapeR sh' -> IRPermuteFun Native aenv (e -> e -> e) -> IRFun1 Native aenv (sh -> PrimMaybe sh') -> MIRDelayed Native aenv (Array sh e) -> CodeGen Native (IROpenAcc Native aenv (Array sh' e)) backpermute :: UID -> Gamma aenv -> ArrayR (Array sh e) -> ShapeR sh' -> IRFun1 Native aenv (sh' -> sh) -> CodeGen Native (IROpenAcc Native aenv (Array sh' e)) stencil1 :: UID -> Gamma aenv -> StencilR sh a stencil -> TypeR b -> IRFun1 Native aenv (stencil -> b) -> IRBoundary Native aenv (Array sh a) -> MIRDelayed Native aenv (Array sh a) -> CodeGen Native (IROpenAcc Native aenv (Array sh b)) stencil2 :: UID -> Gamma aenv -> StencilR sh a stencil1 -> StencilR sh b stencil2 -> TypeR c -> IRFun2 Native aenv (stencil1 -> stencil2 -> c) -> IRBoundary Native aenv (Array sh a) -> MIRDelayed Native aenv (Array sh a) -> IRBoundary Native aenv (Array sh b) -> MIRDelayed Native aenv (Array sh b) -> CodeGen Native (IROpenAcc Native aenv (Array sh c)) | |
Persistent Native | |
Embed Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Embed | |
Execute Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Execute map :: Maybe (a :~: b) -> ArrayR (Array sh a) -> TypeR b -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Array sh a -> Par Native (FutureR Native (Array sh b)) generate :: ArrayR (Array sh e) -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> sh -> Par Native (FutureR Native (Array sh e)) transform :: ArrayR (Array sh a) -> ArrayR (Array sh' b) -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> sh' -> Array sh a -> Par Native (FutureR Native (Array sh' b)) backpermute :: ArrayR (Array sh e) -> ShapeR sh' -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> sh' -> Array sh e -> Par Native (FutureR Native (Array sh' e)) fold :: HasInitialValue -> ArrayR (Array sh e) -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Delayed (Array (sh, Int) e) -> Par Native (FutureR Native (Array sh e)) foldSeg :: IntegralType i -> HasInitialValue -> ArrayR (Array (sh, Int) e) -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Delayed (Array (sh, Int) e) -> Delayed (Segments i) -> Par Native (FutureR Native (Array (sh, Int) e)) scan :: Direction -> HasInitialValue -> ArrayR (Array (sh, Int) e) -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Delayed (Array (sh, Int) e) -> Par Native (FutureR Native (Array (sh, Int) e)) scan' :: Direction -> ArrayR (Array (sh, Int) e) -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Delayed (Array (sh, Int) e) -> Par Native (FutureR Native (Array (sh, Int) e, Array sh e)) permute :: Bool -> ArrayR (Array sh e) -> ShapeR sh' -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Array sh' e -> Delayed (Array sh e) -> Par Native (FutureR Native (Array sh' e)) stencil1 :: TypeR a -> ArrayR (Array sh b) -> sh -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Delayed (Array sh a) -> Par Native (FutureR Native (Array sh b)) stencil2 :: TypeR a -> TypeR b -> ArrayR (Array sh c) -> sh -> ExecutableR Native -> Gamma aenv -> ValR Native aenv -> Delayed (Array sh a) -> Delayed (Array sh b) -> Par Native (FutureR Native (Array sh c)) aforeign :: String -> ArraysR as -> ArraysR bs -> (as -> Par Native (FutureR Native bs)) -> as -> Par Native (FutureR Native bs) | |
Link Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Link data ExecutableR Native linkForTarget :: ObjectR Native -> LLVM Native (ExecutableR Native) | |
Compile Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Compile data ObjectR Native compileForTarget :: PreOpenAcc DelayedOpenAcc aenv a -> Gamma aenv -> LLVM Native (ObjectR Native) | |
Marshal Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Execute.Marshal type ArgR Native marshalInt :: Int -> ArgR Native marshalScalarData' :: SingleType e -> ScalarArrayData e -> Par Native (DList (ArgR Native)) | |
Foreign Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Foreign foreignAcc :: Foreign asm => asm (a -> b) -> Maybe (a -> Par Native (FutureR Native b)) foreignExp :: Foreign asm => asm (x -> y) -> Maybe (IRFun1 Native () (x -> y)) | |
Intrinsic Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Compile intrinsicForTarget :: HashMap ShortByteString Label | |
Target Native Source # | |
Remote Native | Data instance for arrays in the native backend. We assume a shared-memory machine, and just manipulate the underlying Haskell array directly. |
Defined in Data.Array.Accelerate.LLVM.Native.Array.Data allocateRemote :: ArrayR (Array sh e) -> sh -> Par Native (Array sh e) useRemoteR :: SingleType e -> Int -> ArrayData e -> Par Native (FutureR Native (ArrayData e)) copyToRemoteR :: SingleType e -> Int -> ArrayData e -> Par Native (FutureR Native (ArrayData e)) copyToHostR :: SingleType e -> Int -> ArrayData e -> Par Native (FutureR Native (ArrayData e)) copyToPeerR :: Native -> SingleType e -> Int -> ArrayData e -> Par Native (FutureR Native (ArrayData e)) useRemoteAsync :: ArraysR arrs -> arrs -> Par Native (FutureArraysR Native arrs) copyToRemoteAsync :: ArraysR arrs -> arrs -> Par Native (FutureArraysR Native arrs) copyToHostAsync :: ArraysR arrs -> arrs -> Par Native (FutureArraysR Native arrs) copyToPeerAsync :: Native -> ArraysR arrs -> arrs -> Par Native (FutureArraysR Native arrs) indexRemoteAsync :: TypeR e -> Array sh e -> Int -> Par Native (FutureR Native e) | |
Async Native Source # | |
Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async new :: HasCallStack => Par Native (FutureR Native a) # put :: HasCallStack => FutureR Native a -> a -> Par Native () # get :: HasCallStack => FutureR Native a -> Par Native a # fork :: Par Native () -> Par Native () # liftPar :: HasCallStack => LLVM Native a -> Par Native a # block :: HasCallStack => FutureR Native a -> Par Native a # spawn :: HasCallStack => Par Native a -> Par Native a # newFull :: HasCallStack => a -> Par Native (FutureR Native a) # | |
MonadState Native (Par Native) Source # | |
Monad (Par Native) Source # | |
Functor (Par Native) Source # | |
Applicative (Par Native) Source # | |
MonadIO (Par Native) Source # | |
MonadCont (Par Native) Source # | |
data ExecutableR Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Link | |
data ObjectR Native | |
Defined in Data.Array.Accelerate.LLVM.Native.Compile | |
type ArgR Native | |
type FutureR Native Source # | |
newtype Par Native a Source # | |
data KernelMetadata Native | |
cloneArray :: ArrayR (Array sh e) -> Array sh e -> LLVM Native (Array sh e) Source #
Copy an array into a newly allocated array. This uses memcpy
.
class Monad (Par arch) => Async arch where #
data Par arch :: Type -> Type #
The monad parallel computations will be executed in. Presumably a stack with the LLVM monad at the base.
type FutureR arch :: Type -> Type #
Parallel computations can communicate via futures.
new :: HasCallStack => Par arch (FutureR arch a) #
Create a new (empty) promise, to be fulfilled at some future point.
put :: HasCallStack => FutureR arch a -> a -> Par arch () #
The future is here. Multiple put
s to the same future are not allowed
and (presumably) result in a runtime error.
get :: HasCallStack => FutureR arch a -> Par arch a #
Read the value stored in a future, once it is available. It is _not_ required that this is a blocking operation on the host, only that it is blocking with respect to computations on the remote device.
fork :: Par arch () -> Par arch () #
Fork a computation to happen in parallel. The forked computation may exchange values with other computations using Futures.
liftPar :: HasCallStack => LLVM arch a -> Par arch a #
Lift an operation from the base LLVM monad into the Par monad
block :: HasCallStack => FutureR arch a -> Par arch a #
Read a value stored in a future, once it is available. This is blocking with respect to both the host and remote device.
spawn :: HasCallStack => Par arch a -> Par arch a #
Evaluate a computation in a new thread/context. This might be implemented more efficiently than the default implementation.
newFull :: HasCallStack => a -> Par arch (FutureR arch a) #
Create a new "future" where the value is available immediately. This might be implemented more efficiently than the default implementation.
Instances
Async Native Source # | |
Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async new :: HasCallStack => Par Native (FutureR Native a) # put :: HasCallStack => FutureR Native a -> a -> Par Native () # get :: HasCallStack => FutureR Native a -> Par Native a # fork :: Par Native () -> Par Native () # liftPar :: HasCallStack => LLVM Native a -> Par Native a # block :: HasCallStack => FutureR Native a -> Par Native a # spawn :: HasCallStack => Par Native a -> Par Native a # newFull :: HasCallStack => a -> Par Native (FutureR Native a) # |
evalPar :: Par Native a -> LLVM Native a Source #
Evaluate a parallel computation
The worker threads execute the computation, while the calling thread effectively sleeps waiting for the result.
putIO :: HasCallStack => Workers -> Future a -> a -> IO () Source #
The value represented by a future is now available. Push any blocked continuations to the worker threads.