[kepler-dev] Multiple Threads per Actor

Norbert Podhorszki pnorbert at cs.ucdavis.edu
Thu Jun 7 11:09:03 PDT 2007

Hi Jared,

Ptolemy's MultiInstanceComposite actor enables you to create several 
instances of the same (composite) actor. But you need to take care of 
their connections into the rest of the workflow.

I use the combo of

   Distributor - MultiInstanceComposite - NondeterministicMerge

       - ptolemy.actor.lib.Distributor
       - ptolemy.actor.lib.hoc.MultiInstanceComposite
       - ptolemy.domains.pn.kernel.NondeterministicMerge

actors. You can put your subworkflow/actor into MultiInstanceComposite
(with its own director, usually an SDF). You then define the number of 
instances you want to be created for that part.

Note that in the above structure, because of the NondeterministicMerge, 
the order of the output tokens is likely not the same as the incoming 

If you use Commutator (ptolemy.actor.lib.Commutator) instead, the order of 
tokens is kept. As long as your actor is balanced (execution time is 
always more-or-less the same) and _always_ consumes/produces 1 token this 
is the perfect solution.

Find attached a test example workflow with the latter 
(distributor-commutator) structure.

Finally, note that your actor instances have their own receiver queues and
the distributor blindly sends the tokens to them in a round-robin manner.
So no load-balancing is possible here with this structure. And faster 
instances may start working earlier on a (later) token while (preceeding) 
tokens are still sitting in the queues of their assigned instances.

Best regards

      Norbert Podhorszki
      University of California, Davis
      Department of Computer Science
      1 Shields Ave, 2236 Kemper Hall
      Davis, CA 95616
      (530) 752-5076
      pnorbert at cs.ucdavis.edu

On Thu, 7 Jun 2007, Chase, Jared M wrote:
> Hello,
> I created an iterative workflow that uses the Ramp actor with the PN
> Director. I would like to design the workflow so that each iteration is
> executed at the same time in parallel. I noticed that when using the PN
> Director that (as documented) one thread is assigned to each actor. I
> was trying to figure out how to that I could allow each iteration to
> invoke the same set of actors all within different threads.
> Is there any way to allow multiple invocations (multiple threads) of the
> same actor to execute at the same time in parallel?
> Thanks for your help!
> Jared
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TaskParallelExecMulti.xml
Type: text/xml
Size: 8952 bytes
Url : http://mercury.nceas.ucsb.edu/ecoinformatics/pipermail/kepler-dev/attachments/20070607/89377d91/TaskParallelExecMulti.xml

More information about the Kepler-dev mailing list