es.udc.gii.common.eaf.algorithm.parallel.topology.operator
Class MSTopology

java.lang.Object
  extended by es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
      extended by es.udc.gii.common.eaf.algorithm.parallel.topology.operator.MSTopology
All Implemented Interfaces:
Configurable, java.io.Serializable

public class MSTopology
extends Topology
implements java.io.Serializable

Author:
rafa
See Also:
Serialized Form

Field Summary
protected  boolean master
          true if this process is the master in this topology.
protected static int MASTER
          Rank of the default master process.
protected static int MSG_TAG
           
protected  int myMaster
          The rank of the master of this topology.
static int NONE
          Special return value when there is no master.
private  java.util.Map<mpi.Request,MSEnvelope[]> pendingSendRequest
           
 
Fields inherited from class es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
communicator, receivers, senders, topologyRank
 
Constructor Summary
MSTopology()
          Creates a new instance of EvaluationTopology.
MSTopology(int races)
          Creates a new instance of EvaluationTopology.
 
Method Summary
private  void addSendRequest(mpi.Request request, MSEnvelope[] evalObj)
           
protected  void doConfigure()
          A subclass might need additional configuration.
protected  void doConfigure(org.apache.commons.configuration.Configuration conf)
          A subclass might need additional configuration.
protected  void doInitialize()
          Performs the initialization.
protected  MSEnvelope doReceive()
          Performs the receive operation.
protected  void doSend(MSEnvelope evalObj)
          Performs the send operation.
 boolean evaluationObjectReceived()
          Checks if some evaluation object has been received.
 void finish()
           
 int getMaster()
          Retuns the rank of the master of this topology.
 boolean isMaster()
          Returns true if the calling process is the master process of this topology.
 MSEnvelope receive()
          Receives a MSEnvelope from a slave or from a master.
 void send(MSEnvelope evalObj)
          Sends a MSEnvelope to a slave or to the master.
private  void testSendRequests()
           
 
Methods inherited from class es.udc.gii.common.eaf.algorithm.parallel.topology.Topology
configure, getCommunicator, getRaces, getReceivers, getSenders, getSize, getTopologyRank, initialize, isConnected, isInitialized, setInitialized, setRaces, synchronize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pendingSendRequest

private java.util.Map<mpi.Request,MSEnvelope[]> pendingSendRequest

MSG_TAG

protected static final int MSG_TAG
See Also:
Constant Field Values

MASTER

protected static final int MASTER
Rank of the default master process.

See Also:
Constant Field Values

master

protected boolean master
true if this process is the master in this topology.


NONE

public static final int NONE
Special return value when there is no master.

See Also:
Constant Field Values

myMaster

protected int myMaster
The rank of the master of this topology.

Constructor Detail

MSTopology

public MSTopology()
Creates a new instance of EvaluationTopology.


MSTopology

public MSTopology(int races)
Creates a new instance of EvaluationTopology.

Method Detail

doInitialize

protected void doInitialize()
Performs the initialization.

Specified by:
doInitialize in class Topology

doConfigure

protected void doConfigure()
Description copied from class: Topology
A subclass might need additional configuration.

Specified by:
doConfigure in class Topology

doConfigure

protected void doConfigure(org.apache.commons.configuration.Configuration conf)
Description copied from class: Topology
A subclass might need additional configuration.

Specified by:
doConfigure in class Topology

testSendRequests

private void testSendRequests()

addSendRequest

private void addSendRequest(mpi.Request request,
                            MSEnvelope[] evalObj)

doSend

protected void doSend(MSEnvelope evalObj)
Performs the send operation.


send

public void send(MSEnvelope evalObj)
Sends a MSEnvelope to a slave or to the master. The receiver is known by the method MSEnvelope.getDest() of evalObj. This method is implemented with the EvaluationTopology.doSend(es.udc.gii.common.eaf.algorithm.parallel.topology.evaluation.EvaluationObject) method. It is a nonblocking send.


doReceive

protected MSEnvelope doReceive()
Performs the receive operation.


receive

public MSEnvelope receive()
Receives a MSEnvelope from a slave or from a master. For slaves it returns null when the evaluation process is finished. For all processes it returns null when an object is received that's not an instance of MSEnvelope.

This method is implemented with the MSEnvelope#doReceive method. It is a blocking receive, so the caller waits until a message is arrived.


evaluationObjectReceived

public boolean evaluationObjectReceived()
Checks if some evaluation object has been received.

Returns:
true if an evaluation object has been received, false otherwise.

getMaster

public int getMaster()
Retuns the rank of the master of this topology. If there isn't any master it returns EvaluationTopology.NONE.


isMaster

public boolean isMaster()
Returns true if the calling process is the master process of this topology. Returns false otherwise.


finish

public void finish()