ptolemy.domains.psdf.kernel
Class PSDFScheduler

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.kernel.util.Attribute
          extended by ptolemy.actor.sched.Scheduler
              extended by ptolemy.domains.sdf.kernel.BaseSDFScheduler
                  extended by ptolemy.domains.psdf.kernel.PSDFScheduler
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class PSDFScheduler
extends BaseSDFScheduler

A scheduler that implements basic scheduling of PSDF graphs. PSDF scheduling is similar to SDF scheduling, EXCEPT:

1) Because parameter values may change, the solution to the balance equation is computed symbolically. i.e. the repetitions vector is a function of the parameter values.

2) Because the firing vector may change, the schedule determined by this class can only be a quasi-static, or parameterized schedule. Note that parameterized schedules cannot generally be constructed for models with feedback or with unconstrained parameter values.

This class uses a ConstVariableModelAnalysis to determine which scheduling parameters are constants and which may change during execution of the model. Rate parameters that can change are checked to ensure that their change context is not strictly contained by the model being scheduled. If this is the case, then the actor is not locally synchronous, and cannot be statically scheduled. Dynamic parameters with a valid changed context are treated symbolically when computing the repetitions vector.

After computing a schedule, this scheduler determines the external rate of each of the model's external ports. Since the firing vector is only computed symbolically, these rates can also only be computed symbolically. The dependence of these external rates on the rates of ports in the model is declared using a DependenceDeclaration. Higher level directors may use this dependence information to determine the change context of those rate variables and may refuse to schedule the composite actor if those rates imply that this model is not locally synchronous.

This scheduler uses a version of the P-APGAN scheduling algorithm described in [1].

[1] B. Bhattacharya and S. S. Bhattacharyya. Quasi-static scheduling of reconfigurable dataflow graphs for DSP systems. In Proceedings of the International Workshop on Rapid System Prototyping , pages 84-89, Paris, France, June 2000.

Since:
Ptolemy II 3.1
Version:
$Id: PSDFScheduler.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Stephen Neuendorffer, Shuvra S. Bhattacharyya
See Also:
Scheduler, SampleDelay, SDFScheduler, Serialized Form
Accepted Rating:
Red (neuendor)
Proposed Rating:
Red (neuendor)

Nested Class Summary
private  class PSDFScheduler.ScheduleScope
           
private  class PSDFScheduler.SymbolicFiring
          An actor firing with an iteration count that is determined by a symbolic expression.
private  class PSDFScheduler.SymbolicSchedule
          A schedule whose iteration count is given by an expression.
private static interface PSDFScheduler.SymbolicScheduleElement
          An interface for schedule elements whose iteration counts are in terms of symbolic expressions.
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
private  java.util.HashMap _bufferSizeMap
           
private  boolean _debugFlag
           
private  ParserScope _parserScope
           
private  ParseTreeEvaluator _parseTreeEvaluator
           
 
Fields inherited from class ptolemy.domains.sdf.kernel.BaseSDFScheduler
VERBOSE
 
Fields inherited from class ptolemy.actor.sched.Scheduler
_DEFAULT_SCHEDULER_NAME
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
PSDFScheduler()
          Construct a scheduler with no container(director) in the default workspace, the name of the scheduler is "Scheduler".
PSDFScheduler(Director container, java.lang.String name)
          Construct a scheduler in the given container with the given name.
PSDFScheduler(Workspace workspace)
          Construct a scheduler in the given workspace with the name "Scheduler".
 
Method Summary
private  Token _evaluateExpressionInModelScope(ASTPtRootNode node)
           
private  PSDFScheduler.SymbolicScheduleElement _expandAPGAN(mapss.dif.psdf.PSDFGraph graph, Node node, mapss.dif.psdf.PSDFAPGANStrategy strategy)
           
protected  Schedule _getSchedule()
          Return the parameterized scheduling sequence.
private  void _inferFiringCounts(PSDFScheduler.SymbolicScheduleElement element, java.lang.String expression)
           
private  void _init()
           
 void declareRateDependency()
          Declare the rate dependency on any external ports of the model.
 java.lang.String displayBufferSizes()
          Return a string representation of the buffer sizes of the relations in the model.
 
Methods inherited from class ptolemy.domains.sdf.kernel.BaseSDFScheduler
_declareDependency, _saveBufferSizes, _saveContainerRates, _saveFiringCounts
 
Methods inherited from class ptolemy.actor.sched.Scheduler
clone, getSchedule, isValid, setContainer, setValid
 
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, 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, _description, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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

_bufferSizeMap

private java.util.HashMap _bufferSizeMap

_debugFlag

private boolean _debugFlag

_parseTreeEvaluator

private ParseTreeEvaluator _parseTreeEvaluator

_parserScope

private ParserScope _parserScope
Constructor Detail

PSDFScheduler

public PSDFScheduler()
              throws IllegalActionException,
                     NameDuplicationException
Construct a scheduler with no container(director) in the default workspace, the name of the scheduler is "Scheduler".

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.

PSDFScheduler

public PSDFScheduler(Workspace workspace)
              throws IllegalActionException,
                     NameDuplicationException
Construct a scheduler in the given workspace with the name "Scheduler". If the workspace argument is null, use the default workspace. The scheduler is added to the list of objects in the workspace. Increment the version number of the workspace.

Parameters:
workspace - Object for synchronization and version tracking.
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.

PSDFScheduler

public PSDFScheduler(Director container,
                     java.lang.String name)
              throws IllegalActionException,
                     NameDuplicationException
Construct a scheduler in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. This attribute will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace.

Parameters:
container - The container.
name - The name of this attribute.
Throws:
IllegalActionException - If the attribute is not of an acceptable class for the container, or if the name contains a period.
NameDuplicationException - If the name coincides with an attribute already in the container.
Method Detail

declareRateDependency

public void declareRateDependency()
                           throws IllegalActionException
Declare the rate dependency on any external ports of the model. SDF directors should invoke this method once during preinitialize.

Specified by:
declareRateDependency in class BaseSDFScheduler
Throws:
IllegalActionException - If there is a problem setting the rate dependency on an external port.

displayBufferSizes

public java.lang.String displayBufferSizes()
Return a string representation of the buffer sizes of the relations in the model. This diagnostic method shows the buffer size expression for each relation along with the relation itself.

Returns:
A string representation of the buffer sizes.

_getSchedule

protected Schedule _getSchedule()
                         throws NotSchedulableException,
                                IllegalActionException
Return the parameterized scheduling sequence. An exception will be thrown if the graph is not schedulable.

Overrides:
_getSchedule in class Scheduler
Returns:
A schedule of the deeply contained opaque entities in the firing order.
Throws:
NotSchedulableException - If a parameterized schedule cannot be derived for the model.
IllegalActionException - If the rate parameters of the model are not correct, or the computed rates for external ports are not correct.
See Also:
CompositeEntity.deepEntityList()

_evaluateExpressionInModelScope

private Token _evaluateExpressionInModelScope(ASTPtRootNode node)
                                       throws IllegalActionException
Throws:
IllegalActionException

_expandAPGAN

private PSDFScheduler.SymbolicScheduleElement _expandAPGAN(mapss.dif.psdf.PSDFGraph graph,
                                                           Node node,
                                                           mapss.dif.psdf.PSDFAPGANStrategy strategy)

_inferFiringCounts

private void _inferFiringCounts(PSDFScheduler.SymbolicScheduleElement element,
                                java.lang.String expression)
                         throws IllegalActionException,
                                NameDuplicationException
Throws:
IllegalActionException
NameDuplicationException

_init

private void _init()