jbarrier

edu.bonn.cs.net.jbarrier.barrier
Class TournamentBarrier

java.lang.Object
  extended by edu.bonn.cs.net.jbarrier.barrier.AbstractBarrier
      extended by edu.bonn.cs.net.jbarrier.barrier.TournamentBarrier
All Implemented Interfaces:
Barrier
Direct Known Subclasses:
DoubleTournamentReduction, FloatTournamentReduction, IntTournamentReduction, LongTournamentReduction

public class TournamentBarrier
extends AbstractBarrier

Implementation of a tournament barrier algorithm. A tournament barrier algorithm, which makes the parties compete in a series of game "rounds", arranged in a tournament structure. The winning party advances to the next level and "plays" against other winning parties until there is only a single "champion" left. The loser parties simply wait for the tournament to finish (when they are finally woken up by the champion). Since this is not a real competition, the winners and losers of each round are selected in advance to improve performance. The tournament barrier was introduced in the following article:

D. Hensgen, R. Finkel, and U. Manber. "Two Algorithms for Barrier Synchronization". In International Journal of Parallel Programming, volume 17, pages 1-17, 1988.

The following two technical reports may server as good a introduction to different barrier synchronization algorithms:

Version:
1.0
Author:
Patrick Peschlow, Ivan Castilla Rodriguez

Nested Class Summary
protected static class TournamentBarrier.Role
          Possible roles of the different parties in the tournament barrier.
protected static class TournamentBarrier.Round
          Stores pre-computed information about a round of the tournament barrier.
protected  class TournamentBarrier.TournamentBarrierParty
          Stores data required by each party that uses the barrier.
 
Field Summary
protected  boolean flagOut_
          Out flag set by the winner of the tournament.
protected  int numRounds_
          The number of rounds used for the barrier.
protected  TournamentBarrier.TournamentBarrierParty[] parties_
          The barrier information associated to each competitor thread.
 
Fields inherited from class edu.bonn.cs.net.jbarrier.barrier.AbstractBarrier
action_, genericReductor_, numParties_
 
Constructor Summary
TournamentBarrier(int numParties)
          Constructor (if no action is used).
TournamentBarrier(int numParties, java.lang.Runnable barrierAction)
          Constructor.
TournamentBarrier(int numParties, java.lang.Runnable barrierAction, GenericReductor genericReductor)
          Constructor.
 
Method Summary
 void await(int threadId)
          Called by a party that reaches the barrier.
protected  void setUpParties()
          Sets up the parties array, intended to be overridden in subclasses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parties_

protected TournamentBarrier.TournamentBarrierParty[] parties_
The barrier information associated to each competitor thread.


numRounds_

protected final int numRounds_
The number of rounds used for the barrier.


flagOut_

protected volatile boolean flagOut_
Out flag set by the winner of the tournament.

Constructor Detail

TournamentBarrier

public TournamentBarrier(int numParties,
                         java.lang.Runnable barrierAction,
                         GenericReductor genericReductor)
Constructor.

Parameters:
numParties - the number of parties that must reach the barrier before the barrier is tripped
barrierAction - the command to execute when the barrier is tripped, or null if there is no action
genericReductor - an optional generic reductor

TournamentBarrier

public TournamentBarrier(int numParties,
                         java.lang.Runnable barrierAction)
Constructor.

Parameters:
numParties - the number of parties that must reach the barrier before the barrier is tripped
barrierAction - the command to execute when the barrier is tripped, or null if there is no action

TournamentBarrier

public TournamentBarrier(int numParties)
Constructor (if no action is used).

Parameters:
numParties - the number of parties that must reach the barrier before the barrier is tripped
Method Detail

setUpParties

protected void setUpParties()
Sets up the parties array, intended to be overridden in subclasses.


await

public void await(int threadId)
Called by a party that reaches the barrier.

Specified by:
await in interface Barrier
Specified by:
await in class AbstractBarrier
Parameters:
threadId - the ID of the party

jbarrier

Copyright 2010 Patrick Peschlow