euglug.org

[Eug-lug] SWEET CRAP! O_O

작성자

카테고리:



Bob MillerMon Sep 12 23:05:14 PDT 2005

fleming.j at comcast.net wrote:

> Why is it that only a single processor can solve these problems and
> can you site some examples. I find this very interesting stuff
> because I have allways thought multi cpu / clusters would allways be
> better problem solvers, though now that you got me actually thinking
> about it thats just dumb. Also sometime this week I will recieve my
> new box: Ghostwheel (A sort of cosmic computer with a personality
> from Roger Zelazny's Amber series), and i will probably end up
> putting in a water cooler and overclocking it, also trying various
> raid arrays with it too.

Sometimes you have a loop where the n'th value depends on all the
previously calculated values.

Here's a very simple example from digital signal processing called an
IIR filter.  IIR is short for Infinite Impulse Response, which means
that its response to any input sample lasts forever.  That's theory --
in real life, quantization error eventually drives the response to
zero.  So it's not REALLY infinite, and it's not REALLY
unparallelizable, but I can't think of a better example that fits on
one page.

In Python, of course... (-:

	f = 0.9999
	output = []
	accum = 0.0
	for sample in input:
	    accum = f * accum + (1 - f) * sample
	    output.append(accum)

As you can see, you can't calculate the 1,000,000th value of accum
until you've calculated the 999,999th value.  So you can't
simultaneously have one CPU calculate output[0..999999] while another
calculates output[1000000..1999999].

That's the basic idea.  Also, sometimes a program is largely
parallelizable, but certain parts are not.  In those cases, a
sufficiently large cluster will spend very little time in the
parallelizable code, and spend all its time waiting on one CPU for the
part that has to be serial.  This is called the "Von Neumann
Bottleneck".  Wikipedia explains it pretty well.

http://www.google.com/url?sa=t&ct=res&cd=1&url=http%3A//en.wikipedia.org/wiki/Von_Neumann_architecture&ei=s2omQ7-sA7GiiwGQ0KmeDg

I once wrote a ray tracer for the Convex C-series vector processor.  I
got the whole ray tracer to vectorize (similar to parallelizing, but
with some extra constraints) except for one loop that looked at each
ray after each intersection test and added it to a queue of rays
to be processed.  That loop looked roughly like this (but in C).

	for ray in list:
	    if not ray.hit_something:
		object[ray.next_obj].work_queue.append(ray)

That loop accounted for 30% of the ray tracer's runtime, but
only about 0.3% of the total calculation.  A vivid example of
the Von Neumann Bottleneck.

-- 
Bob Miller                              K<bob>
kbobsoft software consulting
http://kbobsoft.com                     kbob at jogger-egg.com