accelerate-llvm-native-1.3.0.0: Accelerate backend for multicore CPUs
Copyright[2016..2020] The Accelerate Team
LicenseBSD3
MaintainerTrevor L. McDonell <trevor.mcdonell@gmail.com>
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Data.Array.Accelerate.LLVM.Native.Foreign

Description

 
Synopsis

Documentation

data ForeignAcc f where Source #

Constructors

ForeignAcc :: String -> (a -> Par Native (Future b)) -> ForeignAcc (a -> b) 

Instances

Instances details
Foreign ForeignAcc Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Foreign

data ForeignExp f where Source #

Constructors

ForeignExp :: String -> IRFun1 Native () (x -> y) -> ForeignExp (x -> y) 

Instances

Instances details
Foreign ForeignExp Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Foreign

data LLVM target a #

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

Instances details
MonadState target (LLVM target) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

get :: LLVM target target #

put :: target -> LLVM target () #

state :: (target -> (a, target)) -> LLVM target a #

Monad (LLVM target) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

(>>=) :: LLVM target a -> (a -> LLVM target b) -> LLVM target b #

(>>) :: LLVM target a -> LLVM target b -> LLVM target b #

return :: a -> LLVM target a #

Functor (LLVM target) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

fmap :: (a -> b) -> LLVM target a -> LLVM target b #

(<$) :: a -> LLVM target b -> LLVM target a #

Applicative (LLVM target) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

pure :: a -> LLVM target a #

(<*>) :: LLVM target (a -> b) -> LLVM target a -> LLVM target b #

liftA2 :: (a -> b -> c) -> LLVM target a -> LLVM target b -> LLVM target c #

(*>) :: LLVM target a -> LLVM target b -> LLVM target b #

(<*) :: LLVM target a -> LLVM target b -> LLVM target a #

MonadIO (LLVM target) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

liftIO :: IO a -> LLVM target a #

MonadMask (LLVM target) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

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) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

catch :: Exception e => LLVM target a -> (e -> LLVM target a) -> LLVM target a #

MonadThrow (LLVM target) 
Instance details

Defined in Data.Array.Accelerate.LLVM.State

Methods

throwM :: Exception e => e -> LLVM target a #

data Native Source #

Native machine code JIT execution target

Constructors

Native 

Fields

Instances

Instances details
Skeleton Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.CodeGen

Methods

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 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Compile.Cache

Embed Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Embed

Methods

embedForTarget :: Native -> ObjectR Native -> Q (TExp (ExecutableR Native))

Execute Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute

Methods

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 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Link

Associated Types

data ExecutableR Native

Methods

linkForTarget :: ObjectR Native -> LLVM Native (ExecutableR Native)

Compile Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Compile

Associated Types

data ObjectR Native

Methods

compileForTarget :: PreOpenAcc DelayedOpenAcc aenv a -> Gamma aenv -> LLVM Native (ObjectR Native)

Marshal Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Marshal

Associated Types

type ArgR Native

Methods

marshalInt :: Int -> ArgR Native

marshalScalarData' :: SingleType e -> ScalarArrayData e -> Par Native (DList (ArgR Native))

Foreign Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Foreign

Methods

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 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Compile

Target Native Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Target

Remote Native

Data instance for arrays in the native backend. We assume a shared-memory machine, and just manipulate the underlying Haskell array directly.

Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Array.Data

Methods

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 # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Associated Types

data Par Native :: Type -> Type #

type FutureR Native :: Type -> Type #

MonadState Native (Par Native) Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Methods

get :: Par Native Native #

put :: Native -> Par Native () #

state :: (Native -> (a, Native)) -> Par Native a #

Monad (Par Native) Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Methods

(>>=) :: Par Native a -> (a -> Par Native b) -> Par Native b #

(>>) :: Par Native a -> Par Native b -> Par Native b #

return :: a -> Par Native a #

Functor (Par Native) Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Methods

fmap :: (a -> b) -> Par Native a -> Par Native b #

(<$) :: a -> Par Native b -> Par Native a #

Applicative (Par Native) Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Methods

pure :: a -> Par Native a #

(<*>) :: Par Native (a -> b) -> Par Native a -> Par Native b #

liftA2 :: (a -> b -> c) -> Par Native a -> Par Native b -> Par Native c #

(*>) :: Par Native a -> Par Native b -> Par Native b #

(<*) :: Par Native a -> Par Native b -> Par Native a #

MonadIO (Par Native) Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Methods

liftIO :: IO a -> Par Native a #

MonadCont (Par Native) Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Methods

callCC :: ((a -> Par Native b) -> Par Native a) -> Par Native a #

data ExecutableR Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Link

data ExecutableR Native = NativeR {}
data ObjectR Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Compile

type ArgR Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Marshal

type ArgR Native = Arg
type FutureR Native Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

newtype Par Native a Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

newtype Par Native a = Par {}
data KernelMetadata Native 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.CodeGen.Base

data KernelMetadata Native = KM_Native ()

liftIO :: MonadIO m => IO a -> m a #

Lift a computation from the IO monad.

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 #

Minimal complete definition

new, put, get, fork, liftPar

Associated Types

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.

Methods

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 puts 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

Instances details
Async Native Source # 
Instance details

Defined in Data.Array.Accelerate.LLVM.Native.Execute.Async

Associated Types

data Par Native :: Type -> Type #

type FutureR Native :: Type -> Type #

data Future a Source #

Constructors

Future !(IORef (IVar a)) 

data IVar a Source #

Constructors

Full !a 
Blocked !(Seq (a -> IO ())) 
Empty 

getArrays :: Async arch => ArraysR a -> FutureArraysR arch a -> Par arch 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.

Orphan instances

Foreign Native Source # 
Instance details

Methods

foreignAcc :: Foreign asm => asm (a -> b) -> Maybe (a -> Par Native (FutureR Native b))

foreignExp :: Foreign asm => asm (x -> y) -> Maybe (IRFun1 Native () (x -> y))