public class SDFScheduler extends BaseSDFScheduler implements ValueListener
Then the actors are ordered such that each actor only fires when the scheduler has determined that enough tokens will be present on its input ports to allow it to fire. In cases where the dataflow graph is cyclic, a valid firing vector exists, but no actor can fire, since they all depend on the output of another actor. This situation is known as deadlock. Deadlock must be prevented in SDF by manually inserting delay actors, which represent initial tokens on each relation. Such delay actors are responsible for creating tokens during initialization that will prevent deadlock. These actors set the tokenInitProduction parameter of their output ports to represent the number of tokens they will create during initialization. The SDFScheduler uses this parameter to break the dependency in a cyclic graph.
In addition, an input port may initially have available input tokens. This is indicated by a tokenInitConsumption parameter on the input port.
Note that this scheduler only ensures that the number of firings is minimal. Most notably, it does not attempt to minimize the size of the buffers that are associated with each relation. The resulting schedule is a linear schedule (as opposed to a looped schedule) and is not suitable for multiprocessing environments.
Any actors may be scheduled by this scheduler, which will, by default, assume homogeneous behavior for each actor. (i.e. each output port produces one token for each firing, and each input port consumes one token on each firing, and no tokens are created during initialization.) If this is not the case then parameters named tokenConsumptionRate, tokenProductionRate, tokenInitProduction, and tokenInitConsumption must be set. The SDFIOPort class provides easier access to these parameters.
Note that reconstructing the schedule is expensive, so the schedule is locally cached for as long as possible, and mutations under SDF should be avoided.
Note that this scheduler supports actors with 0-rate ports as long as the graph is not equivalent to a disconnected graph. This scheduler is somewhat conservative in this respect.
Disconnected graphs are supported if the SDF Director parameter allowDisconnectedGraphs is true.
Scheduler
,
SampleDelay
Green (neuendor) |
Green (neuendor) |
NamedObj.ContainedObjectsIterator
Modifier and Type | Field and Description |
---|---|
protected java.util.Map |
_externalRates
Mmaps from external
ports to the number of tokens that that port
will produce or consume in each firing.
|
protected java.util.Map |
_firingVector
A map from actors to an integer representing the
number of times the actor will fire.
|
protected java.util.List |
_rateVariables
The list of rate variables that this scheduler is listening to
for rate changes.
|
Parameter |
constrainBufferSizes
If true, then buffer sizes are fixed according to the schedule,
and attempts to write to the buffer that cause the buffer to
exceed the schedule size result in an exception.
|
VERBOSE
_DEFAULT_SCHEDULER_NAME
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
Constructor and Description |
---|
SDFScheduler()
Construct a scheduler with no container(director)
in the default workspace, the name of the scheduler is
"Scheduler".
|
SDFScheduler(Director container,
java.lang.String name)
Construct a scheduler in the given container with the given name.
|
SDFScheduler(Workspace workspace)
Construct a scheduler in the given workspace with the name
"Scheduler".
|
Modifier and Type | Method and Description |
---|---|
protected void |
_checkDynamicRateVariables(CompositeActor model,
java.util.List rateVariables)
Populate the given set with the dynamic rate variables in the model.
|
protected int |
_computeMaximumFirings(Actor currentActor)
Determine the number of times the given actor can fire, based on
the number of tokens that are present on its inputs.
|
protected int |
_countUnfulfilledInputs(Actor actor,
java.util.List actorList,
boolean resetCapacity)
Count the number of input ports in the given actor that must be
fulfilled before the actor can fire.
|
protected int |
_getFiringCount(Entity entity)
Return the number of firings associated with the given entity.
|
protected Schedule |
_getSchedule()
Return the scheduling sequence.
|
protected void |
_simulateExternalInputs(IOPort port,
int count,
java.util.List actorList,
java.util.LinkedList readyToScheduleActorList)
Simulate the consumption of tokens from the given external input
port.
|
protected boolean |
_simulateInputConsumption(Actor currentActor,
int firingCount)
Simulate the consumption of tokens by the actor during execution of
the given number of firings.
|
protected java.util.Map |
_solveBalanceEquations(CompositeActor container,
java.util.List actorList,
java.util.Map externalRates)
Solve the balance equations for the list of connected Actors.
|
protected void |
_vectorizeFirings(int vectorizationFactor,
java.util.Map entityToFiringsPerIteration,
java.util.Map externalRates)
Multiply all of the repetition rates
by the given vectorizationFactor.
|
java.lang.Object |
clone(Workspace workspace)
Clone the scheduler into the specified workspace.
|
void |
declareRateDependency()
Declare the rate dependency on any external ports of the model.
|
java.util.Map |
getExternalRates()
Get the external port rates.
|
int |
getFiringCount(Entity entity)
Create the schedule.
|
void |
valueChanged(Settable settable)
React to the fact that the specified Settable has changed by
invalidating the schedule.
|
_declareDependency, _saveBufferSizes, _saveContainerRates, _saveFiringCounts
getSchedule, isValid, setContainer, setValid
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _description, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, 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, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
public Parameter constrainBufferSizes
protected java.util.Map _firingVector
protected java.util.Map _externalRates
protected java.util.List _rateVariables
public SDFScheduler()
public SDFScheduler(Workspace workspace)
workspace
- Object for synchronization and version tracking.public SDFScheduler(Director container, java.lang.String name) throws IllegalActionException, NameDuplicationException
container
- The container.name
- The name of this attribute.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.public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
clone
in class Scheduler
workspace
- The workspace for the cloned object.java.lang.CloneNotSupportedException
- If one of the attributes
cannot be cloned.NamedObj.exportMoML(Writer, int, String)
,
NamedObj.setDeferringChangeRequests(boolean)
public void declareRateDependency() throws IllegalActionException
declareRateDependency
in class BaseSDFScheduler
IllegalActionException
- If there is a problem setting
the rate dependency on an external port.public java.util.Map getExternalRates()
public int getFiringCount(Entity entity) throws IllegalActionException
entity
- The entity that is being fired.IllegalActionException
- If thrown by getSchedule().public void valueChanged(Settable settable)
valueChanged
in interface ValueListener
settable
- The object that has changed value.protected void _checkDynamicRateVariables(CompositeActor model, java.util.List rateVariables) throws IllegalActionException
model
- The model.rateVariables
- A list of rate variables. Each element
is a Variable.IllegalActionException
- If throw while looking for dynamic
rate parameters.protected int _computeMaximumFirings(Actor currentActor) throws IllegalActionException
currentActor
- The actor.IllegalActionException
- If the rate parameters are invalid.protected int _countUnfulfilledInputs(Actor actor, java.util.List actorList, boolean resetCapacity) throws IllegalActionException
actor
- The actor.actorList
- The list of actors that we are scheduling.resetCapacity
- If true, then reset the capacity of each
receiver to infinite capacity (do this during initialization).IllegalActionException
- If any called method throws it.protected int _getFiringCount(Entity entity)
entity
- One of the actors we are scheduling.protected Schedule _getSchedule() throws NotSchedulableException, IllegalActionException
_getSchedule
in class Scheduler
NotSchedulableException
- If the rates specified for
the model imply that the model is not statically schedulable.IllegalActionException
- If the rate parameters
of the model are not correct, or the computed rates for
external ports are not correct.CompositeEntity.deepEntityList()
protected java.util.Map _solveBalanceEquations(CompositeActor container, java.util.List actorList, java.util.Map externalRates) throws NotSchedulableException, IllegalActionException
container
- The container that is being scheduled.actorList
- The actors that we are interested in.externalRates
- A map from external ports of container to
the fractional rates of that port. This starts out initialized with
Fraction.ZERO and will be populated during this method.NotSchedulableException
- If the graph is not consistent
under the synchronous dataflow model, or if the graph is not connected.IllegalActionException
- If any called method throws it.protected void _vectorizeFirings(int vectorizationFactor, java.util.Map entityToFiringsPerIteration, java.util.Map externalRates)
vectorizationFactor
- An integer scaling factor to multiply
the firing vector by.entityToFiringsPerIteration
- Map representing the firing vector.externalRates
- Map representing production rates of
external ports.protected void _simulateExternalInputs(IOPort port, int count, java.util.List actorList, java.util.LinkedList readyToScheduleActorList) throws IllegalActionException
port
- The external input port.count
- The number of tokens assumed to be on that port.actorList
- The list of actors.readyToScheduleActorList
- The list of actors that are ready
to be scheduled. This will be updated if any actors that receive
tokens from outputPort are now ready to fire.IllegalActionException
- If thrown while reading a token,
setting the capacity of a receiver or counting unfulfilled input.sprotected boolean _simulateInputConsumption(Actor currentActor, int firingCount) throws IllegalActionException
currentActor
- The actor to be fired.firingCount
- The number of firings.IllegalActionException
- If the rate parameters are invalid.