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

Safe HaskellNone

Data.Array.Parallel.Unlifted.Distributed.Data.USSegd

Description

Distribution of Segment Descriptors

Synopsis

Documentation

lengthD :: Dist USSegd -> Dist IntSource

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

takeLengthsD :: Dist USSegd -> Dist (Vector Int)Source

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

takeIndicesD :: Dist USSegd -> Dist (Vector Int)Source

O(1). Yield the segment indices.

takeElementsD :: Dist USSegd -> Dist IntSource

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

takeStartsD :: Dist USSegd -> Dist (Vector Int)Source

O(1). Yield the starting indices.

takeSourcesD :: Dist USSegd -> Dist (Vector Int)Source

O(1). Yield the source ids

takeUSegdD :: Dist USSegd -> Dist USegdSource

O(1). Yield the USegd

splitSSegdOnElemsD :: Gang -> USSegd -> Dist ((USSegd, Int), Int)Source

Split a segment descriptor across the gang, element wise. We try to put the same number of elements on each thread, which means that segments are sometimes split across threads.

Each thread gets a slice of segment descriptor, the segid of the first slice, and the offset of the first slice in its segment.

Example: In this picture each X represents 5 elements, and we have 5 segements in total.

   segs:    ----------------------- --- ------- --------------- -------------------
    elems:  |X X X X X X X X X|X X X X X X X X X|X X X X X X X X X|X X X X X X X X X|
            |     thread1     |     thread2     |     thread3     |     thread4     |
    segid:  0                 0                 3                 4
    offset: 0                 45                0                 5

pprp $ splitSegdOnElemsD theGang 
          $ lengthsToUSegd $ fromList [60, 10, 20, 40, 50 :: Int]

segd:    DUSegd lengths:  DVector lengths: [1,3,2,1]
                                        chunks:  [[45],[15,10,20],[40,5],[45]]
                     indices:  DVector lengths: [1,3,2,1]
                                        chunks:  [[0], [0,15,25], [0,40],[0]]
                    elements:  DInt [45,45,45,45]

segids: DInt [0,0,3,4]     (segment id of first slice on thread)
    offsets: DInt [0,45,0,5]    (offset of that slice in its segment)