|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.actor.sched.Scheduler
ptolemy.domains.sdf.kernel.BaseSDFScheduler
ptolemy.domains.sdf.kernel.SDFScheduler
public class SDFScheduler
A scheduler that implements basic scheduling of SDF graphs. This class calculates the SDF schedule in two phases. First, the balance equations for the rates between actors are solved to determine the firing vector (also known as the repetitions vector). The firing vector is the least integer solution such that the number of tokens created on each channel of each relation is equal to the number of tokens consumed. In some cases, no solution exists. Such graphs are not executable under SDF.
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.
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, and tokenInitProduction 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
,
Serialized Form
Green (neuendor) |
Green (neuendor) |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj |
---|
NamedObj.ContainedObjectsIterator |
Field Summary | |
---|---|
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. |
private Fraction |
_minusOne
A fraction equal to -1. |
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. |
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 | |
---|---|
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". |
Method Summary | |
---|---|
private void |
_assertDynamicRateVariable(CompositeActor model,
Variable variable,
java.util.List rateVariables,
ConstVariableModelAnalysis analysis)
|
private void |
_checkDirectInputOutputConnection(CompositeActor container,
java.util.Map externalRates)
Update the The external rates of those directly connected input and output ports to be 1. |
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. |
private void |
_init()
Create the parameter constrainBufferSizes and set its default value and type constraints. |
private void |
_listenToRateVariable(Variable variable,
java.util.List rateVariables)
Add this scheduler as a value listener to the given variable and add the variable to the given list. |
private ComponentEntity |
_pickZeroRatePortActor(java.util.List actorList)
Search the given list of actors for one that contains at least one port that has zero rate. |
private void |
_propagatePort(CompositeActor container,
IOPort currentPort,
java.util.Map entityToFiringsPerIteration,
java.util.Map externalRates,
java.util.LinkedList remainingActors,
java.util.LinkedList pendingActors,
java.util.Set clusteredActors,
java.util.Set clusteredExternalPorts)
Propagate the number of fractional firings decided for this actor through the specified port. |
private Schedule |
_scheduleConnectedActors(java.util.Map externalRates,
java.util.List actorList,
CompositeActor container)
Create a schedule for a set of actors. |
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. |
private void |
_simulateTokensCreated(IOPort outputPort,
int createdTokens,
java.util.List actorList,
java.util.LinkedList readyToScheduleActorList)
Simulate the creation of tokens by the given output port when its actor fires. |
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. |
Methods inherited from class ptolemy.domains.sdf.kernel.BaseSDFScheduler |
---|
_declareDependency, _saveBufferSizes, _saveContainerRates, _saveFiringCounts |
Methods inherited from class ptolemy.actor.sched.Scheduler |
---|
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 java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Parameter constrainBufferSizes
protected java.util.Map _firingVector
private Fraction _minusOne
protected java.util.Map _externalRates
protected java.util.List _rateVariables
Constructor Detail |
---|
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.Method Detail |
---|
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.private void _assertDynamicRateVariable(CompositeActor model, Variable variable, java.util.List rateVariables, ConstVariableModelAnalysis analysis) throws IllegalActionException
IllegalActionException
private void _checkDirectInputOutputConnection(CompositeActor container, java.util.Map externalRates)
container
- The container that is being scheduled.externalRates
- A map from external ports of container to
the fractional rates of that port. The external rates of
those directly connected input and output ports will be updated
to be 1 during this method.private void _init()
private void _listenToRateVariable(Variable variable, java.util.List rateVariables)
variable
- A variable, which is a rate variable that this scheduler
uses for scheduling.rateVariables
- A list of rate variables.private ComponentEntity _pickZeroRatePortActor(java.util.List actorList) throws IllegalActionException
actorList
- The list of all of the actors to search.
IllegalActionException
private void _propagatePort(CompositeActor container, IOPort currentPort, java.util.Map entityToFiringsPerIteration, java.util.Map externalRates, java.util.LinkedList remainingActors, java.util.LinkedList pendingActors, java.util.Set clusteredActors, java.util.Set clusteredExternalPorts) throws NotSchedulableException, IllegalActionException
container
- The actor that is being scheduled.currentPort
- The port that we are propagating from.entityToFiringsPerIteration
- The current Map of
fractional firing ratios for each actor. This map will be
updated if the ratio for any actor has not been previously
computed.externalRates
- A map from external ports of container to
the fractional rates of that port. This will be updated
during this method.remainingActors
- The set of actors that have not had their
fractional firing set. This will be updated during this method.pendingActors
- The set of actors that have had their rate
set, but have not been propagated onwards. This will be updated
during this method.clusteredActors
- The set of actors that are within one
cluster, i.e., they are connected.clusteredExternalPorts
- The set of external ports that
are connected with the same cluster of actors.
NotSchedulableException
- If the model is not
schedulable.
IllegalActionException
- If the expression for a
rate parameter is not valid.private Schedule _scheduleConnectedActors(java.util.Map externalRates, java.util.List actorList, CompositeActor container) throws NotSchedulableException
externalRates
- Map from external port to an Integer
representing the number of tokens produced or consumed from
that port during the course of an iteration.actorList
- The actors that need to be scheduled.container
- The container.
NotSchedulableException
- If the algorithm encounters an SDF
graph that is not consistent with the firing vector, or detects an
inconsistent internal state, or detects a graph that cannot be
scheduled.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.private void _simulateTokensCreated(IOPort outputPort, int createdTokens, java.util.List actorList, java.util.LinkedList readyToScheduleActorList) throws IllegalActionException
outputPort
- The port that is creating the tokens.createdTokens
- The number of tokens to create.actorList
- The list of actors that are being scheduled.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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |