laser.mpi.util.shuffle.test
Class UseCase

java.lang.Object
  |
  +--laser.mpi.util.shuffle.test.UseCase
Direct Known Subclasses:
UseCase0, UseCase1, UseCase2, UseCase3, UseCase4, UseCase5

public class UseCase
extends java.lang.Object

An instance of UseCase contains all the data necessary to perform a single test. Of course, one instance of UseCase will be created on each proc. Each of these should have the same map, but they will have different localData.


Field Summary
(package private)  java.lang.String error
          A message explaining the error if test fails.
(package private)  java.lang.Object[] localData
          The localData for this use case.
(package private)  Mapping[] map
          The map for this use case.
(package private)  int myRank
          The rank (ID) of this process.
(package private)  java.lang.String name
          The name of this use case.
(package private)  java.lang.Object[] newLocalData
          What the localData should look like after shuffling.
(package private)  int nProcs
          The number of processes.
(package private)  Shuffler shuffler
          The Shuffler which will be created to shuffle the data.
 
Constructor Summary
UseCase()
          Constructs a new instance of UseCase with default values for the fields.
 
Method Summary
 boolean test(Shuffler archetype)
          This executes the test specified by this use case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

java.lang.String name
The name of this use case.


map

Mapping[] map
The map for this use case.


localData

java.lang.Object[] localData
The localData for this use case.


newLocalData

java.lang.Object[] newLocalData
What the localData should look like after shuffling.


error

java.lang.String error
A message explaining the error if test fails.


nProcs

int nProcs
The number of processes.


myRank

int myRank
The rank (ID) of this process.


shuffler

Shuffler shuffler
The Shuffler which will be created to shuffle the data.

Constructor Detail

UseCase

public UseCase()
        throws mpi.MPIException
Constructs a new instance of UseCase with default values for the fields. Sets nProcs and myRank to the correct values by calling the appropriate MPI functions.

Throws:
mpi.MPIException - if something goes awry with the MPI calls
Method Detail

test

public boolean test(Shuffler archetype)
             throws mpi.MPIException
This executes the test specified by this use case. First, the map is printed to stdout, then the localArrays are printed, then the shuffling of the data takes place, and then the localData arrays are printed out again with their new values. (If Shuffler.debug is set to true, additional messages will be printed at intermediate stages.) Finally, the result is compared with the expected result on this proc. If they differ, a message is printed to stdout explaining the difference (and it puts a similar message in the string variable error).

Finally, each proc other than 0 sends a bit saying whether the test passed or failed on that proc to proc 0. Proc 0 takes the "and" over all those bits (including its own) and if the result is true, it prints a message saying that the test passed, else it says the test failed.

Finally, the return value. On proc 0, the value returned is the global correctness: i.e., it is true iff every proc passed the test. On all otherh procs, the value returned is the local correctness, i.e., whether or not that particular proc passed.

This method should be called by each proc in the communicator.

Parameters:
archetype - any instance of the Shuffler class which will be used to create a new instance to test
Returns:
if myRank == 0: true iff all procs passed, otherwise true iff this proc passed.
Throws:
mpi.MPIException - if something goes awry with MPI