next up previous
Next: LoopPool Up: Class Hierarchy for Parallel Previous: Schedules

LoopWorker

  The abstract class LoopWorker provides an abstraction of a loop-worker that can be used to execute several iterations of a parallel loop. The instance variables low, high, and stride represent an execution set [low,high) and stride. Instance variables pool and sync provide a hook to a pool of iterations and a set of synchronization variables, respectively, shared amongst all loop-workers that are executing iterations of the same parallel loop:

tabular180

Because the class for loop-workers of a particular parallel loop must always be obtained by sub-classing this class to provide an appropriate run() method, instantiation of LoopWorker itself is prevented by making the class abstract.

Class LoopWorker also provides a class method parloop() that can be used to start the parallel execution of a loop. This method expects the lower and upper bound of a parallel stride-1 loop in two integer parameters l and h, some loop-workers in an array w (in fact, these loop-workers will always be workers of a specific LoopWorker_x class), the number of synchronization variables required in parameter numS, and, finally, the representation of a scheduling policy in parameter sched. First, new instantiations of a pool and the appropriate number of synchronization variables are obtained. Thereafter, these objects are made available to all loop-workers and a fork is performed. Finally, the method performs a join by waiting for all threads to finish:

tabular194



ajcbik@extreme.indiana.edu