views:

175

answers:

6

My experience thus far has shown me that even with multi-core processors, parallelizing an algorithm won't always speed it up noticably. In fact, sometimes it can slow things down. What are some good hints that an algorithm can be sped up significantly by being parallelized?

(Of course given the caveats with premature optimization and their correlation to evil)

+5  A: 

To gain the most benefit from parallelisation, a task should be able to be broken into similiar-sized course-grain chunks that are independent (or mostly so), and require little communication of data or synchronisation between the chunks.

Fine-grain parallelisation, almost always suffers from increased overheads, and will have a finite speed-up regardless of the number of physical cores available.

[The caveat to this, is those architectures that have a very large no. of 'cores' (such as the connection machines 64,000 cores). These are well suited to calculations that can be broken into relatively simple actions assigned to a particular topology (like a rectangular mesh).]

Mitch Wheat
A: 

Well, if you need lots of locks for it to work, then its probably one of those difficult algorithms that doesn't parallelise well. Is there any part of the algorithm that can be broken up into separate parts that don't need to touch each other?

Chris
+2  A: 

First, check out this paper by the late Jim Gray:

Distributed Computing Economics

Actually, this will clear up some misunderstanding based on what you wrote in the question. Obviously, if the less amenable your problem set is to being discretized, the more difficult it will be.

BobbyShaftoe
+3  A: 

If you can divide the work into independent parts then it may be parallelized well.

Remember also Amdahl's Law which is a sobering reminder of how little we can expect in terms of performances gains by adding more cores to most programs.

Assaf Lavie
I definitely agree here. However, one thing to note, that I think Atwood misses all the time in his blog, is that your program typically competes with other unrelated processes, you can gain from multiple cores here as well. But yes most time is spent int he slowest parts of the code. :)
BobbyShaftoe
+2  A: 

Any time you have computations that depend on previous computations, it is not a parallel problem. Things like linear image processing, brute force methods, and genetic algorithms are all easily parallelized.

A good analogy is what could you work on that you could get a bunch of friends to do different parts at once? For example, putting ikea furniture together might parallelize well if different people can work on different sections, but rolling wallpaper might not because you need to do walls in sequence.

rlbond
+1  A: 

If you're doing large matrix computations, like simulations involving finite element models, these can often be broken down into smaller pieces in straight-forward ways. Matrix-vector multiplies can benefit well from parallelization, assuming you are dealing with very large matrices. Unless there is a real performance bottleneck that is causing code to run slowly, it's probably not necessary to hassle with parallel processing.

gnovice
I can see your logic. This is for a school assignment. I figure if I have time, I'll play around with some parallelization if it's simple to do and gives a significant speed increase. Even if I don't find one, I can look good if I say "Here's something else I tried that didn't work."
Jason Baker