* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-08 4:00 ` brianh
1997-10-08 4:00 ` David Chase
@ 1997-10-08 4:00 ` William Clodius
[not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
3 siblings, 0 replies; 99+ messages in thread
From: William Clodius @ 1997-10-08 4:00 UTC (permalink / raw)
Robert Harley wrote:
> <snip>
>
> I think your problem is that C is too flexible for you. It doesn't
> wrongly assume that there is one way of laying out and accessing
> arrays that is appropriate for all purposes.
There are two points here, how arrays are laid out, and how they are
accessed. The compiler/machine determines how they are laid out (given
additional restrictions implicit in the code or language), the
programmer determines how they are accessed. Fortran has fewer
assumptions about how the machine lays out memory than C does. It allows
users the same flexibility in access that C does, at least for teh
examples that you give.
> For instance you can
> choose a flat array, 'float *a', or a hierarchy like 'float ***a'.
>
> Suppose you choose the flat array, Fortran style.
>
> You can access a_{i,j,k} as a[(i*n+j)*m+k] or several other linear
> combinations depending on whether you like row-wise or column-wise
> access or whatever. Your hand isn't forced like in Fortran.
Fortran doesn't force this, it simply povides a less error prone, more
easilly understood and optimized construct for doing the equivalent.
>
> If you're doing simple constant-stride access, decent compilers will
> strength-reduce the multiplications just like decent Fortran compilers
> (or the pre-mungers that they often require to get top performance).
As KAI about pre-mungers for C/C++.
>
> However a non-trivial access pattern will use a lot of slow
> multiplications, just like in Fortran. In that case you have the
> option of strength-reducing by hand if you know better than the compiler.
Same in Fortran.
>
> Also, this often forces you to waste a lot of space, doubling the size
> of triangular matrices with useless zeroes, increasing the size of
> simplicial 3D arrays sixfold etc., just like in Fortran.
Fortran does not require the initialization of unused space.
>
> Furthermore to swap rows, you have to swap all the elements, which
> takes forever just like in Fortran.
>
> Suppose that you choose a hierarchy instead.
>
> Then non-trivial access patterns require pointer accesses, however
> these are typically fast since the number of pointers is very small
> compared to the size of the data. For instance on this Alpha with a
> 100x100x100 array the top level fits in L1 cache easily, the second
> level in L2, whereas the data is twice as big as L3.
Same in Fortran
>
> Also you can allocate exactly as much memory as you want or need.
Same in Fortran
>
> Furthermore you can swap rows (or columns) with a single pointer swap.
Try Fortran array operations, not as good as APL but still... or Fortran
POINTER's
>
> In some cases the former is best, in others the latter. Of course, C
> also lets you choose intermediate layouts such as an array 'float **a'
> of pointers to rectangular matrices, if that is best for your
> application. Perhaps you'd like to tag those sub-matrices with their
> dimensions:
>
> typedef struct { int width, height; float *data; } rectMatWithSizes;
> rectMatWithSizes funky[100];
Different syntax using derived types in Fortran
TYPE rectMatWithSizes
INTEGER :: width, height
REAL, POINTER :: data(:)
END TYPE
TYPE(rectMatWithSizes) :: funky
ALLOCATE(funky%data(100))
>
> and set it up whatever way you like. In other languages you might be
> forced to use training wheels, or you might be lucky enough to be
> permitted to hack up some imitation of the C style. I'd just use C.
> <snip>
I'll take a language that lets you say more things more clearly.
--
William B. Clodius Phone: (505)-665-9370
Los Alamos Nat. Lab., NIS-2 FAX: (505)-667-3815
PO Box 1663, MS-C323 Group office: (505)-667-5776
Los Alamos, NM 87545 Email: wclodius@lanl.gov
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 Final kick at the "Merced Guessing Game" Robert Harley
@ 1997-10-08 4:00 ` brianh
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` Final kick at the "Merced Guessing Game" Gregg E Economou
1997-10-08 4:00 ` David Chase
` (2 subsequent siblings)
3 siblings, 2 replies; 99+ messages in thread
From: brianh @ 1997-10-08 4:00 UTC (permalink / raw)
In article <61g30t$o2n@news-rocq.inria.fr>,
Robert Harley <harley@pauillac.inria.fr> wrote:
>
>I think your problem is that C is too flexible for you. It doesn't
>wrongly assume that there is one way of laying out and accessing
>arrays that is appropriate for all purposes. For instance you can
>choose a flat array, 'float *a', or a hierarchy like 'float ***a'.
Speaking as someone who is writting a math library in C (in his free time,
but I'm actively grappling with these exact issues), also as someone
who hardly knows Fortran, this _SUCKS_. You are forced to either:
1) Only accept predefined sized matricies- generally not an option
2) Every time you access the array either type in the whole address
equation or use a macro (hideous and it tends to make the code hard to
read).
3) In addition to allocating and managing the matrix, also allocate and
manage arrays of pointers into the matrix (with resulting overhead and
additional complexity). This also kills any locality of reference
you're attempting to maintain. This thread started with the hw engineers
complaining that C does too much pointer chasing already.
4) Depend upon non-portable compiler-specific constructs.
The problem I have found with C's "flexibility" is that most of the time
it amounts to "Hey, not only can you reinvent the wheel, you have too!
But if, for some braindamaged reason, you want to reinvent the wheel as
a _square_ instead of the generally accepted circle, it lets you do that
as well!"
There are situations where you need to play pointer games (my day job is
writing device drivers). But it's hard to call being forced to play
pointer games an "advantage".
I don't speak for Bit 3.
Brian
--
"NT and security should never be used in the same breath."
- Winn Schwartau, EETimes #972, 22 September 1997 pp.96
-Brian
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 ` brianh
@ 1997-10-08 4:00 ` boo
1997-10-09 4:00 ` Eric Hildum
` (2 more replies)
1997-10-09 4:00 ` Final kick at the "Merced Guessing Game" Gregg E Economou
1 sibling, 3 replies; 99+ messages in thread
From: boo @ 1997-10-08 4:00 UTC (permalink / raw)
brianh@bit3.com wrote:
>
> In article <61g30t$o2n@news-rocq.inria.fr>,
> Robert Harley <harley@pauillac.inria.fr> wrote:
> >
> >I think your problem is that C is too flexible for you. It doesn't
> >wrongly assume that there is one way of laying out and accessing
> >arrays that is appropriate for all purposes. For instance you can
> >choose a flat array, 'float *a', or a hierarchy like 'float ***a'.
>
> Speaking as someone who is writting a math library in C (in his free time,
> but I'm actively grappling with these exact issues), also as someone
> who hardly knows Fortran, this _SUCKS_.
The first time you play with multi-dimensional "arrays" in C, it is
difficult and frustrating. These are much easier in Fortran for the
uninitiated, and Fortran surely is the language of choice for many
scientists and engineers. Once you have understood exactly how to implement
multiple dimensional "arrays" in C efficiently and have gained
some experience, it doesn't "suck" anymore, and you will understand
exactly how flexible C actually is. But it isn't for amateurs,
or for the Ivory Tower Set of this thread.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-08 4:00 Robert Harley
1997-10-08 4:00 ` brianh
` (3 more replies)
0 siblings, 4 replies; 99+ messages in thread
From: Robert Harley @ 1997-10-08 4:00 UTC (permalink / raw)
xcc@hilbert.ncsc.org (Carlie Coats) writes:
>When I'm programming in C or C++, why the *_hell_* can't
>I do easy things like
>
> void foo( const int m,
> const int n,
> const int p,
> float a[p][n][m] ) {...}
I think your problem is that C is too flexible for you. It doesn't
wrongly assume that there is one way of laying out and accessing
arrays that is appropriate for all purposes. For instance you can
choose a flat array, 'float *a', or a hierarchy like 'float ***a'.
Suppose you choose the flat array, Fortran style.
You can access a_{i,j,k} as a[(i*n+j)*m+k] or several other linear
combinations depending on whether you like row-wise or column-wise
access or whatever. Your hand isn't forced like in Fortran.
If you're doing simple constant-stride access, decent compilers will
strength-reduce the multiplications just like decent Fortran compilers
(or the pre-mungers that they often require to get top performance).
However a non-trivial access pattern will use a lot of slow
multiplications, just like in Fortran. In that case you have the
option of strength-reducing by hand if you know better than the compiler.
Also, this often forces you to waste a lot of space, doubling the size
of triangular matrices with useless zeroes, increasing the size of
simplicial 3D arrays sixfold etc., just like in Fortran.
Furthermore to swap rows, you have to swap all the elements, which
takes forever just like in Fortran.
Suppose that you choose a hierarchy instead.
Then non-trivial access patterns require pointer accesses, however
these are typically fast since the number of pointers is very small
compared to the size of the data. For instance on this Alpha with a
100x100x100 array the top level fits in L1 cache easily, the second
level in L2, whereas the data is twice as big as L3.
Also you can allocate exactly as much memory as you want or need.
Furthermore you can swap rows (or columns) with a single pointer swap.
In some cases the former is best, in others the latter. Of course, C
also lets you choose intermediate layouts such as an array 'float **a'
of pointers to rectangular matrices, if that is best for your
application. Perhaps you'd like to tag those sub-matrices with their
dimensions:
typedef struct { int width, height; float *data; } rectMatWithSizes;
rectMatWithSizes funky[100];
and set it up whatever way you like. In other languages you might be
forced to use training wheels, or you might be lucky enough to be
permitted to hack up some imitation of the C style. I'd just use C.
Bye,
Rob.
.-. Robert.Harley@inria.fr .-.
/ \ .-. .-. / \
/ \ / \ .-. _ .-. / \ / \
/ \ / \ / \ / \ / \ / \ / \
/ \ / \ / `-' `-' \ / \ / \
\ / `-' `-' \ /
`-' Linux + 500MHz Alpha + 256MB SDRAM = heaven `-'
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-08 4:00 ` brianh
@ 1997-10-08 4:00 ` David Chase
1997-10-08 4:00 ` William Clodius
[not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
3 siblings, 0 replies; 99+ messages in thread
From: David Chase @ 1997-10-08 4:00 UTC (permalink / raw)
Robert Harley wrote:
> I think your problem is that C is too flexible for you. It doesn't
> wrongly assume that there is one way of laying out and accessing
> arrays that is appropriate for all purposes. For instance you can
> choose a flat array, 'float *a', or a hierarchy like 'float ***a'.
C's flexibility has two problems:
1. it is mandatory.
2. it is confined to a set of uninteresting choices.
In C, can I choose to have the compiler autoparallelize my dusty
deck onto a 16-processors SparcServer 2000? In C, can I choose to
have my loops automatically interchanged for better cache use?
How about cache blocking? Any automatic vectorizers for C?
Oh, I guess I don't get those choices.
Given detailed knowledge of a particular chip, working in C,
my attempt at a too-big-for-the-cache double-precision matrix
multiply obtained only 30 Mflops (this was on a 50 or 55 Mhz
SuperSparc, back in 1994). The code in Fortran was about
1/10th the size, and ran at 34 Mflops. Both bits of code
contained some hand-optimization, but the C code had much
more (the Fortran was simply blocked for cache locality;
the C code was blocked for both register and cache locality,
as well as software pipelined).
Keep in mind that most C programmers don't know how to
software-pipeline a loop. Most of them are not sure how
to do register blocking. Most of them are not exactly
sure how many double-precision registers are on the chip
they are using. Most of them don't know the size of the
cache on the chip (chip? how about box, since ecache sizes
can vary). I'll bet most of them don't know what cache
blocking is. And, if they do, I'll bet they forget to check
to see if the ecache is physically-indexed direct-mapped
or not, and whether the OS is taking care to "color" virtual
pages so that non-colliding virtual addresses will also be
non-colliding in the external cache.
This stuff is awful to do by hand.
And this, of course, was just matrix multiplication, it
wasn't something tricky to optimize for locality, like
GEPP or QR (for QR, so I am told, you must use a
different algorithm to get your factorization if you
wish to block it for locality). This code is really
tedious to write.
So, this flexibility gets me what? The privilege of writing 10
times as much code, that runs 10% slower, and is harder to port,
understand and maintain?
It is mind-boggling to me how persistently ignorant some people
working in C are. Someone told you once that C is the fastest
language, and it grabbed your brain. Maybe it feels like it
just must be fast, because you work so hard to make it fast.
Maybe you think that all high-level transformations alike,
that since (e.g.) SETL generally runs pretty slowly, that
all languages which are not "close to the machine" must
therefore run slowly. It is not so.
--
David Chase, chase@world.std.com
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-09 4:00 ` boo
@ 1997-10-09 4:00 ` William Clodius
1997-10-10 4:00 ` Tyson Richard DOWD
` (2 subsequent siblings)
3 siblings, 0 replies; 99+ messages in thread
From: William Clodius @ 1997-10-09 4:00 UTC (permalink / raw)
boo wrote:
> <snip>
> I also find it extremely amusing at how you have turned computer
> science into a religion. I find it even more amusing that a
> self-proclaimed expert would be wasting his time slugging it out
> with the likes of me (who has never ever taken a single course
> in CS, or a single programming class of any kind) in a
> spam-satuated newsgroup.
> <snip>
I find it anoying that your recent responses in this newgroup have
consistently treated personal attacks as the only way of dealing with
the comments of others that disagree with your beliefs.
"I also find it extremely amusing at how you have turned computer
science into a religion." An ad hominen attack that does not represent
at all what Richard has said. He has not advocated any one language as
being uniformly better than another, he has avoided attributing
disagreements to a general lack of knowledge or expertise, he has not
said that Fortran is a great language (just that Fortran 90 is
significantly better than Fortran 77 and in many aspects a more modern
language than C89), he has not said more modern is better, that in the
domains of interest to him Fortran is better, etc. I have found far more
"religion" in the way you express yourself on the issue, i.e., an
advocacy of one solution to all problems, a refusal to look at the
issues beyond your personal experience and a tendency to disregard
theory or the (albeit few) controlled experiments on the topic.
"Self-proclaimed expert" is an ad hominen attack that does not recognize
why he considers himself an expert on these issues or that others, that
are knowledgeable, have recognized him as an expert on these issues. It
does not recognize that he has specifically avoided relying on his
appeareance of expertise in his arguments, but has instead relied on
reporting sources, standards, and detailed analyses for his opinions. It
is this behavior that causes him to be recognized as an expert (and a
professional).
"Spam-satuated newsgroup" is an ad hominen attack in its most general
sense. It implies that the majority of respondents in this thread have
not had useful things to say. Compared with most newsgroups comp.arch is
relatively spam free. The number of cross psotings or multiple
repostings of the same material is a very minor problem with this
newsgroup.
Spoken as one who is not an expert in this topic, but has an amateur's
interest in language and machine design and implementation.
--
William B. Clodius Phone: (505)-665-9370
Los Alamos Nat. Lab., NIS-2 FAX: (505)-667-3815
PO Box 1663, MS-C323 Group office: (505)-667-5776
Los Alamos, NM 87545 Email: wclodius@lanl.gov
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 ` brianh
1997-10-08 4:00 ` boo
@ 1997-10-09 4:00 ` Gregg E Economou
1997-10-10 4:00 ` Jan Vorbrueggen
1 sibling, 1 reply; 99+ messages in thread
From: Gregg E Economou @ 1997-10-09 4:00 UTC (permalink / raw)
In article <EHr5EJ.Lov@bit3.com>, <brianh@bit3.com> wrote:
>The problem I have found with C's "flexibility" is that most of the time
>it amounts to "Hey, not only can you reinvent the wheel, you have too!
>But if, for some braindamaged reason, you want to reinvent the wheel as
>a _square_ instead of the generally accepted circle, it lets you do that
>as well!"
Yes, if i feel taken by the compulsion to invent the wheel as a square,
i darn well want ot be able to do it! and thats one of the biggest
reasons (aside from personal preference ot the syntax and tiny set of
primitives) i like C- i can do *whatever* i want and its legal.
C doesent hold my hand or tell me that I can only reinvent round wheels,
or even worse such things as VB where i am presented with 30
pre-made wheels which all have useless and superfluous features to make
them all work on a semi and a '76 tercel, C just lets me reinvent
a square wheel exactly as I please. Somehow the idea that the programmer
has complete control of the computer seems to me to be the idea we invented
computers to begin with.
isildur
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` Eric Hildum
@ 1997-10-09 4:00 ` brianh
1997-10-11 4:00 ` Jan Vorbrueggen
2 siblings, 0 replies; 99+ messages in thread
From: brianh @ 1997-10-09 4:00 UTC (permalink / raw)
In article <343C34A7.B715A348@tonys.ecology.umn.edu>,
boo <boo@tonys.ecology.umn.edu> wrote:
>
>The first time you play with multi-dimensional "arrays" in C, it is
>difficult and frustrating. These are much easier in Fortran for the
>uninitiated, and Fortran surely is the language of choice for many
>scientists and engineers. Once you have understood exactly how to implement
>multiple dimensional "arrays" in C efficiently and have gained
>some experience, it doesn't "suck" anymore, and you will understand
>exactly how flexible C actually is. But it isn't for amateurs,
>or for the Ivory Tower Set of this thread.
Okay:
A) This isn't the first time I've played with multi-dimensional arrays in C.
B) I've been programming in C for nigh onto a decade now, and while I do
not have the experience of many on this list, I do not consider myself
an amateur.
C) I've given up trying to be clever and portable and (since I'm using GCC)
just started using variable arrays. And found at least one bug in my code
because of it (I'm not sure about you, but I do tend to make mistakes)
I don't speak for Bit 3.
Brian
--
"NT and security should never be used in the same breath."
- Winn Schwartau, EETimes #972, 22 September 1997 pp.96
-Brian
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 ` boo
@ 1997-10-09 4:00 ` Eric Hildum
1997-10-09 4:00 ` brianh
1997-10-11 4:00 ` Jan Vorbrueggen
2 siblings, 0 replies; 99+ messages in thread
From: Eric Hildum @ 1997-10-09 4:00 UTC (permalink / raw)
boo wrote:
>
> brianh@bit3.com wrote:
> >
> > In article <61g30t$o2n@news-rocq.inria.fr>,
> > Robert Harley <harley@pauillac.inria.fr> wrote:
> > >
> > >I think your problem is that C is too flexible for you. It doesn't
> > >wrongly assume that there is one way of laying out and accessing
> > >arrays that is appropriate for all purposes. For instance you can
> > >choose a flat array, 'float *a', or a hierarchy like 'float ***a'.
> >
> > Speaking as someone who is writting a math library in C (in his free time,
> > but I'm actively grappling with these exact issues), also as someone
> > who hardly knows Fortran, this _SUCKS_.
>
> The first time you play with multi-dimensional "arrays" in C, it is
> difficult and frustrating. These are much easier in Fortran for the
> uninitiated, and Fortran surely is the language of choice for many
> scientists and engineers. Once you have understood exactly how to implement
> multiple dimensional "arrays" in C efficiently and have gained
> some experience, it doesn't "suck" anymore, and you will understand
> exactly how flexible C actually is. But it isn't for amateurs,
> or for the Ivory Tower Set of this thread.
I have had to implement multidimensional dynamic arrays in C, and sorry,
it does suck. When a language does not support a common construct well
enough to allow an optimizer to do something intellegent with it, the
language has a serious problem. Bliss has a much better mechanism for
doing fancy array or structure implementations, in the sense that it
allows easy generation of structures like arrays, even in cases such as
symetric triangular arrays, without the wasted space C requires while
still allowing an optimizer to operate. In some senses, Bliss allows
object oriented design and implementation without the mess of C++ (which
at best is a kludge on top of a hack).
C falls under the catagory of if all you have is a hammer, everything is
a nail. Since most universities only teach C now, we can expect a
generation of "experts" who work in the "real world" to spend the next
twenty years rediscovering 1960s level programming issues and solutions.
--
"The idea that Bill Gates has appeared like a knight in shining armour
to lead all customers out of a mire of technological chaos neatly
ignores the fact that it was he who, by peddling second-rate technology,
led them into it in the first place."-Douglas Adams
Eric Hildum
Eric.Hildum@Japan.NCR.COM
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
[not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
@ 1997-10-09 4:00 ` boo
1997-10-09 4:00 ` William Clodius
` (3 more replies)
[not found] ` <EHrwv9.2w3@world.std.com>
1 sibling, 4 replies; 99+ messages in thread
From: boo @ 1997-10-09 4:00 UTC (permalink / raw)
Richard A. O'Keefe wrote:
> Here's how you could do it in a language that really _supported_
> programmer control over low level details, instead of merely
> refraining from prohibiting it.
>
> layout Pascal [M,N;I,J] = M*N, I*M+J; //row major
> layout Fortran[M,N;I,J] = M*N, I+J*N; //column major
>
> float Pascal A[10,20];
> float Fortran B[A.M,A.N];
>
> ...
> for (int i = 0; i < A.M; i++)
> for (int j = 0; j < A.N; j++)
> A[i,j] = B[i,j];
>
> (By the way, this is not C++ + layouts, it's C9X + layouts.)
>
> NOW do you understand what we had before C?
That looks like Fortran!! I can see why some people might like
these wonderful new features of your hypothetical C9X++, but
I would never use them. I really cannot fathom why you actually
believe that this is more low level. As far as I understood,
computer memory is not two dimensional, and so I would rather
control the layout of multi-dimensional arrays myself. I've done
it before many times, I know how to achieve efficiency, so why
should I let some compiler (created by some pushed up CS dweeb
like you) do my thinking for me? Hey, what next? Some Goddamn
awful Fortran-like compiler directives? Sure, these are low-level
in a sense, but they are simply ugly hacks.
I also find it extremely amusing at how you have turned computer
science into a religion. I find it even more amusing that a
self-proclaimed expert would be wasting his time slugging it out
with the likes of me (who has never ever taken a single course
in CS, or a single programming class of any kind) in a
spam-satuated newsgroup.
Boo
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-09 4:00 ` boo
` (2 preceding siblings ...)
1997-10-10 4:00 ` boo
@ 1997-10-10 4:00 ` Richard A. O'Keefe
3 siblings, 0 replies; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-10 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]
I wrote:
: layout Pascal [M,N;I,J] = M*N, I*M+J; //row major
: layout Fortran[M,N;I,J] = M*N, I+J*N; //column major
: float Pascal A[10,20];
: float Fortran B[A.M,A.N];
: ...
: for (int i = 0; i < A.M; i++)
: for (int j = 0; j < A.N; j++)
: A[i,j] = B[i,j];
boo <boo@tonys.ecology.umn.edu> writes:
>That looks like Fortran!!
How? This is a feature that Fortran does _not_ provide.
>I can see why some people might like
>these wonderful new features of your hypothetical C9X++, but
>I would never use them. I really cannot fathom why you actually
>believe that this is more low level.
You don't see how letting the programmer specify the address
mapping is more low level than letting the compiler choose it?
>As far as I understood,
>computer memory is not two dimensional,
This is *DEAD* wrong about quite a few historically significant
computers, like the B6700, Multics, and an obscure machine called
the 80286.
>and so I would rather
>control the layout of multi-dimensional arrays myself.
BUT THE NOTATION I JUST DISPLAYED *IS PRECISELY THAT*.
The examples I showed were examples of how you *control* the
layout yourself! What did you think a layout declaration *was*
if not explicit programmer control of layout?
>I've done
>it before many times, I know how to achieve efficiency, so why
>should I let some compiler (created by some pushed up CS dweeb
>like you) do my thinking for me?
I wasn't suggesting that you should. I WAS SHOWING YOU A NOTATION
YOU COULD USE TO DO *EXACTLY* WHAT YOU SAY IT IS YOU WANT TO DO.
Like another poster, I was pointing out that Bliss did this before
there _was_ a C.
>I also find it extremely amusing at how you have turned computer
>science into a religion.
You are being amused by what is exclusively your own fantasy.
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-09 4:00 ` boo
1997-10-09 4:00 ` William Clodius
@ 1997-10-10 4:00 ` Tyson Richard DOWD
1997-10-12 4:00 ` boo
1997-10-10 4:00 ` boo
1997-10-10 4:00 ` Richard A. O'Keefe
3 siblings, 1 reply; 99+ messages in thread
From: Tyson Richard DOWD @ 1997-10-10 4:00 UTC (permalink / raw)
boo <boo@tonys.ecology.umn.edu> writes:
>Richard A. O'Keefe wrote:
>> Here's how you could do it in a language that really _supported_
>> programmer control over low level details, instead of merely
>> refraining from prohibiting it.
>>
>> layout Pascal [M,N;I,J] = M*N, I*M+J; //row major
>> layout Fortran[M,N;I,J] = M*N, I+J*N; //column major
>>
>> float Pascal A[10,20];
>> float Fortran B[A.M,A.N];
>>
>> ...
>> for (int i = 0; i < A.M; i++)
>> for (int j = 0; j < A.N; j++)
>> A[i,j] = B[i,j];
>>
>> (By the way, this is not C++ + layouts, it's C9X + layouts.)
>>
>> NOW do you understand what we had before C?
>That looks like Fortran!! I can see why some people might like
>these wonderful new features of your hypothetical C9X++, but
>I would never use them.
Not even to save coding time, eliminate dozens of hacky macros, and
get the same efficiency you claim to get? You should give reasons why
you reject that feature.
>I really cannot fathom why you actually
>believe that this is more low level. As far as I understood,
>computer memory is not two dimensional, and so I would rather
If I told you computer memory was two dimensional, would you do things
differently? I don't understand this line of reasoning.
>control the layout of multi-dimensional arrays myself. I've done
>it before many times, I know how to achieve efficiency, so why
>should I let some compiler (created by some pushed up CS dweeb
>like you) do my thinking for me?
Is this a joke? "I know how to program efficiently, so why should I let
the compiler do my thinking for me?" What, are you worried about job
security or something? Is this a Luddite argument? What are you
advocating, throwing our clogs into the advanced language constructs
before they dull our thinking?
That's not thinking, it's mental drudgery. It's the necessity that
drove the invention of computers in the first place.
>awful Fortran-like compiler directives? Sure, these are low-level
>in a sense, but they are simply ugly hacks.
At at the top of this paragraph, you couldn't really fathom why
Richard believed these were more low level. Now you're sure they are
low level.
>I also find it extremely amusing at how you have turned computer
>science into a religion. I find it even more amusing that a
Religion? Huh? (Thinking about this, I guess for most computer
scientists, their spirit guide is the mouse ;-).
>self-proclaimed expert would be wasting his time slugging it out
>with the likes of me (who has never ever taken a single course
Yes, for a self-proclaimed expert, he sure doesn't worry about other
people lacking credentials. Nothing wrong with that.
>in CS, or a single programming class of any kind) in a
>spam-satuated newsgroup.
There are a lot of people who are willing to learn something
through discussion and even argument. I would guess that Richard is
one of them, and he thought you were one two. Are you?
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-09 4:00 ` Final kick at the "Merced Guessing Game" Gregg E Economou
@ 1997-10-10 4:00 ` Jan Vorbrueggen
0 siblings, 0 replies; 99+ messages in thread
From: Jan Vorbrueggen @ 1997-10-10 4:00 UTC (permalink / raw)
geest3+@pitt.edu (Gregg E Economou) writes:
> Yes, if i feel taken by the compulsion to invent the wheel as a square,
> i darn well want ot be able to do it!
"There is nothing worse than a not-lazy programmer."
Jan
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
[not found] ` <EHrwv9.2w3@world.std.com>
1997-10-10 4:00 ` David Gould
@ 1997-10-10 4:00 ` David Gould
1997-10-16 4:00 ` Patricia Shanahan
1 sibling, 1 reply; 99+ messages in thread
From: David Gould @ 1997-10-10 4:00 UTC (permalink / raw)
In article <EHrwv9.2w3@world.std.com>,
Joseph H Allen <jhallen@world.std.com> wrote:
>In article <61ho3v$3m0$1@goanna.cs.rmit.edu.au>,
>Richard A. O'Keefe <ok@goanna.cs.rmit.edu.au> wrote:
>> nice features of older languages and C9x...
>
>The real question is why has C caught on in such a big way when other
>more powerful languages have not? There are several answers:
[many good reasons deleted]
I am surprised that no-one has mentioned what may be the most important
reason for the success of C: "The C Programming Language" by messrs K & R.
An excellent book, far better than the language described. A religious text
almost. After reading it, especially early in a career, one is convinced that
"C" not only makes sense, but is even "the right way".
Think about how thinks might have turned out had this book never existed.
The above is a bit tongue in cheek, but twenty years in computing has lead
me to believe that software success owes far more to cultural factors than to
technical merit. This applies to "users" and "corporate IS management" as the
success of MS-DOS, Windows, and now NT amply illustrates. It seems to apply
to programmers or "software engineers" perhaps even more strongly.
The C vs anything else debate often illustrates this. There are a few
central elements to this argument that are common whenever it appears. The
interesting thing is that the same assertions continue to be made persistantly
even in the face evidence to the contrary, and even when they explicitly
contradict each other.
- C is "close to the machine" and somehow, this is "efficient" or good.
Even after proof that say Fortran is more efficient for some problems,
or that Modula or Ada, or lisp is more powerful, or that the whole problem
could have been solved with a 20 line script, the C proponent will reply
(often paraphrasing K&R) that C is both more efficient and more powerful
"since it lets you get close to the machine".
This assertion continues to be made even after contrary facts are
demonstrated. This can go on to absurd lengths where some unholy concoction
of inline assembler and preprocessor abuse on one machine (so sadly no
longer made) is claimed to be faster than the "same" program in fortran.
- C is "portable"
C is certainly common, but even within the confines of the ANSI standard
there is wide scope for major portability problems. In the database
world, the major players all have entire departments with 100+ or so
persons that do nothing except "port" each new release of what is
essential one very large C program.
Often the portability argument will somehow co-exist with the "close to
the machine" argument, even alongside the claim that "if you want real
performance, you need to read all the hardware manuals and rewrite for
each machine"
- C is a simple language with simple syntax.
This is simply not true. A look at either the grammars, or the language
reports will reveal many simpler languages. C may be simpler than ADA or
PL1 or most especially C++, but compared to say Oberon or Modula-3, or
even Fortran it is not a simple language.
More strongly, it does not have simple syntax. Forth, Smalltalk, Self,
the lisp familyi, these have simple syntax. Among the Algol family, some
of the Wirth languages, especially Oberon have much simpler syntax than C.
The assertion (that C is simple) is often comtemporanious (but hardly
supported) with statements that the asserter has frequent reference to
more than one C book and that the questioner "must not understand the
fine points" of C.
- C is terse and elegant.
For any C program there is a much shorter and more elegant solution in
some other language. As simple proof, consider a language "just like C"
but with garbage collection. Most C programs would be far shorter and
more elegant if written that way. For a really tough test of terseness,
pick a random perl script and write it in C. This argument may be
related to the "simple language" argument, except that is seems to be
motivated by a subconscious aversion to typing keywords. This is
almost explicit in K&R where "{" and "}" are equated to "BEGIN" and
"END".
- C lets me do what I want. You can't write operating systems in "other".
This of course begs the question of how common "writing an operating
system" is, and ignores several perfectly good operating systems
not written in C.
The relevance of this point is also hard to fathom since it is usually
raised in opposition to the assertion "for some problems C is not the
best choice".
The counter argument is that C makes it really easy to do what you
do not want. Somehow this is felt to be adaquately countered by assertions
about "competent C programmers" vs "crap programmers". The inconsistancy
with the "simple language" claim is rarely explored.
Enough of the war, now to the unsupported opinions:
Why is C successful, and what lies ahead?
In a word, it is mostly "fashion".
C was initially successful because it had a great book, available
implementations (especially, available to universities), was easy to host
on smaller hardware, and wasn't much worse than the common alternatives of
the time.
C survives because it is ubiquitous, it will do most jobs eventually, and
many people (who should know better) are unaware of the alternatives or
are stuck with it for some reason.
C has fanatic followers because it appeals to lazyness with its "terse"
syntax, to Walter Mitty fantasy with "I could write an OS with this",
and to the need for machismo comparison with its arcane intricacy "a real
C programmer would just use macros for that". Each SEGV becomes a bonding
ritual with the C brethren akin to an extended fraternity hazing.
C++ is successful at the moment, mostly because there are hordes of C
programmers eager to "progress" to the next level. Since it is unlikely
that most programmers will ever be able to work at an economicly acceptable
rate in C++ due to its overwhelming complexity. It also almost completely
lacking the actual virtues of C.
Java is likely to be a sucess, perhaps in a dialect form that omits some of
the tougher parts of the implementation. This will occur not only because it
it is better than C, or C++, but also because it, brilliantly, looks a lot
like both. The hordes of not quite successful C++ programmers and their
managers are going to be casting about for some way out of the swamp.
Java will be there with all the familiar appearance and without most of
the hidden minefields.
Who the heck am I anyway?
I have been programming for a living for almost 20 years. I learned C on a
PDP-11, where it really did make some sense, and have worked mainly with C
for the past 15 years. For the last 10 years I have worked at one or
another of the major SQL database companies on the core server engine(s).
An SQL server engine is typically a large C program, between 500,000 and 2m
lines of code. These engines are about as close to "writing an OS" or
"writing a compiler" as possible. They implement the SQL language processor,
a file system (usually built on raw partitions), a networking protocol (on
top of tcp or other transport), and what looks like an OS kernel (asynch
I/O, threading, sychronization, memory management for threads, etc.)
These programs ported to dozens of platforms, mostly unix flavored, but also
NT and others. They are written, maintained, ported, and enhanced by
engineering departments consisting of a few hundred persons. The code is
expected to be useable for up to a decade. New versions are expected no
more than two years apart.
Performance (both time and space, both compute and I/O) and reliability are
considered critical. Vast effort is spent on testing, somewhat less on
benchmarking, but somehow, performance is easier than reliability.
My opinions about C and software development come from my experience as a
practitioner and as an observer of the DBMS engineering organizations as well
the odd bit of reading here and there.
-dg
David Gould dg@illustra.com 510.628.3783 or 510.305.9468
Informix Software 300 Lakeside Drive Oakland, CA 94612
If simplicity worked, the world would be overrun with insects.
--
David Gould dg@illustra.com 510.628.3783 or 510.305.9468
Informix Software 300 Lakeside Drive Oakland, CA 94612
- A child of five could understand this! Fetch me a child of five.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
[not found] ` <EHrwv9.2w3@world.std.com>
@ 1997-10-10 4:00 ` David Gould
1997-10-10 4:00 ` Maynard Handley
1997-10-10 4:00 ` Final kick at the "Merced Guessing Game" David Gould
1 sibling, 1 reply; 99+ messages in thread
From: David Gould @ 1997-10-10 4:00 UTC (permalink / raw)
In article <EHrwv9.2w3@world.std.com>,
Joseph H Allen <jhallen@world.std.com> wrote:
>In article <61ho3v$3m0$1@goanna.cs.rmit.edu.au>,
>Richard A. O'Keefe <ok@goanna.cs.rmit.edu.au> wrote:
>> nice features of older languages and C9x...
>
>The real question is why has C caught on in such a big way when other
>more powerful languages have not? There are several answers:
[many good reasons deleted]
I am surprised that no-one has mentioned what may be the most important
reason for the success of C: "The C Programming Language" by messrs K & R.
An excellent book, far better than the language described. A religious text
almost. After reading it, especially early in a career, one is convinced that
"C" not only makes sense, but is even "the right way".
Think about how thinks might have turned out had this book never existed.
The above is a bit tongue in cheek, but twenty years in computing has lead
me to believe that software success owes far more to cultural factors than to
technical merit. This applies to "users" and "corporate IS management" as the
success of MS-DOS, Windows, and now NT amply illustrates. It seems to apply
to programmers or "software engineers" perhaps even more strongly.
The C vs anything else debate often illustrates this. There are a few
central elements to this argument that are common whenever it appears. The
interesting thing is that the same assertions continue to be made persistantly
even in the face evidence to the contrary, and even when they explicitly
contradict each other.
- C is "close to the machine" and somehow, this is "efficient" or good.
Even after proof that say Fortran is more efficient for some problems,
or that Modula or Ada, or lisp is more powerful, or that the whole problem
could have been solved with a 20 line script, the C proponent will reply
(often paraphrasing K&R) that C is both more efficient and more powerful
"since it lets you get close to the machine".
This assertion continues to be made even after contrary facts are
demonstrated. This can go on to absurd lengths where some unholy concoction
of inline assembler and preprocessor abuse on one machine (so sadly no
longer made) is claimed to be faster than the "same" program in fortran.
- C is "portable"
C is certainly common, but even within the confines of the ANSI standard
there is wide scope for major portability problems. In the database
world, the major players all have entire departments with 100+ or so
persons that do nothing except "port" each new release of what is
essential one very large C program.
Often the portability argument will somehow co-exist with the "close to
the machine" argument, even alongside the claim that "if you want real
performance, you need to read all the hardware manuals and rewrite for
each machine"
- C is a simple language with simple syntax.
This is simply not true. A look at either the grammars, or the language
reports will reveal many simpler languages. C may be simpler than ADA or
PL1 or most especially C++, but compared to say Oberon or Modula-3, or
even Fortran it is not a simple language.
More strongly, it does not have simple syntax. Forth, Smalltalk, Self,
the lisp familyi, these have simple syntax. Among the Algol family, some
of the Wirth languages, especially Oberon have much simpler syntax than C.
The assertion (that C is simple) is often comtemporanious (but hardly
supported) with statements that the asserter has frequent reference to
more than one C book and that the questioner "must not understand the
fine points" of C.
- C is terse and elegant.
For any C program there is a much shorter and more elegant solution in
some other language. As simple proof, consider a language "just like C"
but with garbage collection. Most C programs would be far shorter and
more elegant if written that way. For a really tough test of terseness,
pick a random perl script and write it in C. This argument may be
related to the "simple language" argument, except that is seems to be
motivated by a subconscious aversion to typing keywords. This is
almost explicit in K&R where "{" and "}" are equated to "BEGIN" and
"END".
- C lets me do what I want. You can't write operating systems in "other".
This of course begs the question of how common "writing an operating
system" is, and ignores several perfectly good operating systems
not written in C.
The relevance of this point is also hard to fathom since it is usually
raised in opposition to the assertion "for some problems C is not the
best choice".
The counter argument is that C makes it really easy to do what you
do not want. Somehow this is felt to be adaquately countered by assertions
about "competent C programmers" vs "crap programmers". The inconsistancy
with the "simple language" claim is rarely explored.
Enough of the war, now to the unsupported opinions:
Why is C successful, and what lies ahead?
In a word, it is mostly "fashion".
C was initially successful because it had a great book, available
implementations (especially, available to universities), was easy to host
on smaller hardware, and wasn't much worse than the common alternatives of
the time.
C survives because it is ubiquitous, it will do most jobs eventually, and
many people (who should know better) are unaware of the alternatives or
are stuck with it for some reason.
C has fanatic followers because it appeals to lazyness with its "terse"
syntax, to Walter Mitty fantasy with "I could write an OS with this",
and to the need for machismo comparison with its arcane intricacy "a real
C programmer would just use macros for that". Each SEGV becomes a bonding
ritual with the C brethren akin to an extended fraternity hazing.
C++ is successful at the moment, mostly because there are hordes of C
programmers eager to "progress" to the next level. Since it is unlikely
that most programmers will ever be able to work at an economicly acceptable
rate in C++ due to its overwhelming complexity. It also almost completely
lacking the actual virtues of C.
Java is likely to be a sucess, perhaps in a dialect form that omits some of
the tougher parts of the implementation. This will occur not only because it
it is better than C, or C++, but also because it, brilliantly, looks a lot
like both. The hordes of not quite successful C++ programmers and their
managers are going to be casting about for some way out of the swamp.
Java will be there with all the familiar appearance and without most of
the hidden minefields.
Who the heck am I anyway?
I have been programming for a living for almost 20 years. I learned C on a
PDP-11, where it really did make some sense, and have worked mainly with C
for the past 15 years. For the last 10 years I have worked at one or
another of the major SQL database companies on the core server engine(s).
An SQL server engine is typically a large C program, between 500,000 and 2m
lines of code. These engines are about as close to "writing an OS" or
"writing a compiler" as possible. They implement the SQL language processor,
a file system (usually built on raw partitions), a networking protocol (on
top of tcp or other transport), and what looks like an OS kernel (asynch
I/O, threading, sychronization, memory management for threads, etc.)
These programs ported to dozens of platforms, mostly unix flavored, but also
NT and others. They are written, maintained, ported, and enhanced by
engineering departments consisting of a few hundred persons. The code is
expected to be useable for up to a decade. New versions are expected no
more than two years apart.
Performance (both time and space, both compute and I/O) and reliability are
considered critical. Vast effort is spent on testing, somewhat less on
benchmarking, but somehow, performance is easier than reliability.
My opinions about C and software development come from my experience as a
practitioner and as an observer of the DBMS engineering organizations as well
the odd bit of reading here and there.
-dg
David Gould dg@illustra.com 510.628.3783 or 510.305.9468
Informix Software 300 Lakeside Drive Oakland, CA 94612
If simplicity worked, the world would be overrun with insects.
--
David Gould dg@illustra.com 510.628.3783 or 510.305.9468
Informix Software 300 Lakeside Drive Oakland, CA 94612
- I realize now that irony has no place in business communications.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-10 4:00 ` David Gould
@ 1997-10-10 4:00 ` Maynard Handley
1997-10-11 4:00 ` new languages Preston Briggs
0 siblings, 1 reply; 99+ messages in thread
From: Maynard Handley @ 1997-10-10 4:00 UTC (permalink / raw)
In article <61kp41$dob@news.informix.com>, dg@montage.com (David Gould) wrote:
[Cultural elements for the success of C omitted.]
> - C is "close to the machine" and somehow, this is "efficient" or good.
>
> Even after proof that say Fortran is more efficient for some problems,
> or that Modula or Ada, or lisp is more powerful, or that the whole problem
> could have been solved with a 20 line script, the C proponent will reply
> (often paraphrasing K&R) that C is both more efficient and more powerful
> "since it lets you get close to the machine".
> This assertion continues to be made even after contrary facts are
> demonstrated. This can go on to absurd lengths where some unholy concoction
> of inline assembler and preprocessor abuse on one machine (so sadly no
> longer made) is claimed to be faster than the "same" program in fortran.
An important issue that's omitted here is this.
The computer world as a whole seems to thrive on the spouting of what is
patent nonsense. Languages are no more immune to this than anyone else.
Each time I get a new rev of a good compiler (for PPC, but the same is
true for any other system) I am told how fantastically efficient it is,
how it utilizes every cycle, etc etc. I build something, look at the
assembly, and in five minute have found five examples of scheduling
inefficiencies, redundant loads etc.
PPC asm output of a C compiler is relevant to where I sit in computer
space, and I deal with it by continuing to write my blit loops in
assembly. I know the extent to which C compiler prowess is hype, and I
know how to test it.
Consider now when I get told on Usenet Lisp (or Bliss or PL/1 or APL or
who knows what is WAY faster than C). Why should I believe it?
What generally happens when one does try to track down such a claim is:
* Well it COULD be much faster than C, but people don't put the effort
into the compiler that they do into C or
* Well yes it does handle that sort of playing around with data
inefficiently, but it was targetted at a different sort of problem.
So the result is to tune this stuff out.
So what's my point?
If you want to prove how great your chosen language is, you have an
obligation to
* explain what it can do well
* explain what it CANNOT do well
* give some REAL NUMBERs of how fast it is, vs C, in some fashion.
Yes, if you write compilers, the contortions that you have to go through
hurt and you'd rather not have to deal with them. Well here's a message. I
don't write compilers, I have no interest in your pain---that's what I pay
you for.
We all of us in computing have to deal with our little nightmares---you
think I like having waste time on 8-bit screen blit loops when 24-bit
video cards exist?
What I care about is the speed of the extant compilers for the problem I
want to solve, not the speed of some compiler that might exist if the
world all saw the light tomorrow and switched languages.
Maynard
--
My opinion only
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-09 4:00 ` boo
1997-10-09 4:00 ` William Clodius
1997-10-10 4:00 ` Tyson Richard DOWD
@ 1997-10-10 4:00 ` boo
1997-10-11 4:00 ` Paul DeMone
` (2 more replies)
1997-10-10 4:00 ` Richard A. O'Keefe
3 siblings, 3 replies; 99+ messages in thread
From: boo @ 1997-10-10 4:00 UTC (permalink / raw)
Richard babbled:
> >As far as I understood,
> >computer memory is not two dimensional,
> This is *DEAD* wrong about quite a few historically significant
> computers, like the B6700, Multics, and an obscure machine called
> the 80286.
Who gives a shit.
How about concentrating on the real world, and actual computer
systems.
> : layout Pascal [M,N;I,J] = M*N, I*M+J; //row major
> : layout Fortran[M,N;I,J] = M*N, I+J*N; //column major
> : float Pascal A[10,20];
> : float Fortran B[A.M,A.N];
> : ...
> : for (int i = 0; i < A.M; i++)
> : for (int j = 0; j < A.N; j++)
> : A[i,j] = B[i,j];
>
> boo <boo@tonys.ecology.umn.edu> writes:
> >That looks like Fortran!!
>
> How? This is a feature that Fortran does _not_ provide.
It looks suspiciously like something you would do with
compiler directives on some variant of Fortran 90, for
example, to tell the compiler how you want the arrays
laid out.
> >I've done
> >it before many times, I know how to achieve efficiency, so why
> >should I let some compiler (created by some pushed up CS dweeb
> >like you) do my thinking for me?
>
> I wasn't suggesting that you should. I WAS SHOWING YOU A NOTATION
> YOU COULD USE TO DO *EXACTLY* WHAT YOU SAY IT IS YOU WANT TO DO.
> Like another poster, I was pointing out that Bliss did this before
> there _was_ a C.
No, you don't understand me. I want to do the nitty-gritty
myself. As I said, computer memory is NOT multi-dimensional,
and I do not trust compilers to do a proper job. Perhaps someday
compilers will do the job properly, but until then, I want
the control myself. The thought of CS snobs like you having a
hand in the process is scary.
And I don't care about what someone did before I was born.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-10 4:00 ` boo
1997-10-11 4:00 ` Paul DeMone
1997-10-11 4:00 ` Toon Moene
@ 1997-10-11 4:00 ` Patricia Shanahan
1997-10-13 4:00 ` Gregg E Economou
2 siblings, 1 reply; 99+ messages in thread
From: Patricia Shanahan @ 1997-10-11 4:00 UTC (permalink / raw)
boo wrote:
...
> No, you don't understand me. I want to do the nitty-gritty
> myself. As I said, computer memory is NOT multi-dimensional,
> and I do not trust compilers to do a proper job. Perhaps someday
> compilers will do the job properly, but until then, I want
> the control myself. The thought of CS snobs like you having a
> hand in the process is scary.
>
> And I don't care about what someone did before I was born.
Why do you say "computer memory is NOT multi-dimensional"? Every
computer memory structure that I have looked at in enough detail for
analysis of its performance has been multi-dimensional. In the case of
a large server, memory may be an array of modules each of which is an
array of banks where each bank is implemented by an array of memory
chips, each of which provides a two dimensional array of data bits.
Some levels of this may be missing in smaller systems, but it is
difficult to avoid having multiple memory chips, or having separate
row and column addresses in talking to each chip. This may have
performance impact. DRAM chips often have a mode in which repeated
access to different columns but the same row can be done significantly
faster than if the row address were changing.
In a virtual address system, there is a layer of array access between
you and the hardware in the form of the virtual-to-real translation.
Virtual memory at its simplest is a two dimensional array indexed by
page number and offset within page.
Cache hierarchies are also multi-dimensional structures, in which
there may be arrays of lines that are divided into arrays of sublines,
which are themselves arrays of bytes. Fitting well with the sizes and
organization of these units may be crucial to the performance of
memory intensive programs.
Even in a real address OS with no caches, any view of a flat
one-dimensional computer memory is just an abstraction that hides much
of the nitty-gritty.
[boo, I don't know whether you are old enough to care about this -
please ignore if early 70's are before your learning cut-off date.]
Even before memory chips, the first memory design that I looked at had
arrays of square units, each of which was a two dimensional array with
wires strung in both directions. Each bit was stored in a small
magnetic rod at an intersection of the vertical and horizontal wires.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` Eric Hildum
1997-10-09 4:00 ` brianh
@ 1997-10-11 4:00 ` Jan Vorbrueggen
1997-10-12 4:00 ` boo
2 siblings, 1 reply; 99+ messages in thread
From: Jan Vorbrueggen @ 1997-10-11 4:00 UTC (permalink / raw)
boo <boo@tonys.ecology.umn.edu> writes:
> Once you have understood exactly how to implement
> multiple dimensional "arrays" in C efficiently and have gained
> some experience, it doesn't "suck" anymore, and you will understand
> exactly how flexible C actually is. But it isn't for amateurs,
> or for the Ivory Tower Set of this thread.
Sure, and there is exactly one way, eh, that will be efficient on _all_
hardware, will it not? And all those FORTRAN compiler writers should return
their paychecks to their employers in shame, as they haven't managed to
implement FORTRAN arrays the same efficient way you do. Or are you claiming
that FORTRAN doesn't allow your one efficient way?
Jan
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-10 4:00 ` boo
@ 1997-10-11 4:00 ` Paul DeMone
1997-10-11 4:00 ` Toon Moene
1997-10-11 4:00 ` Patricia Shanahan
2 siblings, 0 replies; 99+ messages in thread
From: Paul DeMone @ 1997-10-11 4:00 UTC (permalink / raw)
boo wrote:
>
> Richard babbled:
> > >As far as I understood,
> > >computer memory is not two dimensional,
> > This is *DEAD* wrong about quite a few historically significant
> > computers, like the B6700, Multics, and an obscure machine called
> > the 80286.
>
> Who gives a shit.
If you don't care about historically significant machines then what are
doing in these newsgroups, comp.arch in particular? Computer architecture
is a much deeper, wider subject, and goes back a lot further than the last chip
Intel released. Go back to your Nintendo 64 and blow up space aliens. Stay
in your bubble lest you crack open a book and discover the CPU in your N64 is
decendent from grad work done at Stanford U. in the, *gasp*, early eighties.
It is one thing being ignorant but why do you have to proudly parade your ignorance
around like a badge of honour in front of a world wide audience?
>
> How about concentrating on the real world, and actual computer
> systems.
Having used B6700, Multics, and 286 systems at various times I assure you
they were all very real.
[snip]
>
> And I don't care about what someone did before I was born.
Apparently this was yesterday ;-)
--
Paul W. DeMone The 801 experiment SPARCed an ARMs race
Kanata, Ontario to put more PRECISION and POWER into
demone@mosaid.com architectures with MIPSed results but
PaulDeMone@EasyInternet.net ALPHA's well that ends well.
^ permalink raw reply [flat|nested] 99+ messages in thread
* new languages
1997-10-10 4:00 ` Maynard Handley
@ 1997-10-11 4:00 ` Preston Briggs
0 siblings, 0 replies; 99+ messages in thread
From: Preston Briggs @ 1997-10-11 4:00 UTC (permalink / raw)
Maynard Handley <handleym@apple.com> wrote:
>Each time I get a new rev of a good compiler (for PPC, but the same is
>true for any other system) I am told how fantastically efficient it is,
>how it utilizes every cycle, etc etc. I build something, look at the
>assembly, and in five minute have found five examples of scheduling
>inefficiencies, redundant loads etc.
Good to know there's room for improvement!
>Consider now when I get told on Usenet Lisp (or Bliss or PL/1 or APL or
>who knows what is WAY faster than C). Why should I believe it?
>If you want to prove how great your chosen language is, you have an
>obligation to
>* explain what it can do well
>* explain what it CANNOT do well
>* give some REAL NUMBERs of how fast it is, vs C, in some fashion.
Although I admire the motivation, I don't consider these criteria at
all adequate.
A language is not faster or slower than another language; instead,
different compilers produce code that may be faster or slower. It's
easy to find a poor C compiler, but I'm much more interested in a
stringent test.
It's true that some languages may hinder the generation of efficient
code, or may require the programmer to jump through hoops to convince
the compiler to generate the code. That's another interesting
question, but not one that can be answered with a single comparison.
Furthermore, I'd like to compare the results of programs written by
experts in the languages -- perferably experts who stand to gain if
their implementation wins!
Finally, I'd like to see a range of tests. No C programmer will be
swayed by how well or poorly his favorite C compiler does in relation
to some other compiler (for whatever language) on the TAK benchmark,
for instance.
Preston Briggs
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-10 4:00 ` boo
1997-10-11 4:00 ` Paul DeMone
@ 1997-10-11 4:00 ` Toon Moene
1997-10-11 4:00 ` Patricia Shanahan
2 siblings, 0 replies; 99+ messages in thread
From: Toon Moene @ 1997-10-11 4:00 UTC (permalink / raw)
boo <boo@tonys.ecology.umn.edu> wrote:
> And I don't care about what someone did before I was born.
Yep, we know:
"Those who don't know history are doomed to repeat it, by hand"
--
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.ai.mit.edu; NWP: http://www.knmi.nl/hirlam
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-11 4:00 ` Jan Vorbrueggen
@ 1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Carl Perkins
1997-10-13 4:00 ` Michael Williams
0 siblings, 2 replies; 99+ messages in thread
From: boo @ 1997-10-12 4:00 UTC (permalink / raw)
Jan Vorbrueggen babbled inanely:
>
> boo <boo@tonys.ecology.umn.edu> writes:
>
> > Once you have understood exactly how to implement
> > multiple dimensional "arrays" in C efficiently and have gained
> > some experience, it doesn't "suck" anymore, and you will understand
> > exactly how flexible C actually is. But it isn't for amateurs,
> > or for the Ivory Tower Set of this thread.
>
> Sure, and there is exactly one way, eh, that will be efficient on _all_
> hardware, will it not? And all those FORTRAN compiler writers should return
> their paychecks to their employers in shame, as they haven't managed to
> implement FORTRAN arrays the same efficient way you do. Or are you claiming
> that FORTRAN doesn't allow your one efficient way?
I did not say there was ONE efficient way. If you are just looking
for ONE efficient way, then perhaps you should stick with Fortran.
As I said before, Fortran is for the lazy, the feeble-minded,
the incompetent, and for those who aren't doing anything beyond
simple-minded number crunching.
Perhaps you should stop trying to read between the lines, because
you obviously are not very good at it.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-10 4:00 ` Tyson Richard DOWD
@ 1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Patricia Shanahan
1997-10-13 4:00 ` Steve Tate
0 siblings, 2 replies; 99+ messages in thread
From: boo @ 1997-10-12 4:00 UTC (permalink / raw)
Tyson Richard DOWD babbled:
> Not even to save coding time, eliminate dozens of hacky macros, and
> get the same efficiency you claim to get? You should give reasons why
> you reject that feature.
If this does achieve improved efficiency, then of course I would
not reject it.
What I see in this thread, though, is a bunch of aging old
CS farts and another bunch of imcompetent programmers who
can only achieve efficiency through an extremely restrictive
language like Fortran, that is only good for numerical work.
The fact is, I want to use a language that gives me access
to very good, cheap compilers on any platform I like, specifically
platforms that number more than 0.00001% of the market share.
I also want access to libraries, APIs and all that good stuff,
and all the new features in OSes that PEOPLE ACTUALLY USE.
(I should say "MILLIONS OF PEOPLE", not the 3.6 people who
use some unheard of compiler on some ancient and long forgotten
system!)
When I see someone claim that C cannot possibly compete with
Fortran in numerical work, I know from personal experience
that this is complete and utter bullshit.
Of course, for most of the feeble minded who like to consider
themselves "expert numerical programmers", Fortran is all they
are capable of mastering.
>
> >I really cannot fathom why you actually
> >believe that this is more low level. As far as I understood,
> >computer memory is not two dimensional, and so I would rather
>
> If I told you computer memory was two dimensional, would you do things
> differently? I don't understand this line of reasoning.
Because eventually, someone or something is going to have
to map the dimensionality of your "arrays" to the dimensionality
of the computer memory. I don't expect you to understand this,
though, so why don't you just let your Fortran compiler do
the thinking for you.
> There are a lot of people who are willing to learn something
> through discussion and even argument. I would guess that Richard is
> one of them, and he thought you were one two. Are you?
Trolling is fun, you should try it sometime.... :)
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` boo
@ 1997-10-13 4:00 ` Aaron Spink
1997-10-14 4:00 ` boo
0 siblings, 1 reply; 99+ messages in thread
From: Aaron Spink @ 1997-10-13 4:00 UTC (permalink / raw)
boo <boo@tonys.ecology.umn.edu> writes:
> > Your original comment was that "as far as I understood, computer
> > memory is not two dimensional", and then you go off on this latest
> > posting and talk about how you're interested in computers that are
> > used by many people. Well the computers that are used by millions of
> > people DO have two dimensional memory, which you seem unaware of.
> > DRAM (of any kind) is two dimensional: locations have a row address
> > and a column address. This is hidden, for the most part, by other
> > hardware, but it really is there and it really can make a performance
> > difference.
>
> Does the OS know about it? If not, it is totally irrelevant, and
> you have missed the whole point. Next, you are going to say that
> because the chips themselves are arranged across on the simm/dimm
> models, which are arranged sequentially, that the memory is arranged
> three dimensionally. You obviously have no clue as to what my
> point it. The platforms I use have one dimensional flat memory
> spaces, and if I cannot access the mythical underlying structure
> you hint at, what is the point? What is your point, anyway?
The question is not whether or not the OS knows about it, its whether
you as the programmer know about it. In fact almost every thing
inside a computer has either two or more dimensions. If you actually
ever looked at a memory sub-system, you would find that its is made of
of a block oriented 3D pyramid stucture, with hard drives being the
base and the register being the tip. Actually dram itself depends
heavily of the actual thing accessing it to know about its internal
structure in order to get good memory performance. And AFAIK, one
dimensional flat memory spaces die out a long time ago. What we have
today is multi-dimensional multi-segmented memory conglomorations.
Now as a programer you can treat them as 1DFMS and piss away
performance, but personally if you did, I wouldn't run anything you
would write.
aaron spink
not speaking for dec
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Steve Tate
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Bernd Paysan
@ 1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Victor Yodaiken
` (3 more replies)
2 siblings, 4 replies; 99+ messages in thread
From: boo @ 1997-10-13 4:00 UTC (permalink / raw)
Steve Tate babbled:
> Your original comment was that "as far as I understood, computer
> memory is not two dimensional", and then you go off on this latest
> posting and talk about how you're interested in computers that are
> used by many people. Well the computers that are used by millions of
> people DO have two dimensional memory, which you seem unaware of.
> DRAM (of any kind) is two dimensional: locations have a row address
> and a column address. This is hidden, for the most part, by other
> hardware, but it really is there and it really can make a performance
> difference.
One other thing.... the important thing really is cache memory,
not DRAM. Even if you have several cache lines, they still
are cache LINES. Do you see what I am saying? If you can show
me some dimensionality of the cache (or other) memory that
I can actually take advantage of at the assembly level, then
I would love to hear about it. Seriously, I would, because I
would use it, so please enlighten me. Some of the arrays I have
played with in F90 have been 6 or 7 dimensional, so this is
quite important.
Alas! I fear that this is all a matter of semantics, and
the usual cyber-babble that computer scientists are prone to
sprout.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` Paul Rubin
@ 1997-10-13 4:00 ` boo
1997-10-15 4:00 ` Craig Burley
1 sibling, 1 reply; 99+ messages in thread
From: boo @ 1997-10-13 4:00 UTC (permalink / raw)
Craig Burley bored us with his thesis, which contained the gem:
> But, in my experience, the numerical types who use Fortran *already*
> have their algorithm issues worked out, because they're engineers,
> not programmers, and because they *have* to. E.g. it doesn't bother
> me much if my compiler is twice as slow as it could otherwise be
> on my home PC, at least, not compared to how much these numerical
> types are bothered when their latest number-cruncher is 2% slower than
> it could otherwise be, when that 2% costs them $10,000 per week due
> to it being run on a supercomputer on which they're buying time.
>
> C programmers just don't usually have as much vested interest in
> squeezing out that last 2% or so -- after all, their users can just
> wait for the next Pentium to come out anyway, while Fortran programmers
> include a pretty substantial group that depends on today's fastest
> and most expensive computers, and a newer, faster computer only
> means they can stuff more data into, or make more accurate
> calculations in, their programs, instead of using the next generation
> to cover up their programming inefficiencies.
How about super-computer user who wants the best possible performance
and the greatest flexibility, and chooses C over Fortran?
I think you have it wrong. The best compilers on the supercomputers
have traditionally been Fortran compilers. Those ones always get
the most development time, so naturally lead. Why do they get the
most attention? Because the supercomputer user is more likely than
not, a Fortran programmer, the language of the Engineer. If a typical
supercomputer user were a C programmer, the Fortran compilers would
not be as good! Fortran leads because Fortran is Entrenched! However,
with the advent of MPP supercomputers and nodal message passing
programming styles possible, efficient C code compares very favorably
with the best F90 code, surpassing it in many instances. Of course,
it is much easier and quicker to write a F90 program, than a
carefully thought out messaging passing nodal C code. (Nodal f77
code is also extremely efficient, compared with the F90 type
"parallel" code... but I see this as writing a Fortran program
in a C style, because the same level of thinking is required of
C to lay the "arrays" out across the nodes explicitly, what you
call "lowering"). It certainly was true on the Cray vector
supercomputers that C performance simply sucked compared with
the mature Fortran compilers, but this is not the case anymore!
(for some, not all). This really has only changed relatively recently.
It is much easier to produce an efficient F90 code than an
efficient C code, that much is obvious.
> [childish MS bashing masquerading as a analogy snipped]
Exactly what does Microsoft bashing have to do with C vs Fortran?
> In other words: there's been no real "contest" here. Childish insults
> from the (umn).edu side of things, yes, but no contest.
Usenet is fun, isn't it?
There is always the possibility that I am a crap Fortran programmer...
heh!
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-12 4:00 ` boo
@ 1997-10-13 4:00 ` Patricia Shanahan
1997-10-15 4:00 ` boo
1997-10-13 4:00 ` Steve Tate
1 sibling, 1 reply; 99+ messages in thread
From: Patricia Shanahan @ 1997-10-13 4:00 UTC (permalink / raw)
boo wrote:
...
> Because eventually, someone or something is going to have
> to map the dimensionality of your "arrays" to the dimensionality
> of the computer memory. I don't expect you to understand this,
> though, so why don't you just let your Fortran compiler do
> the thinking for you.
...
And someone or something is going to have to map the dimensionality of
your flat address space onto the dimensionality of the memory
hardware. It is all just abstractions and mappings - the issue is
which abstractions and mappings to use where and how.
Which gets right back to the issue of language/hardware interaction.
On the left, there is a large set of problems that need to be solved.
On the right, there are some relatively well-understood pieces such as
processor pipeline structures, cache structures, various types of
memory chips, I/O devices, and glue for sticking them together to make
a computer system. In the middle, there are transformations that can
be done by compilers, operating systems (for example managing virtual
memory mapping), and hardware (for example, mapping flat addresses
into the realities of memory hardware).
However much one may argue about which languages should be used for
which problems, the first stage of mapping of the problems has to be
done by programmers writing in some machine-processable language.
However the hardware pieces are put together, getting data to the
right places in the right processors is a key problem.
Are there changes that can be made in languages or the architectures
that would make the intermediate transformations go better, so that
way the program runs and the way the data is stored and moved around
the system would fit together better? Generally, a lot of attention
has been focussed on architectures that run existing programs well, so
if there is mileage here, at least some of it has to come from the
language end.
From this point of view "restrictiveness" in the source language is by
no means always a bad thing. Contraints that prevent the programmer
from doing something weird may help the rest of the system by limiting
what might be going on but almost always isn't.
The classic problem that got this discussion started was the variable
aliasing problem. Distinct formal parameters ALMOST always refer to
different objects. There are memory access re-orderings that work if
they actually refer to different objects, but that break the program
if they are the same object. I didn't like how Fortran77 handled this,
because the aliasing rule was too non-local. It was very easy for a
programmer changing an existing program to introduce a violation
without noticing it. There is little point in having a rule if it is
unenforceable in the compiler, not necessarily understood by the
programmer, and difficult to test a program for conformance.
Are there rules that would be testable and enforceable that would help
programs run well?
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Steve Tate
1997-10-13 4:00 ` boo
@ 1997-10-13 4:00 ` Bernd Paysan
1997-10-13 4:00 ` boo
2 siblings, 0 replies; 99+ messages in thread
From: Bernd Paysan @ 1997-10-13 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3017 bytes --]
Steve Tate wrote:
> A while back (this is probably 5 or 6 years ago) I was trying to get
> as fast an FFT as possible, so I was experimenting with split-radix
> FFT. Being a C programmer first, I implemented this in C and spent
> quite a bit of time getting everything as efficient as possible. When
> I was done I decided, on a lark, to implement the same general
> algorithm in a very straight-forward fashion using FORTRAN. I spent a
> couple of days timing and tuning the C code, and about an hour on the
> FORTRAN code. And the FORTRAN code was probably 5% FASTER. That
> surprised me quite a bit. Now it could very well be that I was using
> gcc as a C compiler, which isn't the greatest compiler in the world,
> and I was using a propriety very optimized FORTRAN compiler. So maybe
> a better C compiler would give me that 5% of runtime speed back. But
> what would give me that 2 days of C tuning time back?
A while back (3 years ago, IIRC), someone in my university donated a
bottle of champagner (which was turned into a chinese meal later) for
the first student who exceeds 30 MFLOPS on our 50 MHz PA-RISCs on
500x500 matrix multiplication (using the standard O(n�) algorithm). The
naive fortran version got around 10 MFLOPS (compiled with +O3, where the
compiler replaced the multiplication with a call to mat_mult()), the
naive C version got around 0.2 MFLOPS (because it was heavily swapping,
on machines with more memory, it got around 1 MFLOPS).
After a short discussion, whether this is possible, and why champagner,
I decided to do it, and I got just above 30 MFLOPS, using GCC. Using
HP's C didn't help (it was slightly worse); I examined the assembler
output, there was nothing to improve.
Well, it was hand-blocked for registers and memory, hand-layoutet so
that it got the best out of GCC's weak scheduler... and it took me two
days (certainly not full 9-5 days, that was on university).
It would have taken longer to generalize the approach (either by writing
a general matmul function, or by writing a generator for specialized
matmul functions), and certainly, this result is _not_
language-dependent (I could have get it out of Fortran, too). Any
language with a code generator that allows me to write code that matches
the machine instructions and allows me to choose my memory layout does.
I often use C, especially GCC, as portable assembler. GCC's built in
operations map to many instructions (including indirect branches, which
are missing in ANSI C), and when it doesn't, a bug report often helps
great. Writing fast software is complicated, it requires deep knowledge
of the machine you use, and 99.9% of the programmers will get better
code for numerical programs if they use the better compiler (thus
Fortran in most cases).
For writing larger applications, I don't use C, because it doesn't allow
the design methods I like to tune these applications. I use Forth.
--
Bernd Paysan
"Late answers are wrong answers!"
http://www.informatik.tu-muenchen.de/~paysan/
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Carl Perkins
@ 1997-10-13 4:00 ` Michael Williams
1997-10-13 4:00 ` Craig Burley
1 sibling, 1 reply; 99+ messages in thread
From: Michael Williams @ 1997-10-13 4:00 UTC (permalink / raw)
In article <3440F805.C98BB347@tonys.ecology.umn.edu>,
boo <boo@tonys.ecology.umn.edu> wrote:
>I did not say there was ONE efficient way. If you are just looking
>for ONE efficient way, then perhaps you should stick with Fortran.
>As I said before, Fortran is for the lazy, the feeble-minded,
>the incompetent, and for those who aren't doing anything beyond
>simple-minded number crunching.
I've tried to read both sides of the argument in this thread so
far. As far as I can tell, the argument is that, whereas it is
possible to do multi-dimensional arrays in C, it's not possible to
deal with them efficiently, if you write the 'natural' code.
In fact, my reading of it - and I have to admit it's not something I'd
considered before - is that the problem is largely to do with arrays
in general, rather than multidimensional.
The problem with using a construct such as array[i*(x*y) + j*y + k]
(via, say, a macro), compared to array[i][j][k] is the latter is
undefined if i, j, or k is out of range, whereas the former isn't. (It
may be in your application, but the compiler can't assume this.) The
compiler could use that information to improve the dataflow through
your program. Without it you have to jump through hoops, in C, to get
a similar result. Hoops which probably vary from machine to machine.
The other part of the argument probably centers around the way the
various Fortran advocates[1] seem to know what they're talking about,
whilst being insulted and derided by their opponents. I don't know
about the intel and dec groups, but it's a bit out of place on
comp.arch.
Mike[2].
[1] Actually, I suspect many of them are just experienced programmers.
[2] Never written a large numerical processing program in his life; C
programmer; managed to avoid Fortran completely for the past 6 1/2
years.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Patricia Shanahan
@ 1997-10-13 4:00 ` Steve Tate
1997-10-13 4:00 ` boo
` (2 more replies)
1 sibling, 3 replies; 99+ messages in thread
From: Steve Tate @ 1997-10-13 4:00 UTC (permalink / raw)
boo (boo@tonys.ecology.umn.edu) wrote:
> Tyson Richard DOWD babbled:
> > >I really cannot fathom why you actually
> > >believe that this is more low level. As far as I understood,
> > >computer memory is not two dimensional, and so I would rather
> >
> > If I told you computer memory was two dimensional, would you do things
> > differently? I don't understand this line of reasoning.
> Because eventually, someone or something is going to have
> to map the dimensionality of your "arrays" to the dimensionality
> of the computer memory. I don't expect you to understand this,
> though, so why don't you just let your Fortran compiler do
> the thinking for you.
Your original comment was that "as far as I understood, computer
memory is not two dimensional", and then you go off on this latest
posting and talk about how you're interested in computers that are
used by many people. Well the computers that are used by millions of
people DO have two dimensional memory, which you seem unaware of.
DRAM (of any kind) is two dimensional: locations have a row address
and a column address. This is hidden, for the most part, by other
hardware, but it really is there and it really can make a performance
difference. Not that this relates directly to the current language
war...
The whole thread here of FORTRAN vs. C is a common religious war, but
let me throw in my 2 cents and risk being called a "crap C programmer"
by people (which would definitely not be true, incidentally).
A while back (this is probably 5 or 6 years ago) I was trying to get
as fast an FFT as possible, so I was experimenting with split-radix
FFT. Being a C programmer first, I implemented this in C and spent
quite a bit of time getting everything as efficient as possible. When
I was done I decided, on a lark, to implement the same general
algorithm in a very straight-forward fashion using FORTRAN. I spent a
couple of days timing and tuning the C code, and about an hour on the
FORTRAN code. And the FORTRAN code was probably 5% FASTER. That
surprised me quite a bit. Now it could very well be that I was using
gcc as a C compiler, which isn't the greatest compiler in the world,
and I was using a propriety very optimized FORTRAN compiler. So maybe
a better C compiler would give me that 5% of runtime speed back. But
what would give me that 2 days of C tuning time back?
Bottom line is this. People arguing that "C is always better" are
being silly. People arguing that "FORTRAN is always better" are being
silly. Each has its place. If I were writing straight numerical code
with very nice predictable access patterns, I'd use FORTRAN and have
the compiler optimize the hell out of it. If I were doing a
non-numerical problem and had to implement some advanced linked data
structure (for example, an AVL tree or a skip list), I'd use C.
Don't delude yourself into thinking everything looks like a nail just
because you want to use your hammer all the time (a mangling of a
popular cliche there, but what the hell...).
--
Steve Tate --- srt@cs.unt.edu | "As often as a study is cultivated by narrow
Dept. of Computer Sciences | minds, they will draw from it narrow
University of North Texas | conclusions." -- John Stuart Mill, 1865.
Denton, TX 76201 |
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Michael Williams
@ 1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` Paul Rubin
1997-10-13 4:00 ` boo
0 siblings, 2 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-13 4:00 UTC (permalink / raw)
michael.williams@arm-sponge.com (Michael Williams) writes:
> In article <3440F805.C98BB347@tonys.ecology.umn.edu>,
> boo <boo@tonys.ecology.umn.edu> wrote:
> >I did not say there was ONE efficient way. If you are just looking
> >for ONE efficient way, then perhaps you should stick with Fortran.
> >As I said before, Fortran is for the lazy, the feeble-minded,
> >the incompetent, and for those who aren't doing anything beyond
> >simple-minded number crunching.
>
> I've tried to read both sides of the argument in this thread so
> far. As far as I can tell, the argument is that, whereas it is
> possible to do multi-dimensional arrays in C, it's not possible to
> deal with them efficiently, if you write the 'natural' code.
It's *possible* for a compiler to deal with them efficiently. It's
rare for a compiler to *actually* do so in practice. Programmers
with sufficient time and/or interest can always "lower" their code
in C -- or Fortran, a fact which nobody seems to have bothered with,
since Fortran already lets you just type it in the "natural" way and
let the compiler do the work for you.
For example, a Fortran compiler in beta test that is nevertheless
widely used, GNU Fortran (g77), in some cases generates substantially
better code if you replace array declarations and references like
"REAL A(M,N)...A(I,J)" with "lowered" ones like "REAL A(0:M*N)...
A((J-1)*M+(I-1))" (or whatever the equivalence would be).
The reason is that the back end it uses is C-oriented, and it has
been pretty well optimized to produce good code for "lowered" C code
to do some of these things, whereas g77, given the higher-level Fortran
constructs (which cannot be expressed in C, ANSI C, or C++), implements
them via back-end mechanisms that are not as well optimized. (Although
this is being worked on....)
However, some g77 users have discovered that turning on an old
macro definition in the g77 sources causes it to convert the
higher-level Fortran constructs directly into the lower-level C-like
form when it comes to calling on the back end -- and this *also* results
in generating (the same, or similar) faster code.
In other words, while using C *requires* you to "lower" your code
to get anything like decent efficiency *and* use a pretty sophisticated
optimizing compiler to "discern" what you're really trying to do, using
Fortran *allows* you to leave your code in its "original", higher form.
Then, if your Fortran compiler produces great code from it, wonderful;
if not, you can then lower your Fortran code just like you can with C
(though a C preprocessor is not standard with Fortran, you can use
statement functions where you'd use C macros for this) *or* you can
just modify your compiler -- the latter being far easier to do when
it's a Fortran compiler than a C compiler, as illustrated by the g77
example.
Since g77 is in beta test and has only recently had performance issues
come under some scrutiny in terms of actual improvements to the
compiler, I suspect few production Fortran compilers *require* lowering
of Fortran code to get substantially better performance, except perhaps
in rare cases.
Of course, once you "lower" your code -- either by changing your Fortran
code, or by writing your application in C -- you've lost some *other*
features, like ease of debugging, and catching out-of-bounds references
(especially the kind that are out of the bounds of their dimension,
where the complete array-offset calculation is *not* out of bounds --
which is nevertheless a programming error).
A similar example of C *requiring* lowering because it doesn't provide
linguistic features other languages (like Fortran) have is illustrated
by the following Fortran snippet:
IMPLICIT LOGICAL(A-Z)
BOOL = F() .AND. (G() .OR. H())
C has no way to express the above. It *requires* you to lower it, to,
for example,
bool = f() & (g() | h())
or:
bool = f() && (g() || h())
C programmers typically claim this "low-level" nature of their language
*allows* them to write "faster" code for a particular machine, but,
in practice, that isn't true in cases like the above, because even
Fortran allows such a thing. The Fortran versions of the above "lowered"
code are
BOOL1 = F()
BOOL2 = G()
BOOL3 = H()
BOOL = BOOL1 .AND. (BOOL2 .OR. BOOL3)
and
IF (F()) THEN
IF (G()) THEN
BOOL = .TRUE.
ELSE IF (H()) THEN
BOOL = .TRUE.
ELSE
BOOL = .FALSE.
END IF
ELSE
BOOL = .FALSE.
END IF
(respectively).
In both cases clunkier, but in both cases *semantically equivalent*
when it comes to code generation. That is, aside from other,
unrelated semantic differences between C and Fortran, the compilers
have pretty much the exact same degrees of freedom when it
comes to generating fast code. E.g. in the first lowered versions,
each compiler *must* ensure that all three functions are called
(and thus their side effects performed), whereas in the second
lowered versions, each compiler must ensure that the functions
are called in order and only depending on the results from the
previous calls, again, due to side effects.
However, the *original* Fortran code is (assuming it's correct)
most faithful in expressing the original problem. As soon as you
write it in C, you've lost information regarding how flexibly the
implementation can be in calculating the answer, but while it's
in Fortran, the implementation can even do things like run-time
determination of which of F(), G(), and H() will take longest to
run and call them in any order, or call them in parallel, or call
only one or two of them, or whatever -- stuff a C compiler can do
*only* if it does far more global analysis than the Fortran compiler
typically needs to do. (Although, just as C programmers often overstep
what the standard lets them do, meaning compilers must sometimes avoid
doing otherwise-okay optimizations, the same is true for Fortran.
E.g. a C compiler could, but users might otherwise complain if it
does, optimize "*p1 ^= *p2 ^= *p3 ^= *p4;" in a way that "breaks"
if p1==p3 and/or p2==p4. But, similarly, Fortran users might complain
if "BOOL = F() .AND. G()" doesn't actually perform the side effects
of F() when G() evaluates to .FALSE.. In both cases, the users are
requiring the compiler to implement a more strict form of their
respective language, something real-world compiler writers must
take into account.)
In summary, C often *requires* you to write *lowered* code instead
of expressing what you mean directly, whereas languages like Fortran
merely *allow* this.
In fact, I was talking with someone at Dakota Scientific Systems (sp?)
a few months ago. They take (normally Fortran) code doing real
number-crunching and optimize the heck out of it for a particular
platform/chipset/whatever. E.g. stuff like BLAS, IIRC.
Anyway, what *really* surprised me was that the guy explained that
they do *not* simply take the compiler's output and optimize the
assembly -- instead, they optimize the *original Fortran*, leaving
the optimized code in Fortran! That is, they move assignment
statements around, and, I'd guess, "lower" the code when necessary
(probably rare), to get the *compiler* to produce the native code.
And, apparently, they get at or near industry-best results this way.
Proof, or persuasive evidence, that pretty much any lowering C requires
you to do, Fortran *allows* you to do, especially in the realm of
numerical computing.
There's little doubt in my mind that C offers great notational
convenience, though. I'm much happier, for now, writing compilers in
C than Fortran or, say, PL/I, *because* it has `&&' and `||', among
other things. Yes, sometimes I'd like to use the (missing)
higher-level constructs and let the compiler decide, but in the
kind of code I write (non-numerical), it doesn't usually matter --
the performance relates more to algorithm selection and overall
design than to low-level implementation issues.
But, in my experience, the numerical types who use Fortran *already*
have their algorithm issues worked out, because they're engineers,
not programmers, and because they *have* to. E.g. it doesn't bother
me much if my compiler is twice as slow as it could otherwise be
on my home PC, at least, not compared to how much these numerical
types are bothered when their latest number-cruncher is 2% slower than
it could otherwise be, when that 2% costs them $10,000 per week due
to it being run on a supercomputer on which they're buying time.
C programmers just don't usually have as much vested interest in
squeezing out that last 2% or so -- after all, their users can just
wait for the next Pentium to come out anyway, while Fortran programmers
include a pretty substantial group that depends on today's fastest
and most expensive computers, and a newer, faster computer only
means they can stuff more data into, or make more accurate
calculations in, their programs, instead of using the next generation
to cover up their programming inefficiencies.
(My take on the difference between an engineer and a programmer:
an engineer takes real-world complexities into account when designing
his system, and thus tends to produce a simple, robust system; a
programmer ignores real-world complexities so he can design an
unnecessarily complicated system. For example, if Microsoft designed
the Golden Gate Bridge, it'd allow traffic in only one direction at
any given time; if two cars got on at the same time in opposite
directions, it'd fall into the sea ("user error"); you'd have to drive
a Microsoft-approved car to go 10mph, otherwise you'd have to go below
5mph; you'd have to use that bridge to drive from LA to San Diego in
your Microsoft-approved car; you'd be unable to drive over any
*non*-Microsoft bridge in your Microsoft-approved car; and they'd
expect to be funded to "upgrade" the bridge two years later, which
would mean they'd take the money, tear down the old bridge, and build
a new bridge, requiring slower speeds, somewhere else. :)
> The other part of the argument probably centers around the way the
> various Fortran advocates[1] seem to know what they're talking about,
> whilst being insulted and derided by their opponents. I don't know
> about the intel and dec groups, but it's a bit out of place on
> comp.arch.
Well, if the Dallas Cowboys played a "real" game against some high
school's team, I wouldn't consider the high-school team to be their
"opponents", no matter how good that team was at trash-talking.
Even if the score ended up in favor of the high-school team, nobody
in their right mind would assume that meant they were "better" than
the Cowboys or (most) any other NFL team.
In other words: there's been no real "contest" here. Childish insults
from the (umn).edu side of things, yes, but no contest.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Paul Rubin
@ 1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` William Clodius
1997-10-14 4:00 ` Richard A. O'Keefe
2 siblings, 0 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-13 4:00 UTC (permalink / raw)
Paul Rubin <phr@netcom.com> writes:
> Craig Burley <burley@tweedledumb.cygnus.com> writes:
> >
> > IMPLICIT LOGICAL(A-Z)
> > BOOL = F() .AND. (G() .OR. H())
> >
> Is this C statement equivalent to the Fortran?
>
> bool = !(!f() | (!g() & !h()));
>
> Translation: sets bool to 1 (.true.) if f() is nonzero (.false.)
> and g() or h() is nonzero; makes sure all the functions are called,
> but they could be called in any order.
No, forget about the int/bool distinction, that's not what I was
getting at.
The Fortran statement does not *mean* "[make] sure all the functions
are called". That's why Fortran is "higher-level" in this case,
because it offers a construct that cannot be expressed in C, whereas
it does offer (verbose, but still clear) ways to specify the lower-level
constructs C specifies. This example is probably not important in
most cases when it comes to generating optimal code, but it does
illustrate the concept, being discussed here, that higher-level
constructs have important advantages over lower-level ones. And,
Fortran offers many higher-level constructs (functions, boolean
operators, multi-dimensional arrays, adjustable arrays, and so on)
that are inexpressible in C. I think even C's pointers can be
expressed in FORTRAN 77, using a translation method that would be quite
painful to live with (and thus worthless as a language to write code in),
but there *are* no translations of some common, and frequently used,
Fortran constructs available in the C language. Fortunately, there
are typically several choices of *implementations* of such constructs
that are available in C, which is why products like f2c (which
*converts*, rather than translates, FORTRAN 77 to K&R C) can exist.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Craig Burley
@ 1997-10-13 4:00 ` Paul Rubin
1997-10-13 4:00 ` Craig Burley
` (2 more replies)
1997-10-13 4:00 ` boo
1 sibling, 3 replies; 99+ messages in thread
From: Paul Rubin @ 1997-10-13 4:00 UTC (permalink / raw)
Craig Burley <burley@tweedledumb.cygnus.com> writes:
> A similar example of C *requiring* lowering because it doesn't provide
> linguistic features other languages (like Fortran) have is illustrated
> by the following Fortran snippet:
>
> IMPLICIT LOGICAL(A-Z)
> BOOL = F() .AND. (G() .OR. H())
>
> C has no way to express the above. It *requires* you to lower it, to,
> for example,
>
> bool = f() & (g() | h())
>
> or:
>
> bool = f() && (g() || h())
>
> C programmers typically claim this "low-level" nature of their language
> *allows* them to write "faster" code for a particular machine, but,
> in practice, that isn't true in cases like the above, because even
> Fortran allows such a thing. The Fortran versions of the above "lowered"
> code are [ugly translations snipped]
Is this C statement equivalent to the Fortran?
My Fortran is very rusty.... :-)
bool = !(!f() | (!g() & !h()));
Translation: sets bool to 1 (.true.) if f() is nonzero (.false.)
and g() or h() is nonzero; makes sure all the functions are called,
but they could be called in any order.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Gregg E Economou
@ 1997-10-13 4:00 ` Patricia Shanahan
1997-10-14 4:00 ` Richard A. O'Keefe
1 sibling, 0 replies; 99+ messages in thread
From: Patricia Shanahan @ 1997-10-13 4:00 UTC (permalink / raw)
Gregg E Economou wrote:
>
> In article <343FAA72.2ED97125@acm.org>,
> Patricia Shanahan <pats@acm.org> wrote:
> >
> >Why do you say "computer memory is NOT multi-dimensional"? Every
> >computer memory structure that I have looked at in enough detail for
> >analysis of its performance has been multi-dimensional. In the case of
>
> You miss the point that while yes, they may be physically multidimensional,
> and even organisationally multidimensional, and even architecturally
> multidimensional, they are *logically* linear, and accessed in a linear
> fashion. Yes, there are strange exceptions out there, but the majority
> of memories are linear int the majorities or architectures and the
> majority of machines ever designed, made, or sold.
>
> isildur
No, I am very aware of that point. Flat addressing is still only an
abstration. It is a very, very, useful one. The operating system,
processor, and memory controller deal with these issues in such a way
that a normal programmer never has to worry about them. Much of the
time when I am programming I act as though it were real even on
systems where I know the realities of the memory hierarchy in gory
detail.
For programs that logically need a lot of multi-dimensional array
handling, the model provided by a language such as Fortran that makes
it look as though there are multi-dimensional arrays is just as
valuable and valid as the one that makes it look as though there is a
flat address space. Those multi-dimensional arrays are neither more
nor less real than the flat address space. Both, ultimately, get
mapped into caches and memories that are neither flat nor necessarily
dimensioned the same as the program arrays.
Most of the art of computing is choosing just which abstractions to
use when.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` boo
@ 1997-10-13 4:00 ` Victor Yodaiken
1997-10-14 4:00 ` Aaron Spink
` (2 subsequent siblings)
3 siblings, 0 replies; 99+ messages in thread
From: Victor Yodaiken @ 1997-10-13 4:00 UTC (permalink / raw)
On Mon, 13 Oct 1997 14:58:30 -0500, boo <boo@tonys.ecology.umn.edu> wrote:
>One other thing.... the important thing really is cache memory,
>not DRAM.
With fast SDRAM and gigantic programs that trash any cache
anyways, the whole point of hardwired cacheing starts to
become unclear. For many problems allowing software to makeuse of
page-mode or to optimize for interleaving would be a big win.
>Even if you have several cache lines, they still
>are cache LINES. Do you see what I am saying? If you can show
>me some dimensionality of the cache (or other) memory that
>I can actually take advantage of at the assembly level, then
Some architectures already offer some instructions to touch
caches. PPC allows "zero cache line with no memory read" and
load-register-bypass-cache. I'd like to see some
"write cache-line for vaddr1 to memory vaddr2 " etc.
Also it would be nice to see some more imagination in virtual
addressing so that linked lists could be combined into virtual
flat arrays conveniently.
>Alas! I fear that this is all a matter of semantics, and
>the usual cyber-babble that computer scientists are prone to
>sprout.
Another bitter physicist, I presume. Sorry that the cold war ended,
but there's nothing I can do.
---------------------------------
Victor Yodaiken
Department of Computer Science
New Mexico Institute of Mining and Technology
Socorro NM 87801
Homepage http://www.cs.nmt.edu/~yodaiken
PowerPC Linux page http://www.cs.nmt.edu/~linuxppc
Real-Time Page http://luz.cs.nmt.edu/~rtlinux
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Paul Rubin
1997-10-13 4:00 ` Craig Burley
@ 1997-10-13 4:00 ` William Clodius
1997-10-14 4:00 ` Richard A. O'Keefe
2 siblings, 0 replies; 99+ messages in thread
From: William Clodius @ 1997-10-13 4:00 UTC (permalink / raw)
Paul Rubin wrote:
> <snip>
> Is this C statement equivalent to the Fortran?
> My Fortran is very rusty.... :-)
>
> bool = !(!f() | (!g() & !h()));
>
> Translation: sets bool to 1 (.true.) if f() is nonzero (.false.)
> and g() or h() is nonzero; makes sure all the functions are called,
> but they could be called in any order.
No it is not equivalent. The Fortran compiler can choose any of the
available shortcircuiting paths and hence need not execute more than one
of the functions. However unlike C you have not explicitly specified a
shortcircuiting path and have no standard conforming means of knowing
which (if any) shortcircuiting path it took. In other similar code it
need not execute any of the functions, if they had been previously
executed and the semantics of Fortran implies that the value returned
would not change. I.e., no intervening subroutine call had occurred.
--
William B. Clodius Phone: (505)-665-9370
Los Alamos Nat. Lab., NIS-2 FAX: (505)-667-3815
PO Box 1663, MS-C323 Group office: (505)-667-5776
Los Alamos, NM 87545 Email: wclodius@lanl.gov
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Steve Tate
@ 1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Aaron Spink
1997-10-13 4:00 ` Bernd Paysan
1997-10-13 4:00 ` boo
2 siblings, 1 reply; 99+ messages in thread
From: boo @ 1997-10-13 4:00 UTC (permalink / raw)
Steve Tate babbled:
>
> boo (boo@tonys.ecology.umn.edu) wrote:
> > Tyson Richard DOWD babbled:
>
> > > >I really cannot fathom why you actually
> > > >believe that this is more low level. As far as I understood,
> > > >computer memory is not two dimensional, and so I would rather
> > >
> > > If I told you computer memory was two dimensional, would you do things
> > > differently? I don't understand this line of reasoning.
>
> > Because eventually, someone or something is going to have
> > to map the dimensionality of your "arrays" to the dimensionality
> > of the computer memory. I don't expect you to understand this,
> > though, so why don't you just let your Fortran compiler do
> > the thinking for you.
>
> Your original comment was that "as far as I understood, computer
> memory is not two dimensional", and then you go off on this latest
> posting and talk about how you're interested in computers that are
> used by many people. Well the computers that are used by millions of
> people DO have two dimensional memory, which you seem unaware of.
> DRAM (of any kind) is two dimensional: locations have a row address
> and a column address. This is hidden, for the most part, by other
> hardware, but it really is there and it really can make a performance
> difference.
Does the OS know about it? If not, it is totally irrelevant, and
you have missed the whole point. Next, you are going to say that
because the chips themselves are arranged across on the simm/dimm
models, which are arranged sequentially, that the memory is arranged
three dimensionally. You obviously have no clue as to what my
point it. The platforms I use have one dimensional flat memory
spaces, and if I cannot access the mythical underlying structure
you hint at, what is the point? What is your point, anyway?
> So maybe
> a better C compiler would give me that 5% of runtime speed back. But
> what would give me that 2 days of C tuning time back?
Maybe you ARE a crap programmer, did you consider that?
> Bottom line is this. People arguing that "C is always better" are
> being silly. People arguing that "FORTRAN is always better" are being
> silly.
C is usually better FOR ME, and Fortran is usually better FOR OTHERS.
That is my point. If you are a crap programmer, then Fortran or
Visual Basic or Delphi are probably for you.
> Each has its place. If I were writing straight numerical code
> with very nice predictable access patterns, I'd use FORTRAN and have
> the compiler optimize the hell out of it. If I were doing a
> non-numerical problem and had to implement some advanced linked data
> structure (for example, an AVL tree or a skip list), I'd use C.
Not all of us have such clear-cut classifications for our software
development.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-12 4:00 ` boo
@ 1997-10-13 4:00 ` Carl Perkins
1997-10-13 4:00 ` Michael Williams
1 sibling, 0 replies; 99+ messages in thread
From: Carl Perkins @ 1997-10-13 4:00 UTC (permalink / raw)
boo <boo@tonys.ecology.umn.edu> writes...
}Jan Vorbrueggen babbled inanely:
}> boo <boo@tonys.ecology.umn.edu> writes:
}> > Once you have understood exactly how to implement
}> > multiple dimensional "arrays" in C efficiently and have gained
}> > some experience, it doesn't "suck" anymore, and you will understand
}> > exactly how flexible C actually is. But it isn't for amateurs,
}> > or for the Ivory Tower Set of this thread.
}>
}> Sure, and there is exactly one way, eh, that will be efficient on _all_
}> hardware, will it not? And all those FORTRAN compiler writers should return
}> their paychecks to their employers in shame, as they haven't managed to
}> implement FORTRAN arrays the same efficient way you do. Or are you claiming
}> that FORTRAN doesn't allow your one efficient way?
}
}I did not say there was ONE efficient way. If you are just looking
}for ONE efficient way, then perhaps you should stick with Fortran.
}As I said before, Fortran is for the lazy, the feeble-minded,
}the incompetent, and for those who aren't doing anything beyond
}simple-minded number crunching.
}
}Perhaps you should stop trying to read between the lines, because
}you obviously are not very good at it.
Probably because the message was written by a feeble-minded incompetent.
(Brought to you by the Pot & Kettle School of Ad Hominem "Logic".)
--- Carl
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-11 4:00 ` Patricia Shanahan
@ 1997-10-13 4:00 ` Gregg E Economou
1997-10-13 4:00 ` Patricia Shanahan
1997-10-14 4:00 ` Richard A. O'Keefe
0 siblings, 2 replies; 99+ messages in thread
From: Gregg E Economou @ 1997-10-13 4:00 UTC (permalink / raw)
In article <343FAA72.2ED97125@acm.org>,
Patricia Shanahan <pats@acm.org> wrote:
>
>Why do you say "computer memory is NOT multi-dimensional"? Every
>computer memory structure that I have looked at in enough detail for
>analysis of its performance has been multi-dimensional. In the case of
You miss the point that while yes, they may be physically multidimensional,
and even organisationally multidimensional, and even architecturally
multidimensional, they are *logically* linear, and accessed in a linear
fashion. Yes, there are strange exceptions out there, but the majority
of memories are linear int the majorities or architectures and the
majority of machines ever designed, made, or sold.
isildur
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Michael Williams
@ 1997-10-14 4:00 ` Richard Black
1997-10-15 4:00 ` Craig Burley
` (2 more replies)
0 siblings, 3 replies; 99+ messages in thread
From: Richard Black @ 1997-10-14 4:00 UTC (permalink / raw)
michael.williams@arm-sponge.com (Michael Williams) writes:
>
> In article <61uoiu$19e$1@goanna.cs.rmit.edu.au>,
> Richard A. O'Keefe <ok@goanna.cs.rmit.edu.au> wrote:
> >A Fortran compiler is allowed to say "hey, I know the result of 0*F()
> >without calling F, so I won't call F". A C compiler is not.
> >Sun's f77 compiler actually does this. I put that example in a file
> >called 'foo.f' and did f77 -O5 foo.f; a.out The program compiled,
> >linked, ran, and printed 0. The C version, however, doesn't link,
> >because it must call f.
>
> Actually, gcc probably wouldn't link even if it had optimised out the
> call to f(), e.g.:
>
> if (0) f();
>
> still generates an undefined reference to 'f' in the object file (even
> though the call to 'f' is optimised out, in this case).
> F
>
> Mike. (Learning even more about Fortran every day.)
But if gcc knows the same amount of information as Fortran (i.e. that
f() is side-effect-free) it can also make the same optimisation. viz:
extern int f(int a) __attribute__ ((const));
int b(int a)
{
return 0 * f(a);
}
becomes (since you are at ARM):
@ Generated by gcc 2.7.2 for ARM/(generic)
rfp .req r9
sl .req r10
fp .req r11
ip .req r12
sp .req r13
lr .req r14
pc .req r15
gcc2_compiled.:
___gnu_compiled_c:
.text
.align 0
.global _b
_b:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, current_function_anonymous_args = 0
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
mov r0, #0
sub fp, ip, #4
ldmea fp, {fp, sp, pc}
At its core this whole discussion is not really a FORTRAN versus C
issue. Its a question of "How do we come up with a language that
allows us to represent what is really going on in such a way that it
is easy for the programmer to specify (correctly!) and possible for
the compiler to make effective use of it."
Fortran "solves" this problem by having a restricted type system which
makes it inappropriate for some problems (e.g. writing operating
systems and device drivers). C's type system is simply pathetic, C++
is worse, and Java's is only marginally better than C's.
From the other point of view the functional programming people
understand type systems properly but have yet (in my experience) to
provide a language which allows nasty things like device drivers to be
written.
[ Consider 'void reschedule(void)' Fortran might optimise such a thing
out, which might be very bad for your operating system.... ]
Oh, and this language has to be both non-proprietary and have huge
industry support. It may well be that we have to go from here to
there in steps, and that Java is the first such.
--
----------------------------------------------+------------------------
Dr. R.J. Black, University Lecturer, | Phone: +44 141 330 6039
University of Glasgow, Computing Science Dept.| Fax: +44 141 330 4913
17 Lillybank Gdns., Glasgow G12 8RZ, U.K. | Mail: rjb@dcs.gla.ac.uk
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Paul Rubin
1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` William Clodius
@ 1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-14 4:00 ` Michael Williams
` (2 more replies)
2 siblings, 3 replies; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-14 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3573 bytes --]
Paul Rubin <phr@netcom.com> writes:
>> BOOL = F() .AND. (G() .OR. H())
>Is this C statement equivalent to the Fortran?
>My Fortran is very rusty.... :-)
> bool = !(!f() | (!g() & !h()));
In a word, NO. The C version absolutely requires all of the function
calls to be performed. A C compiler is not allowed to discard a function
call simply because it knows the result. A simpler example is
#include <stdio.h>
INTEGER I, F extern int f(void);
EXTERNAL F int main(void) {
int i;
I = 0*F() i = 0*f();
PRINT *, I printf("%d\n", i);
END return 0;
}
A Fortran compiler is allowed to say "hey, I know the result of 0*F()
without calling F, so I won't call F". A C compiler is not.
Sun's f77 compiler actually does this. I put that example in a file
called 'foo.f' and did f77 -O5 foo.f; a.out The program compiled,
linked, ran, and printed 0. The C version, however, doesn't link,
because it must call f.
Whatever code a C compiler generates for the
> bool = !(!f() | (!g() & !h()));
fragment, it must arrange for f, g, and h to all be called exactly
once, whatever results are returned.
To be perfectly frank, I am not convinced that _this_ particular
freedom in Fortran is a good idea. Pascal has the same freedom.
The machine I used as an undergraduate, a B6700, had Fortran and
Pascal compilers that said 'avoid conditional branches' so that
BOOL = 1.LE.I .AND. I.LE.N .AND. A(I).LT.0. !Fortran
Bool := (1<=I) and (I<=N) and (A[I]<0.0); {Pascal}
evaluated _all_ the subexpressions. This wasn't a problem for me
writing new code for these machines, but it was a truly horrible
problem when I tried to port code written by sloppy programmers
for other machines with compilers that used short-circuit AND and OR.
I typically had to examine every AND and OR to see whether they needed
to be rewritten to conform to the strictures of the standard.
The really sad thing here is that for the 1.LT.I .AND. I.LE.N bit,
compare =1, rI, R1
compare rI, rN, R2
and R1, R2, R1
branch_if_false R1, L
is easier for modern machines to deal with, having fewer conditional
branches, than
compare =1, rI, R1
branch_if_false R1, L
compare rI, rN, R1
branch_if_false R1, L
so 'strict' evaluation of AND and OR can be useful, and it generalises
very nicely to arrays, which short-circuit AND and OR do not.
Burroughs Algol in this case would have had me write
BOOL := IF 1 <= I AND I <= N THEN A[I] < 0.0 ELSE FALSE;
where the AND is strict, and the short-circuit AND is expressed with
an IF.
There are three issues here.
(1) Strict and short-circuit AND/OR can have different consequences
when some of the operands may be undefined, raise exceptions, or
have side effects, *whatever* the architecture.
(2) For the 'portable' Pascal and Fortran formulas, which _do_ yield
the same outcomes either way, there are *efficiency* differences,
and it is _this_ that the Fortran and Pascal standards were trying
to exploit, by giving the compiler freedom to choose what is best
for this model of this machine today.
(3) Leaving the interpretation open in the other cases created nasty
porting problems, as leaving interpretations open generally does.
I don't pretend to have any generally optimal solution to this.
Ada, with its 'and' -vs- 'and then' and 'or' -vs- 'or else',
seems to be a very workable compromise here.
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Gregg E Economou
1997-10-13 4:00 ` Patricia Shanahan
@ 1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` boo
1 sibling, 1 reply; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-14 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4080 bytes --]
geest3+@pitt.edu (Gregg E Economou) writes:
>You miss the point that while yes, they may be physically multidimensional,
>and even organisationally multidimensional, and even architecturally
>multidimensional, they are *logically* linear, and accessed in a linear
>fashion. Yes, there are strange exceptions out there, but the majority
>of memories are linear int the majorities or architectures and the
>majority of machines ever designed, made, or sold.
With everybody accusing everyone else of missing *the* point,
perhaps it is time to make *a* point.
Today, if you want to write high-performance code on stock hardware,
you have to view your plain ordinary so-called 'linear' address space
as three dimensional.
For example, I am writing this on an UltraSPARC 2.
Level 1 data cache: (The L1 code cache is the same,
16 kbytes I _think_)
32 bytes per line
1-way association
Level 2 cache: (Unified, I _think_)
512 kbytes
64 bytes per line
1-way association
VM
2 Gbytes
8 kbytes per page
Physical memory
512 Mbytes
I've loaned the manual to a student, but if I remember correctly,
latency for load from L1 cache: 3 cycles
latency for load from L2 cache: 8 cycles
latency for load from physical: 30 cycles (if mapped)
latency for load from disc : on the order of 2 000 000 cycles
The machine is four-way superscalar. With well-blocked code working
on data that fits into L2 cache, it isn't very hard to get a floating
add and a floating multiply every cycle. But you simply cannot
sustain that kind of speed on larger amounts of data without taking
the memory hierarchy with extreme seriousness.
I had my first real lesson in memory hierachies back on a Sun 3/50
years ago, where an algorithm that normally did 6000 interesting things
per second suddenly dropped to 6 things per second, thanks to paging.
We fixed that problem by replacing a conventional internal hash table
with a kind of hash table originally designed for data on disc.
There are about 130 processes running on this machine. Perhaps a
more useful indicator is the number of people logged in, which is
about 50 (not counting multiple logins). 512Mb of memory sounds
like a lot, but practically speaking my share is about 10Mb. (About
what you'd get to yourself on a PC with 32Mb of RAM if you shut just
about everything not directly connected with your task down).
If I want to do anything that takes _much_ more than my share of
(physical) memory, I had better design my code very carefully.
'boo' said something about not having to worry about the dimensionality
of memory, and also said something about cache in the same message.
Well, that's another area where it _does_ matter. This machine, like
some others, offers block load and block store instructions. A single
load or store can move 64 bytes. For marching sequentially through
big arrays, it's pretty good, because these instructions don't pollute
the cache, so you can walk through a large array _without_ flushing
stuff you'll want again out of the cache. NIce. But in order to use
those instructions, you have to envisoage your simple linear vector
as an array of 64-byte vectors.
On this machine, think of memory as
an array of 65536 // physical memory
arrays of 128 // pages
arrays of 64 // L2 cache lines (load/store blocks)
bytes
Organising your code to stick with the same small set of 'rows' (cache
lines) wins up to a factor of 4 in memory performance compared with
scattered access.
Organising your code to stick with the same small set of 'planes'
(pages) wins a factor of 10s of thousands in memory performance
compared with scatted access.
The means whereby you access a location is independent of where it is,
but the *cost* certainly isn't. (Oh, and I didn't mention the page
mapping caches! There's another performance knee there, if you don't
watch out.)
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Victor Yodaiken
1997-10-14 4:00 ` Aaron Spink
@ 1997-10-14 4:00 ` Jason.Ozolins
1997-10-15 4:00 ` boo
1997-10-15 4:00 ` David Chase
3 siblings, 1 reply; 99+ messages in thread
From: Jason.Ozolins @ 1997-10-14 4:00 UTC (permalink / raw)
In <34427D66.F3558989@tonys.ecology.umn.edu> boo <boo@tonys.ecology.umn.edu> writes:
>Steve Tate babbled:
>> Your original comment was that "as far as I understood, computer
>> memory is not two dimensional", and then you go off on this latest
>> posting and talk about how you're interested in computers that are
>> used by many people. Well the computers that are used by millions of
>> people DO have two dimensional memory, which you seem unaware of.
>> DRAM (of any kind) is two dimensional: locations have a row address
>> and a column address. This is hidden, for the most part, by other
>> hardware, but it really is there and it really can make a performance
>> difference.
>
>One other thing.... the important thing really is cache memory,
>not DRAM. Even if you have several cache lines, they still
>are cache LINES. Do you see what I am saying? If you can show
>me some dimensionality of the cache (or other) memory that
>I can actually take advantage of at the assembly level, then
>I would love to hear about it. Seriously, I would, because I
>would use it, so please enlighten me. Some of the arrays I have
>played with in F90 have been 6 or 7 dimensional, so this is
>quite important.
Oh, come on - what would REAL dimensionality look like to you?
Cache, virtual memory, main memory, and disk all happen to be
linearly addressable, but that linear addressability is an
*abstraction* imposed upon implementations which show their
multi-dimensionality in the way that some patterns of access are
much more efficient than others, and I expect that you or anyone
else with half a clue would take this into account when writing
speed-critical code. That kind of locality behaviour sure *sounds*
like there is a preferred *dimension* to access along... who gives
a gnat fart if memory isn't "seven-dimensional" like your arrays?
When you decide to use eight-dimensional arrays do you want memory
to magically be eight-dimensional instead?
>Alas! I fear that this is all a matter of semantics, and
>the usual cyber-babble that computer scientists are prone to
>sprout.
Worry not! Your fears are unfounded. It is a truly relevant matter
of real-world machine behaviour.
The bottom line (as I, not being a computer scientist, see it):
The design of the standard C language is less suited to optimization
by compiler for modern mainstream processor architectures than some
other languages. FORTRAN looks to be one of those other languages,
from what most people have pointed out in this thread.
You may be a mighty software god who can do all that optimization at
the C source level, but I think most people don't want to have to cope
with that kind of lossage. And I suspect you might feel the same way
if you had to enhance or port the resultant code.
-Jason (who likes C and C++ better than FORTRAN, but that's not saying much)
__________________________________________________________________________
Jason Ozolins (Jason.Ozolins@anu.edu.au) | Put your hands over your eyes.
Teaching and Learning Technology Support | Jump out of the plane.
Unit, Australian National University | There is no pilot.
My opinions, not ANU's. | You are not alone.
--
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Richard A. O'Keefe
@ 1997-10-14 4:00 ` Michael Williams
1997-10-14 4:00 ` Richard Black
1997-10-14 4:00 ` Shankar Unni
1997-10-15 4:00 ` Paul Hsieh
2 siblings, 1 reply; 99+ messages in thread
From: Michael Williams @ 1997-10-14 4:00 UTC (permalink / raw)
In article <61uoiu$19e$1@goanna.cs.rmit.edu.au>,
Richard A. O'Keefe <ok@goanna.cs.rmit.edu.au> wrote:
>A Fortran compiler is allowed to say "hey, I know the result of 0*F()
>without calling F, so I won't call F". A C compiler is not.
>Sun's f77 compiler actually does this. I put that example in a file
>called 'foo.f' and did f77 -O5 foo.f; a.out The program compiled,
>linked, ran, and printed 0. The C version, however, doesn't link,
>because it must call f.
Actually, gcc probably wouldn't link even if it had optimised out the
call to f(), e.g.:
if (0) f();
still generates an undefined reference to 'f' in the object file (even
though the call to 'f' is optimised out, in this case).
Mike. (Learning even more about Fortran every day.)
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Aaron Spink
@ 1997-10-14 4:00 ` boo
1997-10-18 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-18 4:00 ` tgg
0 siblings, 2 replies; 99+ messages in thread
From: boo @ 1997-10-14 4:00 UTC (permalink / raw)
Aaron Spink wrote:
>
> boo <boo@tonys.ecology.umn.edu> writes:
>
> > > Your original comment was that "as far as I understood, computer
> > > memory is not two dimensional", and then you go off on this latest
> > > posting and talk about how you're interested in computers that are
> > > used by many people. Well the computers that are used by millions of
> > > people DO have two dimensional memory, which you seem unaware of.
> > > DRAM (of any kind) is two dimensional: locations have a row address
> > > and a column address. This is hidden, for the most part, by other
> > > hardware, but it really is there and it really can make a performance
> > > difference.
> >
> > Does the OS know about it? If not, it is totally irrelevant, and
> > you have missed the whole point. Next, you are going to say that
> > because the chips themselves are arranged across on the simm/dimm
> > models, which are arranged sequentially, that the memory is arranged
> > three dimensionally. You obviously have no clue as to what my
> > point it. The platforms I use have one dimensional flat memory
> > spaces, and if I cannot access the mythical underlying structure
> > you hint at, what is the point? What is your point, anyway?
>
> The question is not whether or not the OS knows about it, its whether
> you as the programmer know about it. In fact almost every thing
> inside a computer has either two or more dimensions. If you actually
> ever looked at a memory sub-system, you would find that its is made of
> of a block oriented 3D pyramid stucture, with hard drives being the
> base and the register being the tip.
I am almost embarrassed for you, you missed the point so badly. I
don't even know how to respond to such a stupid comment.
> aaron spink
> not speaking for dec
Thank God, for DEC's sake.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Victor Yodaiken
@ 1997-10-14 4:00 ` Aaron Spink
1997-10-14 4:00 ` Jason.Ozolins
1997-10-15 4:00 ` David Chase
3 siblings, 0 replies; 99+ messages in thread
From: Aaron Spink @ 1997-10-14 4:00 UTC (permalink / raw)
boo <boo@tonys.ecology.umn.edu> writes:
> One other thing.... the important thing really is cache memory,
> not DRAM. Even if you have several cache lines, they still
> are cache LINES. Do you see what I am saying? If you can show
> me some dimensionality of the cache (or other) memory that
> I can actually take advantage of at the assembly level, then
> I would love to hear about it. Seriously, I would, because I
> would use it, so please enlighten me. Some of the arrays I have
> played with in F90 have been 6 or 7 dimensional, so this is
> quite important.
>
Well, since you mentioned assembly...
A lot of future enhandments to architectures are going to be in part
comprised of things like prefetch buffers and streaming buffers.
Basically EXPLICITLY user controlled caches. Another thing, the DRAM
does matter! If I'm going to organize an array of data, I want the
layout in such a way that I can achieve maximum bandwidth from the
memory system. Most compilers don't support this yet... They will.
Programming in a flat memory abstraction is fine. But languages and
compilers that can exploit increasingly complex memory systems will,
in the end, give the best performance. Because of the structure of
the fortan language it is easier to adapt a lot of these memory
intensive optimization to it than C.
aaron spink
not speaking for dec
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-14 4:00 ` Michael Williams
@ 1997-10-14 4:00 ` Shankar Unni
1997-10-15 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` Achim Gratz
1997-10-15 4:00 ` Paul Hsieh
2 siblings, 2 replies; 99+ messages in thread
From: Shankar Unni @ 1997-10-14 4:00 UTC (permalink / raw)
Richard A. O'Keefe wrote:
> > bool = !(!f() | (!g() & !h()));
>
> In a word, NO. The C version absolutely requires all of the function
> calls to be performed.
First of all, this is true for "&" and "|", but not "&&" or "||". I'm
sure you knew that. (Does Fortran allow .AND. of INTEGER variables, or
only LOGICAL variables? If the latter, then "&" is a bad analog anyway).
Secondly, even for "&" (or "*", as in the 0*f() example) , it can elide
the call if the effect is the same whether it had or had not called the
function. I.e. if the compiler *knows* that the function has no side
effects (either by deduction, or by programmer intervention), it can
skip the call. Thus, in
static int foo() { return 10; }
...
for (i = 1; i <= 1000; i++) {
(void) 0*f();
}
the compiler is allowed to boil down the entire loop into nothing. And
in fact, it does, using Sun cc. (gcc 2.7.2 is a little stupid: it
removes the call, but leaves an empty loop behind!)
Other such optimizations are also allowed: if the function had been
static int foo() { return globalvariable = 10; }
then the entire loop can be boiled down into
globalvariable = 10;
(The point is that yes, you can create contrived examples in which C is
not allowed to optimize what Fortran is, but sophisticated compiler
analysis can make up for a lot of these problems. Not a panacea, but
it's better than nothing.)
--
Shankar Unni Powertel Global, Inc.
(650) 259-1700 shankar@powertelglobal.com
(650) 259-1702 (fax) shankar@webnexus.com
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Shankar Unni
@ 1997-10-15 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` Paul D. DeRocco
1997-10-17 4:00 ` Shankar Unni
1997-10-15 4:00 ` Achim Gratz
1 sibling, 2 replies; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-15 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3875 bytes --]
Shankar Unni <shankar@powertelglobal.com> writes:
>Richard A. O'Keefe wrote:
>> > bool = !(!f() | (!g() & !h()));
>>
>> In a word, NO. The C version absolutely requires all of the function
>> calls to be performed.
>First of all, this is true for "&" and "|", but not "&&" or "||". I'm
>sure you knew that. (Does Fortran allow .AND. of INTEGER variables, or
>only LOGICAL variables? If the latter, then "&" is a bad analog anyway).
Yes, I know that. One of the points here is precisely that Fortran
refuses to distinguish between & and &&. Another point is that Fortran
applies exactly the same rule to *all* operators: if the compiler
can determine that the *result* of some subcomputation is irrelevant
to the value of the whole, it can delete that subcomputation entirely.
Another point is that the C operators & and | were introduced in this example
in a failed attempt to express the Fortran .AND. and .OR. operators.
(Hence all the bangs, to make sure the operators only received 0/1 arguments.)
What they do on general integer values is irrelevant to the argument.
>Secondly, even for "&" (or "*", as in the 0*f() example) , it can elide
>the call if the effect is the same whether it had or had not called the
>function. I.e. if the compiler *knows* that the function has no side
>effects (either by deduction, or by programmer intervention), it can
>skip the call.
But the compiler *can't* know that in many practical cases.
(With a richer type system, e.g. with the LCL specifications that the
LC-lint checker can enforce, where you _can_ pin down the possible
side effects of a function you haven't seen yet, a C compiler _could_
know this, but of course the language isn't quite C any more.)
The point here is that a Fortran compiler can *always* do this;
it is *always* legal for a Fortran compiler to treat *any* function
call as if it had no side effects
> Thus, in
> static int foo() { return 10; }
> ...
> for (i = 1; i <= 1000; i++) {
> (void) 0*f();
> }
>the compiler is allowed to boil down the entire loop into nothing.
Sure. But just you try and move foo() into another file.
>Other such optimizations are also allowed: if the function had been
> static int foo() { return globalvariable = 10; }
>then the entire loop can be boiled down into
> globalvariable = 10;
Again, so what? Fortran compilers have always been allowed to do
inlining too. Nobody is arguing that inlining is a bad idea or that
compilers should not or cannot optimise code they have *full information*
about.
>(The point is that yes, you can create contrived examples in which C is
>not allowed to optimize what Fortran is, but sophisticated compiler
>analysis can make up for a lot of these problems. Not a panacea, but
>it's better than nothing.)
No, the point is that sophisticated compiler analysis (read: not just
interprocedural data flow analysis but cross *translation unit* data
flow analysis) is *required*.
Lest anybody mistake my attitude, let me state again that here I
think Fortran and C are *both* wrong.
C is wrong because it cannot optimise code that _is_ clean very
well without going to a hell of a lot of work to find out that it
is clean.
Fortran is wrong because it _does_ optimise code on the _assumption_
that it is clean.
What we really want are languages for which a compiler _can_ exploit
the absence of aliasing, side effects, &c whenever it is safe to,
needing only linear cost analysis of the source code to determine
when it is safe. The Larch annotations for C strike me as a move
in the right direction. Not only is there the potential of getting
better optimisation if the compiler could know this stuff, LClint
makes a _great_ debugging tool.
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` Richard A. O'Keefe
@ 1997-10-15 4:00 ` Paul D. DeRocco
1997-10-15 4:00 ` William Clodius
` (2 more replies)
1997-10-17 4:00 ` Shankar Unni
1 sibling, 3 replies; 99+ messages in thread
From: Paul D. DeRocco @ 1997-10-15 4:00 UTC (permalink / raw)
Richard A. O'Keefe wrote:
>
> Another point is that Fortran
> applies exactly the same rule to *all* operators: if the compiler
> can determine that the *result* of some subcomputation is irrelevant
> to the value of the whole, it can delete that subcomputation entirely.
This is certainly true of C++, whose current draft standard
states that the observable effects of running the program must
be the same as if the program were executed as described in the
standard. It's commonly called the "as if" rule.
--
Ciao,
Paul
(Please remove the extra "crud" from the return address,
which has been altered to foil junk mail senders.)
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Richard Black
1997-10-15 4:00 ` Craig Burley
@ 1997-10-15 4:00 ` Michael Williams
1997-10-15 4:00 ` Dr. Richard Black
1997-10-18 4:00 ` Bruce Hoult
2 siblings, 1 reply; 99+ messages in thread
From: Michael Williams @ 1997-10-15 4:00 UTC (permalink / raw)
In article <t7d8l88qr8.fsf@tanna.dcs.gla.ac.uk>,
Richard Black <rjb@tanna.dcs.gla.ac.uk> wrote:
>michael.williams@arm-sponge.com (Michael Williams) writes:
>But if gcc knows the same amount of information as Fortran (i.e. that
>f() is side-effect-free) it can also make the same optimisation. viz:
>
>extern int f(int a) __attribute__ ((const));
>
>int b(int a)
>{
> return 0 * f(a);
>}
>
>becomes (since you are at ARM):
>
>@ Generated by gcc 2.7.2 for ARM/(generic)
>rfp .req r9
>sl .req r10
>fp .req r11
>ip .req r12
>sp .req r13
>lr .req r14
>pc .req r15
>gcc2_compiled.:
>___gnu_compiled_c:
>.text
> .align 0
> .global _b
>_b:
> @ args = 0, pretend = 0, frame = 0
> @ frame_needed = 1, current_function_anonymous_args = 0
> mov ip, sp
> stmfd sp!, {fp, ip, lr, pc}
> mov r0, #0
> sub fp, ip, #4
> ldmea fp, {fp, sp, pc}
Tsk.
Norcroft ARM C compiles the equivalent:
extern __pure int f(int a);
int b(int a)
{
return 0 * f(a);
}
to
b
000000 e3a00000 MOV a1,#0
000004 e1a0f00e MOV pc,lr
I thought gcc was supposed to be catching up with our compiler? ;-)
Back to thread, a point to make is that neither of these programs are
ANSI C any more, and what's being discussed is ANSI C vs. ISO (?)
Fortran.
Or, as you rightly point out "how do we make a language that ...",
which is what Nick Maclaren has changed the subject to, essentially.
>Fortran "solves" this problem by having a restricted type system which
>makes it inappropriate for some problems (e.g. writing operating
>systems and device drivers).
I think what Fortran solves in this argument is that it guarantees much
less than C. E.g.:
void copy(char *p, char *q, int n)
{
while (n--) *p++ = *q++;
}
C defines the behaviour should p and q overlap.
return 0 * f();
C defines that f is called.
return f() || g();
C defines that g is not called, if f returns non-zero, and that f is called
before g in any case.
Fortran, from what I have read, makes none of these guarantees, which
leaves more flexibility in the compiler to target the application at
a given processor.
Nick Maclaren's gripe appears to be virtual functions, of the type used
often in C (X11, e.g.), C++ and Java. (Java's a bit of a red-herring, as
JIT compiled code might be able to remove the virtual function calls, and
a JVM isn't really executing the Java bytecode - it's a prefetching from
the datacache problem, which is there with any programming style.)
A strong type system certainly helps the compiler - but it isn't all the
problem. (Though it might help with inter-procedural optimisations, which
would solve some of the examples above - e.g. the compiler discovers for
itself that 'f' is __pure.)
Mike.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` boo
` (2 preceding siblings ...)
1997-10-14 4:00 ` Jason.Ozolins
@ 1997-10-15 4:00 ` David Chase
3 siblings, 0 replies; 99+ messages in thread
From: David Chase @ 1997-10-15 4:00 UTC (permalink / raw)
boo wrote:
> ... If you can show
> me some dimensionality of the cache (or other) memory that
> I can actually take advantage of at the assembly level, then
> I would love to hear about it.
Depends on the cache; certainly, linearly addressing along (in
the same linear dimension, so to speak) works well. If you have
a direct-mapped cache (I think these are rare on on-chip caches)
then you must worry about accesses to colliding addresses; that is,
there are three possible choices for two consecutive memory accesses:
1. same line, same tag (i.e., reuse line)
2. different lines
3. same line, different tag (i.e., collision)
Choice #1 is preferred, but is not always possible
Choice #3 is considered to be bad, unless you are so good at
planning your memory accesses that the first access in the
pair is that last access to its tag (i.e., you will not collide
on this pair again), in which case it is a necessary evil.
There are some additional complications to this problem:
sometimes on-chip caches are somewhat associative, whereas
off-chip caches may be direct. If the external cache "includes"
the on-chip cache, then two lines that could co-reside in the
on-chip cache but induce a collision in the external cache,
cannot co-reside (because otherwise the external cache would
not include the contents of the on-chip cache).
sometimes external caches are accessed using physical addresses.
This means that if there are collisions, they depend on properties
of the address that are not visible to the programmer (virtual
addresses are the common case).
sometimes operating systems are not entirely predictable or repeatable
in how they assign virtual addresses to physical pages; some do
"page coloring" (I figured this out once, but have long since
forgotten the details) where virtual addresses that look like
they ought not collide, are assigned to non-colliding physical
pages (my guess is that there are some caveats, provisos, and
quid pro quos related to what happens when no such pages are
available).
Sometimes operating systems do something else; they may reserve
a bunch of physical pages that collide into the same few cache
lines for use in a processes stack. The reasoning here is that
stack access is generally linear and local (at least in certain
industry-standard-benchmarks) and that collisions with the stack
(e.g., code and stack, or hot data and stack) can lead to performance
anomalies. I don't know if anyone does this.
If you have threads, and there is shared data, then you need to
know more. It's a very bad idea, for instance, to allocate thread
specific flags like this:
char thread_specific_flags[NTHREADS];
if the threads are all writing to their flags all the time, because
they will continually compete for ownership of the cache line
containing that statically allocated variable. Better to do
something like this:
struct {
char flag;
char padding[cache_line_size_minus_one];
} thread_specific_flags[NTHREADS];
though it would be even nicer if you could align these suckers
to the cache line size and store all your per-thread info like
that. Keep in mind that the processor-level granularity for
owning memory may not correspond to the on-chip cache line size.
In some cases, there is also an issue with TLB thrashing;
if you (frequently) access more virtual pages than can fit
in the TLB, then that will slow you down, too. I don't know
what recent processors do here.
As far as I know, no compiler does a very good job at the
cache-collision game. Friends from IBM claim that anyone
building a direct-mapped cache is foolish (because of these
intractable problems) and friends at Tera claim that they
will take care of all of this by threading everything up,
down, and sideways. The Tera approach is tremendously
elegant, and will almost certainly work for a large
category of Fortran programs, and may even work well for
C.
I wouldn't really want to claim that this mess has any
particular "dimension" to it.
--
David Chase, chase@world.std.com
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` Michael Williams
@ 1997-10-15 4:00 ` Dr. Richard Black
1997-10-16 4:00 ` Richard A. O'Keefe
0 siblings, 1 reply; 99+ messages in thread
From: Dr. Richard Black @ 1997-10-15 4:00 UTC (permalink / raw)
> I thought gcc was supposed to be catching up with our compiler? ;-)
gcc -fomit-frame-pointer will also generate:
mov r0, #0
mov pc, lr
by default it obeys the ARM procedure call standard.
But, to get back to the current discussion.
> Nick Maclaren's gripe appears to be virtual functions, of the type used
> often in C (X11, e.g.), C++ and Java.
There is no free lunch. Late binding (virtual functions) has
advantages for programs, and implementation costs. Most of those
costs can be avoided, however. Maybe whats really annoying Nick is
that one of his ex-peers, now at DEC, has a patent on the technique....
--
----------------------------------------------+------------------------
Dr. R.J. Black, University Lecturer, | Phone: +44 141 330 6039
University of Glasgow, Computing Science Dept.| Fax: +44 141 330 4913
17 Lillybank Gdns., Glasgow G12 8RZ, U.K. | Mail: rjb@dcs.gla.ac.uk
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` Paul D. DeRocco
1997-10-15 4:00 ` William Clodius
@ 1997-10-15 4:00 ` Joe Buck
1997-10-16 4:00 ` Richard A. O'Keefe
2 siblings, 0 replies; 99+ messages in thread
From: Joe Buck @ 1997-10-15 4:00 UTC (permalink / raw)
Richard A. O'Keefe wrote:
>> Another point is that Fortran
>> applies exactly the same rule to *all* operators: if the compiler
>> can determine that the *result* of some subcomputation is irrelevant
>> to the value of the whole, it can delete that subcomputation entirely.
"Paul D. DeRocco" <pderocco@ix.netcom.crud.com> writes:
>This is certainly true of C++, whose current draft standard
>states that the observable effects of running the program must
>be the same as if the program were executed as described in the
>standard. It's commonly called the "as if" rule.
Actually the draft standard goes farther than this, as it permits the C++
compiler to eliminate copy constructor calls even if the copy constructors
have visible side effects (e.g. the compiler can assume that a copy
constructor just does a copy, and it can eliminate it if it doesn't have
to copy).
--
-- Joe Buck http://www.synopsys.com/pubs/research/people/jbuck.html
If you thought flashing ads on Web sites were annoying, wait till the Web
and your operating system are "seamlessly integrated" and watch the
pulsating promotional crud spill out over your desktop. -- Scott Rosenburg
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Richard Black
@ 1997-10-15 4:00 ` Craig Burley
1997-10-15 4:00 ` Michael Williams
1997-10-18 4:00 ` Bruce Hoult
2 siblings, 0 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-15 4:00 UTC (permalink / raw)
Richard Black <rjb@tanna.dcs.gla.ac.uk> writes:
> [ Consider 'void reschedule(void)' Fortran might optimise such a thing
> out, which might be very bad for your operating system.... ]
No, it won't. Fortran *subroutines* are viewed as containing
must-be-executed imperative steps, so since `reschedule' would be
a subroutine, it *would* be called at the specified point. (You
know, we used to write operating systems in Fortran, back before
C became popular! :)
It's Fortran *functions* that are viewed, to some degree (and, frankly,
even the Fortran community and the standards committee itself are
widely divided on the extent of this!), as more "functional", or
mathematical, in a traditional sense. C doesn't have this concept;
a C "function" is really like a Fortran subroutine with a convenient
extra "argument" to return a variable.
(The debate in the Fortran community over this issue is pretty much
bounded by complete agreement that "R = 0 * S()" need not call S()
and that "CALL FOO" *must* call FOO. In the sense of the omnipresent
"as if" rule, this means their side effects must be performed in the
order indicated by their definitions. The debate is over things
like whether "R = S()" need call S when that R is not used or is used
once as in "T = 0 * R". The FORTRAN 77 and Fortran 90 standards seem
to say, especially when all the text and examples are taken into account,
that S *must* be called in this case, but some members of the standards
committee appear to be claiming either that the F90 standard is not
really requiring this, or that future standards won't require it, or
both.)
Please, everyone keep in mind in these discussions, that there *is*
no tradeoff between Fortran, with its "high-level constructs", and
C with its "low-level constructs".
The tradeoff is between Fortran, which *has* (some) high-level
constructs, and C, which does not. *Both* languages have the
pertinent low-level constructs: Fortran allows writing code that
views memory/arrays as linear just as C does, Fortran allows writing
what C has as `&&' and `||', and so on. In some of these cases,
Fortran is more verbose (too so for my tastes and the kind of software
I write, but I'm not writing numerical software), but C offers
*no way* for a programmer to express multi-dimensional arrays,
Fortran's (and English's ;-) .AND. and .OR., and so on.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` Paul D. DeRocco
@ 1997-10-15 4:00 ` William Clodius
1997-10-15 4:00 ` Joe Buck
1997-10-16 4:00 ` Richard A. O'Keefe
2 siblings, 0 replies; 99+ messages in thread
From: William Clodius @ 1997-10-15 4:00 UTC (permalink / raw)
Paul D. DeRocco wrote:
>
> Richard A. O'Keefe wrote:
> >
> > Another point is that Fortran
> > applies exactly the same rule to *all* operators: if the compiler
> > can determine that the *result* of some subcomputation is irrelevant
> > to the value of the whole, it can delete that subcomputation entirely.
>
> This is certainly true of C++, whose current draft standard
> states that the observable effects of running the program must
> be the same as if the program were executed as described in the
> standard. It's commonly called the "as if" rule.
> <snip>
For better or worse, Fortran is more liberal in its as if rule. If the
value returned by a FUNCTION (what O'Keefe implies by *result* above)
can be shown to be the same under the assumptions that its arguments and
global variables are not modified and any internal state of the FUNCTION
does not alter the value returned, then the subcomputation can be
deleted entirely. The difference from the vast majority of other
languages is in the above assumptions which result in local analysis
being sufficient for the as if rule for more than standard library
procedures. This means that internal state of FUNCTIONs is intended for
efficiency of computation purposes only. It also means that
modifications of arguments and global variables by FUNCTIONs are well
defined, if at all, only for error flags or similar constructs. However,
it is difficult for a compiler to detect intent and report erroneous
useages of constructs.
--
William B. Clodius Phone: (505)-665-9370
Los Alamos Nat. Lab., NIS-2 FAX: (505)-667-3815
PO Box 1663, MS-C323 Group office: (505)-667-5776
Los Alamos, NM 87545 Email: wclodius@lanl.gov
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Jason.Ozolins
@ 1997-10-15 4:00 ` boo
0 siblings, 0 replies; 99+ messages in thread
From: boo @ 1997-10-15 4:00 UTC (permalink / raw)
Jason.Ozolins@anu.edu.au babbled:
>
> In <34427D66.F3558989@tonys.ecology.umn.edu> boo <boo@tonys.ecology.umn.edu> writes:
>
> >Steve Tate babbled:
> >> Your original comment was that "as far as I understood, computer
> >> memory is not two dimensional", and then you go off on this latest
> >> posting and talk about how you're interested in computers that are
> >> used by many people. Well the computers that are used by millions of
> >> people DO have two dimensional memory, which you seem unaware of.
> >> DRAM (of any kind) is two dimensional: locations have a row address
> >> and a column address. This is hidden, for the most part, by other
> >> hardware, but it really is there and it really can make a performance
> >> difference.
> >
> >One other thing.... the important thing really is cache memory,
> >not DRAM. Even if you have several cache lines, they still
> >are cache LINES. Do you see what I am saying? If you can show
> >me some dimensionality of the cache (or other) memory that
> >I can actually take advantage of at the assembly level, then
> >I would love to hear about it. Seriously, I would, because I
> >would use it, so please enlighten me. Some of the arrays I have
> >played with in F90 have been 6 or 7 dimensional, so this is
> >quite important.
>
> Oh, come on - what would REAL dimensionality look like to you?
> Cache, virtual memory, main memory, and disk all happen to be
> linearly addressable, but that linear addressability is an
> *abstraction* imposed upon implementations which show their
> multi-dimensionality in the way that some patterns of access are
> much more efficient than others, and I expect that you or anyone
> else with half a clue would take this into account when writing
> speed-critical code. That kind of locality behaviour sure *sounds*
> like there is a preferred *dimension* to access along... who gives
> a gnat fart if memory isn't "seven-dimensional" like your arrays?
> When you decide to use eight-dimensional arrays do you want memory
> to magically be eight-dimensional instead?
Oh, come on. You and the other clueless here do not seem to understand
what I meant by "multi-dimensional". Only a dimwit would conclude
that because you have registers, L1 cache, L2 cache, L3 cache
and virtual memory, that you therefore have a 5 dimensional
structure! Multi-dimensionality usually requires that there are
certain symmetries that apply, no matter which "axis" you
are pointing along. I assumed that you were all smart enough
to realize that I was talking about SPEED and BANDWIDTH, since
I thought were were discussing PERFORMANCE. There is no such
symmetry in what you mention, and therefore I conclude that
you and the other compubabblers are merely using the word
"dimension" without thinking about what it means, in the
context that I used it. Note that 1+1 is not always equal to 2.
>
> >Alas! I fear that this is all a matter of semantics, and
> >the usual cyber-babble that computer scientists are prone to
> >sprout.
>
> Worry not! Your fears are unfounded. It is a truly relevant matter
> of real-world machine behaviour.
>
> The bottom line (as I, not being a computer scientist, see it):
> The design of the standard C language is less suited to optimization
> by compiler for modern mainstream processor architectures than some
> other languages. FORTRAN looks to be one of those other languages,
> from what most people have pointed out in this thread.
>
> You may be a mighty software god who can do all that optimization at
> the C source level, but I think most people don't want to have to cope
> with that kind of lossage. And I suspect you might feel the same way
> if you had to enhance or port the resultant code.
Did I ever say otherwise? Of course you are right.
But for me, writing more efficient code can reduce running time
from 4 months to 1 month, even if I am using a 300 Gflop machine.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` boo
@ 1997-10-15 4:00 ` Craig Burley
[not found] ` <623ek6$ef5$1@news.iastate.edu>
1997-10-16 4:00 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
0 siblings, 2 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-15 4:00 UTC (permalink / raw)
boo <boo@tonys.ecology.umn.edu> writes:
> Craig Burley bored us with his thesis, which contained the gem:
>
> > But, in my experience, the numerical types who use Fortran *already*
> > have their algorithm issues worked out, because they're engineers,
> > not programmers, and because they *have* to. E.g. it doesn't bother
> > me much if my compiler is twice as slow as it could otherwise be
> > on my home PC, at least, not compared to how much these numerical
> > types are bothered when their latest number-cruncher is 2% slower than
> > it could otherwise be, when that 2% costs them $10,000 per week due
> > to it being run on a supercomputer on which they're buying time.
> >
> > C programmers just don't usually have as much vested interest in
> > squeezing out that last 2% or so -- after all, their users can just
> > wait for the next Pentium to come out anyway, while Fortran programmers
> > include a pretty substantial group that depends on today's fastest
> > and most expensive computers, and a newer, faster computer only
> > means they can stuff more data into, or make more accurate
> > calculations in, their programs, instead of using the next generation
> > to cover up their programming inefficiencies.
>
> How about super-computer user who wants the best possible performance
> and the greatest flexibility, and chooses C over Fortran?
I'd guess that he probably isn't doing intense numerical
computation. Personally, if I had to choose between C and
Fortran in implementing a supercomputer-based compiler (for
some other language entirely, let's assume), I'd *still* want
to write it in C. But I'd miss some of Fortran's advantages
when it came to generating a faster version of the compiler.
Similarly, I'd think that numerical programmers would find
that Fortran gets them the most performance on their supercomputers
(especially vector machines and the like), especially if they
care about portability to *other* supercomputers. (If they don't,
it probably doesn't matter which language they choose, though if
they're going as low as writing lots of explicitly-parallelizing
code, maybe C becomes a better choice at that point...especially
if the API being dealt with it written in C, which means that
C's been given an unfair advantage in this case, but it is a
*practical* advantage.)
> I think you have it wrong. The best compilers on the supercomputers
> have traditionally been Fortran compilers. Those ones always get
> the most development time, so naturally lead. Why do they get the
> most attention? Because the supercomputer user is more likely than
> not, a Fortran programmer, the language of the Engineer. If a typical
> supercomputer user were a C programmer, the Fortran compilers would
> not be as good! Fortran leads because Fortran is Entrenched! However,
> with the advent of MPP supercomputers and nodal message passing
> programming styles possible, efficient C code compares very favorably
> with the best F90 code, surpassing it in many instances. Of course,
> it is much easier and quicker to write a F90 program, than a
> carefully thought out messaging passing nodal C code. (Nodal f77
> code is also extremely efficient, compared with the F90 type
> "parallel" code... but I see this as writing a Fortran program
> in a C style, because the same level of thinking is required of
> C to lay the "arrays" out across the nodes explicitly, what you
> call "lowering"). It certainly was true on the Cray vector
> supercomputers that C performance simply sucked compared with
> the mature Fortran compilers, but this is not the case anymore!
> (for some, not all). This really has only changed relatively recently.
All good points. Note that once you take up the argument that
F77 compilers tend to do better on numerical code than C compilers
only because they've got more acceptance and hence more resources,
however, you pretty much depart from what I thought we were discussing
here, which is which *language* offers the best constructs for
efficient programming.
My point has been, all along, to point out that while C and Fortran
share pretty much the same set of low-level operations -- the kind
that allow programmers who know their algorithms *and machines*
inside and out to write code that a compiler can, fairly easily,
compile directly to efficient code, Fortran offers higher-level
constructs that are a) not offered *at all* by C and b) important
for scientific/numeric programming.
So, in my opinion (and I do claim this is basically 100% fact, so it
is *not* a humble opinion), the back end of a Fortran compiler will
pretty much *always* be able to do a better job compiling "vanilla",
that is, straightforward, write-what-you-mean-type numerical code, for
a variety of machines, than the back end of a C compiler will, *given
that the same amount of resources went into developing each of the
back ends*.
Yes, I *know* that if we threw tons of resources behind making
C compilers more clever at teasing out the original intent of the
programmer, we could make it produce fast code for even numerical
codes. Then we could tell all Fortran programmers to spend more
time writing C code than they have to write Fortran code, but we'd
have One True Language that everyone could use.
But, the same *could* be said for the ix86 instruction set. Why
not throw, say, 10x-100x the resources we'd otherwise spend on making
better C compilers behind making better ix86 decompilers/recompilers
instead (more resources needed to tease out more original info)?
Then we'd have One True Language indeed, and nobody would have
to rewrite Fortran to C, or port C code from ix86 to Alpha or SPARC,
we'd just make the ix86 set, which has a huge existing code base,
the universal language, by "solving" the performance problem!
I'm not seriously suggesting this, of course, but pointing out that
once you start saying "well, with enough resources, we could make
code written in language X as efficient as that written in language
Y", you invite all sorts of options -- and trouble.
The fact is that people are *still* unable to write what they mean
in their common, everyday codes, regardless of whether they're
writing it in Fortran or C. But Fortran *does* offer some
improved opportunities in these areas, with its multi-dimensional
arrays, its functions, its .AND. and .OR., its lack of permitted
aliasing, and C *is*, in the form of various (often poorly
engineered, IMO) extensions, trying desperately to catch up --
suggesting C compiler writers have chosen to burden the programmer
rather than have their compilers perform the kinds of analyses you,
and other C enthusiasts, keep claiming *would* make C as good a
performer on *existing* code as Fortran.
That suggests to me that, if you're as smart as you think you
are, stop wasting time writing optimized C code for particular
machines, and go implement a C compiler that blows Fortran
away for numeric processing. You'd make *millions* of dollars
within the first two years, I suggest.
> It is much easier to produce an efficient F90 code than an
> efficient C code, that much is obvious.
>
> > [childish MS bashing masquerading as a analogy snipped]
Not childish at all, since it wasn't MS-bashing. It was "humor",
a style of writing used to make a point. If you want to claim
that the point was invalid, or MS was a bad example, or that
I really was "bashing" MS instead of making a point, you're
free to make that argument here, if you like.
> Exactly what does Microsoft bashing have to do with C vs Fortran?
Not bashing Microsoft per se -- I was pointing out how different
*programmers* are from *engineers*, and Microsoft is The Example
our industry has of that difference, given how many programmers
they gainfully employ. C and UNIX are other, great, examples
of the winning out of programming/hacking over engineering, but
they're rather stale at this point. I even hesitate to use
Microsoft as an example, given that they've been a popular target
for years anyway, but they're still the best example for the analogy
today, especially in a humorous analogy.
(For example, assuming that programmers who write Java code today
*will* be still using Microsoft products to run their same code
tomorrow *is* a case of ignoring real-world complexities to make
one's own life simpler. Even Digital was explicitly showing,
using different colors, which Fortran features were industry standard
versus Digital-provided extensions in their Fortran manuals
back in the early '80s, and maybe earlier for all I know. Does
Microsoft make such distinctions clear to its users, who *think*,
due to industry hype they are believing in, that they're writing
"Java", or creating "Web pages", or writing "HTML documents", when
in fact they're writing "Microsoft sorta-Java-like", or creating
"Internet Explorer pages", or writing "MS-HTML documents"? I don't
know, but somehow, I get the impression, the answer is no, they're
not making the distinctions clear so their users can know which
features to avoid to write Java/Web/HTML. So their users *think*
they're creating industry-standard works, when in fact they're
locking themselves into Microsoft's world, something they should
be doing only as part of a well-thought-out strategy, if at all.)
We all have a choice, as end users, as programmers, and as
engineers, whether to honor people and businesses who put
"making it work" at a lower priority than #1 in designing
and building products. "Making it work as long as..." is
often a recipe for disaster. Tacoma Narrows Bridge: "making
it work as long as winds below 35mph (or whatever)", because
it *was* more important to make it inexpensive and elegant.
(This is the bridge that tore itself apart within a few years
of being built.) CitiCorp building in NYC: "making it work as
long as high winds don't hit edge on", because it *was* more
important to come up with a new, dramatic design to look good
on the skyline (and, presumably, again, be less expensive).
(That building was quietly and, I hope, effectively fixed
in the dark of night, with secret, large-scale evacuation plans
in place should a storm turn into NYC ahead of schedule.)
Then again, Empire State Building in NYC: "making it work" #1.
Even as the Depression hit, they didn't start cutting corners,
even down to preserving the design work on the interior,
certainly preserving the structural integrity, making sure it
"stood up" before they worred whether it "stood out". Result?
It's still standing. Even after being hit by a largish plane.
(And, of course, many more storms than most modern buildings have
experienced.)
Yes, it's *possible* to build increasingly complex, interrelated
things and manage the complexity sufficiently to keep the
risks and costs down, but today's wise man recognizes that
we're *already* at, or beyond, our ability to cope with our
own technological creations sufficiently to keep them safe,
standing, and working, and so generally chooses simpler systems
designed to cope with today's complex environment over more
complex systems that are designed assuming the environment will
be simplified by their existence. (Not that the distinctions
are all that clear. Is a smoke alarm a simple device? Maybe,
but in our house, sometimes, when we hear a "beep", it takes
us *way* too long to determine whether a microwave oven is
going off, a pager is going off, a phone is ringing, a security
alarm is going off, etc., or any of these things are happening
on the TV program played through a fairly decent stereo, before
we consider the smoke alarm. The overly-simplifying assumption
in all these devices here? "I'm the only one that makes a sound
like this, so I'll be instantly recognized." Worked great for car
alarms, didn't it? ;-)
So, the wise man prefers a language where the programmer gets
to say what he *means* (e.g. use Fortran's multi-dimensional
arrays) to one where he must say something else entirely (C),
just as the wise man prefers open systems, interfaces, environments,
and maybe even source code (UNIX, HTML, the Web, and GNU,
for respective examples, perhaps) over single-sourced closed
ones (Microsoft, Microsoft, Microsoft, and Microsoft, for
respective examples, I would think).
Similarly, the wise man prefers C for use of pointers to
FORTRAN 77. (I've maintained FORTRAN-66 code that does the
necessary tricks to provide structures and pointers. What
a pain in the butt. C would have been *vastly* more elegant
for this application, which happened to be a low-level system
utility -- one that copied files and directory, deleted directory
trees, and so on, a la UNIX `cp -r' and `rm -r' -- and many of the
bugs we ran into came from the fact that we were using an
inappropriate language...though there was little choice back in
the mid-'70s on these machines, and, thanks to C's *other*
unnecessary complexities, these machines were a bear to port C and
its existing body of code to in the '80s.)
A given person can manage only so much complexity at a time.
If he's spending mental energy coping with a missing feature
(such as multi-dimensional arrays, or pointers), that's energy
not being spent on the *application*, meaning he's probably
going to forget something important, or not have time to test
some feature, in the application.
What I've seen you saying here is "hey, I'm so awesome a
programmer, I've been able to write C code that blows away
vanilla Fortran code on a particular machine, by using C's
low-level facilities to get close to the iron". What I *haven't*
seen you say is why you couldn't have done the *same thing*
in Fortran 90 (which I'd *love* to know, given my current
project affiliations ;-), or whether that time you spent making
the C code run faster was really "worth it" compared to what
it might have taken to obtain a Fortran 90 compiler that
did the same efficient job on your original vanilla code
(assuming one was available).
What *I* know is that getting a VLIW machine I used to work
on to perform optimally on many numerical problems required
*either* coding them by hand *or* using a very advanced FORTRAN
77 compiler we were developing at the time. Using C, no matter
at how low a level, would *not* have gotten *close* to the
performance available to the assembler/Fortran programmer. *Maybe*
introducing a bunch of extensions would have allowed us to build
a C compiler that did this, but they'd all have required the C
programmer to use all sorts of syntactic trickery (`restrict'
attributes and such) to get that performance, whereas our Fortran
compiler "just worked" given the original, clear, Fortran code,
and the effort needed to make the C compiler do the kinds of
analyses necessary to meet the Fortran compilers' performance
characteristics would have been much larger than we had to spend
on the Fortran compiler (when you factor out common, first-time-
through-type stuff typical of such projects).
(Of course, users of this machine were mostly scientific and
numerical types -- they weren't running operating systems, spreadsheets,
or word processors on it, more like doing geological exploration,
calculating missile trajectories, sampling and encoding real-time
seismic data, and so on.)
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Richard A. O'Keefe
@ 1997-10-15 4:00 ` boo
1997-10-16 4:00 ` Timothy A. Seufert
` (4 more replies)
0 siblings, 5 replies; 99+ messages in thread
From: boo @ 1997-10-15 4:00 UTC (permalink / raw)
Richard A. O'Keefe wrote:
>
> geest3+@pitt.edu (Gregg E Economou) writes:
> >You miss the point that while yes, they may be physically multidimensional,
> >and even organisationally multidimensional, and even architecturally
> >multidimensional, they are *logically* linear, and accessed in a linear
> >fashion. Yes, there are strange exceptions out there, but the majority
> >of memories are linear int the majorities or architectures and the
> >majority of machines ever designed, made, or sold.
>
> With everybody accusing everyone else of missing *the* point,
> perhaps it is time to make *a* point.
>
> Today, if you want to write high-performance code on stock hardware,
> you have to view your plain ordinary so-called 'linear' address space
> as three dimensional.
>
> For example, I am writing this on an UltraSPARC 2.
>
> Level 1 data cache: (The L1 code cache is the same,
> 16 kbytes I _think_)
> 32 bytes per line
> 1-way association
>
> Level 2 cache: (Unified, I _think_)
> 512 kbytes
> 64 bytes per line
> 1-way association
>
> VM
> 2 Gbytes
> 8 kbytes per page
>
> Physical memory
> 512 Mbytes
Yes, you have made a point.
You have made the point that memory is not uniform,
you have not made the point that memory is multi-dimensional. Perhaps I
should discuss exactly what I meant when I mentioned "multi-dimensionality".
When I use the word "4 dimensional", for example, I usually refer to
a situation where there are certain symmetries present, not matter which
direction (or axis) you are pointing along. (I should point out,
proudly, that I have had no formal computer training of any kind, ever,
so I may not use the same terms that you use in that
Ivory Tower of yours over there). In the context of memory,
I naturally assumed that any sensible person would realize that the
symmetry of interest would be "speed of access". What you have described
does NOT have this symmetry, and therefore I cannot fathom why you
would claim that it is multi-dimensional. I can only assume you are using
some broader abstract concept of the term, which does not really fit
well with my scientific concepts. The fact that you have various
components of the memory system is meaningless! OF COURSE, you are
going to have to take into account the fact that there are registers,
various levels of cache, local memory, shared memory, virtual memory....
Only a poor programmer would not take this into account! However, all this
proves is that you have a 1+1+1+...+1 dimensional structure to your
memory, and 1+1 is NOT equal to 2. You can still make most efficient
use of the memory through the use of one dimensional structures,
whilst optimizing data layout and use in such a way as to maximize
usage of the cache, main memory, etc.
Ok, now let me discuss where MY use of the word "dimensional". Say
for example, you are working with a 3D or 4D "array", representing
space or space-time. The actual symmetries of spacetime are
reflected in the fact that you would do best with a memory system
in which access is equally fast no matter which axis you are
doing access along. (If you want specifics, imagine some kind
of a N-dimensional 3rd order derivative operator, requiring
information from neigboring points in the 2N directions).
When I said "memory is not multi-dimensional", I meant "memory
access is not equally fast along all axes of a multi-dimensional
array". Of course it is not!! Some points are in the cache,
some may be stored in registers from some previous calculation,
some are in main memory, some may be on another node in some
MPP supercomputer. I know that high performance fortran actually
usually does an excellent job of optimizing the calculations,
but my personal experience is that I can usually do better
by really thinking hard, and coming up with an algorithm that
realizes that the various ONE-DIMENSIONAL components of the
memory system are utilized in an optimal manner. And as I said
elsewhere, most people don't need to bother wasting their time
on this kind of optimization, but for me, doing so can reduce
a simulation from one month down to one week, on a 300 Gflop
supercomputer that I have very limited resources on.
It is amazing that almost everyone jumped on my statement that
memory is not multi-dimensional with absurds comments about the
"multi-dimensional structure of memory hardware". I suggest you
all replace "dimensional" with "component" in the above phrase,
to which I reply:
DUH
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Shankar Unni
1997-10-15 4:00 ` Richard A. O'Keefe
@ 1997-10-15 4:00 ` Achim Gratz
1 sibling, 0 replies; 99+ messages in thread
From: Achim Gratz @ 1997-10-15 4:00 UTC (permalink / raw)
Shankar Unni <shankar@powertelglobal.com> writes:
> the compiler is allowed to boil down the entire loop into nothing. And
> in fact, it does, using Sun cc. (gcc 2.7.2 is a little stupid: it
> removes the call, but leaves an empty loop behind!)
That's documented behaviour for gcc, read the Non-Bugs section in the
manual.
Achim Gratz.
--+<[ It's the small pleasures that make life so miserable. ]>+--
WWW: http://www.inf.tu-dresden.de/~ag7/{english/}
E-Mail: gratz@ite.inf.tu-dresden.de
Phone: +49 351 463 - 8325
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-13 4:00 ` Patricia Shanahan
@ 1997-10-15 4:00 ` boo
1997-10-15 4:00 ` Patricia Shanahan
0 siblings, 1 reply; 99+ messages in thread
From: boo @ 1997-10-15 4:00 UTC (permalink / raw)
Patricia Shanahan babbled:
>
> boo wrote:
> ...
> > Because eventually, someone or something is going to have
> > to map the dimensionality of your "arrays" to the dimensionality
> > of the computer memory. I don't expect you to understand this,
> > though, so why don't you just let your Fortran compiler do
> > the thinking for you.
> ...
>
> And someone or something is going to have to map the dimensionality of
> your flat address space onto the dimensionality of the memory
> hardware.
Someone else who does not understand that 1+1 is not always
equal to 2.....
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-14 4:00 ` Michael Williams
1997-10-14 4:00 ` Shankar Unni
@ 1997-10-15 4:00 ` Paul Hsieh
2 siblings, 0 replies; 99+ messages in thread
From: Paul Hsieh @ 1997-10-15 4:00 UTC (permalink / raw)
On 14 Oct 1997 13:23:10 +1000, Richard A. O'Keefe said:
> Paul Rubin <phr@netcom.com> writes:
> >> BOOL = F() .AND. (G() .OR. H())
>
> >Is this C statement equivalent to the Fortran?
> >My Fortran is very rusty.... :-)
>
> > bool = !(!f() | (!g() & !h()));
>
> In a word, NO. The C version absolutely requires all of the function
> calls to be performed.
In the above expression that is true. However if the expression was
written as:
bool = !(!f() || (!g() && !h()));
Of course, this has a different behavior which includes potentially not
calling some of these expressions.
> [...] A C compiler is not allowed to discard a function
> call simply because it knows the result. A simpler example is
>
> #include <stdio.h>
> INTEGER I, F extern int f(void);
> EXTERNAL F int main(void) {
> int i;
> I = 0*F() i = 0*f();
> PRINT *, I printf("%d\n", i);
> END return 0;
> }
>
> A Fortran compiler is allowed to say "hey, I know the result of 0*F()
> without calling F, so I won't call F". A C compiler is not.
This is not technically true. The C compiler may inline the function
f(), and upon realizing that it has no global side effects (if this is
true) will have the option of optimizing the f() away.
I find it odd, if your claim is true, that a Fortran compiler would
simply neglect to call F() no matter what. Isn't it possible for F()
to modify a common/global?
--
Paul Hsieh
http://www.geocities.com/SiliconValley/9498/mailme.html
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` boo
@ 1997-10-15 4:00 ` Patricia Shanahan
0 siblings, 0 replies; 99+ messages in thread
From: Patricia Shanahan @ 1997-10-15 4:00 UTC (permalink / raw)
boo wrote:
>
> Patricia Shanahan babbled:
> >
> > boo wrote:
> > ...
> > > Because eventually, someone or something is going to have
> > > to map the dimensionality of your "arrays" to the dimensionality
> > > of the computer memory. I don't expect you to understand this,
> > > though, so why don't you just let your Fortran compiler do
> > > the thinking for you.
> > ...
> >
> > And someone or something is going to have to map the dimensionality of
> > your flat address space onto the dimensionality of the memory
> > hardware.
>
> Someone else who does not understand that 1+1 is not always
> equal to 2.....
Thank you for the honor of having my understanding denigrated by you.
I really do appreciate being placed in such distinguished company.
Take a look at
http://www.fujitsumicro.com/products/memory/memory_pdf/mb81410c.pdf,
the data sheet for an arbitrarily selected DRAM chip with fast page
mode. On page 2 there is a block diagram showing the actual bit array,
"4,194,304 Bit Storage Cell", as a rectangular block with the Row
Decoder feeding in to the left hand side and the Column Decoder
feeding in to the top. Even if you are unfamiliar with hardware block
diagrams, this one is fairly simple and clear. At its center, this
DRAM is a 512x512 array of 16 bit items.
If you don't think this has any performance significance, consider the
following quote from near the bottom of page 4: "The fast page mode of
operation provides faster memory access and lower power dissipation.
The fast page mode is implemented by keeping the same row address and
strobing in successive column addresses."
Someone or something is going to take your linear address space model
and map it down to a memory bank select, a row address, and a column
address. The row and column addresses will be passed consecutively to
the address pins of the DRAM chips in the bank.
The mapping between a program memory array and a flat address space,
at its very simplest, is equivalent to the mapping between a Fortran
multi-dimensional array and a flat address space. In general purpose
computers one rarely meets the simplest case - the mapping between
data address spaces in a program and computer memory is usually
substantially more complicated than the Fortran multi-dimensional
array mapping.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-10 4:00 ` Final kick at the "Merced Guessing Game" David Gould
@ 1997-10-16 4:00 ` Patricia Shanahan
0 siblings, 0 replies; 99+ messages in thread
From: Patricia Shanahan @ 1997-10-16 4:00 UTC (permalink / raw)
David Gould wrote:
>
> In article <EHrwv9.2w3@world.std.com>,
> Joseph H Allen <jhallen@world.std.com> wrote:
> >In article <61ho3v$3m0$1@goanna.cs.rmit.edu.au>,
> >Richard A. O'Keefe <ok@goanna.cs.rmit.edu.au> wrote:
> >> nice features of older languages and C9x...
> >
> >The real question is why has C caught on in such a big way when other
> >more powerful languages have not? There are several answers:
>
> [many good reasons deleted]
>
> I am surprised that no-one has mentioned what may be the most important
> reason for the success of C: "The C Programming Language" by messrs K & R.
> An excellent book, far better than the language described. A religious text
> almost. After reading it, especially early in a career, one is convinced that
> "C" not only makes sense, but is even "the right way".
...
During the architectural explosion in the mid-80's I was languages
project leader at a one of the numerous small computer manufacturers
that cropped up and died out.
My absolute, unquestionable, MUST-make-this-objective first priority
when I started on the compilers was to have a C cross compiler running
on a VAX but generating code for my employer's instruction set by a
specified date shortly before the first prototype hardware was due to
be available. I undertook that project with NO discussion of the
technical merits or otherwise of C, or of our prospective customers'
language needs - I expected them to use more Fortran than C.
To have a usable system for the amount of money we could raise in
venture capital we had to take advantage of one of the all-time
bargains in computing - a 1980's UNIX source code license. Any other
approach to getting an OS, file system, utilities etc. would have cost
too much and taken too long. Most of the source code, including all
the OS source code that we were going to preserve, was in C.
You could get a UNIX system working with a totally flaky or
nonexistant Fortran, Pascal, or Lisp, but producing a working UNIX
system with all the commands implies possession of something
more-or-less reasonable in the way of a C compiler. I suspect that
this affected writers of programs that needed to run on multiple
systems - if C was the only language that turned out to be reasonably
reliable on all of their target systems, what were they going to code
in?
^ permalink raw reply [flat|nested] 99+ messages in thread
* Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-15 4:00 ` Craig Burley
[not found] ` <623ek6$ef5$1@news.iastate.edu>
@ 1997-10-16 4:00 ` Ian Dall
1997-10-16 4:00 ` Craig Burley
1997-10-17 4:00 ` Richard A. O'Keefe
1 sibling, 2 replies; 99+ messages in thread
From: Ian Dall @ 1997-10-16 4:00 UTC (permalink / raw)
Craig Burley <burley@tweedledumb.cygnus.com> writes:
> A given person can manage only so much complexity at a time.
> If he's spending mental energy coping with a missing feature
> (such as multi-dimensional arrays, or pointers), that's energy
> not being spent on the *application*, meaning he's probably
> going to forget something important, or not have time to test
> some feature, in the application.
When I went to school (quite some time ago) I was taught I should use
the appropriate language for the job. This is still good advice, but
there are factors which tend to prevent one doing this. One is that
there may be a limited range of languages available. In my first job
the choice was PDP 11 assembler or Fortran IV. When I needed pointers
I did it in assembler, the rest in Fortran.
Another factor is incompatibility. Most largish projects have bits
which could be best written in one language and bits which could best
be written in another language, however, they may not be compatible
and are almost certainly not portably compatible. Digital tried to
address this problem in VMS, with a universal calling convention,
which is good as far as it goes. The problem is that it is difficult
to have a standard/convention which is flexible enough for all future
language developments. There is an even more serious compatibility
problem. Languages such as C++, lisp, java, prolog have extensive run
time support. Whilst it is common for languages such as this to
support calling C or Fortran procedures, doing things the other way
around is impossible in practice and may even be impossible in principle.
Lastly, as you say, as person can manage only so much complexity at a
time. What you don't say is effort spent maintaining expertise in many
languages is effort not spent producing the application.
In short, regrettable though it may be, there are good reasons for
people to pick a reasonably flexible language and stick with it. It
is so obvious that different languages have different strengths it is
not worth debating. A more interesting discussion would be: How do you
reduce the barriers to using the most appropriate language for the job?
Ian
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
[not found] ` <623ek6$ef5$1@news.iastate.edu>
@ 1997-10-16 4:00 ` Craig Burley
1997-10-16 4:00 ` SimGraphics
0 siblings, 1 reply; 99+ messages in thread
From: Craig Burley @ 1997-10-16 4:00 UTC (permalink / raw)
rhawkins@iastate.edu (Rick Hawkins) writes:
> In article <y6oh4qzyyr.fsf@tweedledumb.cygnus.com>,
> Craig Burley <burley@tweedledumb.cygnus.com> wrote:
>
> >Yes, I *know* that if we threw tons of resources behind making
> >C compilers more clever at teasing out the original intent of the
> >programmer, we could make it produce fast code for even numerical
> >codes. Then we could tell all Fortran programmers to spend more
> >time writing C code than they have to write Fortran code, but we'd
> >have One True Language that everyone could use.
>
> And here you get to the crux of it, at least for some of us.
>
> Yes, i could get far more control, and do more hand optimization for my
> machine, with c than Fortran. But why should I? I'm a scientist, not a
> programmer. I want to get from formulating my problem to an answer as
> soon as possible. This code will only run a couple of times once
> debugged. Spending *any* extra time to use c would be a waste of time,
> unless it actually ran faster for the *same amount* of work.
Agreed, except for the part about "get far more control, and do more
hand optimization for my machine, with c than Fortran". I keep saying
this, nobody seems to have put forth any evidence, or even persuasive
counter-arguments, to the contrary: C offers *very* little in terms
of low-level constructs that Fortran doesn't offer. Richard O'Keefe
pointed out "pointers", and some people jumped all over him for saying
that (because he didn't list a lot more), but he's essentially right,
that's basically all ANSI/K&R C has to offer over FORTRAN 77 (and note
we're comparing a circa-1985-standardized language, ANSI C, to a
circa-1978-standardized one, FORTRAN 77, the latter having even more
historical baggage dating to back when people didn't *know* how to
do language design properly, instead of simply not bothering to learn
about what had gone before...Fortran 90, standardized circa 1991 or
whenever, *has* pointers, overly fancy ones if you ask me, certainly
fancier than any C variant I'm aware of).
And, most Fortran compilers (g77 and f2c probably being the only
exceptions that are at all popular) offer some form of pointers anyway
-- certainly all Fortran 90 compilers do.
Though, adding pointers to Fortran was about as painful and weird
as was adding `restrict' and all the other baggage to C to make
it approach vanilla Fortran performance on similarly expressed code.
In other areas where Fortran lacked the syntactic elegance of C,
adding intrinsics like IAND, IOR, ISHFT, and so on was quite easy
and consistent with normal Fortran expectations, and pretty much
all compilers support these (or they can be added easily by
programmers as external routines, typically at a performance
penalty).
What Fortran doesn't offer is the syntactic *convenience* of
things like `&&' and `||', which is a huge pain in the butt for
some kinds of work (it was for me anyway, back when I used Fortran
and PL/I for my work, as PL/I also lacked these, back then).
But syntactic convenience is not really a performance issue -- not
for wiz kids with nifty editors (like Emacs ;-) anyway. (Speaking
of that, isn't "wiz" the proper spelling? I see "whiz" used for
"wizard" sometimes, as in "Weather Whiz" and such, but that makes
me think of "Cheese Whiz", a name I don't believe was intended to
connote wizardly qualities. Yet while "wiz" makes sense to me as
a noun, when I go to use it as an adjective, I do type the "h"
and then have to edit it out -- I typed "whiz kids" above first,
and it *felt* right, but isn't "wiz kids" correct? This is a
much more important an issue than which programming language people
should use for multi-million-line numerical-programming projects, IMO.)
The other painful thing about using Fortran for low-level coding
is interfacing to C APIs (just as using C to interface to Fortran
APIs is painful). Yes, in most Fortrans you can use %VAL, %REF,
%DESCR, and so on to achieve what you want, but that's hardly
a friendly way to go. But, again, it's a matter of syntactic
convenience, mostly, with a strong dash of portability thrown in
(since the C API might look exactly the same to C code on another
system, whereas Fortran code munged to interface to that API might
not).
But I haven't seen these issues raised in this thread. The main
issue was multi-dimensionality, and I have yet to see *anyone*
explain why C's flat, single-dimension facility is *superior*
for low-level coding to Fortran's `REAL A(0:N)', which is the
same thing, essentially. So I *still* don't understand why C
is *better* as a low-level translation of code originally,
and properly, written in Fortran, than is Fortran.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` boo
1997-10-16 4:00 ` Timothy A. Seufert
@ 1997-10-16 4:00 ` Toon Moene
1997-10-17 4:00 ` Richard A. O'Keefe
` (2 subsequent siblings)
4 siblings, 0 replies; 99+ messages in thread
From: Toon Moene @ 1997-10-16 4:00 UTC (permalink / raw)
boo <boo@boo.boo> wrote:
> Ok, now let me discuss where MY use of the word "dimensional". Say
> for example, you are working with a 3D or 4D "array", representing
> space or space-time. The actual symmetries of spacetime are
> reflected in the fact that you would do best with a memory system
> in which access is equally fast no matter which axis you are
> doing access along. (If you want specifics, imagine some kind
> of a N-dimensional 3rd order derivative operator, requiring
> information from neigboring points in the 2N directions).
> When I said "memory is not multi-dimensional", I meant "memory
> access is not equally fast along all axes of a multi-dimensional
> array". Of course it is not!! Some points are in the cache,
> some may be stored in registers from some previous calculation,
> some are in main memory, some may be on another node in some
> MPP supercomputer. I know that high performance fortran actually
> usually does an excellent job of optimizing the calculations,
> but my personal experience is that I can usually do better
> by really thinking hard, and coming up with an algorithm that
> realizes that the various ONE-DIMENSIONAL components of the
> memory system are utilized in an optimal manner. And as I said
> elsewhere, most people don't need to bother wasting their time
> on this kind of optimization, but for me, doing so can reduce
> a simulation from one month down to one week, on a 300 Gflop
> supercomputer that I have very limited resources on.
Yep, I start to see better now what you meant (most people would be highly
confused by this use of the word dimension, even non-CS types like me).
Currently, it often is so that in the distributed memory case, hand
optimisation out-performs compiler optimisation (this is not always so; about
a year ago I read a white paper on the Digital Equipment Web site about a
problem they solved faster with a program generated by their HPF compiler
than ordinary Fortran (compiled by the same compiler) + message passing
calls, mainly because the compiler happily combined messages that seemed
totally unrelated to the human Fortran programmer).
The other parts of the memory hierarchy are already dealt with in most high
perfomance Fortran compilers (i.e. the ones you get for a few k$ with your
high end workstation).
Now if we could get the coGNUscenti to work on this for g77, that would be
great :-)
--
Toon Moene (mailto:toon@moene.indiv.nluug.nl)
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Phone: +31 346 214290; Fax: +31 346 214286
g77 Support: mailto:fortran@gnu.ai.mit.edu; NWP: http://www.knmi.nl/hirlam
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` Paul D. DeRocco
1997-10-15 4:00 ` William Clodius
1997-10-15 4:00 ` Joe Buck
@ 1997-10-16 4:00 ` Richard A. O'Keefe
1997-10-16 4:00 ` Craig Burley
2 siblings, 1 reply; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-16 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1505 bytes --]
I wrote:
: Another point is that Fortran
: applies exactly the same rule to *all* operators: if the compiler
: can determine that the *result* of some subcomputation is irrelevant
: to the value of the whole, it can delete that subcomputation entirely.
"Paul D. DeRocco" <pderocco@ix.netcom.crud.com> replied:
>This is certainly true of C++, whose current draft standard
>states that the observable effects of running the program must
>be the same as if the program were executed as described in the
>standard. It's commonly called the "as if" rule.
You have drawn a false conclusion. C++ (like C) is entitled to
delete a subcomputation if the *EFFECTS* would be the same.
Fortran is entitled to delete a subcomputation if the *VALUE*
isn't needed, *REGARDLESS OF ANY EFFECTS*.
To take a fairly extreme case, consider
extern int system(char const *);
int i;
i = 0*system("rm *");
A C or C++ compiler is unable to delete the call to system(), because
it has an *effect* which would not take place if the call were deleted.
Whereas, give "the same thing"
INTEGER SYSTEM
EXTERNAL SYSTEM
INTEGER I
I = 0*SYSTEM('rm *')
to a Fortran compiler, and it is entitled to delete the call to SYSTEM,
because the *value* is irrelevant, and the fact that major effects will
no longer take place isn't allowed to matter.
I do wish people would read more carefully.
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` boo
@ 1997-10-16 4:00 ` Timothy A. Seufert
1997-10-16 4:00 ` boo
1997-10-16 4:00 ` Toon Moene
` (3 subsequent siblings)
4 siblings, 1 reply; 99+ messages in thread
From: Timothy A. Seufert @ 1997-10-16 4:00 UTC (permalink / raw)
In article <34452746.3F9BC63B@boo.boo>, boo <boo@boo.boo> wrote:
>(I should point out,
>proudly, that I have had no formal computer training of any kind, ever,
>so I may not use the same terms that you use in that
>Ivory Tower of yours over there).
That's great, now how about knocking off the anti-intellectualism already,
OK? Slagging off people as "ivory tower" types does nothing to support
your position. Mainly it makes you look petty and jealous, not to mention
incapable of reasoned debate.
BTW, if you have no formal computer training of any kind, ever, how are
you posting from a umn.edu machine?
-- Tim
To mail me unsolicited advertisements: Move to Siberia. Wait until I
say it's OK to send. Everybody else, remove "noUCE." from my address.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-16 4:00 ` Richard A. O'Keefe
@ 1997-10-16 4:00 ` Craig Burley
0 siblings, 0 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-16 4:00 UTC (permalink / raw)
ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:
> I do wish people would read more carefully.
Those that do rarely need USENET to teach them things they can
look up in manuals (like standards documents) for themselves,
especially ones that are online anyway.
In essence, USENET is a medium largely populated by people
who prefer to employ a SOWM (Skim-Once-Write-Many) strategy. ;-)
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-16 4:00 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
@ 1997-10-16 4:00 ` Craig Burley
1997-10-17 4:00 ` Richard A. O'Keefe
1 sibling, 0 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-16 4:00 UTC (permalink / raw)
Ian Dall <Ian.Dall@dsto.defence.gov.au> writes:
> Lastly, as you say, as person can manage only so much complexity at a
> time. What you don't say is effort spent maintaining expertise in many
> languages is effort not spent producing the application.
Oh, but my comments applied to the *whole* job -- so, indeed,
complexity includes managing the hassle of pulling chunks of
code written in different languages together, not to mention
maintaining the resulting mess several years out.
My point is that *everything* in the project must be considered
in terms of its complexity, and this can mean one's definition
of "project" should be widened to include more than at first
thought. (For example, it doesn't mean "set of tasks needed to
get the product out the door", since that doesn't take into account
the complexity of subsequent maintenance, enhancement, porting,
training new hires, and so on.)
So, IMO, your point is well taken. People working on *projects*
shouldn't have to manage the complexity of multiple languages; but
those of us involving in language *design* (and, frankly, that
includes most compiler writers, or at least the "senior" ones,
since it's this group that adds "extensions", for better or worse)
*already* are managing the complexity of multiple languages, so
it behooves us to become sufficiently expert in the science/art
of language design so it becomes *less* complex to us (it certainly
has to me). That is, by learning the rules that underly all
artifical-language design (not yet documented to my knowledge ;-)
and the patterns that are typically built out of them, we can
then more easily navigate the waters of multiple languages without
it being quite so complex to us. Certainly it's vastly easier
for me to cope with learning new languages and systems now that
I recognize the recurring patterns, themes, and so on, and I can
even spot and explain mistakes much more easily now, than it
was for me 20 or so years ago when language design seemed like a
"black art" open to anyone who could implement a compiler.
For example, the "apparent" complexity of a Mozart symphony and
Stravinsky's "Le Sacre du Printemps" might seem roughly equivalent
to someone unacquainted with musical theory, but if you're going to
spend a lot of time coping with Mozart and his ilk, you can afford
to spend the time learning the underlying rules/patterns, and suddenly
the complexities of a particular Mozart symphony become a lot
smaller than for the Stravinsky, which still seems complex by
comparison (because it doesn't fit the models you've learned to
cope with Mozart).
Meanwhile, most programmers seem to *already* be coping with
multiple languages, but believe that, because they use just one
for one *phase* of their project (the phase that involves writing
code that is compiled to produce a particular executable), they're
using just one.
But, if you use `make', `awk', `sed', Emacs, Perl, X, Windows, any
shell, any file system, and so on, in your programming project,
you already *are* coping with multiple languages, and lots of
interface issues between them.
Think about it: do any of the above offer constructs *similar*,
but not exactly the same, as Fortran's `=', .AND., .OR., or
multi-dimensional arrays? As C's `&&' or `||'? Do more than one
of these offer a way to express dependencies (`make' being one)?
How about selection? How about explicit signaling when a set of
fields has been filled out, or "published" (hitting the RETURN/ENTER
key while in a shell being an example, or clicking on OK in a
windowing environment being another)? How about naming? Scoping?
Wildcarding? Listing? Debugging? Automated checking for correctness?
Do *many* of these things seem to recur, often with weird or different
features or limitations depending on the tool? I think it's clear
they do, and we spend a lot of time learning just how `make' is
similar to, but slightly different than, `sh', for example.
I'm *fascinated* by the possibility of sufficiently exploring all
these linguistic spaces, coming up with some kind of metalanguage
to clearly express, perhaps to at least document, what is really
going on with lots of these, and perhaps then coming up with one,
though probably two or three, simple-but-comprehensive languages
to subsume all those other little languages, and yet (otherwise
it'd be pointless) offer *superior* performance in addition to being
simply easier for human beings to cope with (by lowering complexity).
And, whenever I've put even the baby-steps of what I've learned
by thinking about these issues over the past 20 or so years into
actual practice, it's *always* been beneficial, though I've never
done any kind of scientific study of this. (Often, others working
with me have thought I might be slightly "off" in my approach,
even worrying I would be late completing it, and I've ended up doing
just the opposite: getting it done early, perhaps doing more in
terms of features and/or quality than they thought possible using
their "classic" approach. So I am looking forward to learning more
about these issues, and putting more of them into practice, though
I'm probably still a long way from actually designing a prototype
language for writing code, which is, of course, kind of a fantasy
for me.)
> In short, regrettable though it may be, there are good reasons for
> people to pick a reasonably flexible language and stick with it. It
> is so obvious that different languages have different strengths it is
> not worth debating. A more interesting discussion would be: How do you
> reduce the barriers to using the most appropriate language for the job?
Perhaps that question isn't strictly appropriate here, but comp.arch
ends up being, frequently, a place where one "locus" of such a
discussion takes place *in practice*.
That is, since the way one chooses the "most appropriate language"
often includes the "fit" of the languages' existing compilers to the
existing machines and existing performance requirements, and since
the way one chooses the "most appropriate architecture" for *future*
machines (to implement a machine, or to choose an architecture for
one's new project) often includes the "fit" of that architecture
to existing codes written in existing languages meeting existing
performance requirements, comp.arch often ends up being a place
where we start by asking the eternal question "What is the One True
Architecture" and thus, necessarily, ask "What is the One True
Language", which then becomes "What is the One True Application", and
so on and so forth. None of these elements (architecture, language,
or application) really drives the industry-wide design cycle, but
they *each* have too much impact on the other elements, adding
more complexity than I feel will be necessary once we understand
the art of managing and reducing complexity, which will happen
in our field only once we can really understand how to properly
engineer artifical languages (my term for Fortran, C, `make', and
so on).
Nowadays, there are so many languages with widely portable implementations
to choose from, what we have to manage is not so much the complexity
of choosing the appropriate one, but maintaining the code written
in one when having to hire new people. Hence the ongoing popularity
of Fortran, C, and the hype-resultant (which *is* important for
success!) popularity of Java...not to mention the x86 architecture.
Since it turns out the most expensive part of a typical programming
project is not in the *writing* of the code, it ends up being
not unreasonable that a less-than-ideal language for such writing
is chosen. That's why I don't think it's productive to simply
design a "clean" language for writing a certain kind, or even many
kinds, of application, and expect people to just adopt it -- besides,
others have attempted to do that, and pretty much failed.
Personally, I think the Free Software community (e.g. Project GNU)
offers a lot of potential here, which is a big reason why I'm in it.
Yes, properly designing a new language is important, but making its
first implementation not only solid but free, highly performing,
portable, complete with debugging support, *and* with converters
to/from other popular languages for that "nice, warm feeling"
management often wants, all are just as important...and, it's hard
to see how such an effort can be made outside the free-sw community
due to the investment needed to realize it (and the fact that it's
gotta be free meaning there won't be a clear ROI).
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` Dr. Richard Black
@ 1997-10-16 4:00 ` Richard A. O'Keefe
0 siblings, 0 replies; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-16 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 941 bytes --]
rjb@tanna.dcs.gla.ac.uk (Dr. Richard Black) writes:
>There is no free lunch. Late binding (virtual functions) has
>advantages for programs, and implementation costs. Most of those
>costs can be avoided, however. Maybe whats really annoying Nick is
>that one of his ex-peers, now at DEC, has a patent on the technique....
Which technique is that? What does the patent cover?
Simula 67 had virtual functions (and still has).
Late binding of functions was very well understood in the early 60s.
(When did IBM introduce what they very confusingly call 'user exits'
and Lisp people call 'hooks'?)
There's a very obvious method for single inheritance virtual function
dispatch which requires a load from the object, an add, and a dynamic
branch, with no vtables. Is that what the patent covers?
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-16 4:00 ` Timothy A. Seufert
@ 1997-10-16 4:00 ` boo
0 siblings, 0 replies; 99+ messages in thread
From: boo @ 1997-10-16 4:00 UTC (permalink / raw)
Timothy A. Seufert babbled:
> In article <34452746.3F9BC63B@boo.boo>, boo <boo@boo.boo> wrote:
>
> >(I should point out,
> >proudly, that I have had no formal computer training of any kind, ever,
> >so I may not use the same terms that you use in that
> >Ivory Tower of yours over there).
>
> That's great, now how about knocking off the anti-intellectualism already,
> OK?
I am in the very last stages of my PhD, so I hardly think I am
"anti-intellecual".I am
anti-people-who-use-big-words-for-the-sake-of-using-big-words though.
> BTW, if you have no formal computer training of any kind, ever, how are
> you posting from a umn.edu machine?
I am surprised to learn that you required formal training to post yourreply to
the USENET.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-16 4:00 ` Craig Burley
@ 1997-10-16 4:00 ` SimGraphics
1997-10-17 4:00 ` Craig Burley
0 siblings, 1 reply; 99+ messages in thread
From: SimGraphics @ 1997-10-16 4:00 UTC (permalink / raw)
In article <y6en5m9p9z.fsf@tweedledumb.cygnus.com>,
Craig Burley <burley@tweedledumb.cygnus.com> wrote:
>this, nobody seems to have put forth any evidence, or even persuasive
>counter-arguments, to the contrary: C offers *very* little in terms
>of low-level constructs that Fortran doesn't offer.
All right, I'll try.
Think of implementing run time library for two languages,
using two choices of languages.
1) C runtime implemented in C
2) C runtime implemented in Fortran
3) Fortran runtime implemented in C
4) Fortran runtime implemented in Fortran
My ordering, from easiest to hardest: 1,3,4,2.
Regards,
Sylvester (who never wrote a compiler from scratch, but adapted
some for unusual requirements, or just plain major performance
improvements)
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` boo
1997-10-16 4:00 ` Timothy A. Seufert
1997-10-16 4:00 ` Toon Moene
@ 1997-10-17 4:00 ` Richard A. O'Keefe
1997-10-20 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-20 4:00 ` Jason.Ozolins
4 siblings, 0 replies; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-17 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3720 bytes --]
boo <boo@boo.boo> writes:
>You have made the point that memory is not uniform,
>you have not made the point that memory is multi-dimensional. Perhaps I
>should discuss exactly what I meant when I mentioned "multi-dimensionality".
If you wish to claim Humpty-Dumpty's privilege, it is wise to advertise
that fact rather earlier.
We were talking about arrays, so the sense of 'dimension' accessible
to other readers of this thread was array dimensions.
>(I should point out,
>proudly, that I have had no formal computer training of any kind, ever,
>so I may not use the same terms that you use in that
>Ivory Tower of yours over there).
Leave the ad hominem attacks aside. I may be teaching in a CS
department, but I have no CS degree. (Statistics, Physics, and AI.)
I learned terms like 'dimension' (in a computing context) from the
same place you should have: books about programming languages and
hardware reference manuals.
>In the context of memory,
>I naturally assumed that any sensible person would realize that the
>symmetry of interest would be "speed of access".
>What you have described
>does NOT have this symmetry, and therefore I cannot fathom why you
>would claim that it is multi-dimensional.
Since you have conceded that memory is *not* isochronic in any
'direction', it is rather baffling why you argue that memory is
NOT multidimensional.
>I can only assume you are using
>some broader abstract concept of the term, which does not really fit
>well with my scientific concepts.
No, you are the one using abstract concepts, which do not usefully
apply to the realities we are discussing. It seems as if you are
confusing a *coordinate system* (the fact that virtual memory addresses
look like single numbers) with a *space* (the fact that memory has a
structure which can be modelled using tree structures or arrays,
with different levels or axes having different costs).
>Ok, now let me discuss where MY use of the word "dimensional". Say
>for example, you are working with a 3D or 4D "array", representing
>space or space-time. The actual symmetries of spacetime are
>reflected in the fact that you would do best with a memory system
>in which access is equally fast no matter which axis you are
>doing access along.
Surely whether that is so depends entirely on what you are DOING
with your mesh.
>(If you want specifics, imagine some kind
>of a N-dimensional 3rd order derivative operator, requiring
>information from neigboring points in the 2N directions).
>When I said "memory is not multi-dimensional", I meant "memory
>access is not equally fast along all axes of a multi-dimensional
>array".
Everyone else understood your denial of memory's structurd nature
to be a claim that memory *is* equally fast along all axes of an
array.
>realizes that the various ONE-DIMENSIONAL components of the
>memory system are utilized in an optimal manner.
It has been repeatedly pointed out that the components that
real memory systems are built out of are NOT one-dimensional.
>It is amazing that almost everyone jumped on my statement that
>memory is not multi-dimensional with absurds comments about the
>"multi-dimensional structure of memory hardware". I suggest you
>all replace "dimensional" with "component" in the above phrase,
>to which I reply:
> DUH
Well, DUH to you too, Mr boo, because you really have no right to
complain if people react to what you *write* instead of the direct
opposite that you *mean*. Everyone else in the thread understands
'not multidimensional' to mean 'having uniform access'.
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-17 4:00 ` Craig Burley
@ 1997-10-17 4:00 ` David Chase
1997-10-18 4:00 ` Victor Yodaiken
1997-10-17 4:00 ` William Clodius
1997-10-18 4:00 ` Peter L. Montgomery
2 siblings, 1 reply; 99+ messages in thread
From: David Chase @ 1997-10-17 4:00 UTC (permalink / raw)
> simg@netcom.com (SimGraphics) writes:
> > All right, I'll try.
> >
> > Think of implementing run time library for two languages,
> > using two choices of languages.
> >
> > 1) C runtime implemented in C
> > 2) C runtime implemented in Fortran
> > 3) Fortran runtime implemented in C
> > 4) Fortran runtime implemented in Fortran
> >
> > My ordering, from easiest to hardest: 1,3,4,2.
Fortran compilers have been written in Fortran, and the
worst operating system stuff is usually written in assembly
language anyway.
I'd like to plug, again, my current favorite bit of research,
which is the SPIN kernel done at U Washington. This is an OS
written in a language that has both safe and unsafe variants,
and carefully defined rules for how safe and unsafe code
interact. What this means is that user code can (using a
"trusted compiler", the weak link in this system) be loaded
into the kernel. In practice, this is used to enhance existing
OS services while avoiding the high cost of an untrusted
user-to-kernel transfer of control, and the benchmarks they
get are great (with a single exception that is merely equal,
uniformly better than commercial OSes running on the same
hardware). Note that the language used (Modula-3) suffers
from having a merely ok compiler, plus all the overhead
associated with checked pointer casts and array bounds checks,
as well as garbage collection. These low-level performance
handicaps were overcome by a better design made possible
by certain language features.
Just another reminder not to miss the forest for the trees.
No amount of C-hacking expertise can get you the security
benefits of a safe language with such good performance.
--
David Chase, chase@world.std.com
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-17 4:00 ` Craig Burley
1997-10-17 4:00 ` David Chase
@ 1997-10-17 4:00 ` William Clodius
1997-10-19 4:00 ` Craig Burley
1997-10-18 4:00 ` Peter L. Montgomery
2 siblings, 1 reply; 99+ messages in thread
From: William Clodius @ 1997-10-17 4:00 UTC (permalink / raw)
Craig Burley wrote:
>
> simg@netcom.com (SimGraphics) writes:
>
> > In article <y6en5m9p9z.fsf@tweedledumb.cygnus.com>,
> > Craig Burley <burley@tweedledumb.cygnus.com> wrote:
> > >this, nobody seems to have put forth any evidence, or even persuasive
> > >counter-arguments, to the contrary: C offers *very* little in terms
> > >of low-level constructs that Fortran doesn't offer.
> >
> > All right, I'll try.
> >
> > Think of implementing run time library for two languages,
> > using two choices of languages.
> >
> > 1) C runtime implemented in C
> > 2) C runtime implemented in Fortran
> > 3) Fortran runtime implemented in C
> > 4) Fortran runtime implemented in Fortran
> >
> > My ordering, from easiest to hardest: 1,3,4,2.
>
> I don't see any rebuttal there.
Agree.
> Care to explain what *low-level*
> constructs C is offering that Fortran doesn't offer, aside from
> pointers?
Guaranteed ability to pass some arguments by value, or have a well
defined result in the presence of aliasing (whether or not the initial
programmer or the user of the code knows what that well defined result
is).
Compared to Fortran 77, not Fortran 90, structures.
Unions (but much of that can be kluged using EQUIVALENCE). (Then again
unions themselves are usually kluges in their application.)
Of the three above constructs only structures, Fortran 90's derived
types, provide what I think of as usefull functionality for numeric
programming.
> I've already *said* that C's notational convenience
> makes it easier to type in the code, but that's not particularly
> relevant to getting maximum performance out of existing or new
> architectures. <snip>
There is also the problem of API's on C implemented systems, name
mangling, the possibility of copy-in/copy-out Fortran argument passing,
i.e., the interlanguage interfacing problem. None of this is strictly a
problem with the Fortran language per se, but does influence its
useability as a runtime library on most current systems.
--
William B. Clodius Phone: (505)-665-9370
Los Alamos Nat. Lab., NIS-2 FAX: (505)-667-3815
PO Box 1663, MS-C323 Group office: (505)-667-5776
Los Alamos, NM 87545 Email: wclodius@lanl.gov
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-17 4:00 ` Keith Adams
1997-10-17 4:00 ` [Reposted due to Enlow UCE cancel]: " John Bayko
@ 1997-10-17 4:00 ` John Bayko
1997-10-18 4:00 ` Kelly Hall
2 siblings, 0 replies; 99+ messages in thread
From: John Bayko @ 1997-10-17 4:00 UTC (permalink / raw)
In article <627sbt$r7g@cocoa.brown.edu>,
Keith Adams <kma@doorknob.cs.brown.edu> wrote:
[...prior stuff...]
>"The effort spent maintaining expertise in many languages." It takes an
>investment of time and energy to learn any programming language. To become
>productively competent in a programming language takes considerably more time
>and energy. [...]
It takes me about two weeks to become productively competent in a
programming language, as long as it's not too unusual. At NorTel I had
to learn their proprietary telephone switch language in about that
time, and I didn't do badly during my term that (to become good
obviously takes longer, and I missed a few subtlties - for example,
'case' and 'select' had the same structure, but one created a multiple
comparison, while the other produced a jump table. I used the wrong
one once, but it didn't break anything - as far as I know, NorTel
telephone switches are still running).
--
John Bayko (Tau).
bayko@cs.uregina.ca
http://www.cs.uregina.ca/~bayko
^ permalink raw reply [flat|nested] 99+ messages in thread
* [Reposted due to Enlow UCE cancel]: Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-17 4:00 ` Keith Adams
@ 1997-10-17 4:00 ` John Bayko
1997-10-20 4:00 ` Paul D. DeRocco
1997-10-17 4:00 ` John Bayko
1997-10-18 4:00 ` Kelly Hall
2 siblings, 1 reply; 99+ messages in thread
From: John Bayko @ 1997-10-17 4:00 UTC (permalink / raw)
In article <627sbt$r7g@cocoa.brown.edu>,
Keith Adams <kma@doorknob.cs.brown.edu> wrote:
[...prior stuff...]
>"The effort spent maintaining expertise in many languages." It takes an
>investment of time and energy to learn any programming language. To become
>productively competent in a programming language takes considerably more time
>and energy. [...]
It takes me about two weeks to become productively competent in a
programming language, as long as it's not too unusual. At NorTel I had
to learn their proprietary telephone switch language in about that
time, and I didn't do badly during my term that (to become good
obviously takes longer, and I missed a few subtlties - for example,
'case' and 'select' had the same structure, but one created a multiple
comparison, while the other produced a jump table. I used the wrong
one once, but it didn't break anything - as far as I know, NorTel
telephone switches are still running).
--
John Bayko (Tau).
bayko@cs.uregina.ca
http://www.cs.uregina.ca/~bayko
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Control: cancel <628q9j$bto$1@sue.cc.uregina.ca>
Newsgroups: comp.arch
Path: ...!news.hn.netlink.co.nz!canterbury.ac.nz!southpower.co.nz!nobody
From: rra@eyrie.org,sw@eyrie.org,rgm@eyrie.org
Subject: cmsg cancel <628q9j$bto$1@sue.cc.uregina.ca>
Approved: rra@eyrie.org,sw@eyrie.org,rgm@eyrie.org
Message-ID: <cancel.628q9j$bto$1@sue.cc.uregina.ca>
X-No-Archive: Yes
Sender: bayko@pollux.cs.uregina.ca (John Bayko)
X-Cancelled-By: rra@eyrie.org,sw@eyrie.org,rgm@eyrie.org
Organization: Southpower Ltd
Date: Sun, 19 Oct 1997 05:28:01 GMT
Lines: 2
The article was canceled on 10/19/97 at 1:18:01 AM with the Usenet Cancel Engine (UCE).
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-16 4:00 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
1997-10-16 4:00 ` Craig Burley
@ 1997-10-17 4:00 ` Richard A. O'Keefe
1997-10-17 4:00 ` Keith Adams
1 sibling, 1 reply; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-17 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]
Ian Dall <Ian.Dall@dsto.defence.gov.au> writes:
>There is an even more serious compatibility
>problem. Languages such as C++, lisp, java, prolog have extensive run
>time support. Whilst it is common for languages such as this to
>support calling C or Fortran procedures, doing things the other way
>around is impossible in practice and may even be impossible in principle.
C or Fortran calling Prolog or Lisp is by no means impossible in practice.
It is perfectly normal. (How do you think the X window interface in a
commercial system works? X callbacks call C functions which then call
the appropriate Prolog predicate or Lisp function.)
Or take Poplog, where *one* address space simultaneously supports
Prolog, Pop11, Common Lisp, ML, and whatever C or Fortran you care
to link in, with any language easily able to call any other.
>Lastly, as you say, as person can manage only so much complexity at a
>time. What you don't say is effort spent maintaining expertise in many
>languages is effort not spent producing the application.
What effort?
Sounds a lot like "we're too busy trying to catch up with our missed
deadlines to bother with any of this software engineering c---."
>In short, regrettable though it may be, there are good reasons for
>people to pick a reasonably flexible language and stick with it.
There are, but the reasons you have cited are not among them.
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-17 4:00 ` Richard A. O'Keefe
@ 1997-10-17 4:00 ` Keith Adams
1997-10-17 4:00 ` [Reposted due to Enlow UCE cancel]: " John Bayko
` (2 more replies)
0 siblings, 3 replies; 99+ messages in thread
From: Keith Adams @ 1997-10-17 4:00 UTC (permalink / raw)
Richard A. O'Keefe (ok@goanna.cs.rmit.edu.au) wrote:
: >Lastly, as you say, as person can manage only so much complexity at a
: >time. What you don't say is effort spent maintaining expertise in many
: >languages is effort not spent producing the application.
: What effort?
"The effort spent maintaining expertise in many languages." It takes an
investment of time and energy to learn any programming language. To become
productively competent in a programming language takes considerably more time
and energy. And once you've made this initial investment, you must make the
continued effort of staying current as the language and the tools that support
it change.
Keith Adams
kma@cs.brown.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-16 4:00 ` SimGraphics
@ 1997-10-17 4:00 ` Craig Burley
1997-10-17 4:00 ` David Chase
` (2 more replies)
0 siblings, 3 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-17 4:00 UTC (permalink / raw)
simg@netcom.com (SimGraphics) writes:
> In article <y6en5m9p9z.fsf@tweedledumb.cygnus.com>,
> Craig Burley <burley@tweedledumb.cygnus.com> wrote:
> >this, nobody seems to have put forth any evidence, or even persuasive
> >counter-arguments, to the contrary: C offers *very* little in terms
> >of low-level constructs that Fortran doesn't offer.
>
> All right, I'll try.
>
> Think of implementing run time library for two languages,
> using two choices of languages.
>
> 1) C runtime implemented in C
> 2) C runtime implemented in Fortran
> 3) Fortran runtime implemented in C
> 4) Fortran runtime implemented in Fortran
>
> My ordering, from easiest to hardest: 1,3,4,2.
I don't see any rebuttal there. Care to explain what *low-level*
constructs C is offering that Fortran doesn't offer, aside from
pointers? I've already *said* that C's notational convenience
makes it easier to type in the code, but that's not particularly
relevant to getting maximum performance out of existing or new
architectures. (And I've already pointed out that entire *operating
systems*, implemented on machines that C couldn't cope with
properly in fact, have been implemented largely in FORTRAN 66,
so I doubt a C runtime implemented in Fortran would be particularly
challenging, when it comes to gaining the same performance, as
compared to one implemented in C. Can you say the same thing
about a Fortran runtime that includes popular numeric-library
routines? I *know* you can't, the aliasing problems alone would
require you to use C extensions that are only being discussed and,
sometimes, implemented *today*.)
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` Paul D. DeRocco
@ 1997-10-17 4:00 ` Shankar Unni
1 sibling, 0 replies; 99+ messages in thread
From: Shankar Unni @ 1997-10-17 4:00 UTC (permalink / raw)
Richard A. O'Keefe wrote:
> No, the point is that sophisticated compiler analysis (read: not just
> interprocedural data flow analysis but cross *translation unit* data
> flow analysis) is *required*.
However, such analysis is becoming increasingly commonly available these
days from most serious compiler vendors. I used to consider
interprocedural analysis as an exotic and expensive frill, but no
longer. This is not to excuse the language design shortcomings, but to
say that they are no longer as great a drawback as they used to be..
> C is wrong because it cannot optimise code that _is_ clean very
> well without going to a hell of a lot of work to find out that it
> is clean.
> Fortran is wrong because it _does_ optimise code on the _assumption_
> that it is clean.
> What we really want are languages for which a compiler _can_ exploit
> the absence of aliasing, side effects, &c whenever it is safe to,
> needing only linear cost analysis of the source code to determine
> when it is safe. The Larch annotations for C strike me as a move
> in the right direction.
Mmm. I'm torn on that front. I agree that such annotations are very
useful. However, as a C purist, I would be satisfied with a small set of
qualifiers that provided enough hints to the optimizer to exploit
significant opportunities without being perfectly optimal.
"const" and "volatile" (and the much-discussed "noalias" or its bastard
child "restrict") are steps in the right direction. I'd also vote for a
hint that a function had no memory side effects (something that, even
with source, is often hard to determine). The most aggressive
optimizations that *relied* on these keywords would have to be an
optional level (because of the curse of legacy code), but at least they
would be available.
--
Shankar Unni Powertel Global, Inc.
(650) 259-1700 shankar@powertelglobal.com
(650) 259-1702 (fax) shankar@webnexus.com
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-17 4:00 ` David Chase
@ 1997-10-18 4:00 ` Victor Yodaiken
1997-10-20 4:00 ` Eric Hildum
0 siblings, 1 reply; 99+ messages in thread
From: Victor Yodaiken @ 1997-10-18 4:00 UTC (permalink / raw)
On Fri, 17 Oct 1997 21:21:02 GMT, David Chase <chase@world.std.com> wrote:
>into the kernel. In practice, this is used to enhance existing
>OS services while avoiding the high cost of an untrusted
>user-to-kernel transfer of control, and the benchmarks they
>get are great (with a single exception that is merely equal,
>uniformly better than commercial OSes running on the same
>hardware). Note that the language used (Modula-3) suffers
Spin is an interesting system, but, in fairness, one should note
that benchmarks better than commercial OS's are no big deal.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-17 4:00 ` Craig Burley
1997-10-17 4:00 ` David Chase
1997-10-17 4:00 ` William Clodius
@ 1997-10-18 4:00 ` Peter L. Montgomery
1997-10-19 4:00 ` Craig Burley
1997-10-20 4:00 ` Richard A. O'Keefe
2 siblings, 2 replies; 99+ messages in thread
From: Peter L. Montgomery @ 1997-10-18 4:00 UTC (permalink / raw)
In article <y64t6gs45q.fsf@tweedledumb.cygnus.com>
Craig Burley <burley@tweedledumb.cygnus.com> writes:
>I don't see any rebuttal there. Care to explain what *low-level*
>constructs C is offering that Fortran doesn't offer, aside from
>pointers?
Nobody has been mentioning unsigned arithmetic.
In many implementations of Fortran (and C), signed and unsigned
additions and subtractions behave identically, but C
_guarantees_ what the result will be if it overflows, which
Fortran does not.
C has conditional compilation, which Fortran does not.
Fortran leads C in its large intrinsic function library.
C9X will finally let one write a MAX function which evaluates its
arguments once only and use the INLINE keyword to get good code,
but the user will need to call different functions depending
upon the argument types (cf. labs/abs/fabs in C vs. ABS in Fortran).
Neither language has constructs for the following operations
(although some implementations make them available):
. Trailing zero count of nonzero binary number
(equal to highest power of 2 dividing the number)
. Truncated base-2 logarithm of nonnegative integer,
with LOG2(0) = -1. [Or return the number of bits required
to hold the value, which is one more than its logarithm.]
. Population count of nonnegative integer.
. Upper half of (signed or unsigned) integer product.
. Greatest common divisor (GCD) of two integers.
. Floating point operations with explicit rounding,
such as ROUND_DOWN(a - ROUND_ZERO(b*c))
to round the product b*c towards zero and
round the difference a - b*c towards -infinity.
All of these, except the GCD, have simple translations on the
latest DEC Alpha. They have mathematical definitions
which do not refer to the target architecture,
except that we need the number of bits per datum to
define the upper half of an integer product.
The optimal translations vary widely
with the target architecture, and the first three constructs
have been discussed many times in this newsgroup,
yet the language designers decline to standardize the constructs.
--
Peter L. Montgomery pmontgom@cwi.nl San Rafael, California
A mathematician whose age has doubled since he last drove an automobile.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-17 4:00 ` Keith Adams
1997-10-17 4:00 ` [Reposted due to Enlow UCE cancel]: " John Bayko
1997-10-17 4:00 ` John Bayko
@ 1997-10-18 4:00 ` Kelly Hall
1997-10-20 4:00 ` [Reposted due to Enlow UCE cancel]: " Eric Hildum
2 siblings, 1 reply; 99+ messages in thread
From: Kelly Hall @ 1997-10-18 4:00 UTC (permalink / raw)
In article <627sbt$r7g@cocoa.brown.edu>
kma@doorknob.cs.brown.edu (Keith Adams) wrote:
> "The effort spent maintaining expertise in many languages." It takes an
> investment of time and energy to learn any programming language. To become
> productively competent in a programming language takes considerably more time
> and energy. And once you've made this initial investment, you must make the
> continued effort of staying current as the language and the tools that support
> it change.
I program regularly in C, Perl, and assembly language. Two of these languages are
nearly static. Perl doesn't change so rapidly that I can't keep up easily. I would not
care to rewrite anything I did in C with either Perl or assembly, nor would I want to
replace the assembly with C or Perl code, and so on for the perl stuff.
So I submit that for the mix of programming that I do regularly, I'm more productive
because I use multiple languages than I'd be if I only used one of the three.
If my job required me to start writing code for parallel machines tomorrow, I'd spend
a few weeks getting acquianted with another language before I used any of the three
languages above for a big project. Ditto if I had to start a large project full of
numerical analysis.
Yes, it takes effort to gain proficiency in a new tool. But using the wrong tool can
require even more effort.
Kelly
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` boo
1997-10-18 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
@ 1997-10-18 4:00 ` tgg
1 sibling, 0 replies; 99+ messages in thread
From: tgg @ 1997-10-18 4:00 UTC (permalink / raw)
boo (boo@tonys.ecology.umn.edu) wrote:
|I am almost embarrassed for you, you missed the point so badly. I
|don't even know how to respond to such a stupid comment.
What is your real name, please?
============================================================================
The above are my own views, not the views of HP
Tom Gardner Hewlett Packard Laboratories, Filton Rd,
tgg@hpl.hp.com Stoke Gifford, Bristol, Avon, BS12 6QZ, ENGLAND.
Fax: +44 117 9228924 Tel: +44 117 9799910 ext. 28192
============================================================================
^ permalink raw reply [flat|nested] 99+ messages in thread
* [Reposted due to Enlow UCE cancel]: Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` boo
@ 1997-10-18 4:00 ` tgg
1997-10-18 4:00 ` tgg
1 sibling, 0 replies; 99+ messages in thread
From: tgg @ 1997-10-18 4:00 UTC (permalink / raw)
boo (boo@tonys.ecology.umn.edu) wrote:
|I am almost embarrassed for you, you missed the point so badly. I
|don't even know how to respond to such a stupid comment.
What is your real name, please?
============================================================================
The above are my own views, not the views of HP
Tom Gardner Hewlett Packard Laboratories, Filton Rd,
tgg@hpl.hp.com Stoke Gifford, Bristol, Avon, BS12 6QZ, ENGLAND.
Fax: +44 117 9228924 Tel: +44 117 9799910 ext. 28192
============================================================================
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Control: cancel <EI8sz2.HEq@hplb.hpl.hp.com>
Newsgroups: comp.arch
Path: ...!news.hn.netlink.co.nz!canterbury.ac.nz!southpower.co.nz!nobody
From: rra@eyrie.org,sw@eyrie.org,rgm@eyrie.org
Subject: cmsg cancel <EI8sz2.HEq@hplb.hpl.hp.com>
Approved: rra@eyrie.org,sw@eyrie.org,rgm@eyrie.org
Message-ID: <cancel.EI8sz2.HEq@hplb.hpl.hp.com>
X-No-Archive: Yes
Sender: news@hplb.hpl.hp.com (Usenet News Administrator)
X-Cancelled-By: rra@eyrie.org,sw@eyrie.org,rgm@eyrie.org
Organization: Southpower Ltd
Date: Sun, 19 Oct 1997 05:26:24 GMT
Lines: 2
The article was canceled on 10/19/97 at 1:16:35 AM with the Usenet Cancel Engine (UCE).
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-14 4:00 ` Richard Black
1997-10-15 4:00 ` Craig Burley
1997-10-15 4:00 ` Michael Williams
@ 1997-10-18 4:00 ` Bruce Hoult
2 siblings, 0 replies; 99+ messages in thread
From: Bruce Hoult @ 1997-10-18 4:00 UTC (permalink / raw)
Richard Black <rjb@tanna.dcs.gla.ac.uk> writes:
> Oh, and this language has to be both non-proprietary and have huge
> industry support. It may well be that we have to go from here to
> there in steps, and that Java is the first such.
And the second?
My vote: Dylan.
-- Bruce
--
'We have no intention of shipping another bloated operating system and
forcing that down the throats of our Windows customers'
-- Paul Maritz, Microsoft Group Vice President
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-17 4:00 ` William Clodius
@ 1997-10-19 4:00 ` Craig Burley
0 siblings, 0 replies; 99+ messages in thread
From: Craig Burley @ 1997-10-19 4:00 UTC (permalink / raw)
William Clodius <wclodius@lanl.gov> writes:
> Craig Burley wrote:
> >
> > Care to explain what *low-level*
> > constructs C is offering that Fortran doesn't offer, aside from
> > pointers?
>
> Guaranteed ability to pass some arguments by value, or have a well
> defined result in the presence of aliasing (whether or not the initial
> programmer or the user of the code knows what that well defined result
> is).
C has an IMO important linguistic/syntactic advantage in that
the programmer (and thus the compiler) *knows* that "foo (a);"
will not modify `a', indeed. Fortran's version of this is
"CALL FOO((A))", and of course the FOO *subroutine* can be
fairly easily determined to not modify its argument. However,
in practice, the typical compiler cannot determine that all
calls to FOO are done via (A) and/or that FOO itself can take the
argument by value, so it must assume pass-by-reference.
So, when passing an argument by value as a *mechanism* is faster
in an important way, then I think this is an important advantage
to C.
(Note that I *could* argue that Fortran compilers "could" [and in
fact, I've been told some do] determine that pass-by-value would
work and thus implement the faster form anyway...but what a
super-fancy compiler can *intuit* from code made intentionally
obtuse by the failings of a language is *not* the issue here,
else, as I've pointed out elsewhere, we might as well say that
C and/or the x86 assembly language is "just fine" for achieving
maximum speed on *all* future architectures.)
BTW, another thing I prefer in C, though it's purely linguistic
and has no performance implications, is that function references
are syntactically distinct from array references. I don't usually
bring this up, because, for some reason I haven't quite grokked
yet, Fortran programmers don't seem to experience any problems as
a result of this in practice.
However, Fortran does offer the ability to do aliasing, when
it is important enough to do. Instead of
SUBROUTINE BIGMUL(A,B,C,N)
REAL A(N),B(N),C(N)
DO I=1,N
A(I)=B(I)*C(I)
END DO
END
you provide:
SUBROUTINE BIGMULA(A,IA,IB,IC,N)
REAL A(MAX(IA,IB,IC)+N-1)
DO I=0,N-1
A(IA+I)=A(IB+I)*A(IC+I)
END DO
END
This makes it clear to the compiler (and the person reading the
code, both the caller and callee, pretty much) that aliasing
is designed into the routine. (Strictly speaking, you can't use
intrinsics, like MAX(), in an array decl, I believe; but you can
either expand it to the appropriate expression, or just use `*'.)
> Compared to Fortran 77, not Fortran 90, structures.
Not sure this is superior for performance. Guaranteed it is for
expressability. I've already said I've seen real gross Fortran
code that achieves what amounts to the same thing, performance-wise,
as C structures, though I suspect even if people wanted to force
the issue and use Fortran, they'd end up with the same problem
C imposes on Fortran users by not having multi-dimensional arrays:
the compiler would have to be *lots* smarter to figure out how to
do some nifty optimizations.
On the other hand, C does offer a few ways of being more flexible
in how to specify initial values for variables and aggregates.
One thing I love about C is its file scoping, for example, which
allows several procedures to share static data, which explicitly
permits the compiler (and programmer) to make all sorts of usable,
practical assumptions about the kinds of things that can be done
vis-a-vis the static data.
Then again, C offers nothing like "COMMON /X/ A(1000000)", especially
when in a BLOCK DATA combined with "DATA A(1)/1./". This *can* have
a substantial performance impact, although I suspect that, in
practice, most such cases would be mitigated by the fact that
the Fortran was "written around" not having dynamic allocation (which
C has, of course). (The reason? The Fortran initialization literally
says "the first element of A is 1; the rest are uninitialized",
while C doesn't allow specifying that portions of variables are
uninitialized, or even static/extern ones IIRC, the latter being
mostly a linguistic failing except when the aggregate sizes of
gratuitously zero-initialized entities is large enough to impact
executable size and startup time.)
> Unions (but much of that can be kluged using EQUIVALENCE). (Then again
> unions themselves are usually kluges in their application.)
Yup, I don't see a clear win here, though, personally, I prefer
C's unions to Fortran's EQUIVALENCE.
> There is also the problem of API's on C implemented systems, name
> mangling, the possibility of copy-in/copy-out Fortran argument passing,
> i.e., the interlanguage interfacing problem. None of this is strictly a
> problem with the Fortran language per se, but does influence its
> useability as a runtime library on most current systems.
Yup, I mentioned that elsewhere, except the part about copy-in/copy-out
passing, which is a practical advantage in favor of Fortran on some
systems.
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-18 4:00 ` Peter L. Montgomery
@ 1997-10-19 4:00 ` Craig Burley
[not found] ` <3456700e.14141203@news.demon.co.uk>
1997-10-20 4:00 ` Richard A. O'Keefe
1 sibling, 1 reply; 99+ messages in thread
From: Craig Burley @ 1997-10-19 4:00 UTC (permalink / raw)
pmontgom@cwi.nl (Peter L. Montgomery) writes:
> In article <y64t6gs45q.fsf@tweedledumb.cygnus.com>
> Craig Burley <burley@tweedledumb.cygnus.com> writes:
>
> >I don't see any rebuttal there. Care to explain what *low-level*
> >constructs C is offering that Fortran doesn't offer, aside from
> >pointers?
>
> Nobody has been mentioning unsigned arithmetic.
> In many implementations of Fortran (and C), signed and unsigned
> additions and subtractions behave identically, but C
> _guarantees_ what the result will be if it overflows, which
> Fortran does not.
Good call! I bet this does help low-level stuff. All Fortran
lets you do in unsigned is what you can accomplish with intrinsics
(say, MIL-STD 1753) or external procedures, which isn't as easily
optimized.
> C has conditional compilation, which Fortran does not.
I'd say the fact that `cpp' is so widely available, and can thus
provide conditional compilation for Fortran, mitigates this
sufficiently. In practice, tons of Fortran code is either
written "just fine" without a preprocessor, or one is used.
Though, there are too many different ones. Hard to see how this
really benefits low-level coding, however.
> Fortran leads C in its large intrinsic function library.
> C9X will finally let one write a MAX function which evaluates its
> arguments once only and use the INLINE keyword to get good code,
> but the user will need to call different functions depending
> upon the argument types (cf. labs/abs/fabs in C vs. ABS in Fortran).
Hmm. Still not a big win for low-level coding for Fortran, though.
I wonder if ?: might be an important, but oft-overlooked, win for
low-level coding in C? You can probably *achieve* the same thing
in Fortran using intrinsics and such, and certainly via statements,
plus Fortran wouldn't "want" to have the sequence-point aspect of
it, but I wonder if a generic CASE(N,E1,E2,...,En) intrinsic that
returns the value of expression E(N) would have made Fortran better
for low-level stuff. I use ?: a lot in my C code, and usually
don't care if both choices happen to get evaluated, but sometimes
do care that a C compiler might be able to avoid the subexpression
entirely (something harder for a Fortran compiler if the statement
equivalent, i.e. IF/THEN/ELSE, is used, since it means figuring
out temporary variables' lifetimes, etc.).
Okay, so now I think the list of features "classic" K&R C offers
that "classic" FORTRAN 77 doesn't and that can make writing
fairly clean, *fast* low-level code easier than in FORTRAN consists of:
- Unsigned integer arithmetic
- Pass by value
- Structs
- ?: (*maybe*)
I'll try to keep this list in mind next time I'm tempted to pick
on C again (or, really, rebut the frequent "Fortran is useless"
rants on USENET ;-).
--
"Practice random senselessness and act kind of beautiful."
James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: [Reposted due to Enlow UCE cancel]: Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-17 4:00 ` [Reposted due to Enlow UCE cancel]: " John Bayko
@ 1997-10-20 4:00 ` Paul D. DeRocco
0 siblings, 0 replies; 99+ messages in thread
From: Paul D. DeRocco @ 1997-10-20 4:00 UTC (permalink / raw)
John Bayko wrote:
>
> It takes me about two weeks to become productively competent in a
> programming language, as long as it's not too unusual. At NorTel I had
> to learn their proprietary telephone switch language in about that
> time, and I didn't do badly during my term that (to become good
> obviously takes longer, and I missed a few subtlties - for example,
> 'case' and 'select' had the same structure, but one created a multiple
> comparison, while the other produced a jump table. I used the wrong
> one once, but it didn't break anything - as far as I know, NorTel
> telephone switches are still running).
So that's why I keep getting bumped off the Internet. You
BASTARD!
(Just kidding, heh, heh)
--
Ciao,
Paul
^ permalink raw reply [flat|nested] 99+ messages in thread
* [Reposted due to Enlow UCE cancel]: Re: Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game")
1997-10-18 4:00 ` Kelly Hall
@ 1997-10-20 4:00 ` Eric Hildum
0 siblings, 0 replies; 99+ messages in thread
From: Eric Hildum @ 1997-10-20 4:00 UTC (permalink / raw)
Kelly Hall wrote:
>
> Yes, it takes effort to gain proficiency in a new tool. But using the wrong tool can
> require even more effort.
>
> Kelly
What? You object to writing numerical analysis code in COBOL?
--
"The idea that Bill Gates has appeared like a knight in shining armour
to lead all customers out of a mire of technological chaos neatly
ignores the fact that it was he who, by peddling second-rate technology,
led them into it in the first place."-Douglas Adams
Eric Hildum
Eric.Hildum@Japan.NCR.COM
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <344B4496.4179@Japan.NCR.com>
Newsgroups: comp.arch
Path: ...!ddsw1!news.mcs.net!www.nntp.primenet.com!globalcenter1!news.primenet.com!nntp.primenet.com!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <344B4496.4179@Japan.NCR.com>
Approved: godmom@pagesz.net
Message-ID: <cancel.344B4496.4179@Japan.NCR.com>
X-No-Archive: Yes
Sender: Eric Hildum <Eric.Hildum@Japan.NCR.com>
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 01:51:52 GMT
Lines: 2
This article cancelled within Tin.
^ permalink raw reply [flat|nested] 99+ messages in thread
* [Reposted due to Enlow UCE cancel]: Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` boo
` (2 preceding siblings ...)
1997-10-17 4:00 ` Richard A. O'Keefe
@ 1997-10-20 4:00 ` tgg
1997-10-20 4:00 ` Jason.Ozolins
4 siblings, 0 replies; 99+ messages in thread
From: tgg @ 1997-10-20 4:00 UTC (permalink / raw)
boo (boo@boo.boo) wrote:
|(I should point out,
|proudly, that I have had no formal computer training of any kind, ever,
|so I may not use the same terms that you use in that
|Ivory Tower of yours over there).
1) This is believable
2) Ponder the significance of the quotation "When I use a word, it
means exactly what I want it to mean, no more, no less".
============================================================================
The above are my own views, not the views of HP
Tom Gardner Hewlett Packard Laboratories, Filton Rd,
tgg@hpl.hp.com Stoke Gifford, Bristol, Avon, BS12 6QZ, ENGLAND.
Fax: +44 117 9228924 Tel: +44 117 9799910 ext. 28192
============================================================================
========= WAS CANCELLED BY =======:
Rogue cancel from Michael Enlow, X-Cancelled-by etc. are forged.
Further information can be acquired at http://www.sputum.com/ucepage.htm,
or http://rampages.onramp.net/~eholmes/enlow/enlowce.html
You can express your displeasure with Mr. Enlow by contacting him at:
enlow@direcpc.com
Control: cancel <EICDG4.8Jn@hplb.hpl.hp.com>
Newsgroups: comp.arch
Path: ...!news.tamu.edu!newshost.comco.com!news.altair.com!uwvax!uwm.edu!news.sprintisp.com!sprintisp!news-peer.gsl.net!news-tokyo.gip.net!news.gsl.net!gip.net!nspixp!newsfeed.btnis.ad.jp!newsfeed1.btnis.ad.jp!news.fsinet.or.jp!ubc.co.jp!nobody
From: godmom@pagesz.net
Subject: cmsg cancel <EICDG4.8Jn@hplb.hpl.hp.com>
Approved: godmom@pagesz.net
Message-ID: <cancel.EICDG4.8Jn@hplb.hpl.hp.com>
X-No-Archive: Yes
Sender: news@hplb.hpl.hp.com (Usenet News Administrator)
X-Cancelled-By: godmom@pagesz.net
Organization: UBC
Date: Tue, 21 Oct 1997 01:53:14 GMT
Lines: 2
This article cancelled within Tin.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-15 4:00 ` boo
` (3 preceding siblings ...)
1997-10-20 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
@ 1997-10-20 4:00 ` Jason.Ozolins
4 siblings, 0 replies; 99+ messages in thread
From: Jason.Ozolins @ 1997-10-20 4:00 UTC (permalink / raw)
[Finally, Boo actually defines what the hell he/she/it
is talking about]
In <34452746.3F9BC63B@boo.boo> boo <boo@boo.boo> writes:
>Ok, now let me discuss where MY use of the word "dimensional". Say
>for example, you are working with a 3D or 4D "array", representing
>space or space-time. The actual symmetries of spacetime are
>reflected in the fact that you would do best with a memory system
>in which access is equally fast no matter which axis you are
>doing access along. (If you want specifics, imagine some kind
>of a N-dimensional 3rd order derivative operator, requiring
>information from neigboring points in the 2N directions).
>When I said "memory is not multi-dimensional", I meant "memory
>access is not equally fast along all axes of a multi-dimensional
>array". Of course it is not!! Some points are in the cache,
>some may be stored in registers from some previous calculation,
>some are in main memory, some may be on another node in some
>MPP supercomputer.
Right! So now I know that the Commodore 64 I used to own (which
had exactly the same latency and bandwidth to memory no matter
what pattern it was accessed in) had "multi-dimensional" memory!
Cool! And my BBC Micro, and Amiga 500, and that old 286 in the
cupboard too. Amazing. In fact, I can make my Pentium 200 PC
clone have a close approximation to "multi-dimensional" memory
by turning off the internal and external cache. How incredibly
special.
If you want a higher-performance machine with similar attributes
for certain classes of application then you should break open your
piggybank and go talk to Tera.
> I know that high performance fortran actually
>usually does an excellent job of optimizing the calculations,
>but my personal experience is that I can usually do better
>by really thinking hard, and coming up with an algorithm that
>realizes that the various ONE-DIMENSIONAL components of the
>memory system are utilized in an optimal manner. And as I said
>elsewhere, most people don't need to bother wasting their time
>on this kind of optimization, but for me, doing so can reduce
>a simulation from one month down to one week, on a 300 Gflop
>supercomputer that I have very limited resources on.
Is that one month for a version of the simulation written in
non-optimized C or for a version written in FORTRAN? :-)
>It is amazing that almost everyone jumped on my statement that
>memory is not multi-dimensional with absurds comments about the
>"multi-dimensional structure of memory hardware". I suggest you
>all replace "dimensional" with "component" in the above phrase,
>to which I reply:
>
> DUH
To which I reply: Use terminology known to more people than your own
good self and you stand a much greater chance of being understood.
Now your actual point is made clear, it turns out to be totally
uncontroversial - arbitrary access patterns tend to be less efficient
than unit-stride accesses. Ho hum.
__________________________________________________________________________
Jason Ozolins (Jason.Ozolins@anu.edu.au) | Put your hands over your eyes.
Teaching and Learning Technology Support | Jump out of the plane.
Unit, Australian National University | There is no pilot.
My opinions, not ANU's. | You are not alone.
--
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-18 4:00 ` Peter L. Montgomery
1997-10-19 4:00 ` Craig Burley
@ 1997-10-20 4:00 ` Richard A. O'Keefe
1997-10-20 4:00 ` Peter L. Montgomery
1 sibling, 1 reply; 99+ messages in thread
From: Richard A. O'Keefe @ 1997-10-20 4:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4794 bytes --]
pmontgom@cwi.nl (Peter L. Montgomery) writes:
>Craig Burley <burley@tweedledumb.cygnus.com> writes:
>>I don't see any rebuttal there. Care to explain what *low-level*
>>constructs C is offering that Fortran doesn't offer, aside from
>>pointers?
> Nobody has been mentioning unsigned arithmetic.
The machine I used as an undergraduate didn't _have_ unsigned arithmetic
in any form, and nobody ever missed it. I mean this quite literally:
the machine had _no_ instructions that could be used to do any kind of
unsigned arithmetic directly. Bitwise operations, yes.
I wonder how many people would "need" unsigned arithmetic if C
didn't have it?
> C has conditional compilation, which Fortran does not.
This claim is a little extreme. It's not as if C conditional compilation
were in any way integrated with the language, like SAIL or PL/I or Burroughs
Algol or Lisp. (Lisp is clearly way ahead head, closely followed by SAIL.
PL/I, and the Burroughs Algol imitation of its preprocessor, isn't _too_
far off, but C is way down near the M4 end of things.)
There isn't any preprocessor in the Fortran 90 standard (I don't know
about F95), but that has never stopped anyone who wanted to use
conditional processing with Fortran. I used to use a structured Fortran
preprocessor (now pointless) written in SNOBOL. Presto chango, extremely
powerful conditional processing.
Remember: #if sizeof (int) == 4
is not legal C.
> Fortran leads C in its large intrinsic function library.
>C9X will finally let one write a MAX function which evaluates its
>arguments once only and use the INLINE keyword to get good code,
My understanding is that C9X is likely to contain
f{min,max}{f,,l}
functions anyway.
> Neither language has constructs for the following operations
>(although some implementations make them available):
> . Trailing zero count of nonzero binary number
> (equal to highest power of 2 dividing the number)
This may be a low-level construct, but a lot of machines have no
direct support for it. It may be programmed as easily in Fortran
as in C.
> . Truncated base-2 logarithm of nonnegative integer,
> with LOG2(0) = -1. [Or return the number of bits required
> to hold the value, which is one more than its logarithm.]
This may be a low-level construct, but a lot of machines have no
direct support for it. It may be programmed as easily in Fortran
as in C.
> . Population count of nonnegative integer.
This may be a low-level construct, but a lot of machines have no
direct support for it. It may be programmed as easily in Fortran
as in C.
> . Upper half of (signed or unsigned) integer product.
This may be a low-level construct, but some machines (sigh) have
no direct support for it. Ultra-SPARC is one of them. Perhaps if
C _had_ had this, Ultra-SPARC would have, but then, it hasn't got
a mod instruction either.
LIA-2 has MULLO and MULHI functions, and C9x is taking LIA seriously,
so something of the sort may find its way into C. I wonder what they
will do on an UltraSPARC? A Fortran binding for LIA-2 will also have
to address this.
> . Greatest common divisor (GCD) of two integers.
This too is in LIA, so may be in C9x. A Fortran binding for LIA-2
will also have to address it.
> . Floating point operations with explicit rounding,
> such as ROUND_DOWN(a - ROUND_ZERO(b*c))
> to round the product b*c towards zero and
> round the difference a - b*c towards -infinity.
Very nice, but there are pre-IEC559 machines that are still of
practical importance that have good Fortran systems, even C systems,
and cannot easily support these operations.
>All of these, except the GCD, have simple translations on the
>latest DEC Alpha.
A nice machine.
>They have mathematical definitions
>which do not refer to the target architecture,
>except that we need the number of bits per datum to
>define the upper half of an integer product.
>The optimal translations vary widely
>with the target architecture, and the first three constructs
>have been discussed many times in this newsgroup,
>yet the language designers decline to standardize the constructs.
Not all of these constructs, and not all language designers.
Lisp has your truncated base-2 logarithm, population count, and
greatest common divisor. It doesn't need MULLO/MULHI.
LIA-2 includes GCD, MULLO, and MULHI, and it is supposed to be
"language-independent", in the sense that language standardisers
will be expected to provide standard bindings to it.
--
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; RMIT Comp.Sci; http://www.cs.rmit.edu.au/%7Eok
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-20 4:00 ` Richard A. O'Keefe
@ 1997-10-20 4:00 ` Peter L. Montgomery
0 siblings, 0 replies; 99+ messages in thread
From: Peter L. Montgomery @ 1997-10-20 4:00 UTC (permalink / raw)
In article <62eqtu$2ua$1@goanna.cs.rmit.edu.au>
ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:
>pmontgom@cwi.nl (Peter L. Montgomery) writes:
>>Craig Burley <burley@tweedledumb.cygnus.com> writes:
>
>>>I don't see any rebuttal there. Care to explain what *low-level*
>>>constructs C is offering that Fortran doesn't offer, aside from
>>>pointers?
>
>> Nobody has been mentioning unsigned arithmetic.
>
>The machine I used as an undergraduate didn't _have_ unsigned arithmetic
>in any form, and nobody ever missed it. I mean this quite literally:
>the machine had _no_ instructions that could be used to do any kind of
>unsigned arithmetic directly. Bitwise operations, yes.
>
>I wonder how many people would "need" unsigned arithmetic if C
>didn't have it?
The machine _I_ used as an undergraduate was the CDC 6400.
Later, I used the CDC 7600 for 10 years as a professional.
The CDC was ones' complement with 60-bit registers in the CPU.
It lacked two's complement 60-bit addition/subtraction,
but one could compute A + B mod 2^59 (say) by doing a ones' complement
add and masking off the upper bit. It also lacked
the shifts with zero-fill with Fortran and C now require
(instead having circular shifts to the left and arithmetic shifts
to the right). Just because one architecture lacks
right and left shifts with zero fill is no reason for
Fortran and C to omit such operations from the language.
Lack of unsigned arithmetic made it hard to distinguish
+0 from -0, such as when distinguishing whether
60 successive items are all TRUE from when they are all FALSE,
in a bit array (I would test whether XOR(n, 1) .eq. 1
if I wanted to test n for +0). Code had kludges like this
where unsigned arithmetic would improve the design.
The CDC architecture also lacked double precision floating point
arithmetic (except for addition/subtraction/multiplication
of two single-precision operands), but its Fortran
compiler generated inline code for many double precision operations.
Today the Alpha architecture lacks integer division,
even though the Fortran and C languages specified
that operation long before the Alpha was designed.
> >> C has conditional compilation, which Fortran does not.
> >
>This claim is a little extreme. It's not as if C conditional compilation
> >were in any way integrated with the language, like SAIL or PL/I or Burroughs
> >Algol or Lisp.
>
>Remember: #if sizeof (int) == 4
>is not legal C.
Yes, there are severe limitations in C's
conditional compilation. In the old CDC days, I used
conditional compilation directives within UPDATE
(a card-oriented text editor), but that had limitations too,
like not allowing nested *IF - *ENDIF pairs.
>
> >> Fortran leads C in its large intrinsic function library.
> >>C9X will finally let one write a MAX function which evaluates its
> >>arguments once only and use the INLINE keyword to get good code,
> >
> >My understanding is that C9X is likely to contain
> > f{min,max}{f,,l}
> >functions anyway.
That will be a step forward.
> >> Neither language has constructs for the following operations
> >>(although some implementations make them available):
> >
> >> . Trailing zero count of nonzero binary number
> >> (equal to highest power of 2 dividing the number)
> >
> >This may be a low-level construct, but a lot of machines have no
> >direct support for it. It may be programmed as easily in Fortran
> >as in C.
> >
> >> . Truncated base-2 logarithm of nonnegative integer,
> >> with LOG2(0) = -1. [Or return the number of bits required
> >> to hold the value, which is one more than its logarithm.]
> >
> >This may be a low-level construct, but a lot of machines have no
> >direct support for it. It may be programmed as easily in Fortran
> >as in C.
> >
> >> . Population count of nonnegative integer.
> >
> >This may be a low-level construct, but a lot of machines have no
> >direct support for it. It may be programmed as easily in Fortran
> >as in C.
Many of my number-theoretic codes need these functions.
And they are frequently discussed on comp.arch, so others need them too.
For example, when using the left-to-right method of binary exponentiation,
I need to locate the leftmost nonzero bit in the exponent.
Or I may need to loop through all the one-bits in word,
where I anticipate only a few will be set (say 3 bits out of 32).
The inner loop of the binary GCD algorithm needs to repeatedly divide
a positive integer by 2 until the quotient is odd; that is,
it needs to shift right by the trailing zero count of the operand.
The population count arises when, for example, I
need to take an inner product of two vectors over the
field GF(2): this means taking the bitwise AND of the two vectors,
getting the population count of this AND, and
testing whether this count is odd or even.
Yes, they can be programmed in both languages,
but the straightforward methods have many branches
(or require you to hard-wire the number of bits in the datum,
such as if you try to take a population count by
splitting a 32-bit integer into four eight-bit bytes, and using
table look-ups). Branches are slow on modern processors,
and we want to avoid them.
Going back to the CDC 6400, which had population count, the others
might be implemented as:
Trailing zero count(N), where N <> 0:
return population_count((N-1) & ~N)
Base 2 logarithm(N)
temp = (N >> 12) & 0xFFFFFFFFFFFF; (arithmetic shift)
(constant is ~MASK(12))
if (temp == 0) then (N was less than 2**12)
return 47 - normalize_count(N);
else
return 59 - normalize_count(temp);
end if
(normalize_count is the B-register output of a
normalize instruction, used primarily to
align the mantissa of a floating point operand).
Putting these into a compiler may add a few hundred
bytes to the compiler's executable, but will not penalize
users who do not need the functions, except possibly to add
reserved names to the language.
Users whose codes benefit from the functions can use the functions
(and buy machines from the manufacturers who best support them).
Five years after the functions are in the standard,
they will start appearing in benchmarks, and other architectures may start
providing better support if doing so would improve benchmark speed.
> > >
> > >> . Upper half of (signed or unsigned) integer product.
> > >
> > >This may be a low-level construct, but some machines (sigh) have
> > >no direct support for it. Ultra-SPARC is one of them. Perhaps if
> >C _had_ had this, Ultra-SPARC would have, but then, it hasn't got
> >a mod instruction either.
> >
> >LIA-2 has MULLO and MULHI functions, and C9x is taking LIA seriously,
>so something of the sort may find its way into C. I wonder what they
>will do on an UltraSPARC? A Fortran binding for LIA-2 will also have
>to address this.
Yes, the Ultra-SPARC lacks these for 64-bit operands.
If I want high performance there, I'll need to use radix 2^32 in
my multiple-precision codes (the Ultra-SPARC can multiply two 32-bit
operands and get a 64-bit product). Meanwhile (using conditional compilation)
let me use 64-bit operands on the MIPS and Alpha architectures,
so I can take advantage of the 128-bit products available on those machines.
For (slow) compatibility, the Ultra-SPARC can have a library
routine which splits 64-bit operands into 32-bit operands
and computes the product the hard way.
Meanwhile the Ultra-SPARC can out-perform the MIPS machines and
the pre-21264 Alpha's on codes using population count heavily.
>
> >> . Greatest common divisor (GCD) of two integers.
>
> >This too is in LIA, so may be in C9x. A Fortran binding for LIA-2
> >will also have to address it.
That's good to hear. Few architectures support GCD directly,
so it will be a library routine almost everywhere.
Problems like writing a vectorizable GCD on the Cray will
be solved once (by the compiler writer,
if they consider GCD important), rather than separately
by every user needing the function.
>> . Floating point operations with explicit rounding,
>> such as ROUND_DOWN(a - ROUND_ZERO(b*c))
>> to round the product b*c towards zero and
>> round the difference a - b*c towards -infinity.
>
>Very nice, but there are pre-IEC559 machines that are still of
>practical importance that have good Fortran systems, even C systems,
>and cannot easily support these operations.
Yes, it presumes IEEE arithmetic. If the machine
does not support that, the application probably needs another algorithm.
>
>>All of these, except the GCD, have simple translations on the
>>latest DEC Alpha.
>
>A nice machine.
>
>>They have mathematical definitions
>>which do not refer to the target architecture,
>>except that we need the number of bits per datum to
>>define the upper half of an integer product.
>
> >Lisp has your truncated base-2 logarithm, population count, and
> >greatest common divisor. It doesn't need MULLO/MULHI.
>
Perhaps I should learn Lisp. We've been comparing Fortran and C
(in spite of the Subject: line of this article).
--
Peter L. Montgomery pmontgom@cwi.nl San Rafael, California
A mathematician whose age has doubled since he last drove an automobile.
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
1997-10-18 4:00 ` Victor Yodaiken
@ 1997-10-20 4:00 ` Eric Hildum
0 siblings, 0 replies; 99+ messages in thread
From: Eric Hildum @ 1997-10-20 4:00 UTC (permalink / raw)
Victor Yodaiken wrote:
>
> On Fri, 17 Oct 1997 21:21:02 GMT, David Chase <chase@world.std.com> wrote:
> >into the kernel. In practice, this is used to enhance existing
> >OS services while avoiding the high cost of an untrusted
> >user-to-kernel transfer of control, and the benchmarks they
> >get are great (with a single exception that is merely equal,
> >uniformly better than commercial OSes running on the same
> >hardware). Note that the language used (Modula-3) suffers
>
> Spin is an interesting system, but, in fairness, one should note
> that benchmarks better than commercial OS's are no big deal.
I am not sure that last should be unchallenged. The last time I checked,
most people wanted the system to run their applications, not the OS. The
OS needs to provide services to the applications, but it should do so in
an efficient manner to allow the application to do its work. The less
time an OS uses, the better. Therefore, benchmarks of OS performance do
matter.
That is, I don't want to run Windows NT, Windows 95, Mac OS, or Unix. I
want to run the application that gets my work done.
--
"The idea that Bill Gates has appeared like a knight in shining armour
to lead all customers out of a mire of technological chaos neatly
ignores the fact that it was he who, by peddling second-rate technology,
led them into it in the first place."-Douglas Adams
Eric Hildum
Eric.Hildum@Japan.NCR.COM
^ permalink raw reply [flat|nested] 99+ messages in thread
* Re: Final kick at the "Merced Guessing Game"
[not found] ` <3456700e.14141203@news.demon.co.uk>
@ 1997-10-28 5:00 ` Dirk van der Knijff
0 siblings, 0 replies; 99+ messages in thread
From: Dirk van der Knijff @ 1997-10-28 5:00 UTC (permalink / raw)
In article <3456700e.14141203@news.demon.co.uk>, brian@shapes.demon.co.uk (Brian Drummond) writes:
> Craig Burley <burley@tweedledumb.cygnus.com> wrote:
>
>
> How does a FORTRAN programmer handle real-time things like processes?
> Things like fork() and join(), and handling signals?
>
> Is there an analogous mechanism?
>
It depends on the OS - fork is not a c thing but a Unix thing - as an ex VMS
hacker it was often amusing to see Unix c programmers trying to understand
how non fork-based processes worked (and to see the problems that the DEC
c implementors had getting something like fork to work - not to mention
pipes etc)
To really answer the question, fork is a system call and as such is available
to all languages on the system (or should be) and so a fortran programmer just
calls fork() exactly like his c programming friend does.
dirk
+-----------------------------------------------------------------------------+
| Dirk van der Knijff | INTERNET: dirk@its.unimelb.EDU.AU |
| Research Support Officer | Phone: 61 (3) 9344 4897 |
| Information Technology Services | FAX: 61 (3) 9347 4803 |
| University of Melbourne | Mail: PARKVILLE 3052. AUSTRALIA. |
+-----------------------------------------------------------------------------+
| "HPC is not the panacea for inefficient code" |
+=============================================================================+
^ permalink raw reply [flat|nested] 99+ messages in thread
end of thread, other threads:[~1997-10-28 5:00 UTC | newest]
Thread overview: 99+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-10-08 4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-08 4:00 ` brianh
1997-10-08 4:00 ` boo
1997-10-09 4:00 ` Eric Hildum
1997-10-09 4:00 ` brianh
1997-10-11 4:00 ` Jan Vorbrueggen
1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Carl Perkins
1997-10-13 4:00 ` Michael Williams
1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` Paul Rubin
1997-10-13 4:00 ` Craig Burley
1997-10-13 4:00 ` William Clodius
1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-14 4:00 ` Michael Williams
1997-10-14 4:00 ` Richard Black
1997-10-15 4:00 ` Craig Burley
1997-10-15 4:00 ` Michael Williams
1997-10-15 4:00 ` Dr. Richard Black
1997-10-16 4:00 ` Richard A. O'Keefe
1997-10-18 4:00 ` Bruce Hoult
1997-10-14 4:00 ` Shankar Unni
1997-10-15 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` Paul D. DeRocco
1997-10-15 4:00 ` William Clodius
1997-10-15 4:00 ` Joe Buck
1997-10-16 4:00 ` Richard A. O'Keefe
1997-10-16 4:00 ` Craig Burley
1997-10-17 4:00 ` Shankar Unni
1997-10-15 4:00 ` Achim Gratz
1997-10-15 4:00 ` Paul Hsieh
1997-10-13 4:00 ` boo
1997-10-15 4:00 ` Craig Burley
[not found] ` <623ek6$ef5$1@news.iastate.edu>
1997-10-16 4:00 ` Craig Burley
1997-10-16 4:00 ` SimGraphics
1997-10-17 4:00 ` Craig Burley
1997-10-17 4:00 ` David Chase
1997-10-18 4:00 ` Victor Yodaiken
1997-10-20 4:00 ` Eric Hildum
1997-10-17 4:00 ` William Clodius
1997-10-19 4:00 ` Craig Burley
1997-10-18 4:00 ` Peter L. Montgomery
1997-10-19 4:00 ` Craig Burley
[not found] ` <3456700e.14141203@news.demon.co.uk>
1997-10-28 5:00 ` Dirk van der Knijff
1997-10-20 4:00 ` Richard A. O'Keefe
1997-10-20 4:00 ` Peter L. Montgomery
1997-10-16 4:00 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
1997-10-16 4:00 ` Craig Burley
1997-10-17 4:00 ` Richard A. O'Keefe
1997-10-17 4:00 ` Keith Adams
1997-10-17 4:00 ` [Reposted due to Enlow UCE cancel]: " John Bayko
1997-10-20 4:00 ` Paul D. DeRocco
1997-10-17 4:00 ` John Bayko
1997-10-18 4:00 ` Kelly Hall
1997-10-20 4:00 ` [Reposted due to Enlow UCE cancel]: " Eric Hildum
1997-10-09 4:00 ` Final kick at the "Merced Guessing Game" Gregg E Economou
1997-10-10 4:00 ` Jan Vorbrueggen
1997-10-08 4:00 ` David Chase
1997-10-08 4:00 ` William Clodius
[not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
1997-10-09 4:00 ` boo
1997-10-09 4:00 ` William Clodius
1997-10-10 4:00 ` Tyson Richard DOWD
1997-10-12 4:00 ` boo
1997-10-13 4:00 ` Patricia Shanahan
1997-10-15 4:00 ` boo
1997-10-15 4:00 ` Patricia Shanahan
1997-10-13 4:00 ` Steve Tate
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Aaron Spink
1997-10-14 4:00 ` boo
1997-10-18 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-18 4:00 ` tgg
1997-10-13 4:00 ` Bernd Paysan
1997-10-13 4:00 ` boo
1997-10-13 4:00 ` Victor Yodaiken
1997-10-14 4:00 ` Aaron Spink
1997-10-14 4:00 ` Jason.Ozolins
1997-10-15 4:00 ` boo
1997-10-15 4:00 ` David Chase
1997-10-10 4:00 ` boo
1997-10-11 4:00 ` Paul DeMone
1997-10-11 4:00 ` Toon Moene
1997-10-11 4:00 ` Patricia Shanahan
1997-10-13 4:00 ` Gregg E Economou
1997-10-13 4:00 ` Patricia Shanahan
1997-10-14 4:00 ` Richard A. O'Keefe
1997-10-15 4:00 ` boo
1997-10-16 4:00 ` Timothy A. Seufert
1997-10-16 4:00 ` boo
1997-10-16 4:00 ` Toon Moene
1997-10-17 4:00 ` Richard A. O'Keefe
1997-10-20 4:00 ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-20 4:00 ` Jason.Ozolins
1997-10-10 4:00 ` Richard A. O'Keefe
[not found] ` <EHrwv9.2w3@world.std.com>
1997-10-10 4:00 ` David Gould
1997-10-10 4:00 ` Maynard Handley
1997-10-11 4:00 ` new languages Preston Briggs
1997-10-10 4:00 ` Final kick at the "Merced Guessing Game" David Gould
1997-10-16 4:00 ` Patricia Shanahan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox