Class WorkerTeam
- Direct Known Subclasses:
HybridTeam
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
ConstructorDescriptionConstruct 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
Modifier and TypeMethodDescriptionfinal 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.final WorkerRegion
region()
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.
-
Constructor Details
-
WorkerTeam
public WorkerTeam()Construct a new worker team with one thread per process and using the world communicator for message passing. -
WorkerTeam
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 ifcomm
is null.
-
-
Method Details
-
execute
Execute the given worker region.- Parameters:
theRegion
- Worker region.- Throws:
NullPointerException
- (unchecked exception) Thrown iftheRegion
is null.IllegalStateException
- (unchecked exception) Thrown if this worker team is already executing a worker region. Thrown iftheRegion
is already being executed by a worker team.Exception
- Exception thrown by the worker region'sstart()
,run()
, orfinish()
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
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 ifw
is not in the range 0 ..getTotalThreadCount()
−1.
-