Class WorkerTeam
- java.lang.Object
-
- edu.rit.pj.WorkerTeam
-
- Direct Known Subclasses:
- HybridTeam
public class WorkerTeam extends java.lang.ObjectClass 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.
-
-
Constructor Summary
Constructors Constructor and Description WorkerTeam()Construct a new worker team with one thread per process and using the world communicator for message passing.WorkerTeam(Comm comm)Construct a new worker team with one thread per process and using the given communicator for message passing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidexecute(WorkerRegion theRegion)Execute the given worker region.intgetThreadCount()Determine the number of worker threads in this worker team in this process.intgetTotalThreadCount()Determine the total number of worker threads in this worker team in all processes.booleanisExecutingInParallel()Determine if this worker team is executing a worker region.intmasterRank()Determine the rank of the process that contains the master thread.WorkerRegionregion()Returns the worker region of code that this worker team is executing.intworkerRank(int w)Determine the rank of the process that contains the worker thread with the given index.
-
-
-
Constructor Detail
-
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:
java.lang.NullPointerException- (unchecked exception) Thrown if comm is null.
-
-
Method Detail
-
execute
public final void execute(WorkerRegion theRegion) throws java.lang.Exception
Execute the given worker region.- Parameters:
theRegion- Worker region.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if theRegion is null.java.lang.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.java.lang.Exception- Exception thrown by the worker region's start(), run(), or finish() methods.
-
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:
java.lang.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:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if w is not in the range 0 .. getTotalThreadCount()−1.
-
-
DMelt 3.0 © DataMelt by jWork.ORG