[kepler-users] PN domain multiports
Christopher Brooks
cxh at eecs.berkeley.edu
Thu Sep 15 11:55:15 PDT 2011
Hi Kasia,
Looking at ptolemy/domains/pn/kernel/PNDirector.java, I believe that the
algorithm works
on a per-receiver basis, so it should block only when there is no data
on all the channels of
a multiport. Edward might have some input here, but that is my
understanding.
See also the PN chapter in
"Heterogeneous Concurrent Modeling and Design in Java (Volume 3: Ptolemy
II Domains)" at
http://www.eecs.berkeley.edu/Pubs/TechRpts/2008/EECS-2008-37.html
There are some tests that involve multiports with width greater than 1 in
ptolemy/domains/pn/test/auto/WidthInferenceTest*.xml
I've attached a model that has a Const and a Ramp going to a Commutator.
The Const has its firingCountLimit set to 1.
The Ramp has its firingCountLimit set to 50 because if firingCountLimit
is set to NONE,
then the PN Director will throw
ptolemy.kernel.util.IllegalActionException: Queue size 131072 exceeds
the maximum capacity in port .PNMultiport.Commutator.input. Perhaps you
have an unbounded queue?
in .PNMultiport.PN Director
at
ptolemy.domains.pn.kernel.PNDirector._incrementLowestWriteCapacityPort(PNDirector.java:482)
at
ptolemy.domains.pn.kernel.PNDirector._resolveInternalDeadlock(PNDirector.java:549)
at
ptolemy.actor.process.CompositeProcessDirector._resolveDeadlock(CompositeProcessDirector.java:719)
at ptolemy.actor.process.ProcessDirector.fire(ProcessDirector.java:259)
at ptolemy.actor.CompositeActor.fire(CompositeActor.java:458)
at ptolemy.actor.Manager.iterate(Manager.java:742)
at ptolemy.actor.Manager.execute(Manager.java:351)
at ptolemy.actor.Manager.run(Manager.java:1111)
at ptolemy.actor.Manager$PtolemyRunThread.run(Manager.java:1641)
I modified the development version of PNDirector to indicate which port
is causing the problem
and it looks like what happens when firingCountLimit is NONE is that the
Ramp produces
data and the Commutator fails to read from the Ramp because there is no
token on the
channel connected to the Const port.
Commutator's fire() method indicates what happens when data is not
available:
/** Read <i>blockSize</i> tokens from each input channel and send them
* to the output port. If an input channel does not have enough
* tokens, suspend firing
* and return. In this case, the actor makes a record of the
* input channel that it last attempted to read so that it can
* start reading at that channel in the next iteration. The
* order in which the tokens are produced is the order of the
* channels in the input port.
*
* @exception IllegalActionException If there is no director.
*/
public void fire() throws IllegalActionException {
super.fire();
_tentativeInputPosition = _currentInputPosition;
int width = input.getWidth();
int blockSizeValue = ((IntToken) blockSize.getToken()).intValue();
for (int i = 0; i < width; i++) {
if (!input.hasToken(_tentativeInputPosition, blockSizeValue)) {
break;
}
Token[] inputs = input.get(_tentativeInputPosition++,
blockSizeValue);
output.send(0, inputs, blockSizeValue);
if (_tentativeInputPosition >= width) {
_tentativeInputPosition = 0;
}
}
}
A better answer to your question might be: The Ptolemy II PNDirector
works on a per-channel
basis, so a multiport blocks on a per-channel basis, but it depends on
how the actor
is written. Most actors expect data on each channel and read
sequentially. Some actors,
such as NondeterministicMerge read from channels that have data and skip
channels
that do not have data.
See PNMultiportNondeterministicMerge.xml for a model that has the Const with
a firingCountLimit of 1 and the Ramp with a firingCountLimit of 50.
Note that PN cannot handle a relation with multiple sources connected to
the relation.
PNDirector says:
/** Override the base class to reset the capacities of all the
receivers.
* @exception IllegalActionException If the superclass throws it.
*/
public void preinitialize() throws IllegalActionException {
super.preinitialize();
// Check that no relation has multiple sources of data
connected to it.
// FIXME: This only detects the error at this level of the
hierarchy.
// Probably need to recursively descend into composite actors.
CompositeEntity container = (CompositeEntity) getContainer();
Iterator relations = container.relationList().iterator();
while (relations.hasNext()) {
IORelation relation = (IORelation) relations.next();
if (relation.linkedSourcePortList().size() > 1) {
throw new IllegalActionException(relation,
"Relation has multiple sources of data,"
+ " which is not allowed in PN."
+ " If you want nondeterministic merge,"
+ " use the NondeterministicMerge actor.");
}
}
...
_Christopher
On 9/15/11 7:50 AM, Katarzyna Bylec wrote:
> Hello,
>
> I'm working on some problem from PN domain and while designing the
> solution I'd like to make it clear what's the blocking algorithm
> concerning multiports.
>
> I more detail - I have a multiport input. Does the containing actor
> write blocks when there's no data on the channel it tries to read from
> or can it move to another channel in this port and blocks only when
> there's no data in all channels?
>
> Regards,
> Kasia
--
Christopher Brooks, PMP University of California
CHESS Executive Director US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774
ph: 510.643.9841 (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PNMultiport.xml
Type: text/xml
Size: 8104 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20110915/3ecc4299/attachment.xml>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PNMultiportNondeterministicMerge.xml
Type: text/xml
Size: 5445 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20110915/3ecc4299/attachment-0001.xml>
More information about the Kepler-users
mailing list