[Interest] QtConcurrent programming need help

Sujan Dasmahapatra sujan.dasmahapatra at gmail.com
Thu Sep 27 21:13:50 CEST 2012


Thanks a lot Philippe. I'll look into the link u gave. Thanks a lot for
your help. Thanks Sujan

On Thu, Sep 27, 2012 at 9:49 PM, Philipp Menke <philipp.menke at freenet.de>wrote:

> Am 27.09.2012 20:32, schrieb Sujan Dasmahapatra:
> > I am working on an existing application where  threads are submitted
> > concurrently. he is submitting 8 threads together and then he is
> > waiting for all 8 threads to be finished to submit the next 8 threads.
> > In this way after every 8 threads he is waiting and a lot of time is
> > being taken for waiting. Can you me some suggestions how can I skip
> > this waiting after submitting 8 threads to improve speed. Total number
> > of cpu is 8 so he is submitting 8 threads at  a time.
> > Submitting threads like this
> > int nCpus = Environment::Get_No_Of_Cpus(); // ==8
> > for(z=0; z<21; z++)
> > {
> > for (int cpuID=0; cpuID<nCpus; cpuID++)
> > {
> > Th = QtConcurrent::run(this, zLayerFunction,z,...,cpuID);
> > Threads.push_back(Th);
> > }
> > //then he after submitting 8 threads, he is waiting for all 8 threads
> > to be finished to submit the next 8 threads.
> > for(int th=0; th<Threads.size(); th++ )
> > {
> >      Threads.at(th).waitForFinished();
> >      Threads.cancel();
> > }
> > Threads.clear();
> > z--;
> > }
> > How can i improve the speed so that it doesn't wait. How can I make it
> > continuous. Any suggestions would be highly appreciated. Thanks Sujan
> Try a Thread-Pool-Pattern. So you got a queue where all work to be done
> is stored. As soon as one Thread is finished he checks the queue for new
> work.
> If you have unindependent work (so step 2,3 and 4 require 1 to be
> already done) you can push 2,3 and 4 to the pool as last step of 1.
>
> This approach has several positive effects:
> - You need the time for starting the workers just one time.
> - There is a way to deal with dependencies between steps.
> - You got full usage of your hardware for your tasks (ignoring time to
> manage pool)
>
> here is the Wikipedia-artical on that pattern:
> http://en.wikipedia.org/wiki/Thread_pool_pattern
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>



-- 
Regards
Sujan Dasmahapatra
skype: sujan.dasmahapatra
yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
Mobile no : +966-530184511
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120927/f0cd7536/attachment.html>


More information about the Interest mailing list