Class PthalesDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.Director
-
- ptolemy.actor.sched.StaticSchedulingDirector
-
- ptolemy.domains.sdf.kernel.SDFDirector
-
- ptolemy.domains.pthales.kernel.PthalesDirector
-
- All Implemented Interfaces:
java.lang.Cloneable
,Executable
,Initializable
,PeriodicDirector
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class PthalesDirector extends SDFDirector
A director for multidimensional dataflow.This is based on Array-OL, as described by:
- Boulet, P. (2007). "Array-OL Revisited, Multidimensional Intensive Signal Processing Specification," Technical Report 6113, INRIA, Orsay, France.
A more detailed documentation of the Pthales domain can be found in a technical report currently under preparation and accessible at:
- Remi Barrere, Eric Lenormand, Dai Bui, Edward A. Lee, Christopher Shaver and Stavros Tripakis, "An Introduction to the Pthales Domain of Ptolemy II, EECS Department, University of California, Berkeley, Technical Report No. UCB/EECS-2011-32, April 26, 2011. (http://www.eecs.berkeley.edu/Pubs/TechRpts/2011/EECS-2011-32.html)
The notation used here is intended to follow the spirit of SpearDE [FIXME: Reference?], from Thales, a software system based on Array-OL. In this notation, unlike Boulet's, dimensions are named, and patterns for reading and writing arrays are given using those names.
[FIXME: the description that follows needs update, the contents and syntax of parameter specs have changed] [FIXME: it seems mostly OK to me (Stavros): I made a mild pass. Please check] The execution is governed by the following parameters in the model. In all cases except for the "repetitions" parameter, the parameters are OrderedRecords of the form "[x = n, y = m, ...]", where x and y are arbitrary dimension names and n and m are non-negative integers. For parameters that supports strides (such as the "pattern" parameter), n and m can be replaced by {n,s} or {m,s}, where s is the stride (a positive integer). The stride defaults to 1 if not specified. Unless otherwise stated, the parameters do not support strides. Ports contain the following parameters:
- size: This is a parameter of each output port that specifies the size of the array written in that output port. All dimensions must be specified. This parameter is optional, as the size of an output array can be deduced from the other parameters. In addition, every input port of a composite actor that contains a PthalesDirector must also have such a parameter. [FIXME: true?]
- base: This mandatory parameter gives the base location (origin) of the output or input array at which an actor begins writing or reading at each iteration of this director. All dimensions must be specified. The order in which they are specified does not matter.
- pattern: This is a parameter of each port that
specifies the shape of the portion of the array produced or consumed
on that port at each firing of the actor within an iteration.
The number of firings of an actor within an iteration is specified
by the "repetitions" parameter of the actor (see below).
Moreover, if an actor reads from or writes to the port
sequentially (using get() and send() methods), then the pattern
specifies the order in which the array is filled.
For example, if you send tokens with values 1, 2, 3, 4, 5, 6
using a pattern [x=3, y=2], then the array is filled as
follows (assuming base=[x=0, y=0]):
x y value 0 0 1 1 0 2 2 0 3 0 1 4 1 1 5 2 1 6 x y value 0 0 1 0 1 2 1 0 3 1 1 4 2 0 5 2 1 6 - tiling: This parameter gives the increment of the base location in each dimension for each successive firing of the actor within an iteration. This is a property of an output or an input port of an actor.
- repetitions: This is a required parameter for every actor in the Pthales domain. It is an array of positive integers of the form "{ k, l, ... }". It specifies the number of times an actor fires within an iteration. This number is equal to the product of all elements in the repetitions vector. So, "{2, 4}" specifies that the actor should fire a total of 2*4=8 times at each iteration. Moreover, this parameter defines a set of nested loops (of depth equal to the length of the array) and the number of iterations of each loop (from the inner to the outer loop). So "{2, 4}" specifies an inner loop with 2 iterations and an outer loop with 4 iterations. There is a one-to-one mapping between the elements of the repetitions array and the fields of the tiling parameters of all ports of the corresponding actor. The body of the inner-most loop specifies the processing that the actor performs on a given pattern, during one firing of the actor within an iteration. A complete execution of the entire nested loop specifies the entire processing of the array by the actor. Thus, each firing of the actor produces or consumes only portions of the array and the complete processing is done by assembling these portions together according to the above parameters.
In all cases, when indexes are incremented, they are incremented in a toroidal fashion, wrapping around when they reach the size of the array. Thus, it is always possible (though rarely useful) for an array size to be 1 in every dimension. [FIXME?]
NOTE: It should be possible to define a PtalesPort and PtalesCompositeActor that contain the above parameters, as a convenience. These could be put in a library.
NOTE: It should be possible to create a single interface for this director so that when double clicked, it brings up an interactive dialog that has the form of a Spear table. It would have one row per port, plus a header row to specify the iterations.
FIXME: Need to export production and consumption data for SDF, allowing these Pthales models to be nested within SDF or within Pthales, which will also allow it to be nested within modal models.
- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Edward A. Lee, Eric Lenormand, Stavros Tripakis
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected StringParameter
_library
Buffer memory.-
Fields inherited from class ptolemy.domains.sdf.kernel.SDFDirector
_iterationCount, _periodicDirectorHelper, allowDisconnectedGraphs, allowRateChanges, AUTO_INTTOKEN, AUTO_NAME, constrainBufferSizes, iterations, ITERATIONS_NAME, period, synchronizeToRealTime, UNBOUNDED_INTTOKEN, UNBOUNDED_NAME, vectorizationFactor
-
Fields inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_postfireReturns, _prefire
-
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _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
Constructors Constructor Description PthalesDirector(CompositeEntity container, java.lang.String name)
Constructs a PthalesDirector object, using PthalesScheduler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attributeChanged(Attribute attribute)
Attribute update.java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.void
fire()
Calculate the current schedule, if necessary, and iterate the contained actors in the order given by the schedule.java.lang.String
getLibName()
Get the name of the library to use.Receiver
newReceiver()
Add a new receiver.boolean
prefire()
Return true if the director is ready to fire.void
preinitialize()
Preinitialize the actors associated with this director and compute the schedule.boolean
transferInputs(IOPort port)
Override the base class method to transfer enough tokens to complete an internal iteration.boolean
transferOutputs(IOPort port)
Override the base class method to transfer enough tokens to fulfill the output production rate.-
Methods inherited from class ptolemy.domains.sdf.kernel.SDFDirector
createSchedule, fireAt, getIterations, getModelNextIterationTime, initialize, periodValue, postfire, suggestedModalModelDirectors, supportMultirateFiring
-
Methods inherited from class ptolemy.actor.sched.StaticSchedulingDirector
_setScheduler, addDebugListener, getScheduler, invalidateSchedule, isScheduleValid, removeDebugListener, resumeActor, setScheduler
-
Methods inherited from class ptolemy.actor.Director
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, _transferOutputs, addInitializable, defaultDependency, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, implementsStrictActorSemantics, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, isStrict, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, scheduleContainedActors, setContainer, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suspend, terminate, transferOutputs, wrapup
-
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, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addHierarchyListener, 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, removeHierarchyListener, 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
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
Methods inherited from interface ptolemy.actor.util.PeriodicDirector
isEmbedded
-
-
-
-
Field Detail
-
_library
protected StringParameter _library
Buffer memory.
-
-
Constructor Detail
-
PthalesDirector
public PthalesDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Constructs a PthalesDirector object, using PthalesScheduler.- 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
Attribute update.- Overrides:
attributeChanged
in classSDFDirector
- Parameters:
attribute
- The changed parameter.- Throws:
IllegalActionException
- If the parameter set is not valid.- See Also:
SDFDirector.attributeChanged(ptolemy.kernel.util.Attribute)
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace. The new object is not added to the directory of that workspace (you must do this yourself if you want it there). The result is an object with no container.- Overrides:
clone
in classSDFDirector
- Parameters:
workspace
- The workspace for the cloned object.- Returns:
- The new object.
- Throws:
java.lang.CloneNotSupportedException
- Not thrown in this base class- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Calculate the current schedule, if necessary, and iterate the contained actors in the order given by the schedule. 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. NOTE: This method does not conform with the strict actor semantics because it calls postfire() of actors. Thus, it should not be used in domains that require a strict actor semantics, such as SR or Continuous.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classSDFDirector
- Throws:
IllegalActionException
- If any actor executed by this actor return false in prefire.InvalidStateException
- If this director does not have a container.
-
getLibName
public java.lang.String getLibName() throws IllegalActionException
Get the name of the library to use.- Returns:
- the name of the library to use.
- Throws:
IllegalActionException
-
newReceiver
public Receiver newReceiver()
Add a new receiver.- Overrides:
newReceiver
in classSDFDirector
- Returns:
- A new SDFReceiver.
-
prefire
public boolean prefire() throws IllegalActionException
Return true if the director is ready to fire.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classSDFDirector
- Returns:
- true If all of the input ports of the container of this director have enough tokens.
- Throws:
IllegalActionException
- If the port methods throw it.
-
preinitialize
public void preinitialize() throws IllegalActionException
Preinitialize the actors associated with this director and compute the schedule. 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.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classSDFDirector
- Throws:
IllegalActionException
- If the preinitialize() method of one of the associated actors throws it.
-
transferInputs
public boolean transferInputs(IOPort port) throws IllegalActionException
Override the base class method to transfer enough tokens to complete an internal iteration. If there are not enough tokens, then throw an exception. If the port is not connected on the inside, or has a narrower width on the inside than on the outside, then consume exactly one token from the corresponding outside channels and discard it. Thus, a port connected on the outside but not on the inside can be used as a trigger for an SDF composite actor.- Overrides:
transferInputs
in classSDFDirector
- Parameters:
port
- The port to transfer tokens from.- Returns:
- True if data are transferred.
- Throws:
IllegalActionException
- If the port is not an opaque input port, or if there are not enough input tokens available.
-
transferOutputs
public boolean transferOutputs(IOPort port) throws IllegalActionException
Override the base class method to transfer enough tokens to fulfill the output production rate. This behavior is required to handle the case of non-homogeneous opaque composite actors. The port argument must be an opaque output port. If any channel of the output port has no data, then that channel is ignored.- Overrides:
transferOutputs
in classSDFDirector
- Parameters:
port
- The port to transfer tokens from.- Returns:
- True if data are transferred.
- Throws:
IllegalActionException
- If the port is not an opaque output port.
-
-