dph-prim-seq-0.6.1.1: Data Parallel Haskell segmented arrays. (sequential implementation)

Safe HaskellSafe-Infered

Data.Array.Parallel.Unlifted.Sequential.USSegd

Contents

Description

Scattered Segment Descriptors.

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

Synopsis

Types

data USSegd Source

Scattered Segment Descriptor.

Constructors

USSegd 

Fields

ussegd_contiguous :: !Bool

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.

ussegd_starts :: Vector Int

Starting index of each segment in its flat array.

IMPORTANT: this field is lazy so we can avoid creating it when the flat array is contiguous.

ussegd_sources :: Vector Int

Which flat array to take each segment from.

IMPORTANT: this field is lazy so we can avoid creating it when the flat array is contiguous.

ussegd_usegd :: !USegd

Segment descriptor relative to a contiguous index space. This defines the length of each segment.

Instances

Show USSegd 
PprPhysical USSegd

Pretty print the physical representation of a UVSegd

valid :: USSegd -> BoolSource

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

Constructors

mkUSSegdSource

Arguments

:: Vector Int

Starting index of each segment in its flat array.

-> Vector Int

Which array to take each segment from.

-> USegd

Contiguous segment descriptor.

-> USSegd 

O(1). Construct a new scattered segment descriptor. All the provided arrays must have the same lengths.

empty :: USSegdSource

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

singleton :: Int -> USSegdSource

O(1). Construct a singleton segment descriptor. The single segment covers the given number of elements in a flat array with sourceid 0.

fromUSegd :: USegd -> USSegdSource

O(segs). Promote a plain USegd to a USSegd. All segments are assumed to come from a flat array with sourceid 0.

Predicates

isContiguous :: USSegd -> 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

length :: USSegd -> IntSource

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

takeUSegd :: USSegd -> USegdSource

O(1). Yield the USegd of a USSegd.

takeLengths :: USSegd -> Vector IntSource

O(1). Yield the lengths of the segments of a USSegd.

takeIndices :: USSegd -> Vector IntSource

O(1). Yield the segment indices of a USSegd.

takeElements :: USSegd -> IntSource

O(1). Yield the total number of elements covered by a USSegd.

takeSources :: USSegd -> Vector IntSource

O(1). Yield the source ids of a USSegd.

takeStarts :: USSegd -> Vector IntSource

O(1). Yield the starting indices of a USSegd.

getSeg :: USSegd -> Int -> (Int, Int, Int, Int)Source

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

Operators

appendWithSource

Arguments

:: USSegd

Segment descriptor of first nested array.

-> Int

Number of flat data arrays used to represent first nested array.

-> USSegd

Segment descriptor of second nested array.

-> Int

Number of flat data arrays used to represent second nested array.

-> USSegd 

O(n). Produce a segment descriptor that describes the result of appending two arrays.

cullOnVSegids :: Vector Int -> USSegd -> (Vector Int, USSegd)Source

Cull the segments of a USSegd down to only those reachable from an array of vsegids, and also update the vsegids to point to the same segments in the result.