On Feb 29, 7:13*am, kerravon <kerra...@w3.to> wrote:
> Assuming I am running a C program that is doing some cpu-intensive
> work such as zip -9, I can understand:
>
> If I have 8 CPUs, then it will make no difference at all to the zip
> program, it will only run on one of the CPUs,
C, according to the standard, is not a language that is up to the task
of doing anything about parallel or multithreaded programming. There
has been some interesting research into compilers that perform
automatic conversion of some loops to multithreaded object code, but
these are silly research things that only apply to the most obvious
cases, which LZ compression is *not* an example of.
With pretty much any compiler environment you will get exactly one
core/CPU/thread usage here no matter what.
> [...] although this does allow me to
> run 8 separate zips simultaneously, which would be cool on a large
> site.
If you want to run several instances of zip on something like a
webserver (one per connection), then yes that's fine.
> But what I don't understand is the concept of a "core", as in "dual
> core".
It is essentially the same as dual processor. The difference is more
pronounced on AMD CPUs because they use a shared core-centric memory
controller (this means that memory shared between two different cores
is much faster than between two different processors.) But this is
*way* off topic with respect to the C language specification.
> What implications does that have for a C program like zip?
None.
> [...]*Does it have the ability to look at the instructions ahead of
> time and pipeline them or something? *
That's not what dual core means. The "out of order execution" of
these CPUs is what it allows it to do that (and all the modern stuff
does that on a per CPU basis.)
> [...] Pipelining is something that has been around for
> a long time.
It has. It has nothing to do with dual process or dual core
(excepting in that the concept is to offer more computational
resources.)
> [...]*Did someone just get the bright idea to call it dual
> core instead or what?
Specifically, dual core refers to the specific activity of glueing two
CPU cores into a single microprocessor. Its a chip design thing.
From software's point of view, it should be viewed as if there are
multiple processors in the system.
> Assume the zip in question is written in C89, no fancy parallelism -
> at least not inherent in the language itself.
With such a program, just running one instance of it straight, on
pretty much any contemporary compiler, it means your 8-core machine
will run at one eighth capacity.
To get more performance, you will need 1) To paralellize the algorithm
(its not obvious that can even be done for zip, which is LZ based
compression/decompression) and 2) Use a programming language/compiler
that supports parallelism. Java supports parallelism out of the box,
but many C compilers also support extensions for parallelism support.
--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/