Portability | non-portable (GHC extensions) |
---|---|
Stability | experimental |
Maintainer | Manuel M T Chakravarty <chak@cse.unsw.edu.au> |
Safe Haskell | None |
- Scalar element types
- Scalar type classes
- Array data types
- Array element types
- Array shapes & indices
- Operations to use Accelerate arrays from plain Haskell
- The Accelerate language
- Array and scalar expressions
- Stencil specification
- Common stencil types
- Scalar introduction
- Array construction
- Shape manipulation
- Extraction of subarrays
- Map-like functions
- Reductions
- Scan functions
- Permutations
- Stencil operations
- Pipelining
- Array-level flow-control
- Lifting and unlifting
- Tuple construction and destruction
- Index construction and destruction
- Conditional expressions
- Array operations with a scalar result
- Methods of H98 classes that we need to redefine as their signatures change
- Standard functions that we need to redefine as their signatures change
- Conversions
- Constants
- Map-like
- Reductions
- Scans
- Segmented scans
- Reshaping of arrays
- Enumeration and filling
- Gather and scatter
- Subvector extraction
- Deprecated names for backwards compatibility
- Diagnostics
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:
- Data.Array.Accelerate.Interpreter: simple interpreter in Haskell as a reference implementation defining the semantics of the Accelerate language
- Data.Array.Accelerate.CUDA: an implementation supporting parallel execution on CUDA-capable NVIDIA GPUs
- data Int
- data Int8
- data Int16
- data Int32
- data Int64
- data Word
- data Word8
- data Word16
- data Word32
- data Word64
- data CShort
- data CUShort
- data CInt
- data CUInt
- data CLong
- data CULong
- data CLLong
- data CULLong
- data Float
- data Double
- data CFloat
- data CDouble
- data Bool
- data Char
- data CChar
- data CSChar
- data CUChar
- class Typeable a => IsScalar a
- class (Num a, IsScalar a) => IsNum a
- class IsBounded a
- class (IsScalar a, IsNum a, IsBounded a) => IsIntegral a
- class (Floating a, IsScalar a, IsNum a) => IsFloating a
- class IsNonNum a
- class (Typeable (ArrRepr a), Typeable (ArrRepr' a), Typeable a) => Arrays a
- data Array sh e
- type Scalar e = Array DIM0 e
- type Vector e = Array DIM1 e
- type Segments i = Vector i
- class (Show a, Typeable a, Typeable (EltRepr a), Typeable (EltRepr' a), ArrayElt (EltRepr a), ArrayElt (EltRepr' a)) => Elt a
- data Z = Z
- data tail :. head = tail :. head
- class (Elt sh, Elt (Any sh), Shape (EltRepr sh)) => Shape sh
- data All = All
- data Any sh = Any
- class (Elt sl, Shape (SliceShape sl), Shape (CoSliceShape sl), Shape (FullShape sl)) => Slice sl where
- type SliceShape sl :: *
- type CoSliceShape sl :: *
- type FullShape sl :: *
- sliceIndex :: sl -> SliceIndex (EltRepr sl) (EltRepr (SliceShape sl)) (EltRepr (CoSliceShape sl)) (EltRepr (FullShape sl))
- type DIM0 = Z
- type DIM1 = DIM0 :. Int
- type DIM2 = DIM1 :. Int
- type DIM3 = DIM2 :. Int
- type DIM4 = DIM3 :. Int
- type DIM5 = DIM4 :. Int
- type DIM6 = DIM5 :. Int
- type DIM7 = DIM6 :. Int
- type DIM8 = DIM7 :. Int
- type DIM9 = DIM8 :. Int
- arrayDim :: Shape sh => sh -> Int
- arrayShape :: Shape sh => Array sh e -> sh
- arraySize :: Shape sh => sh -> Int
- indexArray :: Array sh e -> sh -> e
- fromIArray :: (EltRepr ix ~ EltRepr sh, IArray a e, Ix ix, Shape sh, Elt ix, Elt e) => a ix e -> Array sh e
- toIArray :: (EltRepr ix ~ EltRepr sh, IArray a e, Ix ix, Shape sh, Elt ix, Elt e) => Array sh e -> a ix e
- fromList :: (Shape sh, Elt e) => sh -> [e] -> Array sh e
- toList :: forall sh e. Array sh e -> [e]
- data Acc a
- data Exp t
- data Boundary a
- class (Elt (StencilRepr sh stencil), Stencil sh a (StencilRepr sh stencil)) => Stencil sh a stencil
- type Stencil3 a = (Exp a, Exp a, Exp a)
- type Stencil5 a = (Exp a, Exp a, Exp a, Exp a, Exp a)
- type Stencil7 a = (Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a)
- type Stencil9 a = (Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a, Exp a)
- type Stencil3x3 a = (Stencil3 a, Stencil3 a, Stencil3 a)
- type Stencil5x3 a = (Stencil5 a, Stencil5 a, Stencil5 a)
- type Stencil3x5 a = (Stencil3 a, Stencil3 a, Stencil3 a, Stencil3 a, Stencil3 a)
- type Stencil5x5 a = (Stencil5 a, Stencil5 a, Stencil5 a, Stencil5 a, Stencil5 a)
- type Stencil3x3x3 a = (Stencil3x3 a, Stencil3x3 a, Stencil3x3 a)
- type Stencil5x3x3 a = (Stencil5x3 a, Stencil5x3 a, Stencil5x3 a)
- type Stencil3x5x3 a = (Stencil3x5 a, Stencil3x5 a, Stencil3x5 a)
- type Stencil3x3x5 a = (Stencil3x3 a, Stencil3x3 a, Stencil3x3 a, Stencil3x3 a, Stencil3x3 a)
- type Stencil5x5x3 a = (Stencil5x5 a, Stencil5x5 a, Stencil5x5 a)
- type Stencil5x3x5 a = (Stencil5x3 a, Stencil5x3 a, Stencil5x3 a, Stencil5x3 a, Stencil5x3 a)
- type Stencil3x5x5 a = (Stencil3x5 a, Stencil3x5 a, Stencil3x5 a, Stencil3x5 a, Stencil3x5 a)
- type Stencil5x5x5 a = (Stencil5x5 a, Stencil5x5 a, Stencil5x5 a, Stencil5x5 a, Stencil5x5 a)
- constant :: Elt t => t -> Exp t
- use :: Arrays arrays => arrays -> Acc arrays
- unit :: Elt e => Exp e -> Acc (Scalar e)
- replicate :: (Slice slix, Elt e) => Exp slix -> Acc (Array (SliceShape slix) e) -> Acc (Array (FullShape slix) e)
- generate :: (Shape ix, Elt a) => Exp ix -> (Exp ix -> Exp a) -> Acc (Array ix a)
- reshape :: (Shape ix, Shape ix', Elt e) => Exp ix -> Acc (Array ix' e) -> Acc (Array ix e)
- slice :: (Slice slix, Elt e) => Acc (Array (FullShape slix) e) -> Exp slix -> Acc (Array (SliceShape slix) e)
- map :: (Shape ix, Elt a, Elt b) => (Exp a -> Exp b) -> Acc (Array ix a) -> Acc (Array ix b)
- zipWith :: (Shape ix, Elt a, Elt b, Elt c) => (Exp a -> Exp b -> Exp c) -> Acc (Array ix a) -> Acc (Array ix b) -> Acc (Array ix c)
- fold :: (Shape ix, Elt a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array (ix :. Int) a) -> Acc (Array ix a)
- fold1 :: (Shape ix, Elt a) => (Exp a -> Exp a -> Exp a) -> Acc (Array (ix :. Int) a) -> Acc (Array ix a)
- foldSeg :: (Shape ix, Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array (ix :. Int) a) -> Acc (Segments i) -> Acc (Array (ix :. Int) a)
- fold1Seg :: (Shape ix, Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Acc (Array (ix :. Int) a) -> Acc (Segments i) -> Acc (Array (ix :. Int) a)
- scanl :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)
- scanl' :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> (Acc (Vector a), Acc (Scalar a))
- scanl1 :: Elt a => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Vector a)
- scanr :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)
- scanr' :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> (Acc (Vector a), Acc (Scalar a))
- scanr1 :: Elt a => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Vector a)
- permute :: (Shape ix, Shape ix', Elt a) => (Exp a -> Exp a -> Exp a) -> Acc (Array ix' a) -> (Exp ix -> Exp ix') -> Acc (Array ix a) -> Acc (Array ix' a)
- backpermute :: (Shape ix, Shape ix', Elt a) => Exp ix' -> (Exp ix' -> Exp ix) -> Acc (Array ix a) -> Acc (Array ix' a)
- stencil :: (Shape ix, Elt a, Elt b, Stencil ix a stencil) => (stencil -> Exp b) -> Boundary a -> Acc (Array ix a) -> Acc (Array ix b)
- stencil2 :: (Shape ix, Elt a, Elt b, Elt c, Stencil ix a stencil1, Stencil ix b stencil2) => (stencil1 -> stencil2 -> Exp c) -> Boundary a -> Acc (Array ix a) -> Boundary b -> Acc (Array ix b) -> Acc (Array ix c)
- (>->) :: (Arrays a, Arrays b, Arrays c) => (Acc a -> Acc b) -> (Acc b -> Acc c) -> Acc a -> Acc c
- cond :: Arrays a => Exp Bool -> Acc a -> Acc a -> Acc a
- (?|) :: Arrays a => Exp Bool -> (Acc a, Acc a) -> Acc a
- class Lift c e where
- class Lift c e => Unlift c e where
- lift1 :: (Unlift Exp e1, Lift Exp e2) => (e1 -> e2) -> Exp (Plain e1) -> Exp (Plain e2)
- lift2 :: (Unlift Exp e1, Unlift Exp e2, Lift Exp e3) => (e1 -> e2 -> e3) -> Exp (Plain e1) -> Exp (Plain e2) -> Exp (Plain e3)
- ilift1 :: (Exp Int -> Exp Int) -> Exp (Z :. Int) -> Exp (Z :. Int)
- ilift2 :: (Exp Int -> Exp Int -> Exp Int) -> Exp (Z :. Int) -> Exp (Z :. Int) -> Exp (Z :. Int)
- fst :: forall a b. (Elt a, Elt b) => Exp (a, b) -> Exp a
- snd :: forall a b. (Elt a, Elt b) => Exp (a, b) -> Exp b
- curry :: (Elt a, Elt b) => (Exp (a, b) -> Exp c) -> Exp a -> Exp b -> Exp c
- uncurry :: (Elt a, Elt b) => (Exp a -> Exp b -> Exp c) -> Exp (a, b) -> Exp c
- index0 :: Exp Z
- index1 :: Exp Int -> Exp (Z :. Int)
- unindex1 :: Exp (Z :. Int) -> Exp Int
- index2 :: Exp Int -> Exp Int -> Exp DIM2
- unindex2 :: Exp DIM2 -> Exp (Int, Int)
- (?) :: Elt t => Exp Bool -> (Exp t, Exp t) -> Exp t
- (!) :: (Shape ix, Elt e) => Acc (Array ix e) -> Exp ix -> Exp e
- the :: Elt e => Acc (Scalar e) -> Exp e
- shape :: (Shape ix, Elt e) => Acc (Array ix e) -> Exp ix
- size :: (Shape ix, Elt e) => Acc (Array ix e) -> Exp Int
- shapeSize :: Shape ix => Exp ix -> Exp Int
- (==*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp Bool
- (/=*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp Bool
- (<*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp Bool
- (<=*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp Bool
- (>*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp Bool
- (>=*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp Bool
- max :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp t
- min :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp t
- bit :: (Elt t, IsIntegral t) => Exp Int -> Exp t
- setBit, complementBit, clearBit :: (Elt t, IsIntegral t) => Exp t -> Exp Int -> Exp t
- testBit :: (Elt t, IsIntegral t) => Exp t -> Exp Int -> Exp Bool
- shift, shiftR, shiftL :: (Elt t, IsIntegral t) => Exp t -> Exp Int -> Exp t
- rotate, rotateR, rotateL :: (Elt t, IsIntegral t) => Exp t -> Exp Int -> Exp t
- truncate :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp b
- round :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp b
- floor :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp b
- ceiling :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp b
- (&&*) :: Exp Bool -> Exp Bool -> Exp Bool
- (||*) :: Exp Bool -> Exp Bool -> Exp Bool
- not :: Exp Bool -> Exp Bool
- boolToInt :: Exp Bool -> Exp Int
- fromIntegral :: (Elt a, Elt b, IsIntegral a, IsNum b) => Exp a -> Exp b
- ignore :: Shape ix => Exp ix
- zip :: (Shape sh, Elt a, Elt b) => Acc (Array sh a) -> Acc (Array sh b) -> Acc (Array sh (a, b))
- zip3 :: forall sh a b c. (Shape sh, Elt a, Elt b, Elt c) => Acc (Array sh a) -> Acc (Array sh b) -> Acc (Array sh c) -> Acc (Array sh (a, b, c))
- zip4 :: forall sh a b c d. (Shape sh, Elt a, Elt b, Elt c, Elt d) => Acc (Array sh a) -> Acc (Array sh b) -> Acc (Array sh c) -> Acc (Array sh d) -> Acc (Array sh (a, b, c, d))
- unzip :: (Shape sh, Elt a, Elt b) => Acc (Array sh (a, b)) -> (Acc (Array sh a), Acc (Array sh b))
- unzip3 :: forall sh a b c. (Shape sh, Elt a, Elt b, Elt c) => Acc (Array sh (a, b, c)) -> (Acc (Array sh a), Acc (Array sh b), Acc (Array sh c))
- unzip4 :: forall sh a b c d. (Shape sh, Elt a, Elt b, Elt c, Elt d) => Acc (Array sh (a, b, c, d)) -> (Acc (Array sh a), Acc (Array sh b), Acc (Array sh c), Acc (Array sh d))
- foldAll :: (Shape sh, Elt a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array sh a) -> Acc (Scalar a)
- fold1All :: (Shape sh, Elt a) => (Exp a -> Exp a -> Exp a) -> Acc (Array sh a) -> Acc (Scalar a)
- prescanl :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)
- postscanl :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)
- prescanr :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)
- postscanr :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)
- scanlSeg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- scanl'Seg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> (Acc (Vector a), Acc (Vector a))
- scanl1Seg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- prescanlSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- postscanlSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- scanrSeg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- scanr'Seg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> (Acc (Vector a), Acc (Vector a))
- scanr1Seg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- prescanrSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- postscanrSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)
- flatten :: (Shape ix, Elt a) => Acc (Array ix a) -> Acc (Array DIM1 a)
- fill :: (Shape sh, Elt e) => Exp sh -> Exp e -> Acc (Array sh e)
- enumFromN :: (Shape sh, Elt e, IsNum e) => Exp sh -> Exp e -> Acc (Array sh e)
- enumFromStepN :: (Shape sh, Elt e, IsNum e) => Exp sh -> Exp e -> Exp e -> Acc (Array sh e)
- gather :: Elt e => Acc (Vector Int) -> Acc (Vector e) -> Acc (Vector e)
- gatherIf :: (Elt e, Elt e') => Acc (Vector Int) -> Acc (Vector e) -> (Exp e -> Exp Bool) -> Acc (Vector e') -> Acc (Vector e') -> Acc (Vector e')
- scatter :: Elt e => Acc (Vector Int) -> Acc (Vector e) -> Acc (Vector e) -> Acc (Vector e)
- scatterIf :: (Elt e, Elt e') => Acc (Vector Int) -> Acc (Vector e) -> (Exp e -> Exp Bool) -> Acc (Vector e') -> Acc (Vector e') -> Acc (Vector e')
- init :: Elt e => Acc (Vector e) -> Acc (Vector e)
- tail :: Elt e => Acc (Vector e) -> Acc (Vector e)
- take :: Elt e => Exp Int -> Acc (Vector e) -> Acc (Vector e)
- drop :: Elt e => Exp Int -> Acc (Vector e) -> Acc (Vector e)
- slit :: Elt e => Exp Int -> Exp Int -> Acc (Vector e) -> Acc (Vector e)
- class Elt e => Elem e
- class Shape sh => Ix sh
- class Slice sh => SliceIx sh
- tuple :: Lift Exp e => e -> Exp (Plain e)
- untuple :: Unlift Exp e => Exp (Plain e) -> e
- initTrace :: Bool -> IO ()
Scalar element types
data Int
A fixed-precision integer type with at least the range [-2^29 .. 2^29-1]
.
The exact range for a given implementation can be determined by using
minBound
and maxBound
from the Bounded
class.
Bounded Int | |
Enum Int | |
Eq Int | |
Integral Int | |
Num Int | |
Ord Int | |
Read Int | |
Real Int | |
Show Int | |
Ix Int | |
Typeable Int | |
Generic Int | |
Storable Int | |
Bits Int | |
IsScalar Int | |
IsBounded Int | |
IsNum Int | |
IsIntegral Int | |
ArrayElt Int | |
Elt Int | |
IArray UArray Int | |
Lift Exp Int | |
Elt e => Stencil DIM1 e (e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
(Slice (Plain ix), Lift Exp ix) => Lift Exp (:. ix Int) | |
Shape sh => Elt (Any (:. sh Int)) | |
MArray (STUArray s) Int (ST s) | |
Slice sl => Slice (sl, Int) | |
Shape sh => Shape (sh, Int) | |
Slice sl => Slice (:. sl Int) | |
Shape sh => Shape (:. sh Int) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3) | |
(Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row0) => Stencil (:. (:. sh Int) Int) a (row2, row1, row0) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7, Stencil (:. sh Int) a row8, Stencil (:. sh Int) a row9) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7, row8, row9) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7, Stencil (:. sh Int) a row8, Stencil (:. sh Int) a row9) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7, row8, row9) |
data Int8
8-bit signed integer type
data Int16
16-bit signed integer type
Bounded Int16 | |
Enum Int16 | |
Eq Int16 | |
Integral Int16 | |
Num Int16 | |
Ord Int16 | |
Read Int16 | |
Real Int16 | |
Show Int16 | |
Ix Int16 | |
Typeable Int16 | |
Storable Int16 | |
Bits Int16 | |
IsScalar Int16 | |
IsBounded Int16 | |
IsNum Int16 | |
IsIntegral Int16 | |
ArrayElt Int16 | |
Elt Int16 | |
IArray UArray Int16 | |
Lift Exp Int16 | |
MArray (STUArray s) Int16 (ST s) |
data Int32
32-bit signed integer type
Bounded Int32 | |
Enum Int32 | |
Eq Int32 | |
Integral Int32 | |
Num Int32 | |
Ord Int32 | |
Read Int32 | |
Real Int32 | |
Show Int32 | |
Ix Int32 | |
Typeable Int32 | |
Storable Int32 | |
Bits Int32 | |
IsScalar Int32 | |
IsBounded Int32 | |
IsNum Int32 | |
IsIntegral Int32 | |
ArrayElt Int32 | |
Elt Int32 | |
IArray UArray Int32 | |
Lift Exp Int32 | |
MArray (STUArray s) Int32 (ST s) |
data Int64
64-bit signed integer type
Bounded Int64 | |
Enum Int64 | |
Eq Int64 | |
Integral Int64 | |
Num Int64 | |
Ord Int64 | |
Read Int64 | |
Real Int64 | |
Show Int64 | |
Ix Int64 | |
Typeable Int64 | |
Storable Int64 | |
Bits Int64 | |
IsScalar Int64 | |
IsBounded Int64 | |
IsNum Int64 | |
IsIntegral Int64 | |
ArrayElt Int64 | |
Elt Int64 | |
IArray UArray Int64 | |
Lift Exp Int64 | |
MArray (STUArray s) Int64 (ST s) |
data Word
data Word8
8-bit unsigned integer type
Bounded Word8 | |
Enum Word8 | |
Eq Word8 | |
Integral Word8 | |
Num Word8 | |
Ord Word8 | |
Read Word8 | |
Real Word8 | |
Show Word8 | |
Ix Word8 | |
Typeable Word8 | |
Storable Word8 | |
Bits Word8 | |
IsScalar Word8 | |
IsBounded Word8 | |
IsNum Word8 | |
IsIntegral Word8 | |
ArrayElt Word8 | |
Elt Word8 | |
IArray UArray Word8 | |
Lift Exp Word8 | |
MArray (STUArray s) Word8 (ST s) |
data Word16
16-bit unsigned integer type
data Word32
32-bit unsigned integer type
data Word64
64-bit unsigned integer type
data CShort
Haskell type representing the C short
type.
data CUShort
Haskell type representing the C unsigned short
type.
data CInt
Haskell type representing the C int
type.
data CUInt
Haskell type representing the C unsigned int
type.
data CLong
Haskell type representing the C long
type.
data CULong
Haskell type representing the C unsigned long
type.
data CLLong
Haskell type representing the C long long
type.
data CULLong
Haskell type representing the C unsigned long long
type.
data Float
Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
data Double
Double-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE double-precision type.
data CFloat
Haskell type representing the C float
type.
data CDouble
Haskell type representing the C double
type.
data Bool
data Char
The character type Char
is an enumeration whose values represent
Unicode (or equivalently ISO/IEC 10646) characters (see
http://www.unicode.org/ for details). This set extends the ISO 8859-1
(Latin-1) character set (the first 256 characters), which is itself an extension
of the ASCII character set (the first 128 characters). A character literal in
Haskell has type Char
.
To convert a Char
to or from the corresponding Int
value defined
by Unicode, use toEnum
and fromEnum
from the
Enum
class respectively (or equivalently ord
and chr
).
data CChar
Haskell type representing the C char
type.
data CSChar
Haskell type representing the C signed char
type.
data CUChar
Haskell type representing the C unsigned char
type.
Scalar type classes
class Typeable a => IsScalar a Source
All scalar type
Bounded types
class (IsScalar a, IsNum a, IsBounded a) => IsIntegral a Source
Integral types
class (Floating a, IsScalar a, IsNum a) => IsFloating a Source
Floating types
Non-numeric types
Array data types
class (Typeable (ArrRepr a), Typeable (ArrRepr' a), Typeable a) => Arrays a Source
Arrays () | |
(Arrays b, Arrays a) => Arrays (b, a) | |
(Shape sh, Elt e) => Arrays (Array sh e) | |
(Arrays c, Arrays b, Arrays a) => Arrays (c, b, a) | |
(Arrays d, Arrays c, Arrays b, Arrays a) => Arrays (d, c, b, a) | |
(Arrays e, Arrays d, Arrays c, Arrays b, Arrays a) => Arrays (e, d, c, b, a) | |
(Arrays f, Arrays e, Arrays d, Arrays c, Arrays b, Arrays a) => Arrays (f, e, d, c, b, a) | |
(Arrays g, Arrays f, Arrays e, Arrays d, Arrays c, Arrays b, Arrays a) => Arrays (g, f, e, d, c, b, a) | |
(Arrays h, Arrays g, Arrays f, Arrays e, Arrays d, Arrays c, Arrays b, Arrays a) => Arrays (h, g, f, e, d, c, b, a) | |
(Arrays i, Arrays h, Arrays g, Arrays f, Arrays e, Arrays d, Arrays c, Arrays b, Arrays a) => Arrays (i, h, g, f, e, d, c, b, a) |
Multi-dimensional arrays for array processing
- If device and host memory are separate, arrays will be transferred to the device when necessary (if possible asynchronously and in parallel with other tasks) and cached on the device if sufficient memory is available.
type Segments i = Vector iSource
Segment descriptor (vector of segment lengths)
To represent nested one-dimensional arrays, we use a flat array of data values in conjunction with a segment descriptor, which stores the lengths of the subarrays.
Array element types
class (Show a, Typeable a, Typeable (EltRepr a), Typeable (EltRepr' a), ArrayElt (EltRepr a), ArrayElt (EltRepr' a)) => Elt a Source
Class that characterises the types of values that can be array elements, and hence, appear in scalar Accelerate expressions.
Elt Bool | |
Elt Char | |
Elt Double | |
Elt Float | |
Elt Int | |
Elt Int8 | |
Elt Int16 | |
Elt Int32 | |
Elt Int64 | |
Elt Word | |
Elt Word8 | |
Elt Word16 | |
Elt Word32 | |
Elt Word64 | |
Elt () | |
Elt All | |
Elt Z | |
Shape sh => Elt (Any (:. sh Int)) | |
Elt (Any Z) | |
(Elt a, Elt b) => Elt (a, b) | |
(Elt t, Elt h) => Elt (:. t h) | |
(Elt a, Elt b, Elt c) => Elt (a, b, c) | |
(Elt a, Elt b, Elt c, Elt d) => Elt (a, b, c, d) | |
(Elt a, Elt b, Elt c, Elt d, Elt e) => Elt (a, b, c, d, e) | |
(Elt a, Elt b, Elt c, Elt d, Elt e, Elt f) => Elt (a, b, c, d, e, f) | |
(Elt a, Elt b, Elt c, Elt d, Elt e, Elt f, Elt g) => Elt (a, b, c, d, e, f, g) | |
(Elt a, Elt b, Elt c, Elt d, Elt e, Elt f, Elt g, Elt h) => Elt (a, b, c, d, e, f, g, h) | |
(Elt a, Elt b, Elt c, Elt d, Elt e, Elt f, Elt g, Elt h, Elt i) => Elt (a, b, c, d, e, f, g, h, i) |
Array shapes & indices
Array indices are snoc type lists.
For example, the type of a rank-2 array index is Z :.Int :. Int
.
Rank-0 index
Show Z | |
Typeable Z | |
Slice Z | |
Shape Z | |
Elt Z | |
Unlift Exp Z | |
Lift Exp Z | |
Elt e => Stencil DIM1 e (e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt (Any Z) |
Increase an index rank by one dimension
tail :. head |
Typeable2 :. | |
Elt e => Stencil DIM1 e (e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (e, e, e, e, e, e, e, e, e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
(Elt e, Slice (Plain ix), Unlift Exp ix) => Unlift Exp (:. ix (Exp e)) | |
(Elt e, Slice (Plain ix), Lift Exp ix) => Lift Exp (:. ix (Exp e)) | |
(Slice (Plain ix), Lift Exp ix) => Lift Exp (:. ix All) | |
(Slice (Plain ix), Lift Exp ix) => Lift Exp (:. ix Int) | |
Shape sh => Elt (Any (:. sh Int)) | |
(Show tail, Show head) => Show (:. tail head) | |
Slice sl => Slice (:. sl Int) | |
Slice sl => Slice (:. sl All) | |
Shape sh => Shape (:. sh Int) | |
(Elt t, Elt h) => Elt (:. t h) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3) | |
(Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row0) => Stencil (:. (:. sh Int) Int) a (row2, row1, row0) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7, Stencil (:. sh Int) a row8, Stencil (:. sh Int) a row9) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7, row8, row9) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7, Stencil (:. sh Int) a row8, Stencil (:. sh Int) a row9) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7, row8, row9) |
class (Elt sh, Elt (Any sh), Shape (EltRepr sh)) => Shape sh Source
Shapes and indices of multi-dimensional arrays
Marker for entire dimensions in slice descriptors
Marker for arbitrary shapes in slice descriptors
class (Elt sl, Shape (SliceShape sl), Shape (CoSliceShape sl), Shape (FullShape sl)) => Slice sl whereSource
Slices, aka generalised indices, as n-tuples and mappings of slice indices to slices, co-slices, and slice dimensions
sliceIndex :: sl -> SliceIndex (EltRepr sl) (EltRepr (SliceShape sl)) (EltRepr (CoSliceShape sl)) (EltRepr (FullShape sl))Source
Operations to use Accelerate arrays from plain Haskell
arrayShape :: Shape sh => Array sh e -> shSource
Array shape in plain Haskell code
indexArray :: Array sh e -> sh -> eSource
Array indexing in plain Haskell code
fromIArray :: (EltRepr ix ~ EltRepr sh, IArray a e, Ix ix, Shape sh, Elt ix, Elt e) => a ix e -> Array sh eSource
Convert an IArray
to an accelerated array.
toIArray :: (EltRepr ix ~ EltRepr sh, IArray a e, Ix ix, Shape sh, Elt ix, Elt e) => Array sh e -> a ix eSource
Convert an accelerated array to an IArray
fromList :: (Shape sh, Elt e) => sh -> [e] -> Array sh eSource
Convert a list (with elements in row-major order) to an accelerated array.
toList :: forall sh e. Array sh e -> [e]Source
Convert an accelerated array to a list in row-major order.
The Accelerate language
Array and scalar expressions
Array-valued collective computations
Scalar expressions for plain array computations.
Stencil specification
Boundary condition specification for stencil operations.
class (Elt (StencilRepr sh stencil), Stencil sh a (StencilRepr sh stencil)) => Stencil sh a stencil Source
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
Elt e => Stencil DIM1 e (Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e, Exp e) | |
(Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row0) => Stencil (:. (:. sh Int) Int) a (row2, row1, row0) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7) | |
(Stencil (:. sh Int) a row1, Stencil (:. sh Int) a row2, Stencil (:. sh Int) a row3, Stencil (:. sh Int) a row4, Stencil (:. sh Int) a row5, Stencil (:. sh Int) a row6, Stencil (:. sh Int) a row7, Stencil (:. sh Int) a row8, Stencil (:. sh Int) a row9) => Stencil (:. (:. sh Int) Int) a (row1, row2, row3, row4, row5, row6, row7, row8, row9) |
Common stencil types
type Stencil3x3 a = (Stencil3 a, Stencil3 a, Stencil3 a)Source
type Stencil5x3 a = (Stencil5 a, Stencil5 a, Stencil5 a)Source
type Stencil3x3x3 a = (Stencil3x3 a, Stencil3x3 a, Stencil3x3 a)Source
type Stencil5x3x3 a = (Stencil5x3 a, Stencil5x3 a, Stencil5x3 a)Source
type Stencil3x5x3 a = (Stencil3x5 a, Stencil3x5 a, Stencil3x5 a)Source
type Stencil3x3x5 a = (Stencil3x3 a, Stencil3x3 a, Stencil3x3 a, Stencil3x3 a, Stencil3x3 a)Source
type Stencil5x5x3 a = (Stencil5x5 a, Stencil5x5 a, Stencil5x5 a)Source
type Stencil5x3x5 a = (Stencil5x3 a, Stencil5x3 a, Stencil5x3 a, Stencil5x3 a, Stencil5x3 a)Source
type Stencil3x5x5 a = (Stencil3x5 a, Stencil3x5 a, Stencil3x5 a, Stencil3x5 a, Stencil3x5 a)Source
type Stencil5x5x5 a = (Stencil5x5 a, Stencil5x5 a, Stencil5x5 a, Stencil5x5 a, Stencil5x5 a)Source
Scalar introduction
Array construction
use :: Arrays arrays => arrays -> Acc arraysSource
Array inlet: makes an array available for processing using the Accelerate language; triggers asynchronous host->device transfer if necessary.
unit :: Elt e => Exp e -> Acc (Scalar e)Source
Scalar inlet: injects a scalar (or a tuple of scalars) into a singleton array for use in the Accelerate language.
replicate :: (Slice slix, Elt e) => Exp slix -> Acc (Array (SliceShape slix) e) -> Acc (Array (FullShape slix) e)Source
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 (Z :.2 :.All :.3) arr
yields a three dimensional array, where arr
is replicated twice across the
first and three times across the third dimension.
generate :: (Shape ix, Elt a) => Exp ix -> (Exp ix -> Exp a) -> Acc (Array ix a)Source
Construct a new array by applying a function to each index.
For example, the following will generate a one-dimensional array
(Vector
) of three floating point numbers:
generate (index1 3) (\_ -> 1.2)
Or, equivalently:
generate (constant (Z :. (3::Int))) (\_ -> 1.2)
Finally, the following will create an array equivalent to '[1..10]':
generate (index1 10) $ \ ix -> let (Z :. i) = unlift ix in fromIntegral i
Shape manipulation
reshape :: (Shape ix, Shape ix', Elt e) => Exp ix -> Acc (Array ix' e) -> Acc (Array ix e)Source
Change the shape of an array without altering its contents, where
precondition: size ix == size ix'
Extraction of subarrays
slice :: (Slice slix, Elt e) => Acc (Array (FullShape slix) e) -> Exp slix -> Acc (Array (SliceShape slix) e)Source
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.
Map-like functions
map :: (Shape ix, Elt a, Elt b) => (Exp a -> Exp b) -> Acc (Array ix a) -> Acc (Array ix b)Source
Apply the given function element-wise to the given array.
zipWith :: (Shape ix, Elt a, Elt b, Elt c) => (Exp a -> Exp b -> Exp c) -> Acc (Array ix a) -> Acc (Array ix b) -> Acc (Array ix c)Source
Apply the given binary function element-wise to the two arrays. The extent of the resulting array is the intersection of the extents of the two source arrays.
Reductions
fold :: (Shape ix, Elt a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array (ix :. Int) a) -> Acc (Array ix a)Source
Reduction of the innermost dimension of an array of arbitrary rank. The first argument needs to be an associative function to enable an efficient parallel implementation.
fold1 :: (Shape ix, Elt a) => (Exp a -> Exp a -> Exp a) -> Acc (Array (ix :. Int) a) -> Acc (Array ix a)Source
Variant of fold
that requires the reduced array to be non-empty and doesn't need an default
value.
foldSeg :: (Shape ix, Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array (ix :. Int) a) -> Acc (Segments i) -> Acc (Array (ix :. Int) a)Source
Segmented reduction along the innermost dimension. Performs one individual reduction per segment of the source array. These reductions proceed in parallel.
The source array must have at least rank 1. The Segments
array determines the lengths of the
logical sub-arrays, each of which is folded separately.
fold1Seg :: (Shape ix, Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Acc (Array (ix :. Int) a) -> Acc (Segments i) -> Acc (Array (ix :. Int) a)Source
Scan functions
scanl :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)Source
List
-style left-to-right scan, but with the additional restriction that the first
argument needs to be an associative function to enable an efficient parallel implementation.
The initial value (second argument) may be arbitrary.
scanl' :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> (Acc (Vector a), Acc (Scalar a))Source
Variant of scanl
, where the final result of the reduction is returned separately.
Denotationally, we have
scanl' f e arr = (crop 0 (len - 1) res, unit (res!len)) where len = shape arr res = scanl f e arr
scanl1 :: Elt a => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Vector a)Source
List
style left-to-right scan without an initial value (aka inclusive scan). Again, the
first argument needs to be an associative function. Denotationally, we have
scanl1 f e arr = crop 1 len res where len = shape arr res = scanl f e arr
scanr :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)Source
Right-to-left variant of scanl
.
scanr' :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> (Acc (Vector a), Acc (Scalar a))Source
Right-to-left variant of scanl'
.
scanr1 :: Elt a => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Vector a)Source
Right-to-left variant of scanl1
.
Permutations
:: (Shape ix, Shape ix', Elt a) | |
=> (Exp a -> Exp a -> Exp a) | combination function |
-> Acc (Array ix' a) | array of default values |
-> (Exp ix -> Exp ix') | permutation |
-> Acc (Array ix a) | array to be permuted |
-> Acc (Array ix' 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.
:: (Shape ix, Shape ix', Elt a) | |
=> Exp ix' | shape of the result array |
-> (Exp ix' -> Exp ix) | permutation |
-> Acc (Array ix a) | source array |
-> Acc (Array ix' a) |
Backward permutation
Stencil operations
:: (Shape ix, Elt a, Elt b, Stencil ix a stencil) | |
=> (stencil -> Exp b) | stencil function |
-> Boundary a | boundary condition |
-> Acc (Array ix a) | source array |
-> Acc (Array ix b) | destination array |
Map a stencil over an array. In contrast to map
, the domain of a stencil function is an
entire neighbourhood of each array element. Neighbourhoods are sub-arrays centred around a
focal point. They are not necessarily rectangular, but they are symmetric in each dimension
and have an extent of at least three in each dimensions — due to the symmetry requirement, the
extent is necessarily odd. The focal point is the array position that is determined by the
stencil.
For those array positions where the neighbourhood extends past the boundaries of the source array, a boundary condition determines the contents of the out-of-bounds neighbourhood positions.
:: (Shape ix, Elt a, Elt b, Elt c, Stencil ix a stencil1, Stencil ix b stencil2) | |
=> (stencil1 -> stencil2 -> Exp c) | binary stencil function |
-> Boundary a | boundary condition #1 |
-> Acc (Array ix a) | source array #1 |
-> Boundary b | boundary condition #2 |
-> Acc (Array ix b) | source array #2 |
-> Acc (Array ix c) | destination array |
Map a binary stencil of an array. The extent of the resulting array is the intersection of the extents of the two source arrays.
Pipelining
(>->) :: (Arrays a, Arrays b, Arrays c) => (Acc a -> Acc b) -> (Acc b -> Acc c) -> Acc a -> Acc cSource
Pipelining of two array computations.
Denotationally, we have
(acc1 >-> acc2) arrs = let tmp = acc1 arrs in acc2 tmp
Operationally, the array computations acc1
and acc2
will not share any sub-computations,
neither between each other nor with the environment. This makes them truly independent stages
that only communicate by way of the result of acc1
which is being fed as an argument to acc2
.
Array-level flow-control
An array-level if-then-else construct.
Lifting and unlifting
class Lift c e => Unlift c e whereSource
unlift :: c (Plain e) -> eSource
Unlift the outermost constructor through the surface type. This is only possible if the constructor is fully determined by its type - i.e., it is a singleton.
lift1 :: (Unlift Exp e1, Lift Exp e2) => (e1 -> e2) -> Exp (Plain e1) -> Exp (Plain e2)Source
Lift a unary function into Exp
.
lift2 :: (Unlift Exp e1, Unlift Exp e2, Lift Exp e3) => (e1 -> e2 -> e3) -> Exp (Plain e1) -> Exp (Plain e2) -> Exp (Plain e3)Source
Lift a binary function into Exp
.
ilift1 :: (Exp Int -> Exp Int) -> Exp (Z :. Int) -> Exp (Z :. Int)Source
Lift a unary function to a computation over rank-1 indices.
ilift2 :: (Exp Int -> Exp Int -> Exp Int) -> Exp (Z :. Int) -> Exp (Z :. Int) -> Exp (Z :. Int)Source
Lift a binary function to a computation over rank-1 indices.
Tuple construction and destruction
fst :: forall a b. (Elt a, Elt b) => Exp (a, b) -> Exp aSource
Extract the first component of a pair.
snd :: forall a b. (Elt a, Elt b) => Exp (a, b) -> Exp bSource
Extract the second component of a pair.
curry :: (Elt a, Elt b) => (Exp (a, b) -> Exp c) -> Exp a -> Exp b -> Exp cSource
Converts an uncurried function to a curried function.
uncurry :: (Elt a, Elt b) => (Exp a -> Exp b -> Exp c) -> Exp (a, b) -> Exp cSource
Converts a curried function to a function on pairs.
Index construction and destruction
unindex1 :: Exp (Z :. Int) -> Exp IntSource
Turn a rank-1 indexing expression into an Int
expression.
Conditional expressions
Array operations with a scalar result
(!) :: (Shape ix, Elt e) => Acc (Array ix e) -> Exp ix -> Exp eSource
Expression form that extracts a scalar from an array.
shape :: (Shape ix, Elt e) => Acc (Array ix e) -> Exp ixSource
Expression form that yields the shape of an array.
size :: (Shape ix, Elt e) => Acc (Array ix e) -> Exp IntSource
Expression form that yields the size of an array.
shapeSize :: Shape ix => Exp ix -> Exp IntSource
The same as size
but not operates directly on a shape without the
array.
Methods of H98 classes that we need to redefine as their signatures change
(==*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp BoolSource
Equality lifted into Accelerate expressions.
(/=*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp BoolSource
Inequality lifted into Accelerate expressions.
(<*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp BoolSource
Smaller-than lifted into Accelerate expressions.
(<=*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp BoolSource
Smaller-or-equal lifted into Accelerate expressions.
(>*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp BoolSource
Greater-than lifted into Accelerate expressions.
(>=*) :: (Elt t, IsScalar t) => Exp t -> Exp t -> Exp BoolSource
Greater-or-equal lifted into Accelerate expressions.
setBit, complementBit, clearBit :: (Elt t, IsIntegral t) => Exp t -> Exp Int -> Exp tSource
truncate :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp bSource
Conversions from the RealFrac class
round :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp bSource
floor :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp bSource
ceiling :: (Elt a, Elt b, IsFloating a, IsIntegral b) => Exp a -> Exp bSource
Standard functions that we need to redefine as their signatures change
Conversions
fromIntegral :: (Elt a, Elt b, IsIntegral a, IsNum b) => Exp a -> Exp bSource
General coercion from integral types
Constants
ignore :: Shape ix => Exp ixSource
Magic value identifying elements that are ignored in a forward permutation
Map-like
zip :: (Shape sh, Elt a, Elt b) => Acc (Array sh a) -> Acc (Array sh b) -> Acc (Array sh (a, b))Source
Combine the elements of two arrays pairwise. The shape of the result is the intersection of the two argument shapes.
zip3 :: forall sh a b c. (Shape sh, Elt a, Elt b, Elt c) => Acc (Array sh a) -> Acc (Array sh b) -> Acc (Array sh c) -> Acc (Array sh (a, b, c))Source
Take three arrays and and return an array of triples, analogous to zip.
zip4 :: forall sh a b c d. (Shape sh, Elt a, Elt b, Elt c, Elt d) => Acc (Array sh a) -> Acc (Array sh b) -> Acc (Array sh c) -> Acc (Array sh d) -> Acc (Array sh (a, b, c, d))Source
Take three arrays and and return an array of quadruples, analogous to zip.
unzip :: (Shape sh, Elt a, Elt b) => Acc (Array sh (a, b)) -> (Acc (Array sh a), Acc (Array sh b))Source
The converse of zip
, but the shape of the two results is identical to the
shape of the argument.
unzip3 :: forall sh a b c. (Shape sh, Elt a, Elt b, Elt c) => Acc (Array sh (a, b, c)) -> (Acc (Array sh a), Acc (Array sh b), Acc (Array sh c))Source
Take an array of triples and return three arrays, analogous to unzip.
unzip4 :: forall sh a b c d. (Shape sh, Elt a, Elt b, Elt c, Elt d) => Acc (Array sh (a, b, c, d)) -> (Acc (Array sh a), Acc (Array sh b), Acc (Array sh c), Acc (Array sh d))Source
Take an array of quadruples and return four arrays, analogous to unzip.
Reductions
foldAll :: (Shape sh, Elt a) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Array sh a) -> Acc (Scalar a)Source
Reduction of an array of arbitrary rank to a single scalar value. The first argument needs to be an associative function to enable an efficient parallel implementation.
fold1All :: (Shape sh, Elt a) => (Exp a -> Exp a -> Exp a) -> Acc (Array sh a) -> Acc (Scalar a)Source
Variant of foldAll
that requires the reduced array to be non-empty and doesn't need an default
value.
Scans
prescanl :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)Source
Left-to-right prescan (aka exclusive scan). As for scan
, the first argument must be an
associative function. Denotationally, we have
prescanl f e = Prelude.fst . scanl' f e
postscanl :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)Source
Left-to-right postscan, a variant of scanl1
with an initial value. Denotationally, we have
postscanl f e = map (e `f`) . scanl1 f
prescanr :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)Source
Right-to-left prescan (aka exclusive scan). As for scan
, the first argument must be an
associative function. Denotationally, we have
prescanr f e = Prelude.fst . scanr' f e
postscanr :: Elt a => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Vector a)Source
Right-to-left postscan, a variant of scanr1
with an initial value. Denotationally, we have
postscanr f e = map (e `f`) . scanr1 f
Segmented scans
scanlSeg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of scanl
.
scanl'Seg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> (Acc (Vector a), Acc (Vector a))Source
Segmented version of scanl'
.
The first element of the resulting tuple is a vector of scanned values. The second element is a vector of segment scan totals and has the same size as the segment vector.
scanl1Seg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of scanl1
.
prescanlSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of prescanl
.
postscanlSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of postscanl
.
scanrSeg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of scanr
.
scanr'Seg :: forall a i. (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> (Acc (Vector a), Acc (Vector a))Source
Segmented version of scanr'
.
scanr1Seg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of scanr1
.
prescanrSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of prescanr
.
postscanrSeg :: (Elt a, Elt i, IsIntegral i) => (Exp a -> Exp a -> Exp a) -> Exp a -> Acc (Vector a) -> Acc (Segments i) -> Acc (Vector a)Source
Segmented version of postscanr
.
Reshaping of arrays
flatten :: (Shape ix, Elt a) => Acc (Array ix a) -> Acc (Array DIM1 a)Source
Flattens a given array of arbitrary dimension.
Enumeration and filling
fill :: (Shape sh, Elt e) => Exp sh -> Exp e -> Acc (Array sh e)Source
Create an array where all elements are the same value.
enumFromN :: (Shape sh, Elt e, IsNum e) => Exp sh -> Exp e -> Acc (Array sh e)Source
Create an array of the given shape containing the values x, x+1, etc (in row-major order).
Create an array of the given shape containing the values x, x+y, x+y+y, etc (in row-major order).
Gather and scatter
Copy elements from source array to destination array according to a map. This
is a backpermute operation where a map
vector encodes the ouput to input
index mapping. For example:
input = [1, 9, 6, 4, 4, 2, 0, 1, 2] map = [1, 3, 7, 2, 5, 3]
output = [9, 4, 1, 6, 2, 4]
:: (Elt e, Elt e') | |
=> Acc (Vector Int) | map |
-> Acc (Vector e) | mask |
-> (Exp e -> Exp Bool) | predicate |
-> Acc (Vector e') | default |
-> Acc (Vector e') | input |
-> Acc (Vector e') | output |
Conditionally copy elements from source array to destination array according
to a map. This is a backpermute opereation where a map
vector encdes the
output to input index mapping. In addition, there is a mask
vector, and an
associated predication function, that specifies whether an element will be
copied. If not copied, the output array assumes the default vector's value.
For example:
default = [6, 6, 6, 6, 6, 6] map = [1, 3, 7, 2, 5, 3] mask = [3, 4, 9, 2, 7, 5] pred = (> 4) input = [1, 9, 6, 4, 4, 2, 0, 1, 2]
output = [6, 6, 1, 6, 2, 4]
:: Elt e | |
=> Acc (Vector Int) | map |
-> Acc (Vector e) | default |
-> Acc (Vector e) | input |
-> Acc (Vector e) | output |
Copy elements from source array to destination array according to a map. This
is a forward-permute operation where a map
vector encodes an input to output
index mapping. Output elements for indices that are not mapped assume the
default vector's value. For example:
default = [0, 0, 0, 0, 0, 0, 0, 0, 0] map = [1, 3, 7, 2, 5, 8] input = [1, 9, 6, 4, 4, 2, 5]
output = [0, 1, 4, 9, 0, 4, 0, 6, 2]
Note if the same index appears in the map more than once, the result is undefined. The map vector cannot be larger than the input vector.
:: (Elt e, Elt e') | |
=> Acc (Vector Int) | map |
-> Acc (Vector e) | mask |
-> (Exp e -> Exp Bool) | predicate |
-> Acc (Vector e') | default |
-> Acc (Vector e') | input |
-> Acc (Vector e') | output |
Conditionally copy elements from source array to destination array according
to a map. This is a forward-permute operation where a map
vector encodes an
input to output index mapping. In addition, there is a mask
vector, and an
associated predicate function, that specifies whether an elements will be
copied. If not copied, the output array assumes the default vector's value.
For example:
default = [0, 0, 0, 0, 0, 0, 0, 0, 0] map = [1, 3, 7, 2, 5, 8] mask = [3, 4, 9, 2, 7, 5] pred = (> 4) input = [1, 9, 6, 4, 4, 2]
output = [0, 0, 0, 0, 0, 4, 0, 6, 2]
Note if the same index appears in the map more than once, the result is undefined. The map and input vector must be of the same length.
Subvector extraction
init :: Elt e => Acc (Vector e) -> Acc (Vector e)Source
Yield all but the last element of the input vector. The vector may not be empty.
tail :: Elt e => Acc (Vector e) -> Acc (Vector e)Source
Yield all but the first element of the input vector. The vector may not be empty.
take :: Elt e => Exp Int -> Acc (Vector e) -> Acc (Vector e)Source
Yield the first n
elements of the input vector. The vector must contain
no more than n
elements.
drop :: Elt e => Exp Int -> Acc (Vector e) -> Acc (Vector e)Source
Yield all but the first n
elements of the input vector. The vector must
contain no more than n
elements.
slit :: Elt e => Exp Int -> Exp Int -> Acc (Vector e) -> Acc (Vector e)Source
Yield a slit (slice) from the vector. The vector must contain at least i + n elements.