Safe Haskell | Safe-Infered |
---|
Parallel Scattered Segment descriptors.
See Data.Array.Parallel.Unlifted for how this works.
- data UPSSegd
- valid :: UPSSegd -> Bool
- mkUPSSegd :: Vector Int -> Vector Int -> UPSegd -> UPSSegd
- fromUSSegd :: USSegd -> UPSSegd
- fromUPSegd :: UPSegd -> UPSSegd
- empty :: UPSSegd
- singleton :: Int -> UPSSegd
- isContiguous :: UPSSegd -> Bool
- length :: UPSSegd -> Int
- takeUSSegd :: UPSSegd -> USSegd
- takeDistributed :: UPSSegd -> Dist ((USSegd, Int), Int)
- takeLengths :: UPSSegd -> Vector Int
- takeIndices :: UPSSegd -> Vector Int
- takeElements :: UPSSegd -> Int
- takeStarts :: UPSSegd -> Vector Int
- takeSources :: UPSSegd -> Vector Int
- getSeg :: UPSSegd -> Int -> (Int, Int, Int, Int)
- appendWith :: UPSSegd -> Int -> UPSSegd -> Int -> UPSSegd
- foldWithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> a -> UPSSegd -> Vectors a -> Vector a
- fold1WithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> UPSSegd -> Vectors a -> Vector a
- sumWithP :: (Num a, Unbox a, Unboxes a) => UPSSegd -> Vectors a -> Vector a
- foldSegsWithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> (USSegd -> Vectors a -> Vector a) -> UPSSegd -> Vectors a -> Vector a
Types
valid :: UPSSegd -> BoolSource
O(1). Check the internal consistency of a scattered segment descriptor.
Constructors
:: Vector Int | Starting index of each segment in its flat array. |
-> Vector Int | Source id of the flat array to tach each segment from. |
-> UPSegd | Contiguous (unscattered) segment descriptor. |
-> UPSSegd |
Construct a new segment descriptor.
fromUSSegd :: USSegd -> UPSSegdSource
fromUPSegd :: UPSegd -> UPSSegdSource
singleton :: Int -> UPSSegdSource
O(1). Yield a singleton segment descriptor. The single segment covers the given number of elements.
Predicates
isContiguous :: UPSSegd -> BoolSource
O(1). True when the starts are identical to the usegd indices field and the sources are all 0's.
In this case all the data elements are in one contiguous flat array, and consumers can avoid looking at the real starts and sources fields.
Projections
takeUSSegd :: UPSSegd -> USSegdSource
O(1). Yield the global USegd
of a UPSegd
takeDistributed :: UPSSegd -> Dist ((USSegd, Int), Int)Source
O(1). Yield the distributed USegd
of a UPSegd
takeLengths :: UPSSegd -> Vector IntSource
O(1). Yield the lengths of the individual segments.
takeIndices :: UPSSegd -> Vector IntSource
O(1). Yield the segment indices.
takeElements :: UPSSegd -> IntSource
O(1). Yield the total number of data elements.
takeElements upssegd = sum (takeLengths upssegd)
takeStarts :: UPSSegd -> Vector IntSource
O(1). Yield the starting indices.
takeSources :: UPSSegd -> Vector IntSource
O(1). Yield the source ids.
getSeg :: UPSSegd -> Int -> (Int, Int, Int, Int)Source
O(1). Get the length, segment index, starting index, and source id of a segment.
Append
:: UPSSegd | Segment descriptor of first nested array. |
-> Int | Number of flat data arrays used to represent first nested array. |
-> UPSSegd | Segment descriptor of second nested array. |
-> Int | Number of flat data arrays used to represent second nested array. |
-> UPSSegd |
O(n) Produce a segment descriptor that describes the result of appending two segmented arrays.
Appending two nested arrays is an index space transformation. Because
a UPSSegd
can contain segments from multiple flat data arrays, we can
represent the result of the append without copying elements from the
underlying flat data arrays.
Segmented Folds
foldWithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> a -> UPSSegd -> Vectors a -> Vector aSource
Fold segments specified by a UPSSegd
.
fold1WithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> UPSSegd -> Vectors a -> Vector aSource
Fold segments specified by a UPSSegd
, with a non-empty vector.
sumWithP :: (Num a, Unbox a, Unboxes a) => UPSSegd -> Vectors a -> Vector aSource
Sum up segments specified by a UPSSegd
.
foldSegsWithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> (USSegd -> Vectors a -> Vector a) -> UPSSegd -> Vectors a -> Vector aSource
Fold the segments specified by a UPSSegd
.
Low level function takes a per-element worker and a per-segment worker. It folds all the segments with the per-segment worker, then uses the per-element worker to fixup the partial results when a segment is split across multiple threads.