Re: dual core and c
- From: Eric Sosman <Eric.Sosman@xxxxxxx>
- Date: Fri, 29 Feb 2008 10:57:50 -0500
kerravon 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, although this does allow me to
run 8
separate zips simultaneously, which would be cool on a large site.
But what I don't understand is the concept of a "core", as in "dual
core".
<off-topic>
What's usually meant is that a "core" is most of a CPU,
so a "dual-core" processor has two CPUs on one chip, an
eight-core processor has eight, and so on. It's not quite
as hard-and-fast as that, because the chip usually has some
components that are shared by all the cores but that would
be per-CPU resources in a traditional design: Caches, memory
controllers, I/O ports, and so on. But to some fuzzy level
of approximation, a core is a CPU.
</off-topic>
What implications does that have for a C program like zip? Does it
have the ability to look at the instructions ahead of time and
pipeline
them or something? Pipelining is something that has been around for
a long time. Did someone just get the bright idea to call it dual
core
instead or what?
<off-topic>
This is a question for a computer architecture forum,
not a question about a programming language.
</off-topic>
Assume the zip in question is written in C89, no fancy parallelism -
at
least not inherent in the language itself.
<ON-topic>
The C language is defined in terms of an abstract machine
whose operations are almost entirely sequential. ("Almost"
because there are a few grudging nods toward asynchronous
activities -- signals, some uses of `volatile' -- and because
there's some leeway between "sequence points.") Thus, the C
language itself is almost entirely sequential; there's no
built-in way to express parallelism.
However, implementations of C are not required to model
the abstract machine in every detail. A principle called
the "as-if rule" allows an actual C implementation to play
all manner of optimization games, provided the ultimate outcome
is "as if" the abstract machine had performed the computation.
So if a compiler can detect opportunities for parallelism in a
C program, it's free to exploit those opportunities if it can.
But the C language itself gives you no way to control this --
indeed, by the way "as if" works, it gives you no way to
detect that something has been parallelized.
</ON-topic>
--
Eric.Sosman@xxxxxxx
.
- References:
- dual core and c
- From: kerravon
- dual core and c
- Prev by Date: Re: dual core and c
- Next by Date: Re: dual core and c
- Previous by thread: Re: dual core and c
- Next by thread: Re: dual core and c
- Index(es):
Relevant Pages
|