dph-prim-par-0.7.0.1: Data Parallel Haskell segmented arrays. (production version)

Safe HaskellNone

Data.Array.Parallel.Unlifted.Parallel.UPSSegd

Contents

Description

Parallel Scattered Segment descriptors.

See Data.Array.Parallel.Unlifted for how this works.

Synopsis

Types

data UPSSegd

Parallel Scattered Segment sescriptor

valid :: UPSSegd -> Bool

O(1). Check the internal consistency of a scattered segment descriptor.

Constructors

mkUPSSegd

Arguments

:: 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 -> UPSSegd

Promote a global USSegd to a parallel UPSSegd by distributing it across the gang.

fromUPSegd :: UPSegd -> UPSSegd

Promote a plain UPSegd to a UPSSegd, by assuming that all segments come from a single flat array with source id 0.

empty :: UPSSegd

O(1). Yield an empty segment descriptor, with no elements or segments.

singleton :: Int -> UPSSegd

O(1). Yield a singleton segment descriptor. The single segment covers the given number of elements.

Predicates

isContiguous :: UPSSegd -> Bool

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

length :: UPSSegd -> Int

O(1). Yield the overall number of segments.

takeUSSegd :: UPSSegd -> USSegd

O(1). Yield the global USegd of a UPSegd

takeDistributed :: UPSSegd -> Dist ((USSegd, Int), Int)

O(1). Yield the distributed USegd of a UPSegd

takeLengths :: UPSSegd -> Vector Int

O(1). Yield the lengths of the individual segments.

takeIndices :: UPSSegd -> Vector Int

O(1). Yield the segment indices.

takeElements :: UPSSegd -> Int

O(1). Yield the total number of data elements.

takeElements upssegd = sum (takeLengths upssegd)

takeStarts :: UPSSegd -> Vector Int

O(1). Yield the starting indices.

takeSources :: UPSSegd -> Vector Int

O(1). Yield the source ids.

getSeg :: UPSSegd -> Int -> (Int, Int, Int, Int)

O(1). Get the length, segment index, starting index, and source id of a segment.

Append

appendWith

Arguments

:: 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 a

Fold segments specified by a UPSSegd.

fold1WithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> UPSSegd -> Vectors a -> Vector a

Fold segments specified by a UPSSegd, with a non-empty vector.

sumWithP :: (Num a, Unbox a, Unboxes a) => UPSSegd -> Vectors a -> Vector a

Sum up segments specified by a UPSSegd.

foldSegsWithP :: (Unbox a, Unboxes a) => (a -> a -> a) -> (USSegd -> Vectors a -> Vector a) -> UPSSegd -> Vectors a -> Vector a

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.