flocc-pffb

Stabilityexperimental
Maintainerdeveloper@flocc.net
Safe HaskellNone

Compiler.Back.Arrays

Description

For more information please see http://www.flocc.net/

Synopsis

Documentation

data ArrTy

The type of array |Jagged is accessed using IterDimZero |Cont is accedded using IterOffset

Constructors

ArrJag 
ArrCont 

Instances

data ArrStor

The type of array storage

data ConstArrSz

A constant array size

Constructors

ConstArrSz [Int] 

type ArrSzTy = String

Either an array lit of an integer var id

arrSzExp :: ArrSzTy -> Code

Returns the expression code for an array size value

data IdxSpace

Represents an index space to iterate over.

createSpaceFromLens :: [ArrSzTy] -> [ArrSzTy] -> [ArrSzTy] -> IdxSpace

createSpaceFromLens starts lens strids. Creates a new Index space |using lens, and works out limits based on them.

createSpaceFromLims :: [ArrSzTy] -> [ArrSzTy] -> [ArrSzTy] -> IdxSpace

createSpaceFromLims starts lims strids. Creates a new Index space |using lims, and works out lengths based on them.

data ArrRec

Information about a particular array.

Constructors

ArrRec 

Instances

data ArrIterTy

The type of array iterator

data ArrIter

Information about a particular array iterator.

zeros :: Int -> [ArrSzTy]

ones :: Int -> [ArrSzTy]

isRangeValid :: ArrSzTy -> ArrSzTy -> ArrSzTy -> ArrSzTy -> Code

isRangeValid start lim len strid. Returns code that throws an |error if this index range is invalid.

zip4Err :: (Show a, Show b, Show c, Show d) => [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]

zip4Err al bl cl dl. Zips together 4 lists, throwing an error if they differ in length.

isSpaceValid :: IdxSpace -> Code

isIdxSpaceValid space. Returns true if the lengths match the |limits, and false otherwise.

isRangeSubset :: (IdxRange, IdxRange) -> Code

isRangeSubset (ran1,ran2). Returns code that checks if ran2 is a subset of ran1, |and throws an error if it isn't.

isSpaceSubset :: IdxSpace -> IdxSpace -> Code

isSpaceSubset space subSpace. If subspace is not a subset of space |then throws an error.

spaceEqPredicate :: IdxSpace -> IdxSpace -> Code

spaceEqPredicate a b. Returns code to compare two IdxSpaces returning true |iff they are identical.

declareIter :: ArrIter -> Code

declareIter iter. Returns code that declares the iterator |variables, and assigns the iterator's start values to them.

createArrIter :: Monad m => ArrRec -> IdxSpace -> GenM1 m (Code, ArrIter)

createArrIter arr itSpace. Returns a new iterator, to loop |over the subarray, and the code to declare it.

accessElement :: ArrRec -> ArrIter -> Code

accessElement arr iter. Returns an expression for accessing the |element at the iterator's current position in the array.

printLoopNests :: [(Code, Code)] -> Code

printLoopNests l. Prints l as a nested tree with the first pair |starting and finishing the whole block, and the last pair at the middle.s

createArrMpiType :: Monad m => ArrRec -> IdxSpace -> Id -> Id -> GenM1 m (Code, [Id])

createArrMpiType arr space elTyVid arrTyVid. Returns code to generate |the MPI data type for a sub-array. Note: returned vars should be freed using delete [] |when the datatype is nolonger needed.

decCInt :: Monad m => String -> Code -> GenM1 m (Code, Id)

unpair :: [[(a, b)]] -> ([a], [[b]])

binOp :: Code -> (Code, Code) -> Code

convertArrIter arr iter newIterTy. Takes one type of |of iterator, and returns another iterator that iterates over |the same space

zipErr :: Show a => Show b => [a] -> [b] -> [(a, b)]

convertIdxSpace :: IdxSpace -> ArrIterTy -> ArrIterTy -> IdxSpace -> IdxSpace

convertIdxSpace arrSpace iterSpace inTy outTy. Converts an iterater space iterSpace |iterating over a subset of an array with space arrSpace, from inTy to outTy. |Note: conversions to and from IterOffset are only allowed if iterSpace |and arrSpace only have one dimension.

deriveArrIter :: IdxSpace -> ArrIterTy -> ArrIter -> ArrIter

deriveArrIter idxSpace targetIterType inputIter. Creates a new iterator |from the original, by creating expressions for the new indices in terms |of the input.

removeRepeats :: Eq a => [a] -> [[a]] -> [[a]]

removeRepeats [] llist. Removes all repeats of |an element found in an earlier sublist, from all |the sublists that follow it.

defaultLoopDims :: Int -> [[(Int, Int)]]

defaultLoopDims numDims. Creates default loop dims for |looping over a single array space with numDims dims.

genLoops :: [ArrIter] -> [[(Int, Int)]] -> [(Code, Code)]

genLoops iters loopsDims. Generates a list of (nested) for loops, one for |each element in loopsDims. Each element of loopDims defines a number of iterator dims |(fst is iter idx, snd is iter's dim idx) that are to be iterated over in-step in a single |for-loop. |Note: Can't loop over a derived iterator.

dimAt :: Show a => Int -> [a] -> a

dimAt idx lst. Gets the idx'th element of the list lst, returns an error if |idx < 0 or gte the length of lst.

genLoop :: [ArrIter] -> [(Int, Int)] -> (Code, Code)

genLoop iters loopDims. Generates a single for-loop that iterates over all the iterator dims |listed in loopDims instep. Each element of loopDims is fst the iterator idx, and snd |that iterator's dim idx.