ptolemy.distributed.domains.sdf.kernel
Class DistributedSDFDirector

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.util.Attribute
          extended byptolemy.actor.Director
              extended byptolemy.actor.sched.StaticSchedulingDirector
                  extended byptolemy.domains.sdf.kernel.SDFDirector
                      extended byptolemy.distributed.domains.sdf.kernel.DistributedSDFDirector
All Implemented Interfaces:
Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, java.io.Serializable

public class DistributedSDFDirector
extends SDFDirector

Director for the distributed version of the synchronous dataflow (SDF) model of computation.

Distributed-SDF overview

The Distributed-SDF domain is an extended version of the existing SDF Domain that performs the simulation in a distributed manner.

Requirements

Features

A DistributedSDFDirector is the class that controls execution of actors under the distributed version of the SDF domain. It extends SDFDirector.

By default, actor scheduling is handled by the DistributedSDFScheduler class. Furthermore, the newReceiver method creates Receivers of type DistributedSDFReceiver, which extends SDFReceiver.

See ptolemy.domains.sdf.kernel.SDFScheduler for more information about the SDF Domain.

Parameters

Since:
Ptolemy II 5.1
Version:
$Id: DistributedSDFDirector.java,v 1.21.4.1 2006/12/30 22:17:39 cxh Exp $
Author:
Daniel Lazaro Cuadrado (kapokasa@kom.aau.dk)
See Also:
DistributedServerRMIGeneric, DistributedSDFReceiver, DistributedSDFScheduler, SDFDirector, SDFScheduler, Serialized Form
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (kapokasa)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
 Parameter parallelExecution
          A Parameter representing whether a sequential or parallel execution will be performed.
 Parameter parallelSchedule
          A Parameter representing whether a sequential or parallel schedule will be computed.
 Parameter pipelining
          A Parameter representing whether a pipelined parallel execution will be performed.
 
Fields inherited from class ptolemy.domains.sdf.kernel.SDFDirector
_iterationCount, allowDisconnectedGraphs, allowRateChanges, constrainBufferSizes, iterations, period, synchronizeToRealTime, vectorizationFactor
 
Fields inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_postfireReturns
 
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _currentTime, _stopRequested, timeResolution
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
DistributedSDFDirector()
          Construct a director in the default workspace with an empty string as its name.
DistributedSDFDirector(CompositeEntity container, java.lang.String name)
          Construct a director in the given container with the given name.
DistributedSDFDirector(Workspace workspace)
          Construct a director in the workspace with an empty name.
 
Method Summary
 void attributeChanged(Attribute attribute)
          React to a change in an attribute.
 void fire()
          Calculate the current schedule, if necessary, and iterate the contained actors in the order given by the schedule.
 void initialize()
          Initialize the actors associated with this director (super).
 Receiver newReceiver()
          Return a new receiver consistent with the Distributed-SDF domain.
 void preinitialize()
          Preinitialize the actors associated with this director and compute the schedule (super).
 void wrapup()
          Invoke the wrapup() method of all the actors contained in the director's container (super).
 
Methods inherited from class ptolemy.domains.sdf.kernel.SDFDirector
getModelNextIterationTime, postfire, prefire, suggestedModalModelDirectors, supportMultirateFiring, transferInputs, transferOutputs
 
Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener, setScheduler
 
Methods inherited from class ptolemy.actor.Director
_description, _isEmbedded, _isTopLevel, _transferInputs, _transferOutputs, fireAt, fireAt, fireAtCurrentTime, getCurrentTime, getErrorTolerance, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, initialize, invalidateResolvedTypes, isFireFunctional, isStopRequested, isStrict, iterate, requestInitialization, setContainer, setCurrentTime, setModelTime, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.util.Attribute
_getContainedObject, _propagateExistence, clone, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parallelSchedule

public Parameter parallelSchedule
A Parameter representing whether a sequential or parallel schedule will be computed. This parameter must be a boolean. The default value is false BooleanToken.


pipelining

public Parameter pipelining
A Parameter representing whether a pipelined parallel execution will be performed. A pipelined execution only makes sense when parallel execution is true. This parameter must be a boolean. The default value is false BooleanToken.


parallelExecution

public Parameter parallelExecution
A Parameter representing whether a sequential or parallel execution will be performed. This parameter must be a boolean. The default value is false BooleanToken.

Constructor Detail

DistributedSDFDirector

public DistributedSDFDirector()
                       throws IllegalActionException,
                              NameDuplicationException
Construct a director in the default workspace with an empty string as its name. The director is added to the list of objects in the workspace. Increment the version number of the workspace. The DistributedSDFDirector will have a default scheduler of type DistributedSDFScheduler.

Throws:
IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
NameDuplicationException - If the container already contains an entity with the specified name.

DistributedSDFDirector

public DistributedSDFDirector(Workspace workspace)
                       throws IllegalActionException,
                              NameDuplicationException
Construct a director in the workspace with an empty name. The director is added to the list of objects in the workspace. Increment the version number of the workspace. The DistributedSDFDirector will have a default scheduler of type DistributedSDFScheduler.

Parameters:
workspace - The workspace for this object.
Throws:
IllegalActionException - If the name has a period in it, or the director is not compatible with the specified container.
NameDuplicationException - If the container already contains an entity with the specified name.

DistributedSDFDirector

public DistributedSDFDirector(CompositeEntity container,
                              java.lang.String name)
                       throws IllegalActionException,
                              NameDuplicationException
Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace. The DistributedSDFDirector will have a default scheduler of type DistributedSDFScheduler.

Parameters:
container - Container of the director.
name - Name of this director.
Throws:
IllegalActionException - If the director is not compatible with the specified container. May be thrown in a derived class.
NameDuplicationException - If the container is not a CompositeActor and the name collides with an entity in the container.
Method Detail

attributeChanged

public void attributeChanged(Attribute attribute)
                      throws IllegalActionException
React to a change in an attribute. If the changed attribute matches a parameter of the director, then the corresponding local copy of the parameter value will be updated. If the attribute that changes is parallelSchedule the schedule is invalidated.

Overrides:
attributeChanged in class SDFDirector
Parameters:
attribute - The changed parameter.
Throws:
IllegalActionException - If the parameter set is not valid.

fire

public void fire()
          throws IllegalActionException
Calculate the current schedule, if necessary, and iterate the contained actors in the order given by the schedule. Depending on the value of parallelSchedule either a sequential or a parallel schedule will be computed. Depending on the value of parallelExecution either a sequential or a parallel execution of the schedule will be computed. No internal state of the director is updated during fire, so it may be used with domains that require this property, such as CT.

Iterating an actor involves calling the actor's iterate() method, which is equivalent to calling the actor's prefire(), fire() and postfire() methods in succession. If iterate() returns NOT_READY, indicating that the actor is not ready to execute, then an IllegalActionException will be thrown. The values returned from iterate() are recorded and are used to determine the value that postfire() will return at the end of the director's iteration.

This method may be overridden by some domains to perform additional domain-specific operations.

Specified by:
fire in interface Executable
Overrides:
fire in class StaticSchedulingDirector
Throws:
IllegalActionException - If any actor executed by this actor return false in prefire.

initialize

public void initialize()
                throws IllegalActionException
Initialize the actors associated with this director (super). If parallelExecution is true, the infrastructure for a distributed execution is initialized. Once the required number of services are discovered, the actors are mapped on to them, sent to the distributed services and virtually connected over the network.

Specified by:
initialize in interface Executable
Overrides:
initialize in class SDFDirector
Throws:
IllegalActionException - If the initialize() method of one of the associated actors throws it, or if there is no scheduler.

newReceiver

public Receiver newReceiver()
Return a new receiver consistent with the Distributed-SDF domain.

Overrides:
newReceiver in class SDFDirector
Returns:
A new DistributedSDFReceiver.

preinitialize

public void preinitialize()
                   throws IllegalActionException
Preinitialize the actors associated with this director and compute the schedule (super). The schedule is computed during preinitialization so that hierarchical opaque composite actors can be scheduled properly, since the act of computing the schedule sets the rate parameters of the external ports. In addition, performing scheduling during preinitialization enables it to be present during code generation. The order in which the actors are preinitialized is arbitrary. The schedule computed will be either sequential or parallel depending on the value of parallelSchedule.

Specified by:
preinitialize in interface Executable
Overrides:
preinitialize in class SDFDirector
Throws:
IllegalActionException - If the preinitialize() method of one of the associated actors throws it.

wrapup

public void wrapup()
            throws IllegalActionException
Invoke the wrapup() method of all the actors contained in the director's container (super). In case of parallelExecution being true, exit from all the client threads is performed. This method should be invoked once per execution. None of the other action methods should be invoked after it in the execution. This method is not synchronized on the workspace, so the caller should be.

Specified by:
wrapup in interface Executable
Overrides:
wrapup in class Director
Throws:
IllegalActionException - If the wrapup() method of one of the associated actors throws it.
See Also:
ClientThread