appl.parallel.spmd
Class AdvancedSPMDServerController

java.lang.Object
  extended by appl.parallel.spmd.SPMDServerController
      extended by appl.parallel.spmd.AdvancedSPMDServerController
All Implemented Interfaces:
AdvancedSPMDServerInterface, SPMDServerInterface

public class AdvancedSPMDServerController
extends SPMDServerController
implements AdvancedSPMDServerInterface

Performance optimizations can be made with this class. Allows heavy multithreading. Because multiple threads may use this class concurrently nearly all additional methods of this class are internally synchronized using a static variable. Also allows preloading of partitions using SyncPoints.

Author:
Dominik Appl

Field Summary
 
Fields inherited from class appl.parallel.spmd.SPMDServerController
mapPosition
 
Constructor Summary
AdvancedSPMDServerController(PartitionDataManager dataManager, int referenceResouceID)
          same parameters as superclass
 
Method Summary
 void clearSyncData()
          You should call this method from time to time to clear all syncpoints and the associated threads out of the memory
 boolean isMasterThread()
          If there are multiple processors on the machine and the current task supports multithreading there are several threads created.
 void preloadMultiPartition(String multiPartition, int idx, SyncPoint s)
          The partition is loaded in a separate thread into the local PartitionDataManager You must specify the partition name and a SyncPoint.
 void preloadPartition(String partition, SyncPoint s)
          The partition is loaded in a separate thread into the local PartitionDataManager
You must specify the partition name and a SyncPoint.
 void setMasterThread(boolean isMaster)
           
 void synchronizeToSyncPoint(SyncPoint s)
          Waits until the Thread with the specified SyncPoint finishes.
 
Methods inherited from class appl.parallel.spmd.SPMDServerController
destroyMultiPartition, destroyPartition, getBaseParameter, getGlobalBounds, getLocalBounds, getLocalBounds, getLocalCalcMaxX, getLocalCalcMaxY, getLocalCalcMinX, getLocalCalcMinY, getLocalCalculationBounds, getLocalCalculationBounds, getMultiData, getMultiPartition, getMultiPartition, getPartition, setLocalCalculationBounds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface appl.parallel.spmd.SPMDServerInterface
destroyMultiPartition, destroyPartition, getBaseParameter, getGlobalBounds, getLocalBounds, getLocalBounds, getLocalCalcMaxX, getLocalCalcMaxY, getLocalCalcMinX, getLocalCalcMinY, getLocalCalculationBounds, getLocalCalculationBounds, getMultiData, getMultiPartition, getMultiPartition, getPartition
 

Constructor Detail

AdvancedSPMDServerController

public AdvancedSPMDServerController(PartitionDataManager dataManager,
                                    int referenceResouceID)
same parameters as superclass

See Also:
SPMDServerController.SPMDServerController(PartitionDataManager, int)
Method Detail

preloadPartition

public void preloadPartition(String partition,
                             SyncPoint s)
The partition is loaded in a separate thread into the local PartitionDataManager
You must specify the partition name and a SyncPoint.
You can specify a priority for the thread in the SyncPoint.

Preloading will only be done one time independent of the number of parallel threads calling this method. (synchronized)

Specified by:
preloadPartition in interface AdvancedSPMDServerInterface
Parameters:
partition - the name of the partition for identification
s - the associated SyncPoint
See Also:
SPMDServerController.getPartition(String), isMasterThread()

preloadMultiPartition

public void preloadMultiPartition(String multiPartition,
                                  int idx,
                                  SyncPoint s)
The partition is loaded in a separate thread into the local PartitionDataManager You must specify the partition name and a SyncPoint. You can specify a priority for the thread in the SyncPoint
Preloading will only be done one time independent of the number of parallel threads calling this method. (synchronized)

Specified by:
preloadMultiPartition in interface AdvancedSPMDServerInterface
Parameters:
multiPartition - the name of the partition for identification
idx - the index of the partition in the multidata object
s - the associated SyncPoint
See Also:
AdvancedSPMDClientInterface.mergePartition(java.lang.Object, appl.parallel.spmd.SyncPoint), SPMDServerController.getPartition(String)

synchronizeToSyncPoint

public void synchronizeToSyncPoint(SyncPoint s)
Description copied from interface: AdvancedSPMDServerInterface
Waits until the Thread with the specified SyncPoint finishes. After that the Thread is removed. A second call will cause a exeception.

Specified by:
synchronizeToSyncPoint in interface AdvancedSPMDServerInterface
Parameters:
s - the SyncPoint

clearSyncData

public void clearSyncData()
You should call this method from time to time to clear all syncpoints and the associated threads out of the memory

Specified by:
clearSyncData in interface AdvancedSPMDServerInterface

isMasterThread

public boolean isMasterThread()
If there are multiple processors on the machine and the current task supports multithreading there are several threads created. Each thread uses a different calculation area. Now there might be parts of the task code were multithreading is undesired, e.g. when operations affect the whole partition. In this case you should use this method to guarantee that only one thread has access to a code block.

Specified by:
isMasterThread in interface AdvancedSPMDServerInterface
Returns:
whether this thread is the "master" thread, which means whether this thread refers to the first task created.

setMasterThread

public void setMasterThread(boolean isMaster)
Parameters:
isMaster - true, if this should be the master thread
See Also:
isMasterThread()