PDA

View Full Version : qt algorithm speed up problem



leonardhead
20th August 2010, 02:04
Hello,

I have a problem of parallel 3 different algorithm, I want to use the qthread to run this 3 algorithm at the same time.

if i run them in sequence, it will cost 12mins 12 mins and 17 mins which is 41 mins totally.

I tried the QThread to let them run at the same time, the cpu usage shows that they are running at the same time. However, it cost me 2 hours to finish the whole process.

I am just wondering is there anyway to run 3 different algorithm at the same time, and fast speed.


thank you

tbscope
20th August 2010, 06:08
That should not be happening.
Can you provide a compilable demonstration? (if possible)

antialias
20th August 2010, 08:04
If your algorithms are all accessing/changing the same data then you will not see much of a speedup (you will probably see a significant slowdown as the data needs to be locked while one thread is operating on it - to ensure that the data isn't changed by another thread at the same time). This can cause significant overhead from the thread class. It shouldn't double the runtime, though, unless you are performing only micro-calculations after each data access (i.e. if the overhead of thread locking/unlocking is greater than the actual calculation done in each such interval by your algorithms).

Thread safety (http://en.wikipedia.org/wiki/Thread_safety)

As a final note: threads (for speedup) only make sense if you have a multi-core CPU. Otherwise threads are just useful as a method for keeping the GUI from freezing (at the cost of performance of underlying calculations).

leonardhead
27th August 2010, 01:03
That should not be happening.
Can you provide a compilable demonstration? (if possible)

you mean the code? I can forward you the svn branch of my code if you like