planet-mitchell-0.1.0: Planet Mitchell

Safe HaskellNone
LanguageHaskell2010

Parallelism

Contents

Synopsis

Documentation

par :: a -> b -> b infixr 0 #

pseq :: a -> b -> b infixr 0 #

rpar :: Strategy a #

rpar sparks its argument (for evaluation in parallel).

rparWith :: Strategy a -> Strategy a #

Perform a computation in parallel using a strategy.

rparWith strat x

will spark strat x. Note that rparWith strat is not the same as rpar dot strat. Specifically, rpar dot strat always sparks a computation to reduce the result of the strategic computation to WHNF, while rparWith strat need not.

rparWith r0 = r0
rparWith rpar = rpar
rparWith rseq = rpar

rparWith rpar x creates a spark that immediately creates another spark to evaluate x. We consider this equivalent to rpar because there isn't any real additional parallelism. However, it is always less efficient because there's a bit of extra work to create the first (useless) spark. Similarly, rparWith r0 creates a spark that does precisely nothing. No real parallelism is added, but there is a bit of extra work to do nothing.

parEval :: Eval a -> Eval a #

parEval sparks the computation of its argument for evaluation in parallel. Unlike rpar . runEval, parEval

  • does not exit the Eval monad
  • does not have a built-in rseq, so for example parEval (r0 x) behaves as you might expect (it creates a spark that does no evaluation).

It is related to rparWith by the following equality:

parEval . strat = rparWith strat

parTraversable :: Traversable t => Strategy a -> Strategy (t a) #

Like evalTraversable but evaluates all elements in parallel.

parList :: Strategy a -> Strategy [a] #

Evaluate each element of a list in parallel according to given strategy. Equivalent to parTraversable at the list type.

parListChunk :: Int -> Strategy a -> Strategy [a] #

Divides a list into chunks, and applies the strategy evalList strat to each chunk in parallel.

It is expected that this function will be replaced by a more generic clustering infrastructure in the future.

If the chunk size is 1 or less, parListChunk is equivalent to parList

parMap :: Strategy b -> (a -> b) -> [a] -> [b] #

A combination of parList and map, encapsulating a common pattern:

parMap strat f = withStrategy (parList strat) . map f

parTuple2 :: Strategy a -> Strategy b -> Strategy (a, b) #

parTuple3 :: Strategy a -> Strategy b -> Strategy c -> Strategy (a, b, c) #

parTuple4 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy (a, b, c, d) #

parTuple5 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy (a, b, c, d, e) #

parTuple6 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy (a, b, c, d, e, f) #

parTuple7 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy (a, b, c, d, e, f, g) #

parTuple8 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy (a, b, c, d, e, f, g, h) #

parTuple9 :: Strategy a -> Strategy b -> Strategy c -> Strategy d -> Strategy e -> Strategy f -> Strategy g -> Strategy h -> Strategy i -> Strategy (a, b, c, d, e, f, g, h, i) #

Re-exports

module Eval