Package edu.rit.pj

Class WorkerTeam

java.lang.Object
edu.rit.pj.WorkerTeam
Direct Known Subclasses:
HybridTeam

public class WorkerTeam extends Object
Class WorkerTeam provides a team of threads, distributed across the processes of a cluster parallel program, for executing a WorkerRegion in parallel.

A worker team uses a communicator for message passing. The communicator is specified as a constructor argument; if not specified, the world communicator is used. Every process that is part of the communicator must create the worker team. In class WorkerTeam, there is one worker thread per process. (To get more than one worker thread per process, use class HybridTeam.) Every worker thread in every process has a unique index, going from index 0 for the first thread in the first process to index K−1 for the last thread in the last process, where K is the total number of worker threads in all the processes. In process rank 0, there is an additional master thread.

To execute a worker region, create a WorkerTeam object; create an instance of a concrete subclass of class WorkerRegion; and pass this instance to the worker team's execute() method. For further information, see class WorkerRegion.

Version:
19-Jan-2010
Author:
Alan Kaminsky
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a new worker team with one thread per process and using the world communicator for message passing.
    Construct a new worker team with one thread per process and using the given communicator for message passing.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    execute(WorkerRegion theRegion)
    Execute the given worker region.
    final int
    Determine the number of worker threads in this worker team in this process.
    final int
    Determine the total number of worker threads in this worker team in all processes.
    final boolean
    Determine if this worker team is executing a worker region.
    int
    Determine the rank of the process that contains the master thread.
    Returns the worker region of code that this worker team is executing.
    int
    workerRank(int w)
    Determine the rank of the process that contains the worker thread with the given index.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WorkerTeam

      public WorkerTeam()
      Construct a new worker team with one thread per process and using the world communicator for message passing.
    • WorkerTeam

      public WorkerTeam(Comm comm)
      Construct a new worker team with one thread per process and using the given communicator for message passing.
      Parameters:
      comm - Communicator to use for message passing.
      Throws:
      NullPointerException - (unchecked exception) Thrown if comm is null.
  • Method Details

    • execute

      public final void execute(WorkerRegion theRegion) throws Exception
      Execute the given worker region.
      Parameters:
      theRegion - Worker region.
      Throws:
      NullPointerException - (unchecked exception) Thrown if theRegion is null.
      IllegalStateException - (unchecked exception) Thrown if this worker team is already executing a worker region. Thrown if theRegion is already being executed by a worker team.
      Exception - Exception thrown by the worker region's start(), run(), or finish() methods.
      Exception - if any.
    • isExecutingInParallel

      public final boolean isExecutingInParallel()
      Determine if this worker team is executing a worker region.
      Returns:
      True if this worker team is executing a worker region, false otherwise.
    • region

      public final WorkerRegion region()
      Returns the worker region of code that this worker team is executing.
      Returns:
      Worker region.
      Throws:
      IllegalStateException - (unchecked exception) Thrown if this worker team is not executing a worker region.
    • getThreadCount

      public final int getThreadCount()
      Determine the number of worker threads in this worker team in this process. This does not include the master thread if any.
      Returns:
      Number of worker threads in this process.
    • getTotalThreadCount

      public final int getTotalThreadCount()
      Determine the total number of worker threads in this worker team in all processes. This does not include the master thread.
      Returns:
      Number of worker threads in all processes.
    • masterRank

      public int masterRank()
      Determine the rank of the process that contains the master thread. At present, this is always rank 0.
      Returns:
      Master process rank.
    • workerRank

      public int workerRank(int w)
      Determine the rank of the process that contains the worker thread with the given index.
      Parameters:
      w - Worker index.
      Returns:
      Worker process rank.
      Throws:
      IllegalArgumentException - (unchecked exception) Thrown if w is not in the range 0 .. getTotalThreadCount()−1.