Prev Up
Go backward to Control-oriented Parallelism
Go up to Strategies Separate Algorithm from Dynamic Behaviour

Additional Dynamic Behaviour

Strategies can control other aspects of dynamic behaviour, thereby avoiding cluttering the algorithmic code with them. A simple example is a thresholding mechanism that controls thread granularity. In pfib for example, granularity is improved for many machines if threads are not created when the argument is small. More sophisticated applications of thresholding are discussed in Sections * and *.
pfibT n 
  | n <= 1    = 1
  | otherwise = (n1+n2+1) `demanding` strategy
    where
      n1 = pfibT (n-1)
      n2 = pfibT (n-2)
      strategy = if n > 10 
                   then rnf n1 `par` rnf n2 
                   else ()

{trinder,hwloidl,simonpj}@dcs.gla.ac.uk, kh@dcs.st-and.ac.uk

Prev Up