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

Safe HaskellNone

Data.Array.Parallel.Unlifted.Parallel

Contents

Description

Parallel operations on unlifted arrays

Synopsis

Basics

lengthUP :: Unbox e => Vector e -> IntSource

O(1). Take the length of an array.

nullUP :: Unbox e => Vector e -> BoolSource

O(1). Test whether the given array is empty

emptyUP :: Unbox e => Vector eSource

O(1). Construct an empty array.

indexedUP :: (DT e, Unbox e) => Vector e -> Vector (Int, e)Source

Associate each element of the array with its index

replicateUP :: Unbox e => Int -> e -> Vector eSource

Yield an array where all elements contain the same value

repeatUP :: Unbox e => Int -> Vector e -> Vector eSource

Repeat an array the given number of times.

interleaveUP :: Unbox e => Vector e -> Vector e -> Vector eSource

Interleave elements of two arrays

Combinators

mapUP :: (Unbox a, Unbox b) => (a -> b) -> Vector a -> Vector bSource

Apply a worker to all elements of an array.

filterUP :: Unbox a => (a -> Bool) -> Vector a -> Vector aSource

Keep elements that match the given predicate.

packUP :: Unbox e => Vector e -> Vector Bool -> Vector eSource

Take elements of an array where a flag value is true, and pack them into the result.

  • The souce and flag arrays must have the same length, but this is not checked.

combineUP :: Unbox a => Vector Bool -> Vector a -> Vector a -> Vector aSource

Combine two vectors based on a selector. If the selector is true then take the element from the first vector, otherwise take it from the second.

  • The data vectors must have enough elements to satisfy the flag vector, but this is not checked.

combine2UP :: Unbox a => Vector Tag -> UPSelRep2 -> Vector a -> Vector a -> Vector aSource

Combine two vectors based on a selector.

  • The data vectors must have enough elements to satisfy the selector, but this is not checked.

zipWithUP :: (Unbox a, Unbox b, Unbox c) => (a -> b -> c) -> Vector a -> Vector b -> Vector cSource

Apply a worker function to correponding elements of two arrays.

foldUP :: (Unbox a, DT a) => (a -> a -> a) -> a -> Vector a -> aSource

Undirected fold. Note that this function has more constraints on its parameters than the standard fold function from the Haskell Prelude.

  • The worker function must be associative.
  • The provided starting element must be neutral with respect to the worker. For example 0 is neutral wrt (+) and 1 is neutral wrt (*).

We need these constraints so that we can partition the fold across several threads. Each thread folds a chunk of the input vector, then we fold together all the results in the main thread.

fold1UP :: (DT a, Unbox a) => (a -> a -> a) -> Vector a -> aSource

Alias for foldl1UP

foldlUP :: (DT a, Unbox a) => (a -> a -> a) -> a -> Vector a -> aSource

Left fold over an array.

  • If the vector is empty then this returns the provided neural element.
  • The worker function must be associative.
  • The provided starting element must be neutral with respect to the worker, see foldUP for discussion.

foldl1UP :: (DT a, Unbox a) => (a -> a -> a) -> Vector a -> aSource

Left fold over an array, using the first element of the vector as the neural element.

  • If the vector contains no elements then you'll get a bounds-check error.
  • The worker function must be associative.
  • The provided starting element must be neutral with respect to the worker, see foldUP for discussion.

scanUP :: (DT a, Unbox a) => (a -> a -> a) -> a -> Vector a -> Vector aSource

Prefix scan. Similar to fold, but produce an array of the intermediate states.

  • The worker function must be associative.
  • The provided starting element must be neutral with respect to the worker, see foldUP for discussion.

Enum

enumFromToUP :: (Unbox a, Enum a) => a -> a -> Vector aSource

enumFromThenToUP :: (Unbox a, Enum a) => a -> a -> a -> Vector aSource

Permute

bpermuteUP :: Unbox a => Vector a -> Vector Int -> Vector aSource

Backwards permutation.

updateUP :: forall a. Unbox a => Vector a -> Vector (Int, a) -> Vector aSource

Update elements in an array.

Segmented

replicateRSUP :: Unbox a => Int -> Vector a -> Vector aSource

Segmented replication. Each element in the vector is replicated the given number of times.

replicateRSUP 2 [1, 2, 3, 4, 5] = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]

appendSUPSource

Arguments

:: Unbox a 
=> UPSegd

segment descriptor of result

-> UPSegd

left-hand segd

-> Vector a

left-hand data

-> UPSegd

right-hand segd

-> Vector a

right-hand data

-> Vector a 

Segmented append.

appendSUPVSource

Arguments

:: (Unboxes a, Unbox a) 
=> UPSegd

segment descriptor of result

-> UPVSegd

left-hand segd

-> Vectors a

left-hand data

-> UPVSegd

right-hand segd

-> Vectors a

right-hand data

-> Vector a 

foldRUP :: (Unbox a, Unbox b) => (b -> a -> b) -> b -> Int -> Vector a -> Vector bSource

Regular segmented fold.

sumRUP :: (Num e, Unbox e) => Int -> Vector e -> Vector eSource

Regular segmented sum.

Index and Extracts

indexsFromVector :: Unbox a => Vector a -> Vector Int -> Vector aSource

Lookup elements from a Vector.

TODO: make this parallel.

indexsFromVectorsUPVSegd :: (Unbox a, Unboxes a) => Vectors a -> UPVSegd -> Vector (Int, Int) -> Vector aSource

Lookup elements from some Vectors through a UPVSegd

indexsFromVectorsUPVSegdP :: (Unbox a, Unboxes a) => Vectors a -> UPVSegd -> Vector (Int, Int) -> Vector aSource

Lookup elements from some Vectors through a UPVSegd.

TODO: make this parallel.

extractsFromNestedUPSSegd :: Unbox a => UPSSegd -> Vector (Vector a) -> Vector aSource

Copy segments from a nested vectors and concatenate them into a new array.

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

TODO: make this parallel.

extractsFromVectorsUPVSegd :: (Unbox a, Unboxes a) => UPVSegd -> Vectors a -> Vector aSource

Sequential extracts from UPVSegd.

extractsFromVectorsUPVSegdP :: (Unbox a, Unboxes a) => UPVSegd -> Vectors a -> Vector aSource

Parallel extracts from UPVSegd and Segmap TODO: This just distributes the segmap over the gang, and will be unbalanced if there aren't many segments, or they have varying sizes.

Subarrays

dropUP :: Unbox e => Int -> Vector e -> Vector eSource

Drop a the element at the provided index from a vector.

Sums

andUP :: Vector Bool -> BoolSource

Compute the logical AND of all the elements in a array.

orUP :: Vector Bool -> BoolSource

Compute the logical OR of all the elements in a array.

allUP :: Unbox e => (e -> Bool) -> Vector e -> BoolSource

Check whether all the elements in a array meet the given predicate.

anyUP :: Unbox e => (e -> Bool) -> Vector e -> BoolSource

Check whether any of the elements in a array meet the given predicate.

sumUP :: (Unbox a, DT a, Num a) => Vector a -> aSource

Compute the sum all the elements of a array.

productUP :: (DT e, Num e, Unbox e) => Vector e -> eSource

Compute the product of all the elements of an array.

maximumUP :: (DT e, Ord e, Unbox e) => Vector e -> eSource

Determine the maximum element in an array.

maximumByUP :: (DT e, Unbox e) => (e -> e -> Ordering) -> Vector e -> eSource

Determine the maximum element in an array under the given ordering

maximumIndexByUP :: (DT e, Unbox e) => (e -> e -> Ordering) -> Vector e -> IntSource

Determine the index of the maximum element in an array under the given ordering