|
I have to write an application doing image processing. And I have to run my application as fast as possible. One of techniques to accelerate my program is to write multi thread procedure. I seperate my thread procedure and variable into 2 or 4 threads/set. And do the same calculation. My program is run faster (average 2x faster) on Intel Core 2 Duo compare to Single thread. I will try on Intel Xeon 2 CPUs with Hyper Threading. It should be run faster on Intel Xeon.
The result is no different when I run multi threading program on Intel Pentium 4 with Hyper Threading (sometimes run slower- I don't known why). This may be because Hyper Threading is not a real 2 CPUs in one chip set.
I think this article is useful for someone to get an idea on how to accelerate program. Program should be run on Multi Core Processor (Core 2 Duo, Dual Core,...) to get an improvement.
|
|
|
|
|
ya u will only see the advantage on multi core.
last time multi core was damn expensive, dual xeon is good enough.
nowadays multi-core becoming cheaper and easily own.
good luck.
from,
-= aLbert =-
|
|
|
|
|
Simple logic will dictate that most multiple-thread applications will run faster on a dual-processor machine (whether dual CPU or HyperThreaded). How much faster, though, is heavily dependent on what the threads are actually doing. Just because you have two threads and two processors to run them does NOT mean that your threads will actually be running all the time. Certain operations are going to be serialized -- meaning one thread will be stopped while waiting for the other thread. At the lowest level, the hardware will not allow both processors to write to the exact same memory at the exact same time. At a higher level, if both threads are using the base heap, then all memory allocations/freeing/etc. will be serialized. Unless you specifically call asynchronous API's, your file i/o is going to be serialized. On top of all that, sometimes you are going to have to lock your own threads. If both threads can read AND alter the state of a shared variable, then you are going to have to put a critical section around access to that variable which may block your other thread until access is done. Last, but not least, if the threads aren't identical, or they are identical but the data they are processing is not, then one thread will finish sooner then the other. If your main process cannot continue until both threads are done, then as soon as one thread finishes, you are effectively running a single CPU system again.
There are, of course, ways to optimize all of the above to get as much performance as possible out a dual-process system. Unfortunately, none of those methods are covered by this article. There's also ways to write your code such that it runs differently on a single processor system then on a dual processor system -- again something not touched on by this article. Realizing that a multi-thread application "can" run faster on a dual processor system is the first step. But the real challenge is how to fully take advantage of that -- something that goes far beyond running a profiler to see if your program is faster or not.
|
|
|
|
|
Hi Ralph,
i neither recommend nor commited to ppl that by doing this will bring them to moon.
This article will only shows some light in the tunnel for you, it won't get you far.
Here some tips for you. To take advantage of this type of optimisation, my practice is to do profiling of my application, then target for frequenly used function and especially computational expensive algorithm like compression, image filtering process, n5 correlation, and other morphology process..etc.
Just because you have two threads and two processors to run them does NOT mean that your threads will actually be running all the time
not at all. i only emphasis on those thread which is doing computational expensive stuff.
the hardware will not allow both processors to write to the exact same memory at the exact same time. At a higher level, if both threads are using the base heap, then all memory allocations/freeing/etc. will be serialized. Unless you specifically call asynchronous API's, your file i/o is going to be serialized.
use your common sense. would you optimise those thread which needed to be serialised? tips for you, try optimise those thread which handling with large data and independent input/output. can't be dependent, otherwise u will need to wait for one and/or another.
if the threads aren't identical, or they are identical but the data they are processing is not, then one thread will finish sooner then the other. If your main process cannot continue until both threads are done, then as soon as one thread finishes, you are effectively running a single CPU system again.
that's why i was recommending to those image filtering that i had tried before. for all other stuff, the reader is responsible to try it out themselves. i am not able to cover everything over here. if you have something interesting to share with others, please email me, i will help to post it here for you.
There are, of course, ways to optimize all of the above to get as much performance as possible out a dual-process system. Unfortunately, none of those methods are covered by this article. There's also ways to write your code such that it runs differently on a single processor system then on a dual processor system -- again something not touched on by this article. Realizing that a multi-thread application "can" run faster on a dual processor system is the first step. But the real challenge is how to fully take advantage of that -- something that goes far beyond running a profiler to see if your program is faster or not.
totally agreed on this statement, but this article's title is not "A perfect guide on how to utilise your dual-processor" please double check your statement first before quickly post onto here.
from,
-= aLbert =-
|
|
|
|
|
He didn't like your comment which is why he gave you a '1'. If you had praised his article for being "invaluable and high calibered" and how smart he would like other people to believe he is, he would have given you a '5' (like he gave one of the earlier person).
Anyway, I understand what you're saying, because when I bought my first dual processor machine, I requested several benchmarking be done on it, just to see how it'd perform under various conditions.
One such condition involved having the machine run an application that was multithreaded in order to evaluate speed, time, resource utilization, swapping, and other points of interest (both at kernel mode and user mode).
What was impressive was how expediently the OS was handling a lot of the performance issues that indicated some of the things the application was doing was (sort of) an overkill.
I bought the machine, and have ever since purchased subsequent ones (like every two or three years), and next year I'm thinking of going "QUAD".
Particularly, when you look at the statistics of how the OS handles itself in kernel mode, you realize the algorithms that are responsible for the automatic sharing of workloads, are more sophisticated than anything you can write in your multithreading applications, to enhance performance much better. The flip side of that is, if your multithreaded applications are not properly designed and written, you could be adversely impacting the benefits the OS offers when using a multiprocessor machine.
There are so many points to consider when benchmarking multiprocessor machines, because a lot of the results will depend on the applications it's running.
I understand your article, because some of the things you mentioned, I saw them.
William
Fortes in fide et opere!
|
|
|
|
|
realize the algorithms that are responsible for the automatic sharing of workloads, are more sophisticated than anything you can write in your multithreading applications, to enhance performance much better.
<automatic sharing="" of="" workloads=""> can you show some prove on that? are u nuts? how does the OS learn so quickly and dare to do automatic sharing workloads without impact/effect your application? what u are seeing the benchmarking software does, is already multithreaded with independent input/output data. lets imagine if you have a thread doing computation expensive stuff, will the OS split/share your workload evenly? the answer is NO! so why u said it is more sophisticated than anything? because u will not know the thread was programmed to be serialized.
unless this is done during compilation, the compiler will optimise for u(intel compiler), some single thread will be parallelized. see open mp then you will know what i am saying.
like people don't have the intel compiler. you can use hand-optimise some important function to speed up your application.
from,
-= aLbert =-
|
|
|
|
|
hey.. everyone see how he nonsense. this is how civilized person talk.
from,
-= aLbert =-
|
|
|
|
|
same goes to you. let me try again.
"Could u go other places to sh*t?"
Better??
from,
-= aLbert =-
|
|
|
|
|
Considering that is what your article amounts to, you were the one who started shitting on CodeProject first, "LOW LIFE".
William
Fortes in fide et opere!
|
|
|
|
|
take a mirror and look at yourself. the mirror might crack~!!
1. WREY
Status Gold. Member No. 4650
View Member's Blog.
Messages Posted
(while logged in) 880
Articles Submitted
0
Biography None provided
Location United States
Occupation Software development, Software Components, Research
Interests C++, MFC, ATL, COM, Database
Member since Thursday 6th July, 2000
(4 years, 3 months)
Homepage
Hahaha LOL!
you are contributing more and more!!! got improvement from 871 to 880 msg now. shame u! 880 message posted. and still 0 article submitted.
u judge yourself, who is shitting around. CONGRAT!!
if you realise from now on, you may have "some" hope... pls take ur hope and go away~
from,
-= aLbert =-
|
|
|
|
|
under, "INTERESTING", and it got you nowhere.
As the other poster suggested, let's go with this offline, "LOW LIFE", and I'll deal with you there.
William
Fortes in fide et opere!
|
|
|
|
|
do i need you to remind me that? this is your improvement that u've made, that's why i want someone to look at it. because i am PROUD of u. you are extraordinary, man.. *melting*
yo, how come you delete away your own post in this article? where's your BALLs? where's your mojo? come on, tell us why u wanna do so? must be very shame right? dun worry, again, i am proud of you..
from,
-= aLbert =-
|
|
|
|
|
Since everything MUST be explained to you, I keep forgetting how easy it is for your "LOW LIFE" mind to misinterpret and twist things around.
I started deleting my post to show I was SERIOUS about continuing this lesson offline with you, but then stopped when I realized either you wouldn't have the BALLS to do it, or you might interpret it as me backing off.
Just as I suspected, your twisted "LOW LIFE" mind has misinterpreted it as shame being the reason. If that was true, then I would have continued deleting ALL of them. No "LOW LIFE", I stopped because I just had a feeling you would come up with the same excuse you just did.
So the rest of the post will stay up just to correct your twisted "LOW LIFE" way of thinking, and as for shame, that is something you don't have!!
William
Fortes in fide et opere!
|
|
|
|
|
hey ball less guy.. so call civilized people. i dun have such free time like u do, so the lesson u wanna practice is to try it in front of the mirror.
U made me repeat many many times already, dun u bored? as i said, pls use your time diligently, go and write at least one or more article rather shitting around. dun pollute here and there. u are basically worse than chemical waste. please listen to me k? dun try to be bad.
Hopefully you will become more useful person one day. nah!
from,
-= aLbert =-
|
|
|
|
|
... a senseless misfit of evolution that is seeking ways of enhancing its survival chances. Wait your turn for evolution to catch up with your miserable "LOW LIFE" existence. In the meantime, GO BACK TO YOUR CAVE and cleanse mankind of your pitiful "LOW LIFE" contamination.
One only has to look at what you have written to determine what's worthwhile of it. It's better if you weren't throwing trash around than to claim you have done something meaningful.
It's BETTER to write NO TRASH, than to write one and believe you have done something meaningful and worthwhile (but you wouldn't know that, "LOW LIFE").
William
Fortes in fide et opere!
|
|
|
|
|
u are nothing worth compare to a trash. u are still the same, mojo.. u contribute nothing but less than nothing. plus a bonus, u pollute here and there. u actually have some hope, but u didn't appreciate it. now i think, you can't be saved. may god forgive u one day.
so long..
from,
-= aLbert =-
|
|
|
|
|
You copy!
That's one way you seek to improve your survival chances. You copy! But it's not working!
The other way (you believe) is by mixing with higher forms of existence, ... people!
I used to think it's evolution that has not caught up with you. Now I more believed it's evolution which REJECTED you; left you behind. YOU ARE A REJECT OF EVOLUTION!! There's NOTHING redeemable about you.
You need to go back to your cave and stop contaminating the outside world, you PUTRID MASS OF PROTOPLASMIC PUS.
William
Fortes in fide et opere!
|
|
|
|
|
I dont want to be rude here mate.
If the article doesn't suit your needs then perhaps you might like either fix it yourself or not use it at all.
William mojo, stop shitting here and just go away~ i wonder how your stomach able to contain so much sh*t! u are not listening and continuing shitting. u basically no hope at all. i wonder how you can survive..
what articles have *you* posted, you f***ing loser? (nothing)
What *precisely* have you contributed to the site? (justshit)
from,
-= aLbert =-
|
|
|
|
|
No, "LOW LIFE" it's YOU who is not listening, because you won't go back to your cave, and stay there. Stop trying to mix with species of a higher order. Can't you understand, "Evolution has REJECTED YOU!!!"
You are an EVOLUTIONARY REJECT!!!
In a way I can understand why you're fighting like hell not to go back to your cave. You so DESPARARTELY want to survive.
I will keep fighting like hell to send you back.
William
Fortes in fide et opere!
|
|
|
|
|
do you ever see dead man walking. u won't see it, because u are the one.
your whole body is dead, ur brain is corrupted and malfunction, only left your mouth still shitting... u are evil.
what articles have *you* posted, you f***ing loser? (nothing)
What *precisely* have you contributed to the site? (justshit)
from,
-= aLbert =-
|
|
|
|
|
... and fighting like hell to send you back to your "LOW LIFE" cave.
Ask yourself the same question, "LOW LIFE", "What have YOU contributed?" Nothing but a piece of TRASH that you threw some words together, calling it an article but which only shows your ignorance, because as the other poster stated, "Profiling is Pointless!!!" You didn't get it then, and you still don't get it now. So it is YOU who is the f***ing loser, "LOW LIFE", and the one who is contributing sh*t to the site.
If you say it's sh*t I'm contributing, it's to the piece of TRASH you have posted.
What's worst, is that you are adding more SH*T to the same piece of SH*T you call an article.
You are so f***ing IGNORANT, that you believe only someone who has written a book ought to be able to say something about another book.
I am NOT surprised that you are so f***ing IGNORANT, "LOW LIFE", it's why evolution REJECTED you!!!
I am happy to be contributing sh*t to this piece of SH*T you call an article, and I'm even more thrilled to see you are doing the SAME!!!
Go back to your cave "LOW LIFE" and stop contaminating the world outside. You are a REJECT of EVOLUTION.
William
Fortes in fide et opere!
|
|
|
|
|
supprise! WREY is trying to wakeup from dead..
i know you have gone through the EVOLUTION process. so now times up already, u are dead.
so now your whole body is dead, but unluckily ur mouth somehow can still shitting. it is still an unknown subject over here. all kinds of bacteria and viruses will slowly eating up your body, any finally your mouth will be gone as well. i understand is quite a pain and you are struggling to survive. keep it up WREY!!! you should able to make it through! if you have faith in it, you should try with no end to wakeup from dead.. this is another generation of Mutated Resident Evil.
what articles have *you* posted, you f***ing loser? (nothing)
What *precisely* have you contributed to the site? (justshit)
from,
-= aLbert =-
|
|
|
|
|
You are simply recycling your own sh*t, "LOW LIFE". Copying from me what I've described you to be. That's all you're doing. Copying from me the things I've described you to be. "PROOF" again that you didn't evolve fully. EVOLUTION HAS REJECTED YOU, "LOW LIFE", but you feel that by copying things that I've described you to be, you can FAKE that you're not an EVOLUTIONARY REJECT. No matter how much you try to copy my description of you as an EVOLUTIONARY REJECT, it's NOT going to save you. You are already MARKED!!!
Your article is a piece of TRASH, "LOW LIFE". How many times do I have to say it for you to understand that it's BETTER to write NOTHING, than to write TRASH. Do you understand that, "LOW LIFE"?
It's BETTER TO WRITE NOTHING, THAN TO WRITE TRASH!!!
Somehow you feel that by submitting a piece of TRASH, you can prove that EVOLUTION did not REJECT you. TRASH is TRASH, no matter which way you look at it.
I just love the fact that you know I'm shitting on your article, and even better that you are helping in the process. Keep shitting "LOW LIFE",it's obvious you are used to being shitted upon.
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
You are simply recycling your own sh*t, "LOW LIFE". "PROOF" again that you didn't evolve fully.
exactly what you are doing. well done.
WREY wrote:
It's BETTER TO WRITE NOTHING, THAN TO WRITE TRASH!!!
exactly what you are doing. i love this statement. this is more than well done. (i give u 5 on this!)
what articles have *you* posted, you f***ing loser? (nothing)
what *precisely* have you contributed to the site? (justshit)
from,
-= aLbert =-
ps: do you have anything new? otherwise i am bored already... if u keeping repeating at ur joke, ur joke is not new, i can't laugh anymore. hardly visit your joke next time.
|
|
|
|
|
Granted, for some people, this article might have little or no meaning, while for others, it would be the opposite.
But that's besides the point, because for everyone who reads it, IT SHOULD HAVE MEANING, which is what it lacks.
Look at the article, it premises to show the difference in performance by calculating 'pi' using one thread, and then in another instance by using two threads. Other than saying someone would obtain better result running the sample application on a dual processor machine, there is very little information the author reveals about how he proposes proving his point!! His article did not even say he would be using the calculation of 'pi' as the focus of his experiment. You are learning about this from my message.
The statistics he shows at the end of the article, I'm sure has a lot of meaning to him and his work. But if the reader doesn't understand how they are obtained, and what they represent (singularly, or generally), what's the point?
I had to look through his code to derive understanding of what was happening, because running the sample simply showed the calculation of 'pi' (if you could immediately recognize it), followed by a number after each calculation (for which you'd have to look through the code to learn what they represent). The article explains very precious little, which is why I say it is a very poorly written article.
William
Fortes in fide et opere!
|
|
|
|
|