Class HybridTeam
- java.lang.Object
-
- edu.rit.pj.WorkerTeam
-
- edu.rit.pj.HybridTeam
-
public class HybridTeam extends WorkerTeam
Class HybridTeam provides a team of threads, distributed across the processes of a cluster parallel program, for executing a WorkerRegion in parallel.A hybrid 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 hybrid team. In class HybridTeam, there are one or more worker threads per process; typically, the number of threads in each process equals the number of CPUs on the node executing the process. (To get just one worker thread per process, use class WorkerTeam.) 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.
When a hybrid team is constructed, the processes in the communicator send messages amongst themselves to make every process aware of the number of worker threads in each process. These messages use a tag of Integer.MIN_VALUE. If an I/O error occurs during this message passing, the constructor throws an IOException.
To execute a worker region, create a HybridTeam object; create an instance of a concrete subclass of class WorkerRegion; and pass this instance to the hybrid team's execute() method. For further information, see class WorkerRegion.
-
-
Constructor Summary
Constructors Constructor and Description HybridTeam()Construct a new hybrid team with the default number of threads per process and using the world communicator for message passing.HybridTeam(Comm comm)Construct a new hybrid team with the default number of threads per process and using the given communicator for message passing.HybridTeam(int K)Construct a new hybrid team with the given number of threads per process and using the world communicator for message passing.HybridTeam(int K, Comm comm)Construct a new hybrid team with the given number of threads per process and using the given communicator for message passing.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static intgetDefaultThreadCount()Determine the default number of threads per process for a hybrid team.intworkerRank(int w)Determine the rank of the process that contains the worker thread with the given index.-
Methods inherited from class edu.rit.pj.WorkerTeam
execute, getThreadCount, getTotalThreadCount, isExecutingInParallel, masterRank, region
-
-
-
-
Constructor Detail
-
HybridTeam
public HybridTeam() throws java.io.IOExceptionConstruct a new hybrid team with the default number of threads per process and using the world communicator for message passing. If the "pj.nt" Java property is specified, that property gives the default number of threads per process, which must be an integer greater than or equal to 1. If the "pj.nt" Java property is not specified, the default number of threads in each process is the value returned by the Runtime.availableProcessors() method. You can specify the default number of threads per process on the Java command line like this:java -Dpj.nt=4 . . .- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if the "pj.nt" property value is not an integer greater than or equal to 1.java.io.IOException- Thrown if an I/O error occurred.
-
HybridTeam
public HybridTeam(int K) throws java.io.IOExceptionConstruct a new hybrid team with the given number of threads per process and using the world communicator for message passing.- Parameters:
K- Number of threads per process.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if K is less than 1.java.io.IOException- Thrown if an I/O error occurred.
-
HybridTeam
public HybridTeam(Comm comm) throws java.io.IOException
Construct a new hybrid team with the default number of threads per process and using the given communicator for message passing. If the "pj.nt" Java property is specified, that property gives the default number of threads per process, which must be an integer greater than or equal to 1. If the "pj.nt" Java property is not specified, the default number of threads in each process is the value returned by the Runtime.availableProcessors() method. You can specify the default number of threads per process on the Java command line like this:java -Dpj.nt=4 . . .- Parameters:
comm- Communicator to use for message passing.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if the "pj.nt" property value is not an integer greater than or equal to 1.java.lang.NullPointerException- (unchecked exception) Thrown if comm is null.java.io.IOException- Thrown if an I/O error occurred.
-
HybridTeam
public HybridTeam(int K, Comm comm) throws java.io.IOExceptionConstruct a new hybrid team with the given number of threads per process and using the given communicator for message passing.- Parameters:
K- Number of threads per process.comm- Communicator to use for message passing.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if K is less than 1.java.lang.NullPointerException- (unchecked exception) Thrown if comm is null.java.io.IOException- Thrown if an I/O error occurred.
-
-
Method Detail
-
getDefaultThreadCount
public static int getDefaultThreadCount()
Determine the default number of threads per process for a hybrid team. If the "pj.nt" Java property is specified, that property gives the default number of threads per process, which must be an integer greater than or equal to 1. If the "pj.nt" Java property is not specified, the default number of threads in each process is the value returned by the Runtime.availableProcessors() method. You can specify the default number of threads per process on the Java command line like this:java -Dpj.nt=4 . . .- Returns:
- Default number of threads per process for a hybrid team.
- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if the "pj.nt" property value is not an integer greater than or equal to 1.
-
workerRank
public int workerRank(int w)
Determine the rank of the process that contains the worker thread with the given index.- Overrides:
workerRankin classWorkerTeam- 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