You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Benjamin Sznajder <be...@il.ibm.com> on 2007/07/17 20:50:51 UTC

Multi-threading with a CAS Multiplier.

Hello,

I built a CPE including a CAS Multiplier with two pipelines of AE:

A CAS enters the CAS Multiplier and is splitted to two different CASes
that, according to their type, are directed to one or the other pipeline.
Currently, one CAS enters the CAS Multiplier, and then one CAS exits the
CAS Mult and passes the whole relevant pipeline, before the second CAS
Multiplier is outputted by the CAS Multiplier and psases the second
pipeline.

I would be interested by parallelism :
I mean that I would like that when the first CAS outputted by the CAS
Multiplier is passing through its relevant pipeline, the second CAS passes
in parallel by its second relevant pipeline.

Is the section 3.7 in the Developper's guide the answer to my question?
Is there any connection (if yes, which one?) with the parameter:
multipleDeploymentAllowed

Regards,

Benjamin


Re: Multi-threading with a CAS Multiplier.

Posted by Adam Lally <al...@alum.rpi.edu>.
On 7/19/07, Benjamin Sznajder <be...@il.ibm.com> wrote:
> <snip/>
> I would like to get your opinion about the following workaround:
> Why don't we hide the steps done by the CAS Multiplier in the Collection
> Reader: the collection reader will read a document of 10 minutes long, and
> will create 10 CASes corresponding to our 5 and 5 CASes of video and speech
> of 2 minutes duration?
> If we do the above, then setting the processingUnitThreadcount to 3 (or
> more) will create three (or more) instances of our AggregateEngine2 and we
> would get real parallelization between our 10 CASes. Do I miss something?
>

That should work.  As Eddie said, the CPE understands Collection
Readers but doesn't know anything about CAS Multipliers.

-Adam

Re: Multi-threading with a CAS Multiplier.

Posted by Benjamin Sznajder <be...@il.ibm.com>.
Hi Adam,

Thanks for your answer. It was clear, do not worry ;-)

I repeat here my question and describe here the scenario we are interested
by :

Let's suppose we have a video document containing for example 10 minutes
long video.

We are interesting by a CPE that :
- separates the document in 10 CASes representing 5 CAS of 2 minutes long
part of video and 5 CAS of 2 minutes long part of speech.
- analyses via relevant pipeline the CAS representing Video and analyses
via relevant pipeline the CAS representing Speech.
- merges theses 10 CASes and sends to the CAS Consumer.
In addition, we would like to gain parallelism. An obvious way to gain it
would be that when a pipeline is analyzing the Video part, then the second
pipeline analyses in parallel the speech part...
That's our scenario...


Our first implementation was as I described:
A CASMultiplier is hidden in an Aggregated Engine  named AE1.
This AE1 contains
      - a CASMultiplier
      - a second AggregateEngine2 controlled by a FlowController composed
of different pipelines.
      - a CAS Merger
      - a CAS Consumer


The problem is exactly as you pointed: "set the processingUnitThreadcount
to 3 is that
you will get three instances of AE1 (and everything inside it).  Then
all three instances of AE1 will be run in parallel on different CASes."
And we have not really parallelism....


If I well understand, the problem comes from the fact that the CAS
Multipier must be hidden in an Aggregate...
I would like to get your opinion about the following workaround:
Why don't we hide the steps done by the CAS Multiplier in the Collection
Reader: the collection reader will read a document of 10 minutes long, and
will create 10 CASes corresponding to our 5 and 5 CASes of video and speech
of 2 minutes duration?
If we do the above, then setting the processingUnitThreadcount to 3 (or
more) will create three (or more) instances of our AggregateEngine2 and we
would get real parallelization between our 10 CASes. Do I miss something?

I hope my note was clear enough....

Best regards,
Benjamin






                                                                           
             "Adam Lally"                                                  
             <alally@alum.rpi.                                             
             edu>                                                       To 
             Sent by:                  uima-user@incubator.apache.org      
             lally.adam@gmail.                                          cc 
             com                                                           
                                                                   Subject 
                                       Re: Multi-threading with a CAS      
             18/07/2007 17:00          Multiplier.                         
                                                                           
                                                                           
             Please respond to                                             
             uima-user@incubat                                             
               or.apache.org                                               
                                                                           
                                                                           




On 7/18/07, Benjamin Sznajder <be...@il.ibm.com> wrote:
> Hi Eddie,
>
> Thank you for your so rapid answer.
>
> Indeed, my CASMultiplier is hidden in an Aggregated Engine  named AE1.
> This AE1 contains
>       - a CASMultiplier
>       - a second AggregateEngine2 controlled by a FlowController composed
> of different pipelines.
>       - a CAS Merger
>       - a CAS Consumer
>
>
> The whole CPM is composed by a CollectionReader, and the AE1
>
> If I define the AggregateEngine2 (i.e the AE that does not contain the
> CASMultiplier) with multipleDeploymentAllowed=true, with each Analysis
> Engine in it, defined also with multipleDeploymentAllowed=true (including
> the FlowController)
> And if, in addition, I set <casProcessors casPoolSize="5"
> processingUnitThreadCount="3">
>
> In such configuration, do I run in parallel on the pipelines contained in
> AggregateEngine2?

What happens when you set the processingUnitThreadcount to 3 is that
you will get three instances of AE1 (and everything inside it).  Then
all three instances of AE1 will be run in parallel on different CASes.

So that means that the CASes coming out of a particular instance of
the CasMultiplier will not be processed in parallel with each other,
but there will be parallelization _across_ CAS Multipliers.

Hopefully that was clear... the key idea is that the CPM is unaware of
CAS Multipliers and will treat AE1 like a black-box 1-CAS-in,
1-CAS-out AE.  So it cannot parallelize _inside_ AE1, but it can
certainly replicate AE1 and run each instance on a separate thread.

-Adam



Re: Multi-threading with a CAS Multiplier.

Posted by Adam Lally <al...@alum.rpi.edu>.
On 7/18/07, Benjamin Sznajder <be...@il.ibm.com> wrote:
> Hi Eddie,
>
> Thank you for your so rapid answer.
>
> Indeed, my CASMultiplier is hidden in an Aggregated Engine  named AE1.
> This AE1 contains
>       - a CASMultiplier
>       - a second AggregateEngine2 controlled by a FlowController composed
> of different pipelines.
>       - a CAS Merger
>       - a CAS Consumer
>
>
> The whole CPM is composed by a CollectionReader, and the AE1
>
> If I define the AggregateEngine2 (i.e the AE that does not contain the
> CASMultiplier) with multipleDeploymentAllowed=true, with each Analysis
> Engine in it, defined also with multipleDeploymentAllowed=true (including
> the FlowController)
> And if, in addition, I set <casProcessors casPoolSize="5"
> processingUnitThreadCount="3">
>
> In such configuration, do I run in parallel on the pipelines contained in
> AggregateEngine2?

What happens when you set the processingUnitThreadcount to 3 is that
you will get three instances of AE1 (and everything inside it).  Then
all three instances of AE1 will be run in parallel on different CASes.

So that means that the CASes coming out of a particular instance of
the CasMultiplier will not be processed in parallel with each other,
but there will be parallelization _across_ CAS Multipliers.

Hopefully that was clear... the key idea is that the CPM is unaware of
CAS Multipliers and will treat AE1 like a black-box 1-CAS-in,
1-CAS-out AE.  So it cannot parallelize _inside_ AE1, but it can
certainly replicate AE1 and run each instance on a separate thread.

-Adam

Re: Multi-threading with a CAS Multiplier.

Posted by Eddie Epstein <ea...@gmail.com>.
Benjamin,

The CPM does not support one of it's AE returning new CASes. The only
CAS that will come out of an AE called by the CPM is the same CAS that
went in.

Otherwise, the answer to you question is yes, with the CPM you could
have one instance of AE1 followed by 3 instances of AE2. CASes
produced by the collection reader would all be serialized through AE1
but then could be processed in parallel by AE2.

Eddie

On 7/18/07, Benjamin Sznajder <be...@il.ibm.com> wrote:
> Hi Eddie,
>
> Thank you for your so rapid answer.
>
> Indeed, my CASMultiplier is hidden in an Aggregated Engine  named AE1.
> This AE1 contains
>       - a CASMultiplier
>       - a second AggregateEngine2 controlled by a FlowController composed
> of different pipelines.
>       - a CAS Merger
>       - a CAS Consumer
>
>
> The whole CPM is composed by a CollectionReader, and the AE1
>
> If I define the AggregateEngine2 (i.e the AE that does not contain the
> CASMultiplier) with multipleDeploymentAllowed=true, with each Analysis
> Engine in it, defined also with multipleDeploymentAllowed=true (including
> the FlowController)
> And if, in addition, I set <casProcessors casPoolSize="5"
> processingUnitThreadCount="3">
>
> In such configuration, do I run in parallel on the pipelines contained in
> AggregateEngine2?
>
> Thanks
> Benjamin.

Re: Multi-threading with a CAS Multiplier.

Posted by Benjamin Sznajder <be...@il.ibm.com>.
Hi Eddie,

Thank you for your so rapid answer.

Indeed, my CASMultiplier is hidden in an Aggregated Engine  named AE1.
This AE1 contains
      - a CASMultiplier
      - a second AggregateEngine2 controlled by a FlowController composed
of different pipelines.
      - a CAS Merger
      - a CAS Consumer


The whole CPM is composed by a CollectionReader, and the AE1

If I define the AggregateEngine2 (i.e the AE that does not contain the
CASMultiplier) with multipleDeploymentAllowed=true, with each Analysis
Engine in it, defined also with multipleDeploymentAllowed=true (including
the FlowController)
And if, in addition, I set <casProcessors casPoolSize="5"
processingUnitThreadCount="3">

In such configuration, do I run in parallel on the pipelines contained in
AggregateEngine2?

Thanks
Benjamin.



                                                                           
             "Eddie Epstein"                                               
             <eaepstein@gmail.                                             
             com>                                                       To 
                                       uima-user@incubator.apache.org      
             17/07/2007 23:24                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         Re: Multi-threading with a CAS      
             uima-user@incubat         Multiplier.                         
               or.apache.org                                               
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hi Benjamin,

The basic UIMA aggregate analysis engine is single threaded, resulting
in the behavior you describe. Multi-threading must be provided by a layer
above a UIMA analysis engine, for example, the CPM.

The parameter multipleDeploymentAllowed is used by the CPM;
when multiple parallel processing pipelines are specified, any components
with multipleDeploymentAllowed=false will not be replicated.

The CPM only supports a single type of Cas multiplier: the collection
reader.
The CPM does not understand Cas multipliers; such components can exist
within an aggregate AE but only the same Cas sent in to an AE from the CPM
can come out of the AE.

Eddie


On 7/17/07, Benjamin Sznajder <be...@il.ibm.com> wrote:
>
> Hello,
>
> I built a CPE including a CAS Multiplier with two pipelines of AE:
>
> A CAS enters the CAS Multiplier and is splitted to two different CASes
> that, according to their type, are directed to one or the other pipeline.
> Currently, one CAS enters the CAS Multiplier, and then one CAS exits the
> CAS Mult and passes the whole relevant pipeline, before the second CAS
> Multiplier is outputted by the CAS Multiplier and psases the second
> pipeline.
>
> I would be interested by parallelism :
> I mean that I would like that when the first CAS outputted by the CAS
> Multiplier is passing through its relevant pipeline, the second CAS
passes
> in parallel by its second relevant pipeline.
>
> Is the section 3.7 in the Developper's guide the answer to my question?
> Is there any connection (if yes, which one?) with the parameter:
> multipleDeploymentAllowed
>
> Regards,
>
> Benjamin
>
>



Re: Multi-threading with a CAS Multiplier.

Posted by Eddie Epstein <ea...@gmail.com>.
Hi Benjamin,

The basic UIMA aggregate analysis engine is single threaded, resulting
in the behavior you describe. Multi-threading must be provided by a layer
above a UIMA analysis engine, for example, the CPM.

The parameter multipleDeploymentAllowed is used by the CPM;
when multiple parallel processing pipelines are specified, any components
with multipleDeploymentAllowed=false will not be replicated.

The CPM only supports a single type of Cas multiplier: the collection reader.
The CPM does not understand Cas multipliers; such components can exist
within an aggregate AE but only the same Cas sent in to an AE from the CPM
can come out of the AE.

Eddie


On 7/17/07, Benjamin Sznajder <be...@il.ibm.com> wrote:
>
> Hello,
>
> I built a CPE including a CAS Multiplier with two pipelines of AE:
>
> A CAS enters the CAS Multiplier and is splitted to two different CASes
> that, according to their type, are directed to one or the other pipeline.
> Currently, one CAS enters the CAS Multiplier, and then one CAS exits the
> CAS Mult and passes the whole relevant pipeline, before the second CAS
> Multiplier is outputted by the CAS Multiplier and psases the second
> pipeline.
>
> I would be interested by parallelism :
> I mean that I would like that when the first CAS outputted by the CAS
> Multiplier is passing through its relevant pipeline, the second CAS passes
> in parallel by its second relevant pipeline.
>
> Is the section 3.7 in the Developper's guide the answer to my question?
> Is there any connection (if yes, which one?) with the parameter:
> multipleDeploymentAllowed
>
> Regards,
>
> Benjamin
>
>