-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An embedded language for accelerated array processing -- -- This library defines an embedded language for regular, -- multi-dimensional array computations with multiple backends to -- facilitate high-performance implementations. Currently, the only -- backend is an interpreter that serves as a reference implementation of -- the intended semantics of the language. @package accelerate @version 0.6.0.0 -- | This interpreter is meant to be a reference implementation of the -- semantics of the embedded array language. The emphasis is on defining -- the semantics clearly, not on performance. module Data.Array.Accelerate.Interpreter -- | Characterises the types that may be returned when running an array -- program. class (Delayable as) => Arrays as -- | Run a complete embedded array program using the reference interpreter. run :: (Arrays a) => Acc a -> a instance (Arrays as1, Arrays as2) => Arrays (as1, as2) instance Arrays (Array dim e) instance Arrays () -- | This module defines an embedded language of array computations for -- high-performance computing. Computations on multi-dimensional, regular -- arrays are expressed in the form of parameterised collective -- operations (such as maps, reductions, and permutations). These -- computations are online compiled and executed on a range of -- architectures. -- -- Abstract interface -- -- The types representing array computations are only exported abstractly -- i.e., client code can generate array computations and submit them -- for for execution, but it cannot inspect these computations. This is -- to allow for more flexibility for future extensions of this library. -- -- Code execution -- -- Access to the various backends is via a run function in -- backend-specific toplevel modules. Currently, we have the following: -- --
-- precondition: size dim == size dim' --reshape :: (Ix dim, Ix dim', Elem e) => Exp dim -> Acc (Array dim' e) -> Acc (Array dim e) -- | Index an array with a *generalised* array index (supplied as the -- second argument). The result is a new array (possibly a singleton) -- containing all dimensions in their entirety. slice :: (SliceIx slix, Elem e) => Acc (Array (SliceDim slix) e) -> Exp slix -> Acc (Array (Slice slix) e) -- | Replicate an array across one or more dimensions as specified by the -- *generalised* array index provided as the first argument. -- -- For example, assuming arr is a vector (one-dimensional -- array), -- --
-- replicate (2, All, 3) arr ---- -- yields a three dimensional array, where arr is replicated -- twice across the first and three times across the third dimension. replicate :: (SliceIx slix, Elem e) => Exp slix -> Acc (Array (Slice slix) e) -> Acc (Array (SliceDim slix) e) -- | Combine the elements of two arrays pairwise. The shape of the result -- is the intersection of the two argument shapes. zip :: (Ix dim, Elem a, Elem b) => Acc (Array dim a) -> Acc (Array dim b) -> Acc (Array dim (a, b)) -- | The converse of zip, but the shape of the two results is -- identical to the shape of the argument. unzip :: (Ix dim, Elem a, Elem b) => Acc (Array dim (a, b)) -> (Acc (Array dim a), Acc (Array dim b)) -- | Apply the given function elementwise to the given array. map :: (Ix dim, Elem a, Elem b) => (Exp a -> Exp b) -> Acc (Array dim a) -> Acc (Array dim b) -- | Apply the given binary function elementwise to the two arrays. zipWith :: (Ix dim, Elem a, Elem b, Elem c) => (Exp a -> Exp b -> Exp c) -> Acc (Array dim a) -> Acc (Array dim b) -> Acc (Array dim c) -- | Prescan of a vector. The type a together with the binary -- function (first argument) and value (second argument) must form a -- monoid; i.e., the function must be associative and the value -- must be its neutral element. -- -- The resulting vector of prescan values has the same size as the -- argument vector. The resulting scalar is the reduction value. scan :: (Elem a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> (Acc (Vector a), Acc (Scalar a)) -- | Reduction of an array. The type a together with the binary -- function (first argument) and value (second argument) must form a -- monoid; i.e., the function must be associative and the value -- must be its neutral element. fold :: (Ix dim, Elem a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array dim a) -> Acc (Scalar a) -- | Segmented reduction. foldSeg :: (Elem a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc Segments -> Acc (Vector a) -- | Forward permutation specified by an index mapping. The result array is -- initialised with the given defaults and any further values that are -- permuted into the result array are added to the current value using -- the given combination function. -- -- The combination function must be associative. Elements that are -- mapped to the magic value ignore by the permutation function -- are being dropped. permute :: (Ix dim, Ix dim', Elem a) => (Exp a -> Exp a -> Exp a) -> Acc (Array dim' a) -> (Exp dim -> Exp dim') -> Acc (Array dim a) -> Acc (Array dim' a) -- | Backward permutation backpermute :: (Ix dim, Ix dim', Elem a) => Exp dim' -> (Exp dim' -> Exp dim) -> Acc (Array dim a) -> Acc (Array dim' a) class Tuple tup where { type family TupleT tup; } tuple :: (Tuple tup) => tup -> TupleT tup untuple :: (Tuple tup) => TupleT tup -> tup -- | Conditional expression. (?) :: (Elem t) => Exp Bool -> (Exp t, Exp t) -> Exp t -- | Expression form that extracts a scalar from an array. (!) :: (Ix dim, Elem e) => Acc (Array dim e) -> Exp dim -> Exp e shape :: (Ix dim) => Acc (Array dim e) -> Exp dim -- | Equality lifted into Accelerate expressions. (==*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool -- | Inequality lifted into Accelerate expressions. (/=*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool -- | Smaller-than lifted into Accelerate expressions. (<*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool -- | Smaller-or-equal lifted into Accelerate expressions. (<=*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool -- | Greater-than lifted into Accelerate expressions. (>*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool -- | Greater-or-equal lifted into Accelerate expressions. (>=*) :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp Bool -- | Determine the maximum of two scalars. max :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp t -- | Determine the minimum of two scalars. min :: (Elem t, IsScalar t) => Exp t -> Exp t -> Exp t -- | Conjunction (&&*) :: Exp Bool -> Exp Bool -> Exp Bool -- | Disjunction (||*) :: Exp Bool -> Exp Bool -> Exp Bool -- | Negation not :: Exp Bool -> Exp Bool -- | Convert a Boolean value to an Int, where False turns -- into '0' and True into '1'. boolToInt :: Exp Bool -> Exp Int -- | Magic value identifying elements that are ignored in a forward -- permutation ignore :: (Ix dim) => Exp dim