Safe Haskell | None |
---|---|
Language | Haskell98 |
Generic sequential array computation operators.
- fillLinear :: (Int# -> a -> IO ()) -> (Int# -> a) -> Int# -> IO ()
- fillBlock2 :: (Int# -> a -> IO ()) -> (Int# -> Int# -> a) -> Int# -> Int# -> Int# -> Int# -> Int# -> IO ()
- fillCursoredBlock2 :: Elt a => (Int# -> a -> IO ()) -> (Int# -> Int# -> cursor) -> (Int# -> Int# -> cursor -> cursor) -> (cursor -> a) -> Int# -> Int# -> Int# -> Int# -> Int# -> IO ()
- foldAll :: (Int# -> a) -> (a -> a -> a) -> a -> Int# -> a
- foldRange :: (Int# -> a) -> (a -> a -> a) -> a -> Int# -> Int# -> a
- foldInner :: (Int# -> a -> IO ()) -> (Int# -> a) -> (a -> a -> a) -> a -> Int# -> Int# -> IO ()
Filling
:: (Int# -> a -> IO ()) | Update function to write into result buffer. |
-> (Int# -> a) | Function to get the value at a given index. |
-> Int# | Number of elements to fill. |
-> IO () |
Fill something sequentially.
- The array is filled linearly from start to finish.
:: (Int# -> a -> IO ()) | Update function to write into result buffer. |
-> (Int# -> Int# -> a) | Function to get the value at an (x, y) index. |
-> Int# | Width of the whole array. |
-> Int# | x0 lower left corner of block to fill. |
-> Int# | y0 |
-> Int# | w0 width of block to fill |
-> Int# | h0 height of block to fill |
-> IO () |
Fill a block in a rank-2 array, sequentially.
- Blockwise filling can be more cache-efficient than linear filling for rank-2 arrays.
- The block is filled in row major order from top to bottom.
:: Elt a | |
=> (Int# -> a -> IO ()) | Update function to write into result buffer. |
-> (Int# -> Int# -> cursor) | Make a cursor to a particular element from an (x, y) index. |
-> (Int# -> Int# -> cursor -> cursor) | Shift the cursor by an (x, y) offset. |
-> (cursor -> a) | Function to evaluate an element at the given index. |
-> Int# | Width of the whole array. |
-> Int# | x0 lower left corner of block to fill. |
-> Int# | y0 |
-> Int# | w0 width of block to fill |
-> Int# | h0 height of block to fill |
-> IO () |
Fill a block in a rank-2 array, sequentially.
- Blockwise filling can be more cache-efficient than linear filling for rank-2 arrays.
- Using cursor functions can help to expose inter-element indexing computations to the GHC and LLVM optimisers.
- Coordinates given are of the filled edges of the block.
- The block is filled in row major order from top to bottom.
- We need the
Elt
constraint so that we can use itstouch
function to provide an order of evaluation ammenable to the LLVM optimiser. You should compile your Haskell program with-fllvm -optlo-O3
to enable LLVM's Global Value Numbering optimisation.
Reduction
:: (Int# -> a) | Function to get an element from the source. |
-> (a -> a -> a) | Binary associative combining function. |
-> a | Neutral starting value. |
-> Int# | Number of elements. |
-> a |
Sequential reduction of all the elements in an array.
:: (Int# -> a) | Function to get an element from the source. |
-> (a -> a -> a) | Binary associative combining function. |
-> a | Neutral starting value. |
-> Int# | Starting index. |
-> Int# | Ending index. |
-> a |
Sequentially reduce values between the given indices.
:: (Int# -> a -> IO ()) | Function to write into the result buffer. |
-> (Int# -> a) | Function to get an element from the source. |
-> (a -> a -> a) | Binary associative combination function. |
-> a | Neutral starting value. |
-> Int# | Total length of source. |
-> Int# | Inner dimension (length to fold over). |
-> IO () |
Sequential reduction of a multidimensional array along the innermost dimension.