Re: dual core and c



On Feb 29, 7:13 am, kerravon <kerra...@xxxxx> 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/
.



Relevant Pages

  • Re: Fritz 9 & Dual core PCs ..
    ... >>>does anyone know what, if any, use Fritz9 will make of Dual core CPUs ... But the combined number-crunching power of the two ...
    (rec.games.chess.computer)
  • Re: G4 vs. G5 w/ProTools?
    ... Which brings up imac vs. tower if I buy a g5 now. ... Can anyone explain dual core vs. dual processor? ... With the cost of two CPUs and a motherboard capable ... There were dual processor G4s but they were discontinued some time ago. ...
    (rec.audio.pro)
  • Re: Column: Should you build or buy a new Media Center PC?
    ... be benefits to having dual CPUs or dual cores. ... Athlon 64 with a dual core Athlon, someday, when the price comes down. ... I am thinking of building a MCE PC from the guts of a Dell ... > workstation that is dual processor capable, with a single Xeon 2.8 GHz ...
    (microsoft.public.windows.mediacenter)
  • Re: G4 vs. G5 w/ProTools?
    ... Can anyone explain dual core vs. dual processor? ... With the cost of two CPUs and a motherboard capable ... CPUs, combine them onto one chip, and harness the power of two CPUs ... There were dual processor G4s but they were discontinued some time ago. ...
    (rec.audio.pro)
  • Re: Column: Should you build or buy a new Media Center PC?
    ... > CPUs. ... > Athlon 64 with a dual core Athlon, someday, when the price comes down. ... I am thinking of building a MCE PC from the guts of a Dell ... >> workstation that is dual processor capable, with a single Xeon 2.8 GHz ...
    (microsoft.public.windows.mediacenter)