edu.rit.pj.test
Class TestSchedule
- java.lang.Object
-
- edu.rit.pj.Schedule
-
- edu.rit.pj.IntegerSchedule
-
- edu.rit.pj.test.TestSchedule
-
public class TestSchedule extends IntegerSchedule
Class TestSchedule provides a schedule object for testing class IntegerSchedule.
-
-
Constructor Summary
Constructors Constructor and Description TestSchedule()Construct a new test schedule object with an initial chunk size of 1 and a chunk size increment of 0.TestSchedule(int theInitialChunkSize, int theChunkSizeIncrement)Construct a new test schedule object with the given initial chunk size and chunk size increment.TestSchedule(java.lang.String[] args)Construct a new test schedule object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanisFixedSchedule()Determine if this schedule is a fixed schedule.Rangenext(int theThreadIndex)Obtain the next chunk of iterations for the given thread index.voidstart(int K, Range theLoopRange)Start a parallel for loop using this schedule.
-
-
-
Constructor Detail
-
TestSchedule
public TestSchedule()
Construct a new test schedule object with an initial chunk size of 1 and a chunk size increment of 0.
-
TestSchedule
public TestSchedule(int theInitialChunkSize, int theChunkSizeIncrement)Construct a new test schedule object with the given initial chunk size and chunk size increment.- Parameters:
theInitialChunkSize- Initial chunk size.theChunkSizeIncrement- Chunk size increment.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if theInitialChunkSize is less than 1. Thrown if theChunkSizeIncrement is less than 0.
-
TestSchedule
public TestSchedule(java.lang.String[] args)
Construct a new test schedule object. This constructor is for use by the IntegerSchedule.parse() method. args must be an array of two strings, namely the initial chunk size, an integer >= 1, and the chunk size increment, an integer >= 0.- Parameters:
args- Array of argument strings.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if args is not an array of two strings. Thrown if the initial chunk size is less than 1. Thrown if the chunk size increment is less than 0.
-
-
Method Detail
-
isFixedSchedule
public boolean isFixedSchedule()
Determine if this schedule is a fixed schedule. For a parallel team with K threads, a fixed schedule partitions the loop index range into exactly K chunks, one chunk for each thread, each chunk with predetermined upper and lower bounds.- Specified by:
isFixedSchedulein classIntegerSchedule- Returns:
- True if this is a fixed schedule, false otherwise.
-
start
public void start(int K, Range theLoopRange)Start a parallel for loop using this schedule.The start() method is only called by a single thread in the Parallel Java middleware.
- Specified by:
startin classIntegerSchedule- Parameters:
K- Number of threads in the parallel team.theLoopRange- Range of iterations for the entire parallel for loop. The stride may be 1 or greater.
-
next
public Range next(int theThreadIndex)
Obtain the next chunk of iterations for the given thread index. If there are more iterations, a range object is returned whose lower bound, upper bound, and stride specify the chunk of iterations to perform. The returned range object's stride is the same as that given to the start() method. The returned range object's lower bound and upper bound are contained within the range given to the start() method. If there are no more iterations, null is returned.The next() method is called by multiple parallel team threads in the Parallel Java middleware. The next() method must be multiple thread safe.
- Specified by:
nextin classIntegerSchedule- Parameters:
theThreadIndex- Thread index in the range 0 .. K-1.- Returns:
- Chunk of iterations, or null if no more iterations.
-
-
DMelt 3.0 © DataMelt by jWork.ORG