Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Final kick at the "Merced Guessing Game"
@ 1997-09-30  4:00 Paul DeMone
  1997-09-30  4:00 ` Guy Harris
                   ` (3 more replies)
  0 siblings, 4 replies; 207+ messages in thread
From: Paul DeMone @ 1997-09-30  4:00 UTC (permalink / raw)



While reading through an old (Dec 1995) issue of Proceedings of the IEEE the
other day while waiting for an HSPICE run to finish I came across a remarkable
paper entitled "Compiler Technology for Future Microprocessors".  The authors
(W. Hwu, R. Hank, D. Gallagher, S. Mahlke, D. Lavery, G. Haab, J. Gyllenhaal,
and D. August) are associated with the University of Illinois but the research
seems to have strong ties with HP.

The primary thrust of the paper was to describe compiler algorithms and hardware
mechanisms that could be used to get around the problem of branches and false
dependencies in gathering enough instruction level parallelism for an eight issue
RISC-like machine.  The paper showed how predication (kind of like condition codes
that can be used to permit conditional execute any instruction, a generalization of
what ARM does) can be used in conjunction with loop unrolling and basic block 
oalesing to dramatically decrease the number of conditional branches that need to
be predicted/executed (in one example mispredicted branches using the 2-bit branch
prediction model were reduced by almost three orders of magnitude within a complex
inner loop).

The authors give examples of how an eight issue processor with full predication
could give a remarkable improvement (1.2x to 4.5x) over an eight issue design with a 
non-predicated ISA.  Their description of their architecture strikes me as eerily
similar to some predictions about the Intel IA-64 Merced design so I will repeat it:

   "The processor model used for these experiments is an eight-issue extension of
    the HP PA-RISC[TM] architecture.  The processor may issue eight instructions
    of any type each cycle except branches, which are restricted to one per cycle.
    The processor has 64 integer, 64 floating-point, and 64 predicate registers."

The design would seem to effectively avoid the complexity and cycle time impact of
the paraphenalia of aggressive out-of-order designs such as register renaming and
in-order completion unit.  The paper gives brief descriptions of advanced compiler 
techniques to transform around loops (essentially static compile time register re-
naming) and also discusses how to incorporate memory data dependence analysis (used
by the Multiflow Trace scheduling compiler for the TRACE series of VLIW computers)
for another significant speedup.

HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of
weeks but if they exploit the advances described in this paper it could really be
something with the potential for dramatically raising the bar of microprocessor
performance and not just typical Intel hype and FUD.  Comments?


All opinions strictly my own.

--
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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-09-30  4:00 Paul DeMone
@ 1997-09-30  4:00 ` Guy Harris
  1997-10-01  4:00   ` Tom Thornhill
  1997-10-01  4:00 ` Nick Maclaren
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 207+ messages in thread
From: Guy Harris @ 1997-09-30  4:00 UTC (permalink / raw)



Paul DeMone  <PaulDeMone@EasyInternet.net> wrote:
>While reading through an old (Dec 1995) issue of Proceedings of the IEEE the
>other day while waiting for an HSPICE run to finish I came across a remarkable
>paper entitled "Compiler Technology for Future Microprocessors".

A Web search for that title found a page at

	http://www.cs.colorado.edu/~klauser/ilp/ilp.html

which is a reading list of papers in instruction-level parallelism.  It
has a link to a PostScript version of a paper with that title, at:

	ftp://ftp.crhc.uiuc.edu/pub/IMPACT/journal/ieeepro.future.95.ps

although in a quick look I didn't see the comment you quoted aabout the
processor model they used, so maybe this is an earlier version of the
paper.

The page cited above does have a number of papers from HP Labs....

> The design would seem to effectively avoid the complexity and cycle time
> impact of the paraphenalia of aggressive out-of-order designs such as
> register renaming and in-order completion unit.

So are they going to blow off making Merced run IA32 code really really
really fast, leaving that up to future IA32 implementations (perhaps on
the theory that Merced will be used mainly in machines that don't have
to run IA32 stuff really really really fast, just "fast enough"), and
maybe require software to do binary-to-binary translation of IA32
programs if you want them to run really really really fast?  (I.e., it
doesn't have to run Windows 98 or Office 97 really really really fast,
as a P6-generation or next-generation-after-P6 machine can handle that
job, it just has to run big database XXX or big server YYY or big
number-crunching program ZZZ really really really fast, and those will
be compiled into native code?)
-- 
Reply, or follow up, but don't do both, please.

postmaster@localhost
postmaster@[127.0.0.1]



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00         ` Michael D. Nahas
  1997-10-01  4:00           ` Stefan Monnier
@ 1997-10-01  4:00           ` brianh
  1997-10-02  4:00           ` Eric Hildum
  2 siblings, 0 replies; 207+ messages in thread
From: brianh @ 1997-10-01  4:00 UTC (permalink / raw)



In article <34326556.2216DC70@virginia.edu>,
Michael D. Nahas <nahas@virginia.edu> wrote:
>I'm afraid that I must admit that Maclaren, even with his outrageous
>claim, is correct.   Malde has missed the problem - it is not branching,
>but indirection, A.K.A. pointer chasing.
>
>For a standard function, you just branch to the address.  With C++'s
>virtual
>functions you either follow a pointer or perform an indexed lookup to a
>jump
>table, which will load the address you will jump to, and then branch to
>that
>address.
>
>Why is indirection bad?  When the destination address of a jump is known,
>the processor
>can begin fetching from the new address and continue executing.  When the
>destination address of the jump is unknown, the processor usually stalls
>until
>the address comes in from memory.   Some processors do have hardware to
>speed up indirect jumps, but the hardware was developed using C benchmarks,
>
>where 90% of indirect jumps are just returns from functions.

The problem is not the double indirection- which can be handled if the CPU 
prefetchs data as well as instructions- but the fact that you are doing two 
memory accesses now instead of one, and usually widely seperate memory
accesses (most implementations don't AFAIK actually keep the virtual 
function tables with the class data, but in a seperate structure shared by
all objects of the same type- which is usually somewhere far away from
where the data ends up).  This is a symptom of the fact that memory has not
increased in speed the same way CPUs have (I put 70ns memory into my 386-
granted, no FPM or EDO, but still... And the 386 still needed cache).

The only thing more painfull on performance than leaving cache and waiting on
main memory is leaving main memory and swapping pages into disk.  Compilers
(and programmers!) should worry more about locality of reference.

If you are going to blow cache, the question arises "is it worth it?".  For
sparse matricies, the answer is obviously yes (the alternative is to swap
like mad)- although the matrix solving programs should be written to be
cache aware, and keep locality of reference up.  For virtual functions,
I think the benefits outweigh the gains, although it depends critically on
what you're doing.  I note the Fortran is still one of the two best languages
for doing numeric computation in- only recently have there been C compilers
as good as Fortran compilers (and even in these cases you often find they
share an optimizer with a Fortran compiler- examples include SGI's MipsPro
compilers, and HP's compilers).

>
>The truely evil part of indirection is not in function calls, but in the
>non-array
>data structures of most programs.  Think of traversing a linked list.  To
>load the
>first node in the list, it takes as much time as the memory latency.  To
>load the
>second node, you must first load the first node, and then pay the cost of
>the
>memory latency time again.  So to traverse a N node linked list, it takes N
>times
>the memory latency.
>
>For most cases, the nodes are contiguous in memory and most programs run
>inside the L1 and L2 cache, so these latencies are not too bad for most
>programs.
>However, programs which do not fit in large L2 caches, such as sparse
>matrix
>programs and the X Windows system, pay heavily.  The latency time of going
>to
>main memory is growing exponentially in terms of CPU cycles.
>
>So, is this a problem, and if so, how do we fix it.  Yes, it is a problem,
>because any
>stall to the pipeline which prevents speculative execution is bad.  How do
>we
>solve it?  The first thing to do is to make programs which have this
>problem part
>of the SPEC Benchmarks.  This will make it the focus of everyone's
>attention.
>The other thing that can be done is to look at Compiler optimizations -
>many of
>the indirect function calls can be eliminated, especially if all the source
>is compiled
>together.  Separate compilation of object files requires general interfaces
>which
>prevent many optimizations.
>
>Also, a note on Java.  All Java functions are virtual and all require a
>general
>interface on a class level.  Lastly, all objects are referenced indirectly,
>so even an
>array of Java objects is two levels of indirection to get the object you
>want!  So,
>Java is even worse than C++.
>
>    Mike
>
>As always, comments and criticism welcome.
>
>--
>/********************************************************\
>*  Michael David Nahas           nahas@virginia.edu      *
>*  Graduate Student in CS        University of Virginia  *
>\********************************************************/
>

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00         ` Michael D. Nahas
@ 1997-10-01  4:00           ` Stefan Monnier
  1997-10-01  4:00             ` Nick Maclaren
  1997-10-01  4:00           ` brianh
  1997-10-02  4:00           ` Eric Hildum
  2 siblings, 1 reply; 207+ messages in thread
From: Stefan Monnier @ 1997-10-01  4:00 UTC (permalink / raw)



"Michael D. Nahas" <nahas@virginia.edu> writes:
> I'm afraid that I must admit that Maclaren, even with his outrageous
> claim, is correct.   Malde has missed the problem - it is not branching,
> but indirection, A.K.A. pointer chasing.

I believe everyone here is aware of the fact that indirection is *the*
problem. The question was "why should indirection be more of an issue with
C/C++ than with Pascal, Algol, ... ?"


        Stefan



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00           ` Stefan Monnier
@ 1997-10-01  4:00             ` Nick Maclaren
  1997-10-01  4:00               ` Allen Kim
                                 ` (5 more replies)
  0 siblings, 6 replies; 207+ messages in thread
From: Nick Maclaren @ 1997-10-01  4:00 UTC (permalink / raw)



In article <5l90wd2sbj.fsf@tequila.systemsz.cs.yale.edu>,
Stefan Monnier  <monnier+comp/arch/news/@tequila.cs.yale.edu> wrote:
>"Michael D. Nahas" <nahas@virginia.edu> writes:
>> I'm afraid that I must admit that Maclaren, even with his outrageous
>> claim, is correct.   Malde has missed the problem - it is not branching,
>> but indirection, A.K.A. pointer chasing.
>
>I believe everyone here is aware of the fact that indirection is *the*
>problem. The question was "why should indirection be more of an issue with
>C/C++ than with Pascal, Algol, ... ?"

In a word - "aliasing".  With multiple levels of indirection, a conforming
C compiler has to assume that almost every location can be aliased, and
therefore must make a store reference every time.  Almost all fancy
optimisations that are possible in those languages will cause at least
some legal C programs to fail.  "const" helps a little, and "restrict"
(in C9X) will help a bit more, but at best will bring C up to the very
low level of Fortran.  And I am not optimistic about even that.

Michael Nahas also correctly points out that C++, X, Java etc. have MORE
indirections than the equivalent Fortran or 'ordinary' C.  This is a matter
of interface style as much as the underlying language, but that doesn't
help at all.  We are stuck with both of them.

To respond to the previous posting by brianh@bit3.com, the reason that
the multiple indirection is nasty is precisely because it causes trouble
with data prefetching!  Consider A->B->C->D->E.  At each stage, the CPU
has to perform the address calculation before it can start prefetching
the next address.  Now, this very simple case CAN be done by using a
multi-threaded architecture, with prefetching threads running ahead to
preload the next operands.

But what about (P = A->B ? (Q = P->C ? Q->D : P->E) : A->F)?  To handle
THAT, you need speculative pre-execution, which was dabbled with in the
1960s and 1970s, and quite rightly dropped as an abomination.  And, if
you look at the source of the X Windowing System, you will see code that
is pretty well equivalent :-(

For efficient use of modern architectures, we need languages in which we
programmers can express what we want to say in a fashion that can be
converted to the sort of instruction stream that executes fast.  And
the current trends are in exactly the opposite direction.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00             ` Nick Maclaren
  1997-10-01  4:00               ` Allen Kim
@ 1997-10-01  4:00               ` P Murray
  1997-10-01  4:00                 ` Nick Maclaren
  1997-10-02  4:00                 ` Torben AEgidius Mogensen
  1997-10-01  4:00               ` John Wilson
                                 ` (3 subsequent siblings)
  5 siblings, 2 replies; 207+ messages in thread
From: P Murray @ 1997-10-01  4:00 UTC (permalink / raw)



Nick Maclaren (nmm1@cus.cam.ac.uk) wrote:

: For efficient use of modern architectures, we need languages in which we
: programmers can express what we want to say in a fashion that can be
: converted to the sort of instruction stream that executes fast.  And
: the current trends are in exactly the opposite direction.

Any suggestions on what such a language would look like? Hopefully
it will not look like ASM.  Would it be possible to modify C/C++ in
such a way as to allow this?

And finally, could anyone recommend ways to code in C/C++ that
avoid these problems and allow the optimiser to produce the
most efficient code?  I assume virtual function calls would
be out, as well as all forms of aliasing.

Cheers,
- Peter. 



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00               ` P Murray
@ 1997-10-01  4:00                 ` Nick Maclaren
  1997-10-02  4:00                   ` Vesa Karvonen
  1997-10-02  4:00                   ` Andrew Glew
  1997-10-02  4:00                 ` Torben AEgidius Mogensen
  1 sibling, 2 replies; 207+ messages in thread
From: Nick Maclaren @ 1997-10-01  4:00 UTC (permalink / raw)



In article <60ui2q$33a$1@cdn-news.telecom.com.au>,
P Murray <pcm@vus002.telecom.com.au> wrote:
>Nick Maclaren (nmm1@cus.cam.ac.uk) wrote:
>
>: For efficient use of modern architectures, we need languages in which we
>: programmers can express what we want to say in a fashion that can be
>: converted to the sort of instruction stream that executes fast.  And
>: the current trends are in exactly the opposite direction.
>
>Any suggestions on what such a language would look like? Hopefully
>it will not look like ASM.  Would it be possible to modify C/C++ in
>such a way as to allow this?

Well, I would favour something using the more successful ideas of
Algol 68 :-)  But it would have to include some of the concepts of the
stricter functional languages.

>And finally, could anyone recommend ways to code in C/C++ that
>avoid these problems and allow the optimiser to produce the
>most efficient code?  I assume virtual function calls would
>be out, as well as all forms of aliasing.

Yes.  And, if you can code C without implying aliasing, I take my hat
off to you!  The biggest problem with attempting this is that you can
only 'const qualify' at the top level and, for efficient code-generation,
you need to do it at other levels.  I believe that the new 'restrict' in
C9X is a sort of recursive 'const', but have not seen a specification.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00             ` Nick Maclaren
  1997-10-01  4:00               ` Allen Kim
  1997-10-01  4:00               ` P Murray
@ 1997-10-01  4:00               ` John Wilson
  1997-10-02  4:00               ` Jon Leech
                                 ` (2 subsequent siblings)
  5 siblings, 0 replies; 207+ messages in thread
From: John Wilson @ 1997-10-01  4:00 UTC (permalink / raw)



In article <60uek7$fon$1@lyra.csx.cam.ac.uk>,
Nick Maclaren <nmm1@cus.cam.ac.uk> wrote:
>For efficient use of modern architectures, we need languages in which we
>programmers can express what we want to say in a fashion that can be
>converted to the sort of instruction stream that executes fast.  And
>the current trends are in exactly the opposite direction.

Luckily we still have good ol' assembly language!

Sorry, couldn't resist -- the paragraph above nicely supports my
personal prejudices though.  :-)

John Wilson
D Bit



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00 ` Nick Maclaren
@ 1997-10-01  4:00   ` Paul DeMone
  1997-10-01  4:00   ` J. Corbally
  1 sibling, 0 replies; 207+ messages in thread
From: Paul DeMone @ 1997-10-01  4:00 UTC (permalink / raw)



Nick Maclaren wrote:
> 
> In article <3431A2DB.4273@EasyInternet.net>, Paul DeMone <PaulDeMone@EasyInternet.net> writes:
> |>
> |> HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of
> |> weeks but if they exploit the advances described in this paper it could really be
> |> something with the potential for dramatically raising the bar of microprocessor
> |> performance and not just typical Intel hype and FUD.  Comments?
> 
> It will have little or no practical effect, because the dominating
> languages and programming styles have one unpredictable branch or
> data indirection every few instructions.  Until and unless C, C++,
> most windowing systems and similar tripe are scrapped, almost all
> systems will run at a miniscule fraction of their potential CPU
> performance.  A quick look at Java implies that it probably has the
> same problems, but I cannot swear to it.

  I thought much along the same line until I read this paper.  some sample code is
  the inner loop from Unix utilities.  These are really twisty C programs chosen for
  their branch-ugliness, i.e. the poor way conventional compilers and machines can
  handle them.  The job their compiler does on the inner loop of the wc (word count)
  program is amazing.  It eliminates most branches by replicating basic blocks and
  using predication to coalesce around branches and form larger basic blocks.  The
  combination of loop unrolling and formation of hyperblocks allows a good deal of
  instruction level parallelism to be extracted.  In the case of wc the use of pred-
  ication reduced dynamic branch execution from 572K to 315K while reducing branch
  misprediction using the 2-bit scheme from 52K to 56.  On the eight issue target CPU
  wc was sped up by 5.5x versus a single issue RISC CPU while grep was sped up 4x.
  The SPEC92 programs espresso, eqntott, alvinn, ear, and sc were sped up 3.3x, 5.5x,
  7.7x, and 5.8x respectively versus a single issue RISC.

  Considering that the three issue P6/Pentium II and quad issue RISCs like R10K and
  Alpha 21164 probably average only about 2.5x (or less) speed up versus a single
  issue RISC the performance of this new architecture with its advanced compiler is
  damn impressive! Don't forget that this new design likely can be implemented without
  all the overhead of out-of-order machines like P6 and R10K and so can be clocked
  much, much faster (maybe even faster than Alpha in the same process).  Granted some
  of the apparent speedup of the new design will be lost from main memory latency and
  bandwidth limitations or icache inefficiency from code bloat but it still could be
  a significant step forward.

> 
> Nick Maclaren,
> University of Cambridge Computer Laboratory,
> New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
> Email:  nmm1@cam.ac.uk
> Tel.:  +44 1223 334761    Fax:  +44 1223 334679

--
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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00 ` Tom Thornhill
@ 1997-10-01  4:00   ` Paul DeMone
  1997-10-01  4:00   ` Jim Hull
  1 sibling, 0 replies; 207+ messages in thread
From: Paul DeMone @ 1997-10-01  4:00 UTC (permalink / raw)



Tom Thornhill wrote:
[snip]
> > HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of
> > weeks but if they exploit the advances described in this paper it could really be
> 
> Do you have a date?

   Approximately 1:00 pm Tuesday Oct 14 (at the 1997 Microprocessor Forum,
   Fairmont Hotel in San Jose).

[snip]
> I think you're onto something here - I would expect that if Intel introduce
> a new architecture they'd try to ensure that relatively simple implementations
> of it ( ie those without renaming and out of order execution ), outperform
> agressive implementaions of Alpha AXP ( 21264 ? ). This gives them something
> to scale towards.
> 
> Also since they've waited for so long before replacing IA32, you'd expect
> them to come up with something other than an Alpha clone.

  Compiler technology and architecture seems to have advanced significantly
  since Alpha was designed (itself essentially a classic RISC but streamlined
  for superscalar and out-of-order implementations) so Intel would have to
  stumble badly not to be able to get some degree of advantage.

> 
> --
> Mailto: tthornhi@best.ms.philips.com-nospam ( remove the -nospam before replying )
> Talkto: Tom Thornhill, Philips Medical Systems Nederland BV
> Tel +31 4027 64080 (Work), +31 499 338211 (Hotel - after 5pm UK time)

--
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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00             ` Nick Maclaren
@ 1997-10-01  4:00               ` Allen Kim
  1997-10-01  4:00               ` P Murray
                                 ` (4 subsequent siblings)
  5 siblings, 0 replies; 207+ messages in thread
From: Allen Kim @ 1997-10-01  4:00 UTC (permalink / raw)



Nick Maclaren wrote:
> 
> But what about (P = A->B ? (Q = P->C ? Q->D : P->E) : A->F)?  To handle
> THAT, you need speculative pre-execution, which was dabbled with in the
> 1960s and 1970s, and quite rightly dropped as an abomination.  And, if
> you look at the source of the X Windowing System, you will see code that
> is pretty well equivalent :-(
> 
> For efficient use of modern architectures, we need languages in which we
> programmers can express what we want to say in a fashion that can be
> converted to the sort of instruction stream that executes fast.  And
> the current trends are in exactly the opposite direction.

Despite the fact that you guys are coming pretty close to speaking pure
"Greek" here (or is it "geek"?), I'll try and add a little to the
discussion.

My impression with Merced and VLIW-like architectures which move branch
optimization out to the compiler is that instructions like the one above
can be solved by very advanced techniques which effectively turn pieces
of code into "trees" which each calculate a number of possible outcomes
at once.  Now I know that with that statement, I probably distorted the
actual concept, but I'm hoping you'll understand.  Anyway, trees like
this would involve multiple memory accesses at once, which could be the
potential bottleneck unless some very sophisticated caching and bus
transaction mechanisms are developed.

See this link for more info:

	http://www.research.ibm.com/vliw/home.html

Disclaimer: I don't speak officially for Intel, and I don't work on the
Merced processor itself.  I *do* work on the chipset which will support
Merced, but that doesn't mean I know the intricate details of the
processor.

--
Allen Kim
allenkim@scic.intel.com



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00 ` Tom Thornhill
  1997-10-01  4:00   ` Paul DeMone
@ 1997-10-01  4:00   ` Jim Hull
  1 sibling, 0 replies; 207+ messages in thread
From: Jim Hull @ 1997-10-01  4:00 UTC (permalink / raw)



> is Tom Thornhill
> > is Paul DeMone

> > HP and Intel will disclose the native Merced instruction set (IA-64)
> > in a couple of weeks ...

> Do you have a date?

October 14, at Microprocessor Forum.

For details, check:

    http://www.MDRonline.com/mpf

--
Jim Hull

"If so strong the force in Yoda is, construct a sentence with words in
the proper order then why can't he?"    -- Teng-Kiat Lee



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-09-30  4:00 Paul DeMone
  1997-09-30  4:00 ` Guy Harris
@ 1997-10-01  4:00 ` Nick Maclaren
  1997-10-01  4:00   ` Paul DeMone
  1997-10-01  4:00   ` J. Corbally
  1997-10-01  4:00 ` Tom Thornhill
  1997-10-01  4:00 ` Richard A. Schumacher
  3 siblings, 2 replies; 207+ messages in thread
From: Nick Maclaren @ 1997-10-01  4:00 UTC (permalink / raw)



In article <3431A2DB.4273@EasyInternet.net>, Paul DeMone <PaulDeMone@EasyInternet.net> writes:
|> 
|> HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of
|> weeks but if they exploit the advances described in this paper it could really be
|> something with the potential for dramatically raising the bar of microprocessor
|> performance and not just typical Intel hype and FUD.  Comments?

It will have little or no practical effect, because the dominating
languages and programming styles have one unpredictable branch or
data indirection every few instructions.  Until and unless C, C++,
most windowing systems and similar tripe are scrapped, almost all
systems will run at a miniscule fraction of their potential CPU
performance.  A quick look at Java implies that it probably has the
same problems, but I cannot swear to it.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00 ` Nick Maclaren
  1997-10-01  4:00   ` Paul DeMone
@ 1997-10-01  4:00   ` J. Corbally
  1997-10-01  4:00     ` Nick Maclaren
  1 sibling, 1 reply; 207+ messages in thread
From: J. Corbally @ 1997-10-01  4:00 UTC (permalink / raw)



> It will have little or no practical effect, because the dominating
> languages and programming styles have one unpredictable branch or
> data indirection every few instructions.  Until and unless C, C++,
> most windowing systems and similar tripe are scrapped, almost all
> systems will run at a miniscule fraction of their potential CPU
> performance.  A quick look at Java implies that it probably has the
> same problems, but I cannot swear to it.
> 
> Nick Maclaren,
> University of Cambridge Computer Laboratory,
> New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
> Email:  nmm1@cam.ac.uk
> Tel.:  +44 1223 334761    Fax:  +44 1223 334679

I'm sure you have some new hyper-advanced programming language in the
waiting that will realise this "potential CPU performance", and obsolete
all other languages.  Yeah, right.....

Please explain yourself....

Regards,




James.....


-- 
All opinions expressed herein are my own personal observations
and DO NOT represent the views of my past, current, or future
employers.  All opinions included herein due to quoting are
the personal opinions of their respective posters, and no
implication of agreement or endorsement on my part shall be
inferred in them.

Remove *NO_SPAM* to enable mailing



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00     ` Nick Maclaren
@ 1997-10-01  4:00       ` Ketil Z Malde
  1997-10-01  4:00         ` Michael D. Nahas
  0 siblings, 1 reply; 207+ messages in thread
From: Ketil Z Malde @ 1997-10-01  4:00 UTC (permalink / raw)



nmm1@cus.cam.ac.uk (Nick Maclaren) writes:

> If you take a close look at C++, the X Windowing System, the various
> IBM and Microsoft windowing systems etc., you will see that an
> 'object' is implemented as a data structure and you invoke a method
> by picking an address up from that structure and branching to it.

Right - and in Pascal, Algol, Cobol, and all those other superior
languages, function calls are made without branching?  Which is why
Pascal and Cobol is commonly used when performance is important?  Right?

And since programs written in C runs at a ``miniscule fraction of their
potential CPU performance'', could you please inform me which Pascal,
Algol, Cobol or Modula-[23] compiler that create such vastly improved
speed of execution?  And - how much faster can I expect applications to
run? 

HIBT?

~kzm
-- 
If I haven't seen further, it is by standing in the footprints of giants



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00   ` J. Corbally
@ 1997-10-01  4:00     ` Nick Maclaren
  1997-10-01  4:00       ` Ketil Z Malde
  0 siblings, 1 reply; 207+ messages in thread
From: Nick Maclaren @ 1997-10-01  4:00 UTC (permalink / raw)



In article <60t42r$4pd@scnews.sc.intel.com>, "J. Corbally" <icorb*NO_SPAM*@*NO_SPAM*indigo.ie> writes:
|> > It will have little or no practical effect, because the dominating
|> > languages and programming styles have one unpredictable branch or
|> > data indirection every few instructions.  Until and unless C, C++,
|> > most windowing systems and similar tripe are scrapped, almost all
|> > systems will run at a miniscule fraction of their potential CPU
|> > performance.  A quick look at Java implies that it probably has the
|> > same problems, but I cannot swear to it.
|> 
|> I'm sure you have some new hyper-advanced programming language in the
|> waiting that will realise this "potential CPU performance", and obsolete
|> all other languages.  Yeah, right.....
|> 
|> Please explain yourself....

Whether I do or not is irrelevant, as all of the Fortrans, Cobols,
Algols, Pascals, Modulas etc. are streets better.  So, interestingly
enough, are 'object oriented' systems like Smalltalk and (I believe)
Eiffel - but they have other problems.

If you take a close look at C++, the X Windowing System, the various
IBM and Microsoft windowing systems etc., you will see that an
'object' is implemented as a data structure and you invoke a method
by picking an address up from that structure and branching to it.
Furthermore, most of the important data is indirected through multiple
levels of data structure.

When I first described this to a hardware designer, back in the early
days of the latest RISC hype, he said "But nobody writes code like
that!"  When I said that the C++ and X Windowing System did little
else, he said "Well, people won't use them then."


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-09-30  4:00 Paul DeMone
  1997-09-30  4:00 ` Guy Harris
  1997-10-01  4:00 ` Nick Maclaren
@ 1997-10-01  4:00 ` Tom Thornhill
  1997-10-01  4:00   ` Paul DeMone
  1997-10-01  4:00   ` Jim Hull
  1997-10-01  4:00 ` Richard A. Schumacher
  3 siblings, 2 replies; 207+ messages in thread
From: Tom Thornhill @ 1997-10-01  4:00 UTC (permalink / raw)



Paul DeMone <PaulDeMone@EasyInternet.net> wrote in article <3431A2DB.4273@EasyInternet.net>...
> While reading through an old (Dec 1995) issue of Proceedings of the IEEE the
> other day while waiting for an HSPICE run to finish I came across a remarkable
> paper entitled "Compiler Technology for Future Microprocessors".  The authors
> (W. Hwu, R. Hank, D. Gallagher, S. Mahlke, D. Lavery, G. Haab, J. Gyllenhaal,
> and D. August) are associated with the University of Illinois but the research
> seems to have strong ties with HP.
> 
> The primary thrust of the paper was to describe compiler algorithms and hardware
> mechanisms that could be used to get around the problem of branches and false
> dependencies in gathering enough instruction level parallelism for an eight issue
> RISC-like machine.  The paper showed how predication (kind of like condition codes
> that can be used to permit conditional execute any instruction, a generalization of
> what ARM does) can be used in conjunction with loop unrolling and basic block 
> oalesing to dramatically decrease the number of conditional branches that need to
> be predicted/executed (in one example mispredicted branches using the 2-bit branch
> prediction model were reduced by almost three orders of magnitude within a complex
> inner loop).
> 
> The authors give examples of how an eight issue processor with full predication
> could give a remarkable improvement (1.2x to 4.5x) over an eight issue design with a 
> non-predicated ISA.  Their description of their architecture strikes me as eerily
> similar to some predictions about the Intel IA-64 Merced design so I will repeat it:
> 
>    "The processor model used for these experiments is an eight-issue extension of
>     the HP PA-RISC[TM] architecture.  The processor may issue eight instructions
>     of any type each cycle except branches, which are restricted to one per cycle.
>     The processor has 64 integer, 64 floating-point, and 64 predicate registers."
> 
> The design would seem to effectively avoid the complexity and cycle time impact of
> the paraphenalia of aggressive out-of-order designs such as register renaming and
> in-order completion unit.  The paper gives brief descriptions of advanced compiler 
> techniques to transform around loops (essentially static compile time register re-
> naming) and also discusses how to incorporate memory data dependence analysis (used
> by the Multiflow Trace scheduling compiler for the TRACE series of VLIW computers)
> for another significant speedup.
> 
> HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of
> weeks but if they exploit the advances described in this paper it could really be

Do you have a date?

> something with the potential for dramatically raising the bar of microprocessor
> performance and not just typical Intel hype and FUD.  Comments?
> 
> 
> All opinions strictly my own.
> 
> --
> 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.
> 
> 

I think you're onto something here - I would expect that if Intel introduce 
a new architecture they'd try to ensure that relatively simple implementations
of it ( ie those without renaming and out of order execution ), outperform 
agressive implementaions of Alpha AXP ( 21264 ? ). This gives them something
to scale towards. 

Also since they've waited for so long before replacing IA32, you'd expect
them to come up with something other than an Alpha clone.

-- 
Mailto: tthornhi@best.ms.philips.com-nospam ( remove the -nospam before replying )
Talkto: Tom Thornhill, Philips Medical Systems Nederland BV
Tel +31 4027 64080 (Work), +31 499 338211 (Hotel - after 5pm UK time)




^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-09-30  4:00 ` Guy Harris
@ 1997-10-01  4:00   ` Tom Thornhill
  0 siblings, 0 replies; 207+ messages in thread
From: Tom Thornhill @ 1997-10-01  4:00 UTC (permalink / raw)



Guy Harris <guy@netapp.com> wrote in article <60slvu$3pr@tooting.netapp.com>...
> 
> So are they going to blow off making Merced run IA32 code really really
> really fast, leaving that up to future IA32 implementations (perhaps on
> the theory that Merced will be used mainly in machines that don't have
> to run IA32 stuff really really really fast, just "fast enough"), and
> maybe require software to do binary-to-binary translation of IA32
> programs if you want them to run really really really fast?  (I.e., it
> doesn't have to run Windows 98 or Office 97 really really really fast,
> as a P6-generation or next-generation-after-P6 machine can handle that
> job, it just has to run big database XXX or big server YYY or big
> number-crunching program ZZZ really really really fast, and those will
> be compiled into native code?)

Surely for IA32 code it would be possible to do on the fly translation
a la the PPro from instructions fetched from memory to the instructions
executed by the pipeline(s). I suppose that moving complexity out of 
the pipeline just means that you have to do more work on the translation,
but that work will already have been done for Willamette (sp?), assuming
that uses PPro-style decoupled architecture. 

I suppose you could have a kind of modular design with the same pipeline 
design in both chips but with a highly optimised ( and big ) 
translation unit in Willamette feeding a few pipelines, but a less optimised 
and smaller translation unit feeding more pipelines in Merced. 

That way you could have a modular design that could be tuned for executing 
translated IA32 or native IA64. Eventually you can lose the translation unit 
completely and move to an IA64 only architecture at a higher clock speed.
You could then scale this by adding superscalar execution for the VLIW instructions
( is this possible )

Hmm, maybe I should learn VHDL and find out how practical all this stuff is.

> -- 
> Reply, or follow up, but don't do both, please.
> 
> postmaster@localhost
> postmaster@[127.0.0.1]
> 


-- 
***If you can understand this then your brain needs servicing URGENTLY***
Mailto: tthornhi@best.ms.philips.com-nospam ( remove the -nospam before replying )
Talkto: Tom Thornhill, Philips Medical Systems Nederland BV
Tel +31 4027 64080 (Work), +31 499 338211 (Hotel - after 5pm UK time)



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-09-30  4:00 Paul DeMone
                   ` (2 preceding siblings ...)
  1997-10-01  4:00 ` Tom Thornhill
@ 1997-10-01  4:00 ` Richard A. Schumacher
  3 siblings, 0 replies; 207+ messages in thread
From: Richard A. Schumacher @ 1997-10-01  4:00 UTC (permalink / raw)




[...]

>The authors give examples of how an eight issue processor with full predication
>could give a remarkable improvement (1.2x to 4.5x) over an eight issue design with a 
>non-predicated ISA.  Their description of their architecture strikes me as eerily
>similar to some predictions about the Intel IA-64 Merced design so I will repeat it:

[...]

>HP and Intel will disclose the native Merced instruction set (IA-64) in a couple of
>weeks but if they exploit the advances described in this paper it could really be
>something with the potential for dramatically raising the bar of microprocessor
>performance and not just typical Intel hype and FUD.  Comments?


Yes. The label reads "Intel", but it's HP inside.



-- 
-----------------------------------------------
    I do not speak in any capacity for the 
Convex Division of the Hewlett Packard Company.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00       ` Ketil Z Malde
@ 1997-10-01  4:00         ` Michael D. Nahas
  1997-10-01  4:00           ` Stefan Monnier
                             ` (2 more replies)
  0 siblings, 3 replies; 207+ messages in thread
From: Michael D. Nahas @ 1997-10-01  4:00 UTC (permalink / raw)



Ketil Z Malde wrote:

> nmm1@cus.cam.ac.uk (Nick Maclaren) writes:
>
> > If you take a close look at C++, the X Windowing System, the various
> > IBM and Microsoft windowing systems etc., you will see that an
> > 'object' is implemented as a data structure and you invoke a method
> > by picking an address up from that structure and branching to it.
>
> Right - and in Pascal, Algol, Cobol, and all those other superior
> languages, function calls are made without branching?  Which is why
> Pascal and Cobol is commonly used when performance is important?  Right?
>
> And since programs written in C runs at a ``miniscule fraction of their
> potential CPU performance'', could you please inform me which Pascal,
> Algol, Cobol or Modula-[23] compiler that create such vastly improved
> speed of execution?  And - how much faster can I expect applications to
> run?

I'm afraid that I must admit that Maclaren, even with his outrageous
claim, is correct.   Malde has missed the problem - it is not branching,
but indirection, A.K.A. pointer chasing.

For a standard function, you just branch to the address.  With C++'s
virtual
functions you either follow a pointer or perform an indexed lookup to a
jump
table, which will load the address you will jump to, and then branch to
that
address.

Why is indirection bad?  When the destination address of a jump is known,
the processor
can begin fetching from the new address and continue executing.  When the
destination address of the jump is unknown, the processor usually stalls
until
the address comes in from memory.   Some processors do have hardware to
speed up indirect jumps, but the hardware was developed using C benchmarks,

where 90% of indirect jumps are just returns from functions.

The truely evil part of indirection is not in function calls, but in the
non-array
data structures of most programs.  Think of traversing a linked list.  To
load the
first node in the list, it takes as much time as the memory latency.  To
load the
second node, you must first load the first node, and then pay the cost of
the
memory latency time again.  So to traverse a N node linked list, it takes N
times
the memory latency.

For most cases, the nodes are contiguous in memory and most programs run
inside the L1 and L2 cache, so these latencies are not too bad for most
programs.
However, programs which do not fit in large L2 caches, such as sparse
matrix
programs and the X Windows system, pay heavily.  The latency time of going
to
main memory is growing exponentially in terms of CPU cycles.

So, is this a problem, and if so, how do we fix it.  Yes, it is a problem,
because any
stall to the pipeline which prevents speculative execution is bad.  How do
we
solve it?  The first thing to do is to make programs which have this
problem part
of the SPEC Benchmarks.  This will make it the focus of everyone's
attention.
The other thing that can be done is to look at Compiler optimizations -
many of
the indirect function calls can be eliminated, especially if all the source
is compiled
together.  Separate compilation of object files requires general interfaces
which
prevent many optimizations.

Also, a note on Java.  All Java functions are virtual and all require a
general
interface on a class level.  Lastly, all objects are referenced indirectly,
so even an
array of Java objects is two levels of indirection to get the object you
want!  So,
Java is even worse than C++.

    Mike

As always, comments and criticism welcome.

--
/********************************************************\
*  Michael David Nahas           nahas@virginia.edu      *
*  Graduate Student in CS        University of Virginia  *
\********************************************************/






^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                     ` Joseph H Allen
@ 1997-10-02  4:00                       ` Wilco Dijkstra
  1997-10-03  4:00                         ` Stefan Monnier
  1997-10-03  4:00                         ` Jason.Ozolins
  1997-10-03  4:00                       ` Stefan Monnier
  1 sibling, 2 replies; 207+ messages in thread
From: Wilco Dijkstra @ 1997-10-02  4:00 UTC (permalink / raw)



Joseph H Allen wrote:
 
> I'm still waiting for someone to try a hardware fix for the aliasing
> problem.  One way is to make the internal registers more like a cache than
> they are now.  Then when you load a word into a register, you also load the
> memory address where the word came from into some auxiliary part of the
> register.  The register snoops the bus at this point: if a subroutine
> modifies the memory at that address, a bit in the register is set.  If the
> caller then accesses that register you get a trap or delay and a reload
> occurs.  Using this, you can have your compiler safely assume that there are
> no aliases, and avoid doing tons of reloads after every subroutine call.

I don't think it's a good idea to try to create expensive hardware
solutions 
to the aliasing problem - it's software that created it in the first
place! 
You just need to find the cases where aliasing is appropriate and ban
all other
uses. This is similar to gotos.
It's my belief that almost all aliasing is avoidable at low cost during 
compilation. For example most aliasing is due to function calls. With
global 
aliasing analysis the complete set of aliases can be calculated. Of
course
a good language which avoids most of the aliasing problems (eg. the ADA
parameter
passing mechanism) would help!



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00 Robert Harley
@ 1997-10-02  4:00 ` Nick Maclaren
  1997-10-02  4:00   ` Stanley Chow
  0 siblings, 1 reply; 207+ messages in thread
From: Nick Maclaren @ 1997-10-02  4:00 UTC (permalink / raw)



In article <6108a1$157@news-rocq.inria.fr>, harley@pauillac.inria.fr (Robert Harley) writes:
|> Nick Maclaren (nmm1@cus.cam.ac.uk) writes:
|> >[...]  The biggest problem with attempting this is that you can
|> >only 'const qualify' at the top level and, for efficient code-generation,
|> >you need to do it at other levels.
|> 
|> Huh?  What's wrong with 'double const*const*const triMat'?

How do you get a 'double *** triMat' to that?  You have to put a
cast in, which essentially says "don't do ANY checking", and would
be equally happy with a 'double ** triMat' or 'double **** triMat'
argument.

|> >I believe that the new 'restrict' in
|> >C9X is a sort of recursive 'const', but have not seen a specification.
|> 
|> The object accessed via pointers based on a given restricted pointer
|> is only accessed in that way.  No recursive 'const' in sight.

Oh, hell.  Well, that's not going to help a lot then, except for the
simplest of cases (which, admittedly, do include the BLAS).


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                 ` Torben AEgidius Mogensen
@ 1997-10-02  4:00                   ` Patrick F. McGehearty
  1997-10-02  4:00                     ` brianh
  1997-10-03  4:00                     ` Michael Williams
  0 siblings, 2 replies; 207+ messages in thread
From: Patrick F. McGehearty @ 1997-10-02  4:00 UTC (permalink / raw)



In article <60vj9p$7mg@vidar.diku.dk>,
Torben AEgidius Mogensen <torbenm@diku.dk> wrote:
>pcm@vus002.telecom.com.au (P Murray) writes:
>
>>Nick Maclaren (nmm1@cus.cam.ac.uk) wrote:
>
>>: For efficient use of modern architectures, we need languages in which we
>>: programmers can express what we want to say in a fashion that can be
>>: converted to the sort of instruction stream that executes fast.  And
>>: the current trends are in exactly the opposite direction.
>
>>Any suggestions on what such a language would look like? Hopefully
>>it will not look like ASM.  Would it be possible to modify C/C++ in
>>such a way as to allow this?
>
>A possibility is SML using the region-based memory model. You would
>still do pointer cahsing, but the regions model keep a fairly good
>locality (elements of the same list stay close, even when other data
>is allocated in-between). In SML you also avoid most of the aliasing
>problems of C/C++. The technology still needs a few years to be
>competitive with C. One problem is that the polymorphic type system in
>SML introduces extra indirections (boxing). This can be solved if you
>compile the entire program in one job, as the polymorphism can be
>eliminated when all uses are known. Though, theoretically, this can
>give an exponetial blow-up in code size, experiments show that the
>code expansion is usually small.
>

Code expansion is not the problem.  Compile time is.
Large development projects involve 100's of modules of code
in the 100,000 to 1,000,000 lines of code range.  It only takes one
unbounded non-linear optimization algorithm to cause full-program compiles
to take so long that you start worrying about the halting problem.  That is,
after a couple of days of computing, you don't know if the compiler is
in an infinite loop or still computing.  The "couple of days" is not an
exaggeration.  I've seen a 1000 line program take over a day due to a
single unbounded non-linear optimization algorithm.

As someone working professionally in compiler performance for the last few
years, I'll take any help I can get from language definition to bound the
amount of code that must be examined to determine if an optimization is
safe.  Since I've been in graduate school (over 20 years ago), I've been
hearing about how this language feature or that can be optimized, but I've
seldom seen these optimizations actually be performed.  It takes a lot of
work to cover all the cases, and rarely used language features are often
ignored when it comes time to enhance optimizers.

Nick is absolutely dead-on when he identifies the aliasing problem as one of
the most troubling in C.  Fortran avoids that problem by defining it away.
Users are seldom aware of the compiler switches which say "ignore aliasing".
In addition, the switches are different for different platforms, so standard
make files for multiplatform products don't use them.  A plausible
compromise for future languages would be to have a default that assumes
Fortran aliasing rules and to require a declaration to allow aliasing when
it is needed.  Then most of the time, the compiler can generate fast code
and only when aliasing is strictly needed will optimization be degraded.

On the C++ virtual function issue, what is needed is more training of C++
programmers to avoid inefficient constructs except when they are really
necessary, and to provide whatever language advisories possible to help the
compiler along.  While processor speeds continue to increase at exponential
rates, memory latencies are improving much more slowly.  Ten years ago, the
cost of a non-cache memory access was less than 10 instructions.  Four years
ago, it was less than 40 instructions.  Now it is well over 100 instructions
on super-scalar architectures.  The exact numbers will vary depending on
which architectural family you look at, but the trend line is clear.  And
everything I'm aware of indicates that it will only get worse in the future.
Virtual functions that cannot be optimized to static addresses at compile or
link time are the enemy of performance, and future processor speed
improvements will only make situation more extreme.

- Patrick McGehearty
patrick@convex.hp.com



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-02  4:00 Robert Harley
  1997-10-02  4:00 ` Nick Maclaren
  0 siblings, 1 reply; 207+ messages in thread
From: Robert Harley @ 1997-10-02  4:00 UTC (permalink / raw)



Nick Maclaren (nmm1@cus.cam.ac.uk) writes:
>[...]  The biggest problem with attempting this is that you can
>only 'const qualify' at the top level and, for efficient code-generation,
>you need to do it at other levels.

Huh?  What's wrong with 'double const*const*const triMat'?


>I believe that the new 'restrict' in
>C9X is a sort of recursive 'const', but have not seen a specification.

The object accessed via pointers based on a given restricted pointer
is only accessed in that way.  No recursive 'const' in sight.

-- Rob.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-02  4:00 Robert Harley
  1997-10-02  4:00 ` Nick Maclaren
  1997-10-03  4:00 ` Richard A. O'Keefe
  0 siblings, 2 replies; 207+ messages in thread
From: Robert Harley @ 1997-10-02  4:00 UTC (permalink / raw)



Nick Maclaren (nmm1@cus.cam.ac.uk) wrote:
>harley@pauillac.inria.fr (Robert Harley) writes:
>> Nick Maclaren (nmm1@cus.cam.ac.uk) writes:
>> >[...]  The biggest problem with attempting this is that you can
>> >only 'const qualify' at the top level and, for efficient code-generation,
>> >you need to do it at other levels.
>> 
>> Huh?  What's wrong with 'double const*const*const triMat'?
>
>How do you get a 'double *** triMat' to that?  You have to put a cast in,

Well sure, if for some strange reason you wanted to turn a
pointer-pointer-pointer into a pointer-pointer, C allows it via a cast.
But why on earth would you want to do that?  I can only assume that
you meant 'double ** triMat' in which case assign it:
  double const*const*const constTriMat;
  constTriMat = triMat;

or pass it as an argument:
  double myFunc(double const*const*const bla);
  myFunc(triMat);

or something.  Type qualifiers don't affect type compatibility, so
it's fine to add a 'const' in this manner.  It's also OK discard a
'const' but compilers give a warning if you do so.


>which essentially says "don't do ANY checking", [...]

Whereas your beloved Fortran checks that the user's assumptions about
lack of aliasing are correct, perhaps?


>> The object accessed via pointers based on a given restricted pointer
>> is only accessed in that way.  [...]
>
>Oh, hell.  Well, that's not going to help a lot then, except for the
>simplest of cases [...]

Huh?

-- Rob.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00 Robert Harley
@ 1997-10-02  4:00 ` Nick Maclaren
  1997-10-03  4:00 ` Richard A. O'Keefe
  1 sibling, 0 replies; 207+ messages in thread
From: Nick Maclaren @ 1997-10-02  4:00 UTC (permalink / raw)



In article <610rbh$58f@news-rocq.inria.fr>,
Robert Harley <harley@pauillac.inria.fr> wrote:

[ Correctly pointing out that I had miscounted the number of '*'s in
the previous posters C type definition. ]

>...  Type qualifiers don't affect type compatibility, so
>it's fine to add a 'const' in this manner.  It's also OK discard a
>'const' but compilers give a warning if you do so.

This is getting rather off-group, but I don't want anyone to be taken in.
Type qualifiers DO affect type compatibility, your example is incorrect
C, and many compilers will refuse to compile it at all.

I could explain why such constructions are needed, and the consequences
for both efficiency and 'software engineering', but these newgroups are
not appropriate places for that.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00                 ` Nick Maclaren
  1997-10-02  4:00                   ` Vesa Karvonen
@ 1997-10-02  4:00                   ` Andrew Glew
  1 sibling, 0 replies; 207+ messages in thread
From: Andrew Glew @ 1997-10-02  4:00 UTC (permalink / raw)
  To: Nick Maclaren


> Well, I would favour something using the more successful ideas of
> Algol 68 :-)  But it would have to include some of the concepts of the
> stricter functional languages.

Nick: you and I both love Algol68!

But when I have looked at Algol68 compiler produced assembly code, it looks
remarkably like C++.

The best thing that Algol68 had going for it is that it allowed many of the
virtual function decisions to be made lexically, at compile time.  But only, I
believe,
in the absence of separate compilation (or in the presence of a smart linker).





^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00 ` Nick Maclaren
@ 1997-10-02  4:00   ` Stanley Chow
  0 siblings, 0 replies; 207+ messages in thread
From: Stanley Chow @ 1997-10-02  4:00 UTC (permalink / raw)



In article <610dd5$ia0$1@lyra.csx.cam.ac.uk>,
Nick Maclaren <nmm1@cus.cam.ac.uk> wrote:
>In article <6108a1$157@news-rocq.inria.fr>, harley@pauillac.inria.fr (Robert Harley) writes:
>|> Nick Maclaren (nmm1@cus.cam.ac.uk) writes:
>|> >[...]  The biggest problem with attempting this is that you can
>|> >only 'const qualify' at the top level and, for efficient code-generation,
>|> >you need to do it at other levels.
>|> 
>|> Huh?  What's wrong with 'double const*const*const triMat'?
>
>How do you get a 'double *** triMat' to that?  You have to put a
>cast in, which essentially says "don't do ANY checking", and would
>be equally happy with a 'double ** triMat' or 'double **** triMat'
>argument.

Or if the "double ***" is a type macro somewhat that may or may not
be changed from compile to compile.


-- 
Stanley Chow;  schow@nortel.ca, (613) 763-2831
Nortel/BNR, PO Box 3511 Station C, Ottawa, Ontario
Me? Represent other people? Don't make them laugh so hard.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00             ` Nick Maclaren
                                 ` (2 preceding siblings ...)
  1997-10-01  4:00               ` John Wilson
@ 1997-10-02  4:00               ` Jon Leech
  1997-10-02  4:00               ` Stefan Monnier
  1997-10-03  4:00               ` Mike Smith
  5 siblings, 0 replies; 207+ messages in thread
From: Jon Leech @ 1997-10-02  4:00 UTC (permalink / raw)



In article <60uek7$fon$1@lyra.csx.cam.ac.uk>,
Nick Maclaren <nmm1@cus.cam.ac.uk> wrote:
>For efficient use of modern architectures, we need languages in which we
>programmers can express what we want to say in a fashion that can be
>converted to the sort of instruction stream that executes fast.  And
>the current trends are in exactly the opposite direction.

    Perhaps language designers are more concerned with efficient use of
programmers than efficient use of hardware. What we need to do on today's
hardware may be completely inappropriate 10 years down the road, while
fundamental data structures remain pretty much the same.
    Jon
    __@/



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                   ` Patrick F. McGehearty
@ 1997-10-02  4:00                     ` brianh
  1997-10-03  4:00                     ` Michael Williams
  1 sibling, 0 replies; 207+ messages in thread
From: brianh @ 1997-10-02  4:00 UTC (permalink / raw)



>On the C++ virtual function issue, what is needed is more training of C++
>programmers to avoid inefficient constructs except when they are really
>necessary, and to provide whatever language advisories possible to help the
>compiler along.  While processor speeds continue to increase at exponential
>rates, memory latencies are improving much more slowly.  Ten years ago, the
>cost of a non-cache memory access was less than 10 instructions.  Four years
>ago, it was less than 40 instructions.  Now it is well over 100 instructions
>on super-scalar architectures.  The exact numbers will vary depending on
>which architectural family you look at, but the trend line is clear.  And
>everything I'm aware of indicates that it will only get worse in the future.
>Virtual functions that cannot be optimized to static addresses at compile or
>link time are the enemy of performance, and future processor speed
>improvements will only make situation more extreme.

There's a reason Java defined all methods as virtual methods- and why it was
bad that C++ didn't.  One of the big advantages of OO programming is code
reuse- the problem with this is that you never know, when you write an object,
what uses you may put that object to months or years from now.  In fact, it
is the mark of a good object design when it's used in ways the original
author never thought of.  The cost of this is (currently) an extra memory
reference, which is almost certainly not cached, and possibly even swapped
out.

We're trying to get away from the model where "this code will only be used
in this way in this program" is the norm.  Two technologies that may make
the situation better, as I see it:

	1) Just in time compliation, which can say "In the general case,
this needs to be a virtual function, but in this specific case I know it
will always be this function."

        2) Large, native system libraries, which should be written and
compiled by people who really know the system, and only for that system,
probably with -no-aliasing flags set (among others).  

But, in the end, we still have the basic problem: CPUs are way faster than
main memory and getting faster.  _This_ is the problem, not "bad programming".
There is a solution to it (faster memory), but wether or not it's worth it
will be determined by the market.  And we are seeing, at least in the 
workstations, more attention being paid to the memory architectures to help
allieviate this problem.  You're also seeing bigger caches, the other way
to allieviate the problem.

I don't speak for Bit 3.
Brian.

>
>- Patrick McGehearty
>patrick@convex.hp.com


-- 
"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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00             ` Nick Maclaren
                                 ` (3 preceding siblings ...)
  1997-10-02  4:00               ` Jon Leech
@ 1997-10-02  4:00               ` Stefan Monnier
  1997-10-03  4:00                 ` Richard A. O'Keefe
  1997-10-03  4:00               ` Mike Smith
  5 siblings, 1 reply; 207+ messages in thread
From: Stefan Monnier @ 1997-10-02  4:00 UTC (permalink / raw)



nmm1@cus.cam.ac.uk (Nick Maclaren) writes:
> In article <5l90wd2sbj.fsf@tequila.systemsz.cs.yale.edu>,
> Stefan Monnier  <monnier+comp/arch/news/@tequila.cs.yale.edu> wrote:
> >I believe everyone here is aware of the fact that indirection is *the*
> >problem. The question was "why should indirection be more of an issue with
> >C/C++ than with Pascal, Algol, ... ?"
> In a word - "aliasing".  With multiple levels of indirection, a conforming
> C compiler has to assume that almost every location can be aliased, and
> therefore must make a store reference every time.  Almost all fancy

I'm sorry, but I can't seem to remember that Pascal disallows aliasing (I
honestly don't know about Algol). Furthermore, do you really believe that
aliasing information would help for GUI-like code ?

Do you really think the problem is due to coding style (like the Xwin code) and
to programming languages (like C) rather than to what is being coded (like a
user interface rather than a numerical simulation) ?

> For efficient use of modern architectures, we need languages in which we
> programmers can express what we want to say in a fashion that can be
> converted to the sort of instruction stream that executes fast.  And
> the current trends are in exactly the opposite direction.

Because the trend is to say "CPUs are fast enough, let's care about
programmer's convenience". You seem to care about Fortran code, so probably
more numerical-oriented, in which case convenience is still a secondary concern
whereas speed is paramount. I can only agree to the fact that languages should
be developped to better take advantage of current (and future) technology, but
programmer's convenience cannot be sacrificed so easily so it's a very hard
design problem and I still haven't heard of any convincing proposition (the
best I've heard is in the NA area where Sisal sounds pretty interesting).


        Stefan



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00                 ` Nick Maclaren
@ 1997-10-02  4:00                   ` Vesa Karvonen
  1997-10-02  4:00                     ` Joseph H Allen
  1997-10-02  4:00                   ` Andrew Glew
  1 sibling, 1 reply; 207+ messages in thread
From: Vesa Karvonen @ 1997-10-02  4:00 UTC (permalink / raw)



Nick Maclaren wrote:
> In article <60ui2q$33a$1@cdn-news.telecom.com.au>,
> P Murray <pcm@vus002.telecom.com.au> wrote:
> >Nick Maclaren (nmm1@cus.cam.ac.uk) wrote:
> >
> >: For efficient use of modern architectures, we need languages in which we
> >: programmers can express what we want to say in a fashion that can be
> >: converted to the sort of instruction stream that executes fast.  And
> >: the current trends are in exactly the opposite direction.
> >
> >Any suggestions on what such a language would look like? Hopefully
> >it will not look like ASM.  Would it be possible to modify C/C++ in
> >such a way as to allow this?
> 
> Well, I would favour something using the more successful ideas of
> Algol 68 :-)  But it would have to include some of the concepts of the
> stricter functional languages.
> 
> >And finally, could anyone recommend ways to code in C/C++ that
> >avoid these problems and allow the optimiser to produce the
> >most efficient code?  I assume virtual function calls would
> >be out, as well as all forms of aliasing.
> 
> Yes.  And, if you can code C without implying aliasing, I take my hat
> off to you!  The biggest problem with attempting this is that you can
> only 'const qualify' at the top level and, for efficient code-generation,
> you need to do it at other levels.  I believe that the new 'restrict' in
> C9X is a sort of recursive 'const', but have not seen a specification.

Being an assembly language programmer before learning C, I used
to think a bit like you are thinking after seeing the bad code
produced by aliasing problems and the like in C. However, after
reading "The C++ Programming Language" (second edition) by
Bjarne Stroustrup, and seeing that he actually tells you which
language constructs generate extra overhead, I have to disagree
about leaving language features out simply because they are "bad
for the optimizer/processor"; you can always tell the programmers
what is bad for the optimizer and the processor. Leaving out
useful language constructs, like virtual functions, will only
make the language hard to use, by modern standards, and restricts
the useability of the language by making certain applications
too difficult to implement in the language.

With the exception of aliasing problems and problems with
restructuring floating point expressions, I see very little
room for defining a "faster" C (for single processor systems
anyway).

The "restrict" qualifier would/will fix the aliasing problem
in C. Of course, the problem is that a lot of old code has to
be modified, which is usually rather costly.

It might not even be necessary to have "restrict", since
some of the worse aliasing problems could also be fixed by
specifying some kind of syntax for parallel execution of
statements/expressions. Such a syntax could come very handy
in vector code, for instance.

Most optimizing C compilers have optimization switches that
can be used to fix both the aliasing and the floating point
expression restructuring problems.

-- 
<-->
  Vesa Karvonen                |   If I were speaking for my
  Housemarque Games, Inc.      |   employer, you would not be
  http://www.housemarque.com   |   reading this...



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                   ` Vesa Karvonen
@ 1997-10-02  4:00                     ` Joseph H Allen
  1997-10-02  4:00                       ` Wilco Dijkstra
  1997-10-03  4:00                       ` Stefan Monnier
  0 siblings, 2 replies; 207+ messages in thread
From: Joseph H Allen @ 1997-10-02  4:00 UTC (permalink / raw)



In article <3432F896.7FD2@HousemarqueREM.fi>,
Vesa Karvonen  <Vesa.Karvonen@HousemarqueREM.fi> wrote:
>Nick Maclaren wrote:

>> Yes.  And, if you can code C without implying aliasing, I take my hat
>> off to you!  The biggest problem with attempting this is that you can
>> only 'const qualify' at the top level and, for efficient code-generation,
>> you need to do it at other levels.  I believe that the new 'restrict' in
>> C9X is a sort of recursive 'const', but have not seen a specification.

More complicated key words.  Yuck, that's just what C needs.

>Being an assembly language programmer before learning C, I used
>to think a bit like you are thinking after seeing the bad code
>produced by aliasing problems and the like in C.

I'm still waiting for someone to try a hardware fix for the aliasing
problem.  One way is to make the internal registers more like a cache than
they are now.  Then when you load a word into a register, you also load the
memory address where the word came from into some auxiliary part of the
register.  The register snoops the bus at this point: if a subroutine
modifies the memory at that address, a bit in the register is set.  If the
caller then accesses that register you get a trap or delay and a reload
occurs.  Using this, you can have your compiler safely assume that there are
no aliases, and avoid doing tons of reloads after every subroutine call.

Of course this only solves the problem of aliases which depend on a single
memory location as their source, not complicated values which depend on
multiple memory locations.  But in a language like C++, I would guess that
most of the aliases are like this anyway (like the base addresses of
objects, or whatever).  I suppose you could even have more general alias
detection hardware which would allow you to detect if any of the sources of
a derived value were modified- it would just cost more.

Other hardware could conceivably solve more general alias and dependancy
problems than those caused by non-local subroutine calls.  For example:

    if a==z then x=5
    y=x+3

causes a pipeline stall of some sort, because y is an alias for x, but
'y=x+3' can not occur until it is known whether the previous conditional is
going to modify x.  The compiler can't do this because a and z could be
arbitrary non-constant values.

But with extra hardware, there are possibilities.  Maybe you do y=x+3 at the
same time that you do the if(a==z), but also have a 'y=8' on standby, in
case the x=5 ended up happening.  A branchless version of the above code
could be done with a few extra interesting flag bits, instructions which
occur only conditionally as on the ARM and a compiler which is aware of the
processor's pipeline structure.

-- 
/*  jhallen@world.std.com (192.74.137.5) */               /* Joseph H. Allen */
int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00         ` Michael D. Nahas
  1997-10-01  4:00           ` Stefan Monnier
  1997-10-01  4:00           ` brianh
@ 1997-10-02  4:00           ` Eric Hildum
  2 siblings, 0 replies; 207+ messages in thread
From: Eric Hildum @ 1997-10-02  4:00 UTC (permalink / raw)



Michael D. Nahas wrote:
> 
> Ketil Z Malde wrote:
> 
> So, is this a problem, and if so, how do we fix it.  Yes, it is a problem,
> because any
> stall to the pipeline which prevents speculative execution is bad.  How do
> we
> solve it?  The first thing to do is to make programs which have this
> problem part
> of the SPEC Benchmarks.  This will make it the focus of everyone's
> attention.
> The other thing that can be done is to look at Compiler optimizations -
> many of
> the indirect function calls can be eliminated, especially if all the source
> is compiled
> together.  Separate compilation of object files requires general interfaces
> which
> prevent many optimizations.
> 

No, it only only requires a reasonable object code format and linker.
That is, it requires a link editor such as exists under VMS which is
capable of selecting the branch or call instruction and addressing, not
the trival symbol table lookup and drop the bytes in the slot that Unix
linkers perform.

-- 
"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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00               ` P Murray
  1997-10-01  4:00                 ` Nick Maclaren
@ 1997-10-02  4:00                 ` Torben AEgidius Mogensen
  1997-10-02  4:00                   ` Patrick F. McGehearty
  1 sibling, 1 reply; 207+ messages in thread
From: Torben AEgidius Mogensen @ 1997-10-02  4:00 UTC (permalink / raw)



pcm@vus002.telecom.com.au (P Murray) writes:

>Nick Maclaren (nmm1@cus.cam.ac.uk) wrote:

>: For efficient use of modern architectures, we need languages in which we
>: programmers can express what we want to say in a fashion that can be
>: converted to the sort of instruction stream that executes fast.  And
>: the current trends are in exactly the opposite direction.

>Any suggestions on what such a language would look like? Hopefully
>it will not look like ASM.  Would it be possible to modify C/C++ in
>such a way as to allow this?

A possibility is SML using the region-based memory model. You would
still do pointer cahsing, but the regions model keep a fairly good
locality (elements of the same list stay close, even when other data
is allocated in-between). In SML you also avoid most of the aliasing
problems of C/C++. The technology still needs a few years to be
competitive with C. One problem is that the polymorphic type system in
SML introduces extra indirections (boxing). This can be solved if you
compile the entire program in one job, as the polymorphism can be
eliminated when all uses are known. Though, theoretically, this can
give an exponetial blow-up in code size, experiments show that the
code expansion is usually small.

You can use the regions model on C-like languages, but you would have
to give up on a lot of the 'dirty' features of C, such as type
casting and varargs.

>And finally, could anyone recommend ways to code in C/C++ that
>avoid these problems and allow the optimiser to produce the
>most efficient code?  I assume virtual function calls would
>be out, as well as all forms of aliasing.

It is not enough that you avoid aliasing. The compiler must be able to
recognize that there is none. And this is not often possible,
especially if you use separate compilation. If a language is designed
such that aliasing doesn't occur or only does so in easily
identifiable contexts (e.g. array lookups), the compiler can use this
assumption safely, even without complex and inaccurate analysis.

	Torben Mogensen (torbenm@diku.dk)



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00               ` Mike Smith
@ 1997-10-03  4:00                 ` Nick Maclaren
  1997-10-03  4:00                   ` Rob Barris
  0 siblings, 1 reply; 207+ messages in thread
From: Nick Maclaren @ 1997-10-03  4:00 UTC (permalink / raw)



In article <01bcd02b$58e67280$0200000a@kld_mcs>,
Mike Smith <kld_msmith@earthlink.nospam.net> wrote:
>Nick Maclaren <nmm1@cus.cam.ac.uk> wrote in article
><60uek7$fon$1@lyra.csx.cam.ac.uk>...
>> 
>> But what about (P = A->B ? (Q = P->C ? Q->D : P->E) : A->F)?  To handle
>> THAT, you need speculative pre-execution, which was dabbled with in the
>> 1960s and 1970s, and quite rightly dropped as an abomination.  And, if
>
>Eh?  Somebody better tell this to the people at Intel, AMD,
>and Cyrix, all of which have processors that perform specul-
>ative execution, IIRC.

Please don't confuse preloading and branch prediction with speculative
execution.  I gave a very simple example, which could be done solely by
preexecuting address calculation instructions but, in general, that is
not the case.  I am pretty sure that none of the processors you mention
do any significant amount of speculative execution.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00                 ` Nick Maclaren
@ 1997-10-03  4:00                   ` Rob Barris
  1997-10-03  4:00                     ` Andrew Glew
  1997-10-04  4:00                     ` Nick Maclaren
  0 siblings, 2 replies; 207+ messages in thread
From: Rob Barris @ 1997-10-03  4:00 UTC (permalink / raw)



In article <613p2b$g1r$1@lyra.csx.cam.ac.uk>, nmm1@cus.cam.ac.uk (Nick
Maclaren) wrote:

> In article <01bcd02b$58e67280$0200000a@kld_mcs>,
> Mike Smith <kld_msmith@earthlink.nospam.net> wrote:
> >Nick Maclaren <nmm1@cus.cam.ac.uk> wrote in article
> ><60uek7$fon$1@lyra.csx.cam.ac.uk>...
> >> 
> >> But what about (P = A->B ? (Q = P->C ? Q->D : P->E) : A->F)?  To handle
> >> THAT, you need speculative pre-execution, which was dabbled with in the
> >> 1960s and 1970s, and quite rightly dropped as an abomination.  And, if
> >
> >Eh?  Somebody better tell this to the people at Intel, AMD,
> >and Cyrix, all of which have processors that perform specul-
> >ative execution, IIRC.
> 
> Please don't confuse preloading and branch prediction with speculative
> execution.  I gave a very simple example, which could be done solely by
> preexecuting address calculation instructions but, in general, that is
> not the case.  I am pretty sure that none of the processors you mention
> do any significant amount of speculative execution.

   I think what goes on inside processors such as PentiumPro / Pentium-II
as well as PowerPC-604 (and several others, Alpha included? dunno) very
much qualifies as "speculative execution", perhaps it would help if you
shared your definitions of "speculative" and "significant".

   The fact that these processors employ register renaming and are able to
generate results speculatively and later choose whether or not to make
those results part of the visible state certainly sounds like "speculative
execution" to me.

Rob Barris      Quicksilver Software Inc.  rbarris@quicksilver.com
   * Opinions expressed not necessarily those of my employer *



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                       ` Wilco Dijkstra
  1997-10-03  4:00                         ` Stefan Monnier
@ 1997-10-03  4:00                         ` Jason.Ozolins
  1997-10-03  4:00                           ` Alex Colvin
  1 sibling, 1 reply; 207+ messages in thread
From: Jason.Ozolins @ 1997-10-03  4:00 UTC (permalink / raw)



In <3433AAC0.10C4@NOSPAMarm.com> Wilco Dijkstra <Wilco.Dijkstra@NOSPAMarm.com> writes:

>It's my belief that almost all aliasing is avoidable at low cost during 
>compilation. For example most aliasing is due to function calls. With
>global 
>aliasing analysis the complete set of aliases can be calculated. Of
>course
>a good language which avoids most of the aliasing problems (eg. the ADA
>parameter
>passing mechanism) would help!

Hmmm... I think Pascal had the right approach when it came to reference
parameters: the effects of passing the same variable into a function
via more than one VAR parameter were "undefined", which left the
language implementor more scope for optimization.  The mechanism
was perhaps less important than the simple fact that there was no
guarantee that reference parameters would work correctly in the presence
of aliasing, so you didn't do it.

Conclusion: C/C++ would be nicer languages if they had much more undefined
behaviour.  :-)  :-) 

(Not having any C++ standards around, I ought to ask:
 Are C++ references guaranteed to work in the presence of aliasing?)
_____________________________________________________________________________
Jason Ozolins  (Jason.Ozolins@anu.edu.au)    | Put your hands over your eyes.
Teaching and Learning Technology Support Unit| Jump out of the plane.
Australian National University               | There is no pilot.
My opinions, not ANU's.                      | You are not alone.
--



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                   ` Patrick F. McGehearty
  1997-10-02  4:00                     ` brianh
@ 1997-10-03  4:00                     ` Michael Williams
  1 sibling, 0 replies; 207+ messages in thread
From: Michael Williams @ 1997-10-03  4:00 UTC (permalink / raw)



In article <610gbg$k3t@deadzone.rsn.hp.com>,
Patrick F. McGehearty  <patrick@convex.COM> wrote:
>                                                               That is,
>after a couple of days of computing, you don't know if the compiler is
>in an infinite loop or still computing.  The "couple of days" is not an
>exaggeration.  I've seen a 1000 line program take over a day due to a
>single unbounded non-linear optimization algorithm.

I once discovered a case where our compiler's CSE would take O(e^N)
to compile code, where N was the number of variables in the expression.

(The code was x5=x1+x2+x3+x4; x6=x2+x3+x4+x5; ... x4=xN+x1+x2+x3.)

I calculated that a simple 52 line program would take order of 250
years per line to compile. Needless to say, it got fixed.

Mike.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-03  4:00 Robert Harley
  1997-10-06  4:00 ` Richard A. O'Keefe
  0 siblings, 1 reply; 207+ messages in thread
From: Robert Harley @ 1997-10-03  4:00 UTC (permalink / raw)



Richard A. O'Keefe (ok@goanna.cs.rmit.edu.au) wrote:
>Doesn't work.
>
>There's an illuminating discussion in the rationale of the POSIX.1
>standard [...]
>
>THIS is Nick Maclaren's point.  Given
>      char **triMat;
>the declaration
>      double const * const * const constTriMat = triMat;
>is simply illegal.

Sure, and it's "simply illegal" to assume that integer arithmetic is
done in binary.


>It's illegal because there are plausible implementations where it won't work.
>[...ad hominem deleted...]

But guess what, there are other implementations that are not only
plausible but actually exist!  And they have implementation-dependent
features left open by the standard, and extensions not specified by
the standard!  Gasp!

Over here in the real world, we compile our programs with them:
compilers for which integers are in binary and type qualifiers
give warnings sometimes, not errors.  If you are allergic to such a
warning, stick in a cast as Nick suggested.


>>Whereas your beloved Fortran checks that the user's assumptions about
>>lack of aliasing are correct, perhaps?
>
>Yes, there are indeed static checkers available for Fortran that will
>check such assumptions.  I have not used any myself, but I am aware of
>two.

Ah, so in the case of C refer to the standard only, in order to
criticize limitations in it.  But for other languages, dredge up extra
features you "are aware of" in implementations you've never used.

Everybody is fooled by this devastating ploy, so we'll now delete our
programs, apps and O.S.es, the transport protocols that will send this
message and so on, and rewrite them in a superior language.

-- Rob.
     .-.                     Robert.Harley@inria.fr                    .-.
    /   \           .-.                                 .-.           /   \
   /     \         /   \       .-.     _     .-.       /   \         /     \
  /       \       /     \     /   \   / \   /   \     /     \       /       \
 /         \     /       \   /     `-'   `-'     \   /       \     /         \
            \   /         `-'                     `-'         \   /
             `-'  Linux + 500MHz Alpha + 256MB SDRAM = heaven  `-'



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00                         ` Jason.Ozolins
@ 1997-10-03  4:00                           ` Alex Colvin
  1997-10-06  4:00                             ` Richard A. O'Keefe
  0 siblings, 1 reply; 207+ messages in thread
From: Alex Colvin @ 1997-10-03  4:00 UTC (permalink / raw)



>Hmmm... I think Pascal had the right approach when it came to reference
>parameters: the effects of passing the same variable into a function
>via more than one VAR parameter were "undefined", which left the
>language implementor more scope for optimization.  

Last time I mentioned this, I was informed that this restrictition had
been dropped.

Support for aliasing may be a good thing.  Undefining the effect of
aliasing looks likely to lead to seriously obscure bugs, unless you can
check this behavior at compile time.

--
	Alex Colvin
	alex.colvin@dartmouth.edu




^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-01  4:00             ` Nick Maclaren
                                 ` (4 preceding siblings ...)
  1997-10-02  4:00               ` Stefan Monnier
@ 1997-10-03  4:00               ` Mike Smith
  1997-10-03  4:00                 ` Nick Maclaren
  5 siblings, 1 reply; 207+ messages in thread
From: Mike Smith @ 1997-10-03  4:00 UTC (permalink / raw)



Nick Maclaren <nmm1@cus.cam.ac.uk> wrote in article
<60uek7$fon$1@lyra.csx.cam.ac.uk>...
> 
> But what about (P = A->B ? (Q = P->C ? Q->D : P->E) : A->F)?  To handle
> THAT, you need speculative pre-execution, which was dabbled with in the
> 1960s and 1970s, and quite rightly dropped as an abomination.  And, if

Eh?  Somebody better tell this to the people at Intel, AMD,
and Cyrix, all of which have processors that perform specul-
ative execution, IIRC.

--Mike Smith



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00                   ` Rob Barris
@ 1997-10-03  4:00                     ` Andrew Glew
  1997-10-05  4:00                       ` Gianni Mariani
  1997-10-04  4:00                     ` Nick Maclaren
  1 sibling, 1 reply; 207+ messages in thread
From: Andrew Glew @ 1997-10-03  4:00 UTC (permalink / raw)



Y'all may be in a terminology battle:

Current usage:

Speculative execution = executing instructions before you know for certain that
you need to execute them, usually as a result of branch prediction (but also
assuming cache hit, no fault, etc., etc.)  Usually speculative execution implies
only one predicted path.

Eager execution = executing both sides of some flakey branches.




^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                       ` Wilco Dijkstra
@ 1997-10-03  4:00                         ` Stefan Monnier
  1997-10-03  4:00                         ` Jason.Ozolins
  1 sibling, 0 replies; 207+ messages in thread
From: Stefan Monnier @ 1997-10-03  4:00 UTC (permalink / raw)



Wilco Dijkstra <Wilco.Dijkstra@NOSPAMarm.com> writes:

> With global aliasing analysis the complete set of aliases can be
> calculated.

A problem that requires global analysis to be solved is a BIG problem that
should be gotten rid of instead of "solved". Especially because global analysis
is not possible in some settings (that I consider as desirable, by the way).


        Stefan



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00                     ` Joseph H Allen
  1997-10-02  4:00                       ` Wilco Dijkstra
@ 1997-10-03  4:00                       ` Stefan Monnier
  1 sibling, 0 replies; 207+ messages in thread
From: Stefan Monnier @ 1997-10-03  4:00 UTC (permalink / raw)



jhallen@world.std.com (Joseph H Allen) writes:
> I'm still waiting for someone to try a hardware fix for the aliasing
> problem.

It's not so simple: knowledge of "no-aliasing" is not used just to spare a
reload at each use of some value, it's used for dependency analysis to allow
code reordering.


        Stefan



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00               ` Stefan Monnier
@ 1997-10-03  4:00                 ` Richard A. O'Keefe
  0 siblings, 0 replies; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-03  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3514 bytes --]


Stefan Monnier <monnier+comp/arch/news/@tequila.cs.yale.edu> writes:

>I'm sorry, but I can't seem to remember that Pascal disallows aliasing (I
>honestly don't know about Algol). Furthermore, do you really believe that
>aliasing information would help for GUI-like code ?

Do you mean "code like that which USES a GUI" or
"code like that which IMPLEMENTS a GUI"?

I note that one of my favourite languages (Clean) has an elegant
GUI *using* interface which has complete freedom from aliasing.
Clean is a *pure* lazy functional language, there are no assignments
at all.  The intention is that the compiler will _implement_
"make a record/array just like this one except for these few
differences" destructively, _but_ only when it is safe, and the
type system tells the compiler at compile time which references
are the only reference to such a datum.  Let me offer an example:

	:: Complex = { re :: Real, im :: Real }

	conj_in_place : *Complex -> *Complex
	conj_in_place c=:{im=i} = {c & im= ~i}

The * here in front of the type before the arrow means that a call to
this function is legal only if the compiler can prove that this is the
_only_ reference remaining to that record.  The * in front of the type
after the arrow means that there will be no other references to the
result.  Because the argument is 'dead' after the call, the compiler
is allowed to update it in place.

The uniqueness type system in Clean is surprisingly easy to use, and
it means that the compiler can be *certain* that aliasing is not taking
place.

(To be fair, since Clean is a higher order language with Haskell-ish
type classes, it has its own fair share of calling functions via pointers.)

As for code that *implements* a GUI, the bit-shuffling stuff that
gets done in the server would indeed benefit from a language that
allows more and better optimisation.

>Do you really think the problem is due to coding style (like the Xwin
>code) and to programming languages (like C) rather than to what is being
>coded (like a user interface rather than a numerical simulation) ?

Yep.  I keep on pointing out to students here (with examples) that the
*really* big speedups come from high level reasoning that eliminates
operations completely, rather than from *manual* low-level fiddling.

Computer hardware has changed *immensely* in my lifetime.  My intuition
about what is fast and what is slow keeps needing dramatic revision.
The one guideline that still works after 20 years is "keep your code as
clean as possible so that the compiler has a chance of figuring out
what's supposed to happen".  (Well, there's another one:  keep your
working set small; avoid going to slow memory if you can; if you can't
avoid that, avoid the disc; if you can't avoid disc, avoid tape; and
whatever you do, don't use paper tape.)

>> For efficient use of modern architectures, we need languages in which we
>> programmers can express what we want to say in a fashion that can be
>> converted to the sort of instruction stream that executes fast.  And
>> the current trends are in exactly the opposite direction.

>Because the trend is to say "CPUs are fast enough, let's care about
>programmer's convenience".

Hmm.  Current trends include C, C++, and Java, which are all of them
remarkably opposed to the programmer's convenience.  (I have a hard time
believing how clumsy and verbose Java is.)

-- 
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-02  4:00 Robert Harley
  1997-10-02  4:00 ` Nick Maclaren
@ 1997-10-03  4:00 ` Richard A. O'Keefe
  1 sibling, 0 replies; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-03  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2150 bytes --]


harley@pauillac.inria.fr (Robert Harley) writes:
>Well sure, if for some strange reason you wanted to turn a
>pointer-pointer-pointer into a pointer-pointer, C allows it via a cast.
>But why on earth would you want to do that?  I can only assume that
>you meant 'double ** triMat' in which case assign it:
>  double const*const*const constTriMat;
>  constTriMat = triMat;

>or pass it as an argument:
>  double myFunc(double const*const*const bla);
>  myFunc(triMat);

Doesn't work.

There's an illuminating discussion in the rationale of the POSIX.1
standard about why they didn't chuck a const or two into the prototypes
for the exec() functions.

"Specifying two levels of const-qualification for the argv[] and envp[]
 parameters for the exec functions may seem to be the natural choice,
 given that these functions do not modify either the array of pointers
 or the characters to which the function (sic) points, but this would
 disallow existing correct code.  Instead, only the array of pointers
 is noted as constant.  The table of assignment compatibility for
 dst = src, derived from the C standard, summarizes the compatibility:

			dst		  const    char *   const char
	src			char *[]  char *[] const [] * const []
	char *[]		VALID		   VALID
	const char *[]			  VALID		    VALID
	char * const []				   VALID
	const char * const []				    VALID

"  Entries not marked VALID are not valid at all.

THIS is Nick Maclaren's point.  Given
	char **triMat;
the declaration
	double const * const * const constTriMat = triMat;
is simply illegal.

It's illegal because there are plausible implementations where it won't
work.  Anyone who thinks it does clearly hasn't bothered to read the
standard, or even a good textbook (not there are many).

>Whereas your beloved Fortran checks that the user's assumptions about
>lack of aliasing are correct, perhaps?

Yes, there are indeed static checkers available for Fortran that will
check such assumptions.  I have not used any myself, but I am aware of
two.

-- 
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-04  4:00                     ` Nick Maclaren
@ 1997-10-04  4:00                       ` H. Eckert
  1997-10-05  4:00                       ` Andy "Krazy" Glew
  1 sibling, 0 replies; 207+ messages in thread
From: H. Eckert @ 1997-10-04  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2366 bytes --]


nmm1@cus.cam.ac.uk (Nick Maclaren):
> I am, unfortunately, not joking when I say that there are critical paths
> in the X Windowing System etc. that need that sort of optimisation for
> efficiency.

If you define "efficiency" as getting the maximum possible data
throughput from a given machine, you're probably right since a general
purpose machine cannot suit every task equally well.  But what does
"efficiency" mean to a GUI ?  It is certainly nice to have a machine
that does every graphics operation faster than you can visibly follow
but that alone doesn't help a lot...

> Most foully, the paths can run ahead at different rates, and you
> STILL have to get interruption and recovery right :-(

So you need some synchronisation points where you lose some possible
CPU cycles in NOPs.  Some friction is always present; the task for
optimization is to reduce them as much as possible...

>     2) EITHER Intel have reinvented the "Model 91 pipe-line drain"
> instruction under another name OR I could write a valid C program that
> would execute incorrectly.

Do you care to elaborate ?  IMHO this would be a sign for a broken
compile which produces incorrect code.

> My point about languages is that it becomes possible to implement reliable
> speculative execution relatively easily, IF you can assume that certain
> constraints are met.  In particular, you know that the operands may be
> invalid, but they will not change between the preloading and the final use.
> And that is PRECISELY what you do not get with C or any of its derivatives.

Ok, so you want to have a language where you can put additional
optimization hints into the code.  This is fine but pretty useless
unless the programmer knows a lot more about performance implications
of certain high-level instructions.  This is the school of "you need
to know how the computer works from inside to produce good code" to
which I agree to some extent.  This is why assembly language is still
a part in a university computer science degree.

Greetings,
				Ripley
-- 
Ach komm, ich denke schon, da� die Raver sehr tolerant sind. Gerade bei dieser
Love Parade. Du mu�t dir nur mal ansehen, wer da sein wird: Westbam, Marusha,
Bl�mchen, ein Wagen vom Marienhof ... Also, das w�rde meine Toleranzgrenze weit
�berschreiten. (M. Friese in bln.termine, <5pq8le$g1s$1@news.cs.tu-berlin.de>)



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00                   ` Rob Barris
  1997-10-03  4:00                     ` Andrew Glew
@ 1997-10-04  4:00                     ` Nick Maclaren
  1997-10-04  4:00                       ` H. Eckert
  1997-10-05  4:00                       ` Andy "Krazy" Glew
  1 sibling, 2 replies; 207+ messages in thread
From: Nick Maclaren @ 1997-10-04  4:00 UTC (permalink / raw)



In article <rbarris-ya023280000310971555540001@206.82.216.1>,
Rob Barris <rbarris@quicksilver.com> wrote:
>
>   I think what goes on inside processors such as PentiumPro / Pentium-II
>as well as PowerPC-604 (and several others, Alpha included? dunno) very
>much qualifies as "speculative execution", perhaps it would help if you
>shared your definitions of "speculative" and "significant".

Yes, I think that Andrew Glew and you are right, and there is considerable
terminological confusion.  A paragraph that I left out of my previous
posting said that there was no clear boundary between simple operand
pre-loading and speculative/eager/etc/ execution in their fullest sense.
However, I was referring to actions like the following:

    Preloading operands based on,
    address calculations based on,
    both paths of a conditional branch based on,
    some tests based on,
    preloaded operands based on,
    address calculations based on,
    both paths of a conditional branch based on,
    a test that has not yet been evaluated.

I am, unfortunately, not joking when I say that there are critical paths
in the X Windowing System etc. that need that sort of optimisation for
efficiency.  And remember that the address calculations will, in general,
need both addition and multiplication units.  Most foully, the paths can
run ahead at different rates, and you STILL have to get interruption
and recovery right :-(

Naturally, I could be wrong, but I understood the Pentium XXX designs to
include only very limited speculative execution facilities.  If I am
wrong, I am pretty certain of the following:

    1) Interrupt handling has been broken again (though this is getting
be an Intel tradition, and they have got it codified in standards).

    2) EITHER Intel have reinvented the "Model 91 pipe-line drain"
instruction under another name OR I could write a valid C program that
would execute incorrectly.

My point about languages is that it becomes possible to implement reliable
speculative execution relatively easily, IF you can assume that certain
constraints are met.  In particular, you know that the operands may be
invalid, but they will not change between the preloading and the final use.
And that is PRECISELY what you do not get with C or any of its derivatives.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-04  4:00                     ` Nick Maclaren
  1997-10-04  4:00                       ` H. Eckert
@ 1997-10-05  4:00                       ` Andy "Krazy" Glew
  1997-10-06  4:00                         ` Nick Maclaren
  1 sibling, 1 reply; 207+ messages in thread
From: Andy "Krazy" Glew @ 1997-10-05  4:00 UTC (permalink / raw)
  To: Nick Maclaren


> I am, unfortunately, not joking when I say that there are critical paths
> in the X Windowing System etc. that need that sort of optimisation for
> efficiency.  And remember that the address calculations will, in general,
> need both addition and multiplication units.  Most foully, the paths can
> run ahead at different rates, and you STILL have to get interruption
> and recovery right :-(

Actually, precise interrupts seem to be a solved problem. There is some
residual advantage to imprecise interrupts and exceptions, as in Alpha, but it
mainly relates to buffer sizes. Further applications of the exception hierarchy
(see the earlier thread on out-of-order retirement) narrow it further, and, in
fact, seem to surpass exposed imprecise interrupts.

> Naturally, I could be wrong, but I understood the Pentium XXX designs to
> include only very limited speculative execution facilities.  If I am
> wrong, I am pretty certain of the following:

Depends on what you mean by limited:

The Pentium Pro and Pentium II have a ReOrder Buffer of 40 instructions, a load
buffer of 16 (?), and a store buffer of 12. The reservation station size is 20.

Thus, 20 instructions can be waiting to execute at any time. At least an
additional 20 may have executed, and be waiting for the oldest to execute. In
addition, there are many more pipestages of instructions in the process of
being fetched.

There is no limit on how many predicted branches may be speculated past. I.e.
every entry in the reorder buffer, and all the instructions in earlier
pipestages, may be correctly predicted branches.

Cache misses can be performed speculatively: L1 I and D, L2. TLB misses can be
performed speculatively.

Stores are not performed speculatively. Nor are accesses to memory mapped I/O
and ordinary I/O spaces.

Is this "significant" speculative execution?  I think that it is under any
reasonable definition of significant. It is not, of course, eager execution.
What's left is increasing the size of buffers, and tuning the algorithms to be
more efficient of resources.

The only significant restrictions on speculative execution are

(1) I/O not being done speculatively - which, by the way, I think can now be
done away with.

(2) The single Instruction Pointer (Program Counter) for instruction fetch.

and maybe

(3) The Pentium Pro family's mispredicted branch recovery is not so efficient.
If code is divided into segments between mispredicted branches, P6 can only
have one such segment under execution at any time (mo9dulo a limited amount of
overlap).  This wasn't a limitation in our pipeline because the latencies
worked out right, and it should be obvious how it can be fixed.


>     1) Interrupt handling has been broken again (though this is getting
> be an Intel tradition, and they have got it codified in standards).

Depends. The APIC did break some interrupt code, but this was an APIC(Advanced
Programmable Interrupt Controller) issue, introduced in the i486 generation and
standardized in the Pentium (P54C) generation.  Not an issue with the dynamic
execution model of the P6 (out-of-order, speculative).

>     2) EITHER Intel have reinvented the "Model 91 pipe-line drain"
> instruction under another name OR I could write a valid C program that
> would execute incorrectly.

Nope.  "Serializing instructions" do exist. But almost nobody uses them.

I don't think that you can write a valid uniprocessor C program that will
break.





^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00                     ` Andrew Glew
@ 1997-10-05  4:00                       ` Gianni Mariani
  0 siblings, 0 replies; 207+ messages in thread
From: Gianni Mariani @ 1997-10-05  4:00 UTC (permalink / raw)



Andrew Glew wrote:
> 
> Y'all may be in a terminology battle:
> 
> Current usage:
> 
> Speculative execution = executing instructions before you know for certain that
> you need to execute them, usually as a result of branch prediction (but also
> assuming cache hit, no fault, etc., etc.)  Usually speculative execution implies
> only one predicted path.
> 
> Eager execution = executing both sides of some flakey branches.

By this definition the MIPS R10K and the HP PA8XXX do speculative
execution.  To some extent however, the MIPS compilers will
emit "eager" code in the sense that in some cases, both sides
of an if () statement are computed if scheduling of instructions
that way are an advantage.

-- 

     _   ` _              `     Webtv Service Globalization
    / \ / / \  /--  /--  /      
   /  // /  / /  / /  / /	We mean to be understood
   \_/ \ \_ \/  /_/  /_/  o	
 /  /
 \_/	(415) 614 6043		Opinions mine etc ...



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00 Robert Harley
@ 1997-10-06  4:00 ` Richard A. O'Keefe
  1997-10-06  4:00   ` boo
  0 siblings, 1 reply; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-06  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4254 bytes --]


harley@pauillac.inria.fr (Robert Harley) writes:

>Richard A. O'Keefe (ok@goanna.cs.rmit.edu.au) wrote:
>>Doesn't work.
>>
>>There's an illuminating discussion in the rationale of the POSIX.1
>>standard [...]
>>
>>THIS is Nick Maclaren's point.  Given
>>      char **triMat;
>>the declaration
>>      double const * const * const constTriMat = triMat;
>>is simply illegal.

>Sure, and it's "simply illegal" to assume that integer arithmetic is
>done in binary.

This is completely wrong, and betrays a total lack of familiarity
with the history or content of the C standard.

The C standard *requires* binary integer arithmetic.
C89 was carefully worded to allow any of
	sign-and-magnitude	(like Unisys A series machines)
	ones complement		(like Unisys 2200 machines)
	twos complement
But the C standard is quite clear that all integer arithmetic results
must be as if one of these systems were in use.

In contrast, the mismatched pointer example is one where the
compiler is not merely not required to make it work, the
compiler is *REQUIRED* to issue a diagnostic.

>But guess what, there are other implementations that are not only
>plausible but actually exist!

So?  The C standardisers were not interested in limiting C to only
the machines where your prejudices happen to be valid.  The C9X
revisers have no interest in such limitations either.

>And they have implementation-dependent
>features left open by the standard, and extensions not specified by
>the standard!  Gasp!

Yeah, but mixing up pointers to differently qualified objects is NOT
only of those things left open.

>Over here in the real world, we compile our programs with them:
>compilers for which integers are in binary 

which the C standard clearly and explicitly requires

>and type qualifiers
>give warnings sometimes, not errors.

Then you are not using standard C compilers.  That is your privilege.

>If you are allergic to such a
>warning, stick in a cast as Nick suggested.

No.  The diagnostics are required because a cast _wouldn't_ fix the
problem.

>>>Whereas your beloved Fortran checks that the user's assumptions about
>>>lack of aliasing are correct, perhaps?
>>
>>Yes, there are indeed static checkers available for Fortran that will
>>check such assumptions.  I have not used any myself, but I am aware of
>>two.

>Ah, so in the case of C refer to the standard only, in order to
>criticize limitations in it.

Are you serious?

I have not criticised any limitation in the C standard at all.
I have pointed out that the kind of Stupid Pointer Tricks (comp.std.c
idiom) you want to play are explicitly forbidden by the standard.
I THINK THIS IS RIGHT.  I am not criticising the standard there,
I am approving it.

>But for other languages, dredge up extra
>features you "are aware of" in implementations you've never used.

Those checkers enforce aspects of the Fortran standard.
C compilers are required to enforce aspects of the C standard.
As for me, I use the best static checkers for C that I can get
my hands on, and if I did as much Fortran coding as I do C,
I would make sure to use the best static checkers for Fortran
that I could get my hands on.


>Everybody is fooled by this devastating ploy, so we'll now delete our
>programs, apps and O.S.es, the transport protocols that will send this
>message and so on, and rewrite them in a superior language.

Oh grow up.

Where did I say C was inferior?
On *one specific point*, I provided factual support for Nick Maclaren's
claim.  That has absolutely no bearing on whether one language is
better than the other *in general* or for any particular *nominated
purpose*.

C was not designed for high performance numeric computing, so it is
no disgrace that it isn't _quite_ as well suited to that task as
Fortran, which _was_ designed for high performance numeric computing.

Fortran was not designed for implementing operating systems, so it is
no disgrace that it (F95) isn't _quite_ as well suited to that task
as C, which _was_ designed for implementing operating systems.

C is good enough to stand on its own merits without people telling
lies about it.

-- 
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-03  4:00                           ` Alex Colvin
@ 1997-10-06  4:00                             ` Richard A. O'Keefe
  1997-10-08  4:00                               ` Zalman Stern
  0 siblings, 1 reply; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-06  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2604 bytes --]


mac@coos.dartmouth.edu (Alex Colvin) writes:

>>Hmmm... I think Pascal had the right approach when it came to reference
>>parameters: the effects of passing the same variable into a function
>>via more than one VAR parameter were "undefined", which left the
>>language implementor more scope for optimization.  

>Last time I mentioned this, I was informed that this restrictition had
>been dropped.

ISO 10206:1990, Extended Pascal has four kinds of parameters:

	a: integer;		  pass by copy-in, modifiable
	var b: integer;		  pass by reference, modifiable
	protected c: integer;	  pass by copy-in, not modifiable
	protected var d: integer; pass by reference, not modifiable

The confusing thing (Note 2, p55) is that a protected variable
parameter (protected var) may not be changed, but it may change.
This is the only mention of 'aliasing' that I can find in that
standard.

Of course this kind of thing is very upsetting to optimisers.
It means that in the sequence of statements

	x := d;
	<FOO!>
	x := d;

where <FOO!> contains no other assignments to x, if <FOO!> contains
any assignments to non-local integer variables or procedure calls,
x will have to be reloaded, even tough _this_ procedure isn't allowed
to modify d directly.  This is even more upsetting to human reasoning
than to optimisers.


>Support for aliasing may be a good thing.  Undefining the effect of
>aliasing looks likely to lead to seriously obscure bugs, unless you can
>check this behavior at compile time.

Consider this:

C     If this were F90, I'd have INTENT OUT stated explicitly
      SUBROUTINE BREAK(X, Y)
         REAL X, Y
	 X = 1.0
	 Y = 2.0
      END

      PROGRAM MAIN
         REAL A(10)
         INTEGER I, J

         READ * I, J
         CALL BREAK(A(I), A(J))
         PRINT *, A(I), A(J)
      END

What is the output of this program?
How is the compiler to check at compile time that I.NE.J?

It is important to distinguish between case where you WANT to support
aliasing (which is the expensive option) and cases where you DON'T
(which is the high performance option).

Ada 95 did the right thing here, requiring you to explicitly declare
any potentially aliased variables.  

Aliasing is very confusing for people to deal with.
Of course, as soon as you have objects as in Smalltalk or Common Lisp or
Java, you have precisely the same kind of problem when the same object
reference can be passed (the _reference_ is passed by copy-in) to a
procedure.


-- 
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-05  4:00                       ` Andy "Krazy" Glew
@ 1997-10-06  4:00                         ` Nick Maclaren
  0 siblings, 0 replies; 207+ messages in thread
From: Nick Maclaren @ 1997-10-06  4:00 UTC (permalink / raw)



In article <3437F16A.C21B0159@cs.wisc.edu>,
"Andy \"Krazy\" Glew" <glew@cs.wisc.edu> writes:
|> 
|> The Pentium Pro and Pentium II have a ReOrder Buffer of 40 instructions, a load
|> buffer of 16 (?), and a store buffer of 12. The reservation station size is 20.
|> 
|> There is no limit on how many predicted branches may be speculated past. I.e.
|> every entry in the reorder buffer, and all the instructions in earlier
|> pipestages, may be correctly predicted branches.
|> 
|> Is this "significant" speculative execution?  I think that it is under any
|> reasonable definition of significant. It is not, of course, eager execution.
|> What's left is increasing the size of buffers, and tuning the algorithms to be
|> more efficient of resources.

The traditional meaning of "speculative" included what people have now
separated off as "eager" (assuming that usage is now standard), and is
what I was referring to.  In the cases that I was referring to, it is
essential to execute ahead of BOTH branches, and I was therefore
referring to what you call "eager execution".  I made this quite clear
in the example immediately preceding the first paragraph you quoted.

The reason is that the same code is used for two objects, which are
likely to need different branch predictions.  To get this "right" for
single-path speculative execution, you need to do branch prediction on
the basis of the DATA location as well as the CODE location.

To sidetrack a little, ripley@nostromo.in-berlin.de (H. Eckert) writes:

|> If you define "efficiency" as getting the maximum possible data
|> throughput from a given machine, you're probably right since a general
|> purpose machine cannot suit every task equally well.  But what does
|> "efficiency" mean to a GUI ?  It is certainly nice to have a machine
|> that does every graphics operation faster than you can visibly follow
|> but that alone doesn't help a lot...

Unfortunately, most GUIs (and definitely including anything based on X)
make timing assumptions about the responses.  There are a very large
number of X applications where a 0.01 second delay will cause them to
behave incorrectly - and, in fact, I am using one right now (xrn)!
These may be bugs in the application, but are actually almost unfixable,
as they are really due to design errors in X.

I have had similar effects in OS/2, Windows 3.1 and MacOS.  I have never
used Microsoft's latest utterings, but have reason to believe that the
same would apply.

|> Is this "significant" speculative execution?  I think that it is under any
|> reasonable definition of significant. It is not, of course, eager execution.
|> What's left is increasing the size of buffers, and tuning the algorithms to be
|> more efficient of resources.

Yes, it is.  But not under any reasonable definition of "speculative"!
Using your terminology, consider my posting to refer to "significant
eager execution".


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00     ` Richard A. O'Keefe
@ 1997-10-06  4:00       ` Graham Hughes
  1997-10-07  4:00       ` boo
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 207+ messages in thread
From: Graham Hughes @ 1997-10-06  4:00 UTC (permalink / raw)



-----BEGIN PGP SIGNED MESSAGE-----

>>>>> "Richard" == Richard A O'Keefe <ok@goanna.cs.rmit.edu.au> writes:

Richard> I think perhaps it is time instead that _you_ took your
Richard> blinkers off.  Fortran is not my favourite language by a long
Richard> way, but it has come a *long* way in the last 20 years, and
Richard> is by most criteria a more 'modern' language than C.

Well, that's partly because F90/95 really isn't the same language as
F77.

Certain language communities evolve in different ways; the Wirth crowd
tends to invent new languages with different names but similar M.O.'s
(Pascal->Modula 2->Ada|Oberon), LISP reinvents itself with different
semantics but almost exactly the same syntax, and Fortran invents new
languages and calls them the same thing.  Note that both Fortran and
LISP are longer lived than anything out there, so this may not be an
entirely bad thing....

What was the epigram?  ``I don't know what language we'll be using in
2030, but I know it'll be called FORTRAN?''
- -- 
Graham Hughes <graham.hughes@resnet.ucsb.edu> / Never attribute to malice that 
MIME OK, PGP preferred			     / which can adequately be 
http://A31147.resnet.ucsb.edu/~graham/	    / explained by stupidity.
					   /                -- Hanlon's Razor

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3
Charset: noconv
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBNDnLziqNPSINiVE5AQEp1wP+LTa1OFoS+oBQxei5lQnu7RUUDUqe2kbt
FeNcuZyri5IL8D9qvjdG9hssfly0FbAQ5Pe34Cvy2MIav4FVc3XTtdtN1UTGVsoc
pKc2nS06sjXiFXlrGmWo8XEliaZy3piIKGIOSdcjaUPFeNxzJVfq/8BHSdjQI0QB
oo2J/Ey6XDM=
=Bd4P
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-06  4:00 ` Richard A. O'Keefe
@ 1997-10-06  4:00   ` boo
  1997-10-07  4:00     ` Richard A. O'Keefe
                       ` (3 more replies)
  0 siblings, 4 replies; 207+ messages in thread
From: boo @ 1997-10-06  4:00 UTC (permalink / raw)



Richard A. O'Keefe wrote:
> C was not designed for high performance numeric computing, so it is
> no disgrace that it isn't _quite_ as well suited to that task as
> Fortran, which _was_ designed for high performance numeric computing.
> 
> Fortran was not designed for implementing operating systems, so it is
> no disgrace that it (F95) isn't _quite_ as well suited to that task
> as C, which _was_ designed for implementing operating systems.

Oh puh-leeze.

Who cares what it was designed for? C is far more powerful than
Fortran, especially for the kind of work that some of us
do in the real world. If Rob can show me how to do something 
with a particular compiler that speeds up what I need done,
I am listening to him, not to you. 

Time to dismount that Ivory Tower of yours.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00     ` Carlie Coats
@ 1997-10-07  4:00       ` Paul Hsieh
  1997-10-07  4:00         ` boo
  0 siblings, 1 reply; 207+ messages in thread
From: Paul Hsieh @ 1997-10-07  4:00 UTC (permalink / raw)



On 7 Oct 1997 12:53:16 -0400, Carlie Coats (xcc@hilbert.ncsc.org) said:
> This from an advocate of a language that makes arrays second class
> citizens?  C can't even do the equivalent of
> 
>     SUBROUTINE S( M, N, P, A )
>     INTEGER, INTENT( IN ):  M, N, P
>     REAL,    INTENT( IN ): A( M, N, P )
>     ...
> 
> nor can C++, for that matter. Fortran can.  So can lisp.

Excuse the rest of us C/C++ biggots who don't know the F90 syntax, but 
what does the above syntax signify?

-- 
Paul Hsieh
http://www.geocities.com/SiliconValley/9498/mailme.html



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00         ` Greg Weeks
@ 1997-10-07  4:00           ` Martin Rodgers
       [not found]           ` <343AAE5A.A3FCC9D@no.informatik.spam.tu-muenchen.thanks.de>
  1 sibling, 0 replies; 207+ messages in thread
From: Martin Rodgers @ 1997-10-07  4:00 UTC (permalink / raw)



Greg Weeks wheezed these wise words:

> |> Which egg orientation do you prefer?
> 
> Big Endian.

Anyone unsure what we're talking about should read:
<URL:http://www.jaffebros.com/lee/gulliver/bk1/chap1-4.html>
-- 
<URL:http://www.wildcard.demon.co.uk/> You can never browse enough
              Please note: my email address is gubbish
                         assert(got(coat)).



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00       ` Martin Rodgers
@ 1997-10-07  4:00         ` Greg Weeks
  1997-10-07  4:00           ` Martin Rodgers
       [not found]           ` <343AAE5A.A3FCC9D@no.informatik.spam.tu-muenchen.thanks.de>
  0 siblings, 2 replies; 207+ messages in thread
From: Greg Weeks @ 1997-10-07  4:00 UTC (permalink / raw)



In article <MPG.ea44c489d7d2d98989ad7@news.demon.co.uk>, mcr@this_email_address_intentionally_left_crap_wildcard.demon.co.uk (Martin Rodgers) writes:
|> Serge Pachkovsky wheezed these wise words:
|> 
|> > Who cares what it was designed for? Fortran is far more powerful than
|> > C, especially for the kind of work that some of us do in the real world.
|> 
|> Which egg orientation do you prefer?

Big Endian.

Greg Weeks



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-06  4:00   ` boo
  1997-10-07  4:00     ` Richard A. O'Keefe
  1997-10-07  4:00     ` Serge Pachkovsky
@ 1997-10-07  4:00     ` Carlie Coats
  1997-10-07  4:00       ` Paul Hsieh
  1997-10-08  4:00     ` James C. Stutts
  3 siblings, 1 reply; 207+ messages in thread
From: Carlie Coats @ 1997-10-07  4:00 UTC (permalink / raw)



In article <34392537.AA4A9F96@tonys.ecology.umn.edu>,
boo  <boo@tonys.ecology.umn.edu> wrote:
| Richard A. O'Keefe wrote:
| > C was not designed for high performance numeric computing, so it is
| > no disgrace that it isn't _quite_ as well suited to that task as
| > Fortran, which _was_ designed for high performance numeric computing.
| > 
| > Fortran was not designed for implementing operating systems, so it is
| > no disgrace that it (F95) isn't _quite_ as well suited to that task
| > as C, which _was_ designed for implementing operating systems.
| 
| Oh puh-leeze.
| 
| Who cares what it was designed for? C is far more powerful than
| Fortran, especially for the kind of work that some of us
| do in the real world. If Rob can show me how to do something 
| with a particular compiler that speeds up what I need done,
| I am listening to him, not to you. 
| 
| Time to dismount that Ivory Tower of yours.

This from an advocate of a language that makes arrays second class
citizens?  C can't even do the equivalent of

    SUBROUTINE S( M, N, P, A )
    INTEGER, INTENT( IN ):  M, N, P
    REAL,    INTENT( IN ): A( M, N, P )
    ...

nor can C++, for that matter. Fortran can.  So can lisp.

_Whose_ ivory tower?





^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00     ` Richard A. O'Keefe
  1997-10-06  4:00       ` Graham Hughes
  1997-10-07  4:00       ` boo
@ 1997-10-07  4:00       ` William Clodius
       [not found]         ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
                           ` (2 more replies)
  1997-10-08  4:00       ` Gregg E Economou
  3 siblings, 3 replies; 207+ messages in thread
From: William Clodius @ 1997-10-07  4:00 UTC (permalink / raw)



Richard A. O'Keefe wrote:
> <snip>
> >Who cares what it was designed for? C is far more powerful than
> >Fortran, especially for the kind of work that some of us
> >do in the real world.
> 
> I strongly suspect that you don't know what modern Fortran is like.
> There is precisely *one* construction present in C which is not
> supported as well or better by Fortran, and that is pointer arithmetic.
> <snip>

F90 also lacks pointers to procedures. It lacks stream based I/O. (There
are contexts where non-advancing I/O is not sufficient.)

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00 Robert Harley
@ 1997-10-07  4:00 ` Shankar Unni
  1997-10-08  4:00   ` boo
  1997-10-07  4:00 ` Nick Maclaren
  1997-10-07  4:00 ` Martin Rodgers
  2 siblings, 1 reply; 207+ messages in thread
From: Shankar Unni @ 1997-10-07  4:00 UTC (permalink / raw)



Robert Harley wrote:

> ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:
> >There is precisely *one* construction present in C which is not
> >supported as well or better by Fortran, and that is pointer arithmetic.
> 
> That sounds suspiciously like "There is precisely *one* thing present
> on car X which is not on car Y, and that is wheels".

Yo, Robert (and you, too, "boo@somethingorother.umn.edu"):

Richard and Nick have probably forgotten more C than you'll ever learn
in your lifetime, OK? Give it a rest; listen and learn. There's a few
lifetimes of actual working experience behind these opinions..

We see this sort of crazed C cheerleading about the start of every
semester. We've all programmed in C (and in C++). We are painfully aware
of almost every strength and weakness in both C and C++.

No one's slamming C as the worst of all languages. I'll still write an
OS, if I have to, in C or C++, but after breaking my ankles on all the
gopher holes, I'll be real careful where I put my foot the next time.

But if I'm doing numerical analysis or linear regressions, I'll pick
Fortran almost any day. No, I won't do it in C++, even if I can make a
"Matrix" class ("look, Mommy! I made a Matrix!"). If you don't
understand why, you need to take a *real* "Numerical Analysis with C++"
class.

-- 
Shankar Unni                       Powertel Global, Inc.
(650) 259-1700                     shankar@powertelglobal.com
(650) 259-1702 (fax)               shankar@webnexus.com



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00       ` boo
@ 1997-10-07  4:00         ` William Clodius
  0 siblings, 0 replies; 207+ messages in thread
From: William Clodius @ 1997-10-07  4:00 UTC (permalink / raw)



boo wrote:
> 
> Richard A. O'Keefe wrote:
> > I strongly suspect that you don't know what modern Fortran is like.
> > There is precisely *one* construction present in C which is not
> > supported as well or better by Fortran, and that is pointer arithmetic.
> 
> And you think this is a minor difference?
> 

I suspect he considers it to be a major advantage, for Fortran.

> <snip>
> 
> What I do with my C++/C/assembly combination, you cannot possibly
> do with Fortran.... as quickly and easily as I do. I work in the
> virtual reality field, with parallel algorithms, gigabyte databases
> and realtime 3D OpenGL animation, and some serious number crunching
> too. The most heavily used routines I code in C with a little
> inline assembly (which is quick enough to do for any CPU once you
> have a little practice). What do you do? Simple number crunching
> of the style done in the 60's and 70's? Sure, Fortran will suffice!
> <snip>

It is relatively easy to find out what Richard O'Keefe does, check his
news postings using Dejanews (http://www2.dejanews.com/), I suspect you
might find his postings to comp.std.c to be of particular interest, also
check his web page (http://www.cs.rmit.edu.au/%7Eok), note Richard
should remove the trailing semicolon from his signature. While Richard
has done some number crunching, his interests primarilly lies elsewhere:
teaching, algorithms (parallel and sequential), databases, logic
programming, functional programming, language design, and language
implementation.

If Richard comments on an aspect of a language pay attention! I have
read knowledgeable comments from him on Ada (83 & 95), Algol 68, APL, C
(K&R & ISO), C++, Clean, Fortran (77, 90, & HPF), Lisp, Mercury, Pascal
(Standard, Extended, & Borland), Perl, Prolog, S, Scheme, and Sisal.
Comments that indicate that he has both thoroughly read the
documentation and used implementations for all of the above languages.
Further, he has worked on compilers for at least two languages: Prolog
and a dialect of S. He has claimed to have experience with 100+
languages, and I believe him. If you think he has said something that is
incorrect look closely: you probably read too quickly, but it might be a
rare case of ambiguity or (obvious) opinion that is not labeled as such.

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00       ` Paul Hsieh
@ 1997-10-07  4:00         ` boo
  1997-10-08  4:00           ` Carlie Coats
  0 siblings, 1 reply; 207+ messages in thread
From: boo @ 1997-10-07  4:00 UTC (permalink / raw)



On 7 Oct 1997 12:53:16 -0400, Carlie Coats (xcc@hilbert.ncsc.org) said:
> > This from an advocate of a language that makes arrays second class
> > citizens?  C can't even do the equivalent of
> >
> >     SUBROUTINE S( M, N, P, A )
> >     INTEGER, INTENT( IN ):  M, N, P
> >     REAL,    INTENT( IN ): A( M, N, P )
> >     ...
> >
> > nor can C++, for that matter. Fortran can.  So can lisp.

Oh, so you think that high level language constructs are
something to boast about?

How about

#include <LifeTheUniverseAndEverything.h>

int main(void){
	SolveMyProblem();
        return 0;
}

Can yours do that? That header file I included contains the
prototypes for the functions I like the most, in my 
own particular implementation of C. Is this high level 
enough for you?

Paul added:
> Excuse the rest of us C/C++ biggots who don't know the F90 syntax, but
> what does the above syntax signify?

I suspect it says something about how the data ("arrays") should 
be laid out in memory, and says something about how you are
going to access it, to help the compiler out. In other
words, let the compiler do the thinking, and let the
programmer concentrate on the abstract stuff. This kind
of thing is possible in a simple language like Fortran.

To the original poster: If I know something about the
architecture of the machine you are using (such as a T3E, for
example), I could write some nodal C code with inline 
assembly or optimized C (with some non-standard 
code, perhaps) that will thrash your high level Fortran code
any day. I may have to use my noggin a little to figure
out the best way to lay the problem out, but that is ok.
Of course, you most likely will get your code running
before I do.... and THAT precisely is where the power
of Fortran is. Of course, Fortran is also ideal for people
who don't quite "get all the pointer nonsense in C"
(probably the biggest stumbling block that sends people
scurrying back to Fortran, basic, pascal, etc.).

boo



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-06  4:00   ` boo
@ 1997-10-07  4:00     ` Richard A. O'Keefe
  1997-10-06  4:00       ` Graham Hughes
                         ` (3 more replies)
  1997-10-07  4:00     ` Serge Pachkovsky
                       ` (2 subsequent siblings)
  3 siblings, 4 replies; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-07  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1879 bytes --]


boo <boo@tonys.ecology.umn.edu> writes:
>Oh puh-leeze.

>Who cares what it was designed for? C is far more powerful than
>Fortran, especially for the kind of work that some of us
>do in the real world.

I strongly suspect that you don't know what modern Fortran is like.
There is precisely *one* construction present in C which is not
supported as well or better by Fortran, and that is pointer arithmetic.

Modules?  Fortran has them, C hasn't.
Overloading?  Fortran has it, C hasn't.
Records?  Fortran and C both have them.
Pointers? Fortran and C both have them.
Dynamic allocation?  Fortran and C both have them.
Recursive procedures?  Fortran and C both have them.
Nested procedures?  Fortran has one level of nesting, C has none.
Strings?  Fortran has them, C hasn't.
Character-oriented IO?  Fortran and C both have it.
Record-oriented IO?  Fortran has it, C hasn't.
User defined operators?  Fortran has them, C hasn't.
Free-format source form?  Fortran and C both have it.
Bitwise operations?  Fortran and C both have them.
Control over record layout?  Neither language supports this.  (Yes, I know
	about bitfields, and I also know how extremely weak are the
	guarantees you get about them.)

>If Rob can show me how to do something 
>with a particular compiler that speeds up what I need done,
>I am listening to him, not to you. 

Why shouldn't you listen to both of us?  I am, after all, telling the truth,
as you can easily verify for yourself.

>Time to dismount that Ivory Tower of yours.

I think perhaps it is time instead that _you_ took your blinkers off.
Fortran is not my favourite language by a long way, but it has come
a *long* way in the last 20 years, and is by most criteria a more
'modern' language than C.

-- 
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-07  4:00 Robert Harley
  1997-10-07  4:00 ` Shankar Unni
                   ` (2 more replies)
  0 siblings, 3 replies; 207+ messages in thread
From: Robert Harley @ 1997-10-07  4:00 UTC (permalink / raw)



ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:
>There is precisely *one* construction present in C which is not
>supported as well or better by Fortran, and that is pointer arithmetic.

That sounds suspiciously like "There is precisely *one* thing present
on car X which is not on car Y, and that is wheels".


>[... FUD deleted...]

Hey, if some people are under the delusion that C sucks but
Fortran/Lisp/etc are great, that's just fine.  But please resist the
urge to barge into every thread and yammer on about it.

-- R.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-06  4:00   ` boo
  1997-10-07  4:00     ` Richard A. O'Keefe
@ 1997-10-07  4:00     ` Serge Pachkovsky
  1997-10-07  4:00       ` Martin Rodgers
       [not found]       ` <61cv5e$qn$6@vixen.cso.uiuc.edu>
  1997-10-07  4:00     ` Carlie Coats
  1997-10-08  4:00     ` James C. Stutts
  3 siblings, 2 replies; 207+ messages in thread
From: Serge Pachkovsky @ 1997-10-07  4:00 UTC (permalink / raw)



boo (boo@tonys.ecology.umn.edu) wrote:
: Oh puh-leeze.

: Who cares what it was designed for? C is far more powerful than
: Fortran, especially for the kind of work that some of us
: do in the real world. 

Oh puh-leeze.

Who cares what it was designed for? Fortran is far more powerful than
C, especially for the kind of work that some of us do in the real world.

Cheese,

/Serge.P

--

Russian guy from the Zurich university...




^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00 Robert Harley
  1997-10-07  4:00 ` Shankar Unni
@ 1997-10-07  4:00 ` Nick Maclaren
  1997-10-07  4:00 ` Martin Rodgers
  2 siblings, 0 replies; 207+ messages in thread
From: Nick Maclaren @ 1997-10-07  4:00 UTC (permalink / raw)




In article <61cqkc$9r@news-rocq.inria.fr>,
harley@pauillac.inria.fr (Robert Harley) writes:
|> ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:
|> >There is precisely *one* construction present in C which is not
|> >supported as well or better by Fortran, and that is pointer arithmetic.
|> 
|> That sounds suspiciously like "There is precisely *one* thing present
|> on car X which is not on car Y, and that is wheels".

Are you aware of the facts (a) that unchecked pointer arithmetic
is the source of most of the foulest bugs in existing software,
(b) that many software engineering experts believe that it is
impossible to use safely and (c) that a vast amount of experience
shows that it can usually be omitted with little hassle to the
programmer?

Your analogy is more than a little inappropriate.

|> Hey, if some people are under the delusion that C sucks but
|> Fortran/Lisp/etc are great, that's just fine.  But please resist the
|> urge to barge into every thread and yammer on about it.

The original question was "what effect do you think that the amazing
new features will have", and I answered "very little, because of the
loathesome coding style (and language properties) of many standard
applications."  You may regard that as irrelevant, but you would be
wrong.


Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00     ` Serge Pachkovsky
@ 1997-10-07  4:00       ` Martin Rodgers
  1997-10-07  4:00         ` Greg Weeks
       [not found]       ` <61cv5e$qn$6@vixen.cso.uiuc.edu>
  1 sibling, 1 reply; 207+ messages in thread
From: Martin Rodgers @ 1997-10-07  4:00 UTC (permalink / raw)



Serge Pachkovsky wheezed these wise words:

> Who cares what it was designed for? Fortran is far more powerful than
> C, especially for the kind of work that some of us do in the real world.

Which egg orientation do you prefer?
-- 
<URL:http://www.wildcard.demon.co.uk/> You can never browse enough
              Please note: my email address is gubbish
                         assert(got(coat)).



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00 Robert Harley
  1997-10-07  4:00 ` Shankar Unni
  1997-10-07  4:00 ` Nick Maclaren
@ 1997-10-07  4:00 ` Martin Rodgers
  2 siblings, 0 replies; 207+ messages in thread
From: Martin Rodgers @ 1997-10-07  4:00 UTC (permalink / raw)



Robert Harley wheezed these wise words:

> Hey, if some people are under the delusion that C sucks but
> Fortran/Lisp/etc are great, that's just fine.  But please resist the
> urge to barge into every thread and yammer on about it.

Let's ask the C/C++ if they could please follow the same advise. When 
I started reading UseNet, for the first 3 years I saw massed attacks 
from C/C++ programmers, massively crossposting, attacking Lisp.

If C++ is such a fine language, then do so many of its supporters 
express their support by "dumping" on other languages? What are they 
trying to prove? Ditto for C.

Now, can anyone tell me what was significant about 1995 that caused 
those massed attacks (mentioned above) to cease? I think that the form 
of those attacks may offer a wee clue: garbage collection. Is there no 
stronger argument against Lisp than GC? It appears not, judging by the 
post-95 nature of attacks on Lisp.

Surely there're better arguments for using C/C++ than kicking some 
other language? I appreciate good intentions, but I'm puzzled by the 
frequency with which I find people on UseNet (and elsewhere) trying to 
convince a group of people that they shouldn't be using the tools that 
they are in fact using. Even if we do all need saving from ourselves, 
could there not be a better way of doing it than the "hard sell"?

Richard's comments look to me like a reasonable response to a hard 
sell. It's a popular one, and it goes like this, "Thanks for your 
time, but I'm perfectly happy with what I'm currently using." Some 
people go as far as hanging up the phone or closing the door, rather 
than continue an argument that has no end.

Of course, I could be wrong about Richard's comments. I can't 
speak for him! I'll get my coat.
-- 
<URL:http://www.wildcard.demon.co.uk/> You can never browse enough
              Please note: my email address is gubbish
                         assert(got(coat)).



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00     ` Richard A. O'Keefe
  1997-10-06  4:00       ` Graham Hughes
@ 1997-10-07  4:00       ` boo
  1997-10-07  4:00         ` William Clodius
  1997-10-07  4:00       ` William Clodius
  1997-10-08  4:00       ` Gregg E Economou
  3 siblings, 1 reply; 207+ messages in thread
From: boo @ 1997-10-07  4:00 UTC (permalink / raw)



Richard A. O'Keefe wrote:
> I strongly suspect that you don't know what modern Fortran is like.
> There is precisely *one* construction present in C which is not
> supported as well or better by Fortran, and that is pointer arithmetic.

And you think this is a minor difference?

> 
> Modules?  Fortran has them, C hasn't.
> Overloading?  Fortran has it, C hasn't.
> Records?  Fortran and C both have them.
> Pointers? Fortran and C both have them.
> Dynamic allocation?  Fortran and C both have them.
> Recursive procedures?  Fortran and C both have them.
> Nested procedures?  Fortran has one level of nesting, C has none.
> Strings?  Fortran has them, C hasn't.
> Character-oriented IO?  Fortran and C both have it.
> Record-oriented IO?  Fortran has it, C hasn't.
> User defined operators?  Fortran has them, C hasn't.
> Free-format source form?  Fortran and C both have it.
> Bitwise operations?  Fortran and C both have them.
> Control over record layout?  Neither language supports this.  (Yes, I know
>         about bitfields, and I also know how extremely weak are the
>         guarantees you get about them.)

Ever heard of C++?

Hahaha! Now I get it! This is a troll! Nobody could possibly
think this is a serious reply.

What I do with my C++/C/assembly combination, you cannot possibly
do with Fortran.... as quickly and easily as I do. I work in the
virtual reality field, with parallel algorithms, gigabyte databases
and realtime 3D OpenGL animation, and some serious number crunching
too. The most heavily used routines I code in C with a little
inline assembly (which is quick enough to do for any CPU once you
have a little practice). What do you do? Simple number crunching
of the style done in the 60's and 70's? Sure, Fortran will suffice!

> I think perhaps it is time instead that _you_ took your blinkers off.
> Fortran is not my favourite language by a long way, but it has come
> a *long* way in the last 20 years, and is by most criteria a more
> 'modern' language than C.

I happen to have used modern variants of Fortran, I'll have you
know. Fortran has its place, certainly. It is possible to produce
very efficient code with a high level language that is easy to
master. But outside the realm of brain-dead number crunching, it
cannot compare with efficient C++/C.



^ permalink raw reply	[flat|nested] 207+ 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 ` David Chase
@ 1997-10-08  4:00 ` William Clodius
  1997-10-08  4:00 ` brianh
       [not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
  3 siblings, 0 replies; 207+ 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] 207+ 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 ` David Chase
  1997-10-08  4:00 ` William Clodius
@ 1997-10-08  4:00 ` brianh
  1997-10-08  4:00   ` boo
  1997-10-09  4:00   ` Gregg E Economou
       [not found] ` <61ho3v$3m0$1@goanna.cs.rmit.edu.au>
  3 siblings, 2 replies; 207+ 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] 207+ 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   ` Gregg E Economou
  1 sibling, 3 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-08  4:00 Robert Harley
  1997-10-08  4:00 ` David Chase
                   ` (3 more replies)
  0 siblings, 4 replies; 207+ 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] 207+ 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 ` David Chase
  1997-10-08  4:00 ` William Clodius
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-08  4:00 Robert Harley
       [not found] ` <343C0387.41C6@lanl.gov>
  1997-10-09  4:00 ` David Chase
  0 siblings, 2 replies; 207+ messages in thread
From: Robert Harley @ 1997-10-08  4:00 UTC (permalink / raw)



chase@world.std.com writes:
>C's flexibility has two problems:  [...]
>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.  [...]

So you're saying that 3 years ago, you were crap at C programming.

I can believe that.

By the way, did you have a point?


>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.  [...]

Yeah that's it.  Somebody told me and I'm really dumb so it "grabbed
my brain".  Aren't ignorant people like me lucky to have
mind-bogglingly condescending asses like yourself to bray on about the
error of our ways?

-- Rob.
PS: Food for the flames: the only language worth using, apart from C, is ML!
PPS: Isn't Usenet fun? =:-)



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00           ` William Clodius
@ 1997-10-08  4:00             ` Stanley Chow
  0 siblings, 0 replies; 207+ messages in thread
From: Stanley Chow @ 1997-10-08  4:00 UTC (permalink / raw)



In article <343BA412.167E@lanl.gov>,
William Clodius  <wclodius@lanl.gov> wrote:
>
>F90 has this capability. This is typically implemented as a pointer to a
>procedure and can be used to emulate some of the capabilities that you
>want from pointers to procedures, but it is not an explicit pointer to a
>procedure. [...]
>IF ... THEN
>   C => A
>ELSE
>   C => B ! All subsequent invocations of C actually invoke B
>ENDIF
>...
>y = C(z) ! Invokes A or B

I would call this "Procedure Variables" as opposed to "Pointers to
Procedures". I consider procedure variables to be fairly safe (as
these things go) compared to pointers to procedures.

The usual need is for proc vars, and it is a vast overkill (with
dangerous consequences) to force users to implement proc vars via
pointers.

>This is equivalent to C pointers to procedures, and is roughly what is
>planned for F200x. In the most general case, you want procedures to
>return pointers to procedures as values, i.e., a form of closures. This
>is not currently planned.

Not all closures are good.

-- 
Stanley Chow;  schow@nortel.ca, (613) 763-2831
Nortel/BNR, PO Box 3511 Station C, Ottawa, Ontario
Me? Represent other people? Don't make them laugh so hard.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
       [not found] ` <343C0387.41C6@lanl.gov>
@ 1997-10-08  4:00   ` boo
  1997-10-09  4:00     ` Patrick Chase
  1997-10-09  4:00     ` David Chase
  0 siblings, 2 replies; 207+ messages in thread
From: boo @ 1997-10-08  4:00 UTC (permalink / raw)



William Clodius wrote:
> 
> Robert Harley wrote:
> >
> > chase@world.std.com writes:
> > <snip>
> >
> > So you're saying that 3 years ago, you were crap at C programming.
> >
> > I can believe that.
> >
> > By the way, did you have a point?
> >
> > <snip>
> 
> So you are saying that David Chase, (who has spent 10+ years writing
> C/C++ professionally, principally as a writer of compilers and compiler
> tools, who has done compiler work at Rice (Fortran under Ken Kennedy),
> Sun (Fortran?), Olivetti (Modula-3), and Centerline (C++), and is, with
> Boehm, one of the primary authors of the Boehm garbage collector for
> C++) writes lousy C code because he can't get within 10% of the
> performance of Fortran. There are several possibilities here, not all
> mutually exclusive

If someone cannot get within 10% of the performance of Fortran, I 
would say he is a crap programmer. If this fellow is as qualified as
you say, then I can only assume that you have your facts wrong.
          
> Los Alamos Nat. Lab.

Ah, it all makes sense now.

Your comment about the performance of Fortran is quite funny.
About 5 years ago, I wrote a large simulation in CM Fortran for
the CM5 (and you had one of those at lanl, so I think you follow
what I am saying...), and was quite impressed with the performance.
I then wrote the crucial routines in C with CDPEAC (macros
which expand to vector unit assembly codes), and produced something
that thrashed the THEORETICAL PEAK EFFICIENCY POSSIBLE of CM Fortran at
that time, according to their manuals.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00 ` Shankar Unni
@ 1997-10-08  4:00   ` boo
  1997-10-09  4:00     ` Patrick F. McGehearty
  0 siblings, 1 reply; 207+ messages in thread
From: boo @ 1997-10-08  4:00 UTC (permalink / raw)



Shankar Unni wrote:

> But if I'm doing numerical analysis or linear regressions, I'll pick
> Fortran almost any day. 

Hahahah! linear regressions!! I can do those on my watch calculator!!
Hey, that is some high level stuff you are doing there, thank God
you have Fortran to help you out! I agree, with advanced (heh) stuff
like that, you need to have a specialized numerical language.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-09  4:00     ` David Chase
@ 1997-10-08  4:00       ` boo
  1997-10-09  4:00       ` William Clodius
  1 sibling, 0 replies; 207+ messages in thread
From: boo @ 1997-10-08  4:00 UTC (permalink / raw)



David Chase wrote:
> boo wrote:
> 
> > About 5 years ago, I wrote a large simulation in CM Fortran for
> > the CM5 (and you had one of those at lanl, so I think you follow
> > what I am saying...), and was quite impressed with the performance.
> > I then wrote the crucial routines in C with CDPEAC (macros
> > which expand to vector unit assembly codes), and produced something
> > that thrashed the THEORETICAL PEAK EFFICIENCY POSSIBLE of CM Fortran at
> > that time, according to their manuals.
> 
> CDPEAC is defined in what section of the C standard?

It isn't... but the code I wrote still looked like C,
with a huge macro library that I mastered quickly 
enough. The CDPEAC macro package expanded into SPARC
asm blocks with specific memory accesses that 
controlled the four VUs. Yes, I know this is all 
dead now, but so what... It really is not a big
deal to learn a new architecture and new optimization
techniques, and to adapt all the time. It used to be
that Fortran was the only way to achieve performance
on the high end vector and MPP supercomputers, but
thankfully that is not the case anymore. I felt I
had more flexibility with C than the Fortran, and
I know that is my personal choice. I still believe
that (with the help of expert C programmers like
Robert Harley, whose routines are being used in
the fastest lattice QCD code running on the T3E)
I can beat Fortran every time. Fortran-like code is 
usually mandatory on seriously custom MPP harware,
unfortunately.

>  You
> do know that they're not making those vector units anymore,
> don't you, and that they're one of the reasons (but not the
> only reason) why TMC is no longer in the hardware business?
> Custom hardware sucks.
> [more CM5 stuff deleted]

Yes, I know all about that, and agree with you. However, it is
not a big deal for me to redo the crucial parts for whatever
architecture I am working on, in fact I enjoy it. I do
appreciate that many people have better things to
do with their time. It doesn't take long for me to read
several manuals, and attack the problem using the 
optimal method. As I said before, I occasionally chose
Fortran in the past.... back to the example of the extinct
CM5, I learnt C* and CMF, and mastered both. C* (which is
a parallel version of C, quite beautiful in fact)
produced terribly inefficient binaries compared with 
the CMF compiler. Thank you, Sweet Jesus, for the fact that
it is possible to NOT use Fortran these days! If a situation
should arise in which Fortran really is the better choice,
I would hesitate and then go for it. I don't think it
is going to happen, though.

> (otherwise, you were not using the machine efficiently, I
> don't want to think about what weird accounting, padding,
> and coding tricks this may have induced over time.)

I did things that were simply illegal in CDPEAC, but they
worked, they screamed, and they produced identical results
to my CMFortran equivalent. Except faster, of course, and
that is the bottom line for me. If someone else was going
to pick up the code, I would say I failed dismally!



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-06  4:00                             ` Richard A. O'Keefe
@ 1997-10-08  4:00                               ` Zalman Stern
  0 siblings, 0 replies; 207+ messages in thread
From: Zalman Stern @ 1997-10-08  4:00 UTC (permalink / raw)



Richard A. O'Keefe (ok@goanna.cs.rmit.edu.au) wrote:
: Aliasing is very confusing for people to deal with.
: Of course, as soon as you have objects as in Smalltalk or Common Lisp or
: Java, you have precisely the same kind of problem when the same object
: reference can be passed (the _reference_ is passed by copy-in) to a
: procedure.

See for example item 17 in Scott Meyers' _Effective_C++_ titled "Check for
assignment to self in operator=." The item explains that the statement:
	a = a;
in C++ may not be a "nop" for an improperly implemented assignment
operator. (I wonder if the C++ draft standard allows the compiler to punt
on calling the assignment operator in that case. I doubt it...)

-Z-



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00       ` William Clodius
       [not found]         ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
@ 1997-10-08  4:00         ` Richard A. O'Keefe
  1997-10-08  4:00           ` William Clodius
  1997-10-08  4:00           ` William Clodius
  1997-10-09  4:00         ` William Clodius
  2 siblings, 2 replies; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-08  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]


William Clodius <wclodius@lanl.gov> writes:

>F90 also lacks pointers to procedures.

True.  As someone who is peeved with the oddly restricted function
pointers in Ada95, I *should* have remembered this one.  Mind you,
function pointers in C are seriously restricted too.

>It lacks stream based I/O.

I am not quite certain what you mean by this.
If you mean the kind of thing that is found in C,
then I have a printed copy of the specification for stream-based IO in
Fortran somewhere in this office.

>(There
>are contexts where non-advancing I/O is not sufficient.)

Agreed.

Remember though, that the context of this thread was
 - hardware and optimisation
 - limited or not by common programming languages?

An important thing to understand is that if you are seriously concerned
about high performance and reliability, a language may be as useful for
what it _doesn't_ allow as for what it does.

-- 
John �neas Byron O'Keefe; 1921/02/04-1997/09/27; TLG,TLTA,BBTNOTL.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00     ` Richard A. O'Keefe
                         ` (2 preceding siblings ...)
  1997-10-07  4:00       ` William Clodius
@ 1997-10-08  4:00       ` Gregg E Economou
  1997-10-08  4:00         ` David Chase
  1997-10-08  4:00         ` Richard A. O'Keefe
  3 siblings, 2 replies; 207+ messages in thread
From: Gregg E Economou @ 1997-10-08  4:00 UTC (permalink / raw)



In article <61c9kl$94l$1@goanna.cs.rmit.edu.au>,
Richard A. O'Keefe <ok@goanna.cs.rmit.edu.au> wrote:
>
>I strongly suspect that you don't know what modern Fortran is like.
>There is precisely *one* construction present in C which is not
>supported as well or better by Fortran, and that is pointer arithmetic.

I strongly suspect you dont know what C is like. Go read K&R. 

>Modules?  Fortran has them, C hasn't.

C is very simple, and designed such that you can implement things of
a higher nature with it if you wish. You  can write code that 
behaves in a particular style in C. 

>Overloading?  Fortran has it, C hasn't.
one legitimate arguemtn in a cast of many pointless ones. touche.
(need an accent-grave there)

>Records?  Fortran and C both have them.
>Pointers? Fortran and C both have them.
>Dynamic allocation?  Fortran and C both have them.

You're confusing issues of the library with the language. 
That migth be fine in an HLL like Fortran but in C the library
is not part of the language, even if it is standardized and commonly 
accepted. 

>Recursive procedures?  Fortran and C both have them.
>Nested procedures?  Fortran has one level of nesting, C has none.
>Strings?  Fortran has them, C hasn't.

But C is lower-level. You can *implement* those things inside a C progam
if you like, but dont have to take on the extra weight if you dont.
Much more flexible.

>Character-oriented IO?  Fortran and C both have it.
>Record-oriented IO?  Fortran has it, C hasn't.

C has NO I/O. All I/O in the C libraries is implemented using the
basics of the langugae itself in manipulating memory directly. There is 
no I/O native to the language. There is almost nothing beyond the 
basics of memory handling, logic, and conditionals in the language itself.
The fact that C is used for such a wide variety of things is testimony to 
the incredible flexibility it has by NOT being bound to things liek I/O. 

>User defined operators?  Fortran has them, C hasn't.
>Free-format source form?  Fortran and C both have it.
>Bitwise operations?  Fortran and C both have them.
>Control over record layout?  Neither language supports this.  (Yes, I know
>	about bitfields, and I also know how extremely weak are the
>	guarantees you get about them.)

see above.
>
>Why shouldn't you listen to both of us?  I am, after all, telling the truth,
>as you can easily verify for yourself.

only a truth that is based on misdirection. You are obviously mistaken as 
to what C is and what the C libraries are, and are mixing the two fo them up.

>I think perhaps it is time instead that _you_ took your blinkers off.
>Fortran is not my favourite language by a long way, but it has come
>a *long* way in the last 20 years, and is by most criteria a more
>'modern' language than C.

a point to be thought of- Fortan is a high level language, C is not. 
The utility of C is that it is very universally portable and applicable-
because the laguage itself assumes only the presence of memory, a processing
capability to perform logical and arithmetic operations, and the ability
to perform conditional executions. The manipulation of memory is the 
implementation of almost all higher-level fucntionality in the C libraries. 
The beauty fo this is that it ends up that C programs very closely resemble
the actual activity fo the machine and low-level routines with a high-level
structure and syntax, and lead to a much simpler and more portabel coding than
an assembly lends, but is still very close down there to the hardware. 

However, it is not ncessarily the best thing for _every_ job. For example, 
renaming a list of files would be much simpler to accomplish with a short shell
script, and would be much more logically done that way than with a C program
designed explicitly for such a purpose. 

anwyays.. lets NOT start another language war, eh?  

isildur



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00       ` Gregg E Economou
@ 1997-10-08  4:00         ` David Chase
  1997-10-08  4:00         ` Richard A. O'Keefe
  1 sibling, 0 replies; 207+ messages in thread
From: David Chase @ 1997-10-08  4:00 UTC (permalink / raw)



Gregg E Economou wrote:
> ... The manipulation of memory is the
> implementation of almost all higher-level functionality in the C libraries.
> The beauty of this is that it ends up that C programs very closely resemble

a rat's nest of memory and functional unit latency.

> anwyays.. lets NOT start another language war, eh?

Why should the last word be given to someone who so clearly doesn't
know what he is talking about?  Or were you just trolling?

-- 
David Chase, chase@world.std.com



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00       ` Gregg E Economou
  1997-10-08  4:00         ` David Chase
@ 1997-10-08  4:00         ` Richard A. O'Keefe
  1 sibling, 0 replies; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-08  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5338 bytes --]


geest3+@pitt.edu (Gregg E Economou) writes:
>I strongly suspect you dont know what C is like. Go read K&R. 

I have been using C since the days when UNIX V6+ was the latest thing.
I've fixed bugs in two C compilers.
I've bought and read three copies of the C standard (they keep disappearing
from my office; I'm getting sick of it),
and have obtained and read every publically available document about C9x.  
(I was writing a proposal to add offset types to C, but didn't get it
finished in time to submit it to the committee.  Sigh.  It'd sure make
putting linked structures in shared memory easier.)

>>Modules?  Fortran has them, C hasn't.

>C is very simple, and designed such that you can implement things of
>a higher nature with it if you wish. You  can write code that 
>behaves in a particular style in C. 

If you think C is simple, you probably haven't seen the insides of a
C compiler.  And you are going to have a nasty shock when C9X comes out.

>You're confusing issues of the library with the language. 

>That migth be fine in an HLL like Fortran but in C the library
>is not part of the language, even if it is standardized and commonly 
>accepted. 

Clearly you have never participated in any of the threads about this
in comp.std.c.  The C `library' *is* an official part of the language;
malloc() is as standard as &; sqrt() is as standard as +.  (Technically,
there are two kinds of 

>But C is lower-level. You can *implement* those things inside a C progam
>if you like, but dont have to take on the extra weight if you dont.
>Much more flexible.

>C has NO I/O.

Wrong.  stdio is a fully standard part of C.  getc() is as standard
as x = *p++.

>The fact that C is used for such a wide variety of things is testimony to 
>the incredible flexibility it has by NOT being bound to things liek I/O. 

If you want to talk about C being useful for 8051s you are right.
If you are talking about C systems running on Macs, PCs, UNIX boxes,
MVS, CMS, VMS, BeOS, AmigaDOS, then you are talking through your hat.

>only a truth that is based on misdirection. You are obviously mistaken as 
>to what C is and what the C libraries are, and are mixing the two fo them up.

Obviously?  I think perhaps you have not read the standard with due care
and attention.

>a point to be thought of- Fortan is a high level language, C is not. 
>The utility of C is that it is very universally portable and applicable-
>because the laguage itself assumes only the presence of memory, a processing
>capability to perform logical and arithmetic operations, and the ability
>to perform conditional executions.

Oh dear.  There are so many misconceptions here that it is hard to know
where to start.

Take the B6700 mainframes (now the A series).
*Lovely* machines.  Fortran runs *beautifully* on them, as do
COBOL and Pascal.  There _is_ a C compiler for them now, but
the implementors had to fight past C's utterly inappropriate
assumptions about memory.  Heck, C wasn't even a good fit to the PC,
thanks to its extremely strong assumptions about memory.

C in practice does not merely assume the PRESENCE of memory,
it demands a FLAT, LINEAR, BYTE-ADDRESSED memory.

There have been plenty of machines with segmented (PC) or tree-structured
(B6700) memories.  There have been plenty of machines with word-addressed
memories.  The first MIPS designs didn't have byte loads and stores. 
The first Alphas didn't have byte loads or stores.  I don't remember
which models of the AMD29k if any have byte loads and stores, but the
oldest ones didn't.

While the C _standard_ doesn't say that NULL pointers are all bits zero,
there are enough C programs out there that rely on this that one manufacturer
(Prime) had to add special instructions just for C to their computers.
Those same computers had supported Fortran, COBOL, Pascal, and even PL/I
just fine.

Indeed, I once ran into trouble porting a C program to a machine which
was just your ordinary average M68k UNIX box _except_ that the user's
half of the address space was the _negative_ half, and large chunks of
the code relied on user addresses looking positive when you cast them
to long.  "Very universally portable?"  I think not.

I'm trying to bring this thread back into relevance to comp.arch, which
is where I am reading it.

The basic point I want to make is that for *most* (not all) tasks, if you
want efficiency, you want a *high* level language, not an old low level
language.  Why?  Because hardware has changed a lot in the last 20 years
too.  On a good modern machine, load/store can be a HUNDRED TIMES SLOWER
than an add (UltraSPARC II: 4-way superscalar, it's fairly easy to fill
all the slots in vector code with a bit of unrolling, load from main
memory is 30 cycles, 30*4 = 120).

There are plenty of tasks where a low level language is just right,
and C is a welcome step up from assembler.  (Programming an 8051 is an
area that forcibly suggests itself.)  But writing a program that is a
good fit to _this_ year's machine is a good way to end up with a program
that is relatively slow on _next_ year's machine.

Compiler writers are doing truly _awesome_ things these days.  I for one
would rather not get in their way.

-- 
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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-08  4:00 Robert Harley
  1997-10-08  4:00 ` Michael Meissner
  1997-10-09  4:00 ` Richard A. O'Keefe
  0 siblings, 2 replies; 207+ messages in thread
From: Robert Harley @ 1997-10-08  4:00 UTC (permalink / raw)



Shankar Unni <shankar@powertelglobal.com> writes:
>Yo, Robert (and you, too, "boo@somethingorother.umn.edu"):
>
>Richard and Nick have probably forgotten more C than you'll ever learn
>in your lifetime, OK? Give it a rest; listen and learn. There's a few
>lifetimes of actual working experience behind these opinions..

Yo Shankar, their lifetimes of experience hacking primitive Fortrans and
Lisps in 500BC apparently don't help when talking about ANSI C and C9X.

Why exactly should we "listen and learn" to people who screw up on
'const' and admit to not knowing what 'restrict' is, when we're
shaving cycles off critical numerical code with both of them here and now?
Or who claim that:

>Nested procedures?  Fortran has one level of nesting, C has none.

when GCC, for instance, has arbitrarily deep nesting with Pascal-style
lexical scoping?  Oh no!  It's not strictly standard-conforming!
La-di-frickin-da.  It's works just fine on Alpha, ARM, Intel, Sparc
and experimental backroom chips nobody ever heard of, in my
ever-so-humble experience.  (However I find it totally useless).

I believe that Richard does have a clue, however he also has a very
obvious bias.  As Mark Twain said:

  "First get the facts straight,
   then you are free to distort them at your leisure."


>We see this sort of crazed C cheerleading about the start of every
>semester.  We've all programmed in C (and in C++).  [...]

Jeez, lose the patronising bullshit.

-- Rob.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00         ` boo
@ 1997-10-08  4:00           ` Carlie Coats
  0 siblings, 0 replies; 207+ messages in thread
From: Carlie Coats @ 1997-10-08  4:00 UTC (permalink / raw)



In article <343AF933.6EF4EC37@tonys.ecology.umn.edu>,
boo  <boo@tonys.ecology.umn.edu> blathers:
> On 7 Oct 1997 12:53:16 -0400, Carlie Coats (xcc@hilbert.ncsc.org) said:
> > > This from an advocate of a language that makes arrays second class
> > > citizens?  C can't even do the equivalent of
> > >
> > >     SUBROUTINE S( M, N, P, A )
> > >     INTEGER, INTENT( IN ):  M, N, P
> > >     REAL,    INTENT( IN ): A( M, N, P )
> > >     ...
> > >
> > > nor can C++, for that matter. Fortran can.  So can lisp.
> 
> Oh, so you think that high level language constructs are
> something to boast about?

"High level constructs"?  Since when is being able to do decent
things with (multi-dimensional) arrays high level?  Maybe instead
I should have said

<RANT>
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] ) {...}

This idiocy about all subscripting except the outermost
being required to be compile-time constant is really and
truly _brain-dead_!
</RANT>

Would that satisfy you?




^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00         ` Richard A. O'Keefe
  1997-10-08  4:00           ` William Clodius
@ 1997-10-08  4:00           ` William Clodius
  1 sibling, 0 replies; 207+ messages in thread
From: William Clodius @ 1997-10-08  4:00 UTC (permalink / raw)



Richard A. O'Keefe wrote:
> 
> William Clodius <wclodius@lanl.gov> writes:
> <snip>
> >It lacks stream based I/O.
> 
> I am not quite certain what you mean by this.
> If you mean the kind of thing that is found in C,
> then I have a printed copy of the specification for stream-based IO in
> Fortran somewhere in this office.
> <snip>

This is low on the list of priorities for F200x, but still on the list
of priorities. In principle Fortran I/O remains record based. For files
that do not have a fixed record size, (or for which backspace does not
make sense, i.e., standar I/O to a terminal) the execution of any given
read or write statement cannot assume that it will not be followed by a
backspace command. As a result the file must retain some construct that
indicates the size of the record. For non-record based systems, e.g.,
UNIX this is (invariably) implemented by having an integer at the start
and end of the record indicating the size of the record. For writing a
file to be read by other systems this is a minor problem, but for
reading files produced by other processors, e.g., C, the absence of the
starting integer in the file causes no ends of problems. It is also a
problem for interfacing to hardware, e.g., instumentation, although an
appropriate Fortran specified interface that does not rely on READs or
WRITEs can be an acceptable, if sometimes non-intuitive, substitute.
Most vendors I believe offer this as an extension.

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
       [not found]         ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
@ 1997-10-08  4:00           ` William Clodius
  1997-10-08  4:00             ` Stanley Chow
  0 siblings, 1 reply; 207+ messages in thread
From: William Clodius @ 1997-10-08  4:00 UTC (permalink / raw)



Jan Vorbrueggen wrote:
> 
> William Clodius <wclodius@lanl.gov> writes:
> 
> > F90 also lacks pointers to procedures.
> 
> Is that true? Then it isn't a superset of F77 anymore. Or is the way you can
> pass the address of a function or subroutine in F77 not a pointer to a
> procedure?
> <snip>

F90 has this capability. This is typically implemented as a pointer to a
procedure and can be used to emulate some of the capabilities that you
want from pointers to procedures, but it is not an explicit pointer to a
procedure. In priciple in F90 terms you want something like

INTERFACE
   FUNCTION A(x)
      REAL :: A, x
   END FUNCTION A
   FUNCTION B(x)
      REAL :: A, x
   END FUNCTION B
END INTERFACE
INTERFACE(A), POINTER ::C ! define a pointer that accepts real arguments
! and returns real results

IF ... THEN
   C => A
ELSE
   C => B ! All subsequent invocations of C actually invoke B
ENDIF
...
y = C(z) ! Invokes A or B

This is equivalent to C pointers to procedures, and is roughly what is
planned for F200x. In the most general case, you want procedures to
return pointers to procedures as values, i.e., a form of closures. This
is not currently planned.

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00         ` Richard A. O'Keefe
@ 1997-10-08  4:00           ` William Clodius
  1997-10-08  4:00           ` William Clodius
  1 sibling, 0 replies; 207+ messages in thread
From: William Clodius @ 1997-10-08  4:00 UTC (permalink / raw)



One other thing that F90 lacks, that C and F95 provide, is the ability
to define a NULL pointer. This, of course, was perhaps the major problem
with F90.

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-06  4:00   ` boo
                       ` (2 preceding siblings ...)
  1997-10-07  4:00     ` Carlie Coats
@ 1997-10-08  4:00     ` James C. Stutts
  3 siblings, 0 replies; 207+ messages in thread
From: James C. Stutts @ 1997-10-08  4:00 UTC (permalink / raw)



In article <34392537.AA4A9F96@tonys.ecology.umn.edu>, boo <boo@tonys.ecology.umn.edu> writes:

<snip>

>Oh puh-leeze.
>
>Who cares what it was designed for? C is far more powerful than
>Fortran, especially for the kind of work that some of us
>do in the real world. If Rob can show me how to do something 
>with a particular compiler that speeds up what I need done,
>I am listening to him, not to you. 

It's the little touches in Fortran that set it apart from C for
numerical work.  For instance: math.h doesn't give you
the ability to raise an int to an arbitrary power and return
an int.  Pow() only returns floats.  Minor things like that.
Actually having an operator (like ** in Fortran) for this
would also be nicer, IMHO, than pow().

Regards,
----------------------------------------------------------------------
James C. Stutts                                stuttjc@eng.auburn.edu

Adaptive Aerostructures Lab, Department of Aerospace Engineering
211 Aerospace Engineering 		       W: (334)-844-6813
Auburn University, AL 36849		     Lab: (334)-844-6832	
All opinions expressed are my own.
----------------------------------------------------------------------





^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00 Robert Harley
@ 1997-10-08  4:00 ` Michael Meissner
  1997-10-09  4:00 ` Richard A. O'Keefe
  1 sibling, 0 replies; 207+ messages in thread
From: Michael Meissner @ 1997-10-08  4:00 UTC (permalink / raw)



harley@pauillac.inria.fr (Robert Harley) writes:

> when GCC, for instance, has arbitrarily deep nesting with Pascal-style
> lexical scoping?  Oh no!  It's not strictly standard-conforming!
> La-di-frickin-da.  It's works just fine on Alpha, ARM, Intel, Sparc
> and experimental backroom chips nobody ever heard of, in my
> ever-so-humble experience.  (However I find it totally useless).

Nested functions do have problems on some chips (and under some OSes for other
chips) when you take the address of the nested function and the compiler has to
synthesize a trampoline on the stack.

Of course, building executable hunks at runtime comes in use in other
situations, such as just-in-time Java compilers, and writing optimial sort
programs that build the comparison function from a generalized input.

-- 
Michael Meissner, Cygnus Solutions (East Coast)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com,	617-354-5416 (office),	617-354-7161 (fax)



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
       [not found]       ` <61cv5e$qn$6@vixen.cso.uiuc.edu>
@ 1997-10-08  4:00         ` William Clodius
  0 siblings, 0 replies; 207+ messages in thread
From: William Clodius @ 1997-10-08  4:00 UTC (permalink / raw)



Mark Gibson wrote:
> <snip>
> 
> Wow, I haven't used FORTRAN much in at least ten years.  (F77 was new
> when I last did any real work with FORTRAN.)  All this fuss over
> which is better, C or FORTRAN, has made me curious.  Is there a low-priced,
> high quality implementation of the most modern version of FORTRAN? 

Depends on your definition of low priced/high quality. For most people
the answer is no, for some with deep pockets or a restricted range of
emphasis for quality, the answer is yes.

A full F90 highly optimizing implementation is almost invariably
relatively high cost: $300 for a stuent Wintel, $600 professional
Wintel, about twice that for UNIX. With full toolsets, i.e., debugers,
editors, integrated environment, special libraries, another factor of
two or more in price can be introduced.

There are low optimizing compilers, I believe Salford is one, in the
$100 range. There are F90 subset compilers (i.e., they are not supersets
of F77) from Lahey (ELF) and Imagine1 (F), available for free or the
$100 range. The subset compilers are primarilly intended for the
educational market, and will often not be appropriate for professionals.

> Does
> Gnu produce such a thing?

No although G77 does implement some of F90 (e.g. SELECT CASE) it does
not implement modules, pointers, array arithmetic, etc.

> 
> Also, what native support for large-integer arithmetic do the latest
> versions of FORTRAN provide?  Will they allow me to crunch 128-bit
> integers efficiently without writing my own arithmetic routines?

Processor dependent, but relatively easy to use if available. I believe
some vendors for 64 bit machines offer this capability, several of them
offer 128 bit REALs.
> <snip>

-- 

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] 207+ 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     ` Richard A. O'Keefe
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-09  4:00     ` David Chase
  1997-10-08  4:00       ` boo
@ 1997-10-09  4:00       ` William Clodius
  1 sibling, 0 replies; 207+ messages in thread
From: William Clodius @ 1997-10-09  4:00 UTC (permalink / raw)



David:

I should have phrased it better, although my first option does indicate
that I do not consider arguing from credentials to be sufficient. My
real point was, of course, that Robert Harley's criticism of your result
was based not on an analysis of your code (which you did not provide) or
approach (which you did provide in detail), but rather that your result
was not what he wanted to believe, hence the ad hominum option at the
end. I might have better pointed out simply that that if someone that is
as thorough in their analysis of optimization as you described writes
lousy C code, what does that say about the rest of us?David Chase wrote:

For what its worth I consider myself to be terrible at hand
optimization.

Sorry about the strength of the attribution of your work on the Boehm
collector.

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00   ` boo
@ 1997-10-09  4:00     ` Patrick F. McGehearty
  1997-10-10  4:00       ` Richard A. O'Keefe
  0 siblings, 1 reply; 207+ messages in thread
From: Patrick F. McGehearty @ 1997-10-09  4:00 UTC (permalink / raw)



In article <343C1030.4A86F6D6@tonys.ecology.umn.edu>,
boo  <boo@tonys.ecology.umn.edu> wrote:
>Shankar Unni wrote:
>
>> But if I'm doing numerical analysis or linear regressions, I'll pick
>> Fortran almost any day. 
>
>Hahahah! linear regressions!! I can do those on my watch calculator!!
>Hey, that is some high level stuff you are doing there, thank God
>you have Fortran to help you out! I agree, with advanced (heh) stuff
>like that, you need to have a specialized numerical language.

If you think that you can handle serious numerical analysis on your
watch calculator, you have no understanding of current issues in
high end technical computing.  Data set sizes often run to Gigabytes, and
compute times on high end servers (that run in excess of 10Gflops) runs to
days or weeks.  The problem sizes will continue to grow as compute power per
dollar grows to allow larger problems to be attacked.

The problems are not just of academic interest.  Most every major
manufacturing company uses computer simulation before they start "bending
iron" (actually its seldom iron these days).  Technical computing
applications include: simulation of the whole airplane to improve fuel
economy and quietness, crash simulation of cars to improve occupant
surviability, flow analysis of air filters for better durability and
effectiveness, seismic data analysis to improve drilling success rates,
modeling of chemical interactions to reduce time to market for new
treatments for illnesses, and many others.

The overwhelming majority of existing code in these market areas is in
Fortran and C.  New development is moving to C++ and Fortran90.  In most of
these areas, the common method of programming is to the computationally
interesting part of the code in Fortran and the human interface part of the
code in C.  That method works because each language has areas where it is
strongest.  Some developers chose to forgo the advantages of using both
languages in order to have only one development language, but they also pay
a penalty, either in performance if they use only C or ease of development
of elaborate data structures if they use only Fortran.

All high-end vendors that I know of offer reasonable (and semi-portable)
ways to mix Fortran and C.  For example, Fortran arrays are column-major and
C arrays are row-major.  You mix them by being sure to reverse the order of
array indices when going from one language to the other.  If you want
portable code, you avoid passing certain kinds of data structures between
the Fortran and C portions of your (large) application.  Character strings
in particular tend to have non-uniform representations between vendors.
But vectors of float (real*4) and double (real*8) tend to work the same on
almost all vendors between C and Fortran.

All this "my language is best because it is all I know" discussion is not
very enlightening.  Let's get back on the "language features which will
aid/hender future architectures generate fast applications" topic.

- Patrick McGehearty
patrick@convex.hp.rsn



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-07  4:00       ` William Clodius
       [not found]         ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
  1997-10-08  4:00         ` Richard A. O'Keefe
@ 1997-10-09  4:00         ` William Clodius
  1997-10-10  4:00           ` Larry Kilgallen
  2 siblings, 1 reply; 207+ messages in thread
From: William Clodius @ 1997-10-09  4:00 UTC (permalink / raw)



Fortran currently also lacks a standard defined preprocessor. This may,
or may not, be viewed as a problem for Fortran. The received wisdom on
preprocessors is that they can help performance and portability, but
their effect on code maintenance and legibility may not be worth the
price. For example, Denis Ritchie at the HOPL II conference (as quoted
in the latest issue of SIGPLAN) had several criticisms of cpp.

Common substitutes for this lack are cpp (Fortran syntax unaware), m4
(Fortran syntax unaware), CoCo (a conditional compilation code (no
macros) with Fortran like syntax that will probably be part of F200x),
and fpp (a Fortran syntax aware variant of cpp that was proposed as an
alternative to Coco by Sun as standardizing current practice).

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00   ` boo
  1997-10-09  4:00     ` Patrick Chase
@ 1997-10-09  4:00     ` David Chase
  1997-10-08  4:00       ` boo
  1997-10-09  4:00       ` William Clodius
  1 sibling, 2 replies; 207+ messages in thread
From: David Chase @ 1997-10-09  4:00 UTC (permalink / raw)



> William Clodius wrote:

> > So you are saying that David Chase, [resume omitted] writes lousy C code
> > because he can't get within 10% of the performance of Fortran. There
> > are several possibilities here, not all
> > mutually exclusive

You have to be careful there.  First, I try not to argue from
authority.  Second, I know people with PhDs that I would not
necessarily trust to write C; skill at writing C does not
necessarily correlate with anything.  I do think it was pretty
good code that I wrote, at least in terms of performance.

Also, I am emphatically NOT one of the primary authors
of the Boehm-Weiser collector.  Early user, yes, enthusiastic
fan, yes, author, no.  Hans and I worked on the optimizer-
versus-your-garbage-collector problem in the distant past,
trying to come up with some way to trick a C compiler into
certainly not destroying the properties of the generated
code that were needed by the collector, while still allowing
it to generate decent code.

The point, which apparently has not yet sunk in, is that
indeed, C gets you very close to the machine, and on
modern machines, if you want to get best performance,
this means you need to know all sorts of silly stuff,
and hand-apply atrocious transformations that will not
necessarily enhance performance on the next machine.  The
tricks that were taught 5 years ago no longer apply, and the
tricks that will work best 5 years from now will probably
differ from the best tricks today.  The guys at Tera think
they have a solution to this problem, and I hope they are
right (and I still want to know why they decided to build
the damn thing about of GaAs, as if they weren't taking on
enough risk already.)

boo wrote:

> About 5 years ago, I wrote a large simulation in CM Fortran for
> the CM5 (and you had one of those at lanl, so I think you follow
> what I am saying...), and was quite impressed with the performance.
> I then wrote the crucial routines in C with CDPEAC (macros
> which expand to vector unit assembly codes), and produced something
> that thrashed the THEORETICAL PEAK EFFICIENCY POSSIBLE of CM Fortran at
> that time, according to their manuals.

CDPEAC is defined in what section of the C standard?  You
do know that they're not making those vector units anymore,
don't you, and that they're one of the reasons (but not the
only reason) why TMC is no longer in the hardware business?
Custom hardware sucks.  

(Why do you think we were trying to see how fast
stock hardware could be used to multiply matrices,
given the best possible code we knew how to
generate for a typical numerical problem?)

Note to the non-CM users:  a CM-5 contained a collection
of Sparc chips speaking to memory through a pair of
memory controllers, where each memory controlled
was "enhanced" with (sort of) a pair of vector processors.
Thus, you get 1 Sparc + 4 vector units.  Each VU
executes pipelined memory-to-memory operations, with
a throughput of one per tick.  The clock rate of the whole
blob is typically lower than the current Sparc workstation
clock rate; I don't know if this is the limit of the 
VU performance, or if it was done to make the entire machine
reliable enough to use.  The Cypress chip blobs were clocked
at 25Mhz, the SuperSparc blobs were clocked at 40 Mhz.
(I think this is correct; there were different terms
for the blobs depending upon whether you were counting
Sparc chips, memory controllers, or apparent vector units).

CMF at least, you can translate pretty easily into HPF, and
get it compiled onto an SP-2 or whatever else you choose.
If I remember correctly, the current versions of the PowerPC
ought to give the about the same performance as one of those
Sparc+VU combinations.  40 Mhz * 4 multiply adds/tick gives
you 320 Mflops speed-of-light, versus one multiply-add per tick
on a 300+ Mhz PPC, assuming you can keep the damn thing fed
operands, which is the entire point of the pipelining and
blocking nonsense.  The experiments we ran indicated that
we were unlikely to get more than 2/3 of the speed-of-light
on general-purpose hardware, and this was wildly optimistic.
Compilers and Fortran "optimizing preprocessors" available
at the time did a pretty poor job.  On the other hand, peak
performance from the CM was also pretty rare; I think that 1/6th
peak was considered to be "good enough" at one national lab
(otherwise, you were not using the machine efficiently, I
don't want to think about what weird accounting, padding,
and coding tricks this may have induced over time.)

-- 
David Chase, chase@world.std.com



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00 Robert Harley
       [not found] ` <343C0387.41C6@lanl.gov>
@ 1997-10-09  4:00 ` David Chase
  1 sibling, 0 replies; 207+ messages in thread
From: David Chase @ 1997-10-09  4:00 UTC (permalink / raw)



Robert Harley wrote:
> ... Aren't ignorant people like me lucky to have
> mind-bogglingly condescending asses like yourself
> to bray on about the error of our ways?

Hey, someone's got to do it.  How exactly do you want this
stuff explained?  How polite am I supposed to be to someone
who says (incorrectly)

> 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.

This is not condescending?

C's major performance fault is that as defined, and
especially as used, a compiler does not have
a great deal of freedom to move loads and stores around.
C programmers may be very careful to avoid "unnecessary" 
loads and stores, but nowadays, latency is the big problem;
performance is reduced if you do your loads "too late", or
if a conditional branch depends on a result that you computed
"too late".  A "too late" load is typically a bigger performance
hit than a "not necessary" load.  Fortran has many fewer
problems with this, because the aliasing rules make life
much easier for compilers.  The contiguously-allocated
multi-dimensional arrays help with this very much, too,
because it is easier to infer that A(i,w,x) addresses
different storage than A(i+1,y,z) than it is to infer
that

   pa+i*n*p+w*p+x != pa+(i+1)*n*p+y*p+z

Modern hardware goes to some trouble to reduce these costs
in the local sense, by predicting branches and starting
loads early, but this only gets you so much.  Parallelization
can get you superlinear speedup (as in, when I worked at 
Sun, a happy customer observed superlinear speedup on one
of their dusty decks on a 16-processor machine) on a very
good day.  Has anyone anywhere ever taken a dusty C deck,
dropped it on a multiprocessor, asked the compiler to
parallelize it, and obtained even a linear speedup?

Sun's Fortran compiler, back in 1994, would take care of loop
interchange for better cache use.  The dependence analysis
finds many "vector" operations, and these are specially
code-generated as software pipelines to get the best
possible performance.   You can get this sometimes for C
(it helps if the loop contains no stores to globally-accessible
variables) but you'll get it more often for Fortran.
Fortran performance is also pulling ahead on the newer
processors -- friends (former colleagues) told me that
the then-new version of the compilers improved Fortran
performance by 160% over the older compilers, but C and
C++, not nearly so much (I do not recall the figure).
The superoptimizer (converts control flow to very tricky
data flow) is looking better and better on these new
machines, but the combinatorial costs of searching ever-longer
instruction sequences limits usefulness (and the conditional
instructions added to many new processors also expands the
search space, though they also increase the chances of
hitting with a short sequence).

A decent combination of cache blocking, register blocking,
and software pipelining can get you a 20x speedup over
unoptimized code (if I recall, the large-matrix multiply
unoptimized ran at something like 1.5 Mflops).  C compilers,
lacking the restrict keyword, cannot do that (everyone who
knows what the restrict keyword is and what it does, raise
your hand.)  You can do this in C -- I did this in C,
apparently ineptly, since a Fortran program beat me -- but
it is incredibly tedious work, and the peak performance
is not portable (a conservative coding will improve
performance by quite a lot on most machines).
Cache blocking parameters depend on the cache size,
associativity, and line size.
Register blocking parameters depend on how many
registers you have, and registers used for blocking
are stolen from registers used for pipelining.
Pipelining depends on the latency of the loads and CPU
operations, and on where the operands are expected to come
from (dcache? ecache? main memory?  contiguous addresses that
can be prefetched or fetched in a burst?)

And, again, this is slow and tedious work; I normally write
something like 100 lines of debugged code (C, Java, x86 assembly
language) per day over long periods of time (I can count the
lines of code that I have written in the last nine months),
but writing this stuff, my rate falls down to something
under 10 lines per day.  Someone writing similar code in
i860 assembly language at Dana/Ardent/Stardent quoted me
a figure of one line of code per day, for a general case
version of the code (this one someone working on pipelined
implementations of vectorized transcendental functions).

If you were designing a new programming language ( to get back
to the original thread ) it would be a good idea to figure out
either how to make it easy to do alias analysis, or what "rules"
should come wired into the language that are both easy for
programmers to understand and obey, and useful for the compiler
to exploit.  Fortran 77's rules are well outside the bounds of
what I'd call elegant, but they work, and the optimization benefits
are substantial.

Another possibility is to make it as easy as possible
to discover that a program will terminate -- though this is
general-case intractable, there's a large class of interesting
programs for which this can be determined (for instance, all
loops are "for" loops, or all recursion is governed by a
strictly decreasing parameter).  Or, for instance, there is
some datatype that captures the notion "directed acyclic graph",
so that you know that any path traversal will terminate.

I'd also look into some way to make it more tractable to write
programs which use dataflow instead of control flow.  C* went
quite some distance in that direction, and it was a relatively
easy way to get decent performance out of a Connection Machine,
but people always seemed to want more, and I think they tended
to get it with CMF(ortran) or explicit message-passing.  (And,
as "boo" writes, some people programmed the vector units in their
assembly language.  Yuck.)

-- 
David Chase, chase@world.std.com



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00   ` boo
@ 1997-10-09  4:00     ` Patrick Chase
  1997-10-10  4:00       ` boo
  1997-10-09  4:00     ` David Chase
  1 sibling, 1 reply; 207+ messages in thread
From: Patrick Chase @ 1997-10-09  4:00 UTC (permalink / raw)



In article <343C0C92.B6C7A244@tonys.ecology.umn.edu>, boo <boo@tonys.ecology.umn.edu> writes:
|> If someone cannot get within 10% of the performance of Fortran, I 
|> would say he is a crap programmer.

Yes, someone who thoroughly understands the target architecture should be
able to beat (or at least get close to) what a FORTRAN compiler's optimizer 
can do, if they are programming in a lower-level language like C (or, if
you want to take this argument to its logical conclusion, assembly!).

IMO, that argument misses the real point: Programmer-hours are expensive.
IMO the real "crap programmer" is the one who chooses to spend lots of time
hand-optimizing their code, when a different design or tool choice earlier 
in the process (including but not limited to language selection) would have 
given adequate (if not exactly equivalent) performance, saved them the 
trouble, and allowed them to work on the next project that much earlier.

I _strongly_ prefer the C programming language to Fortran, but for 
programming straightforward (no fancy I/O and rudimentary UI) quick and 
dirty numerical apps I often use Fortran. The reason is simple: I know 
that doing so will give me the most performance for a minimum level of
of effort invested.

From your references to programming Los Alamos' CM-5, I gather that you
come from a peformance-at-any-cost background. That's fine and well, but
you need to keep in mind that not everybody shares your perspective.

Regards,

Patrick



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-08  4:00 Robert Harley
  1997-10-08  4:00 ` Michael Meissner
@ 1997-10-09  4:00 ` Richard A. O'Keefe
  1 sibling, 0 replies; 207+ messages in thread
From: Richard A. O'Keefe @ 1997-10-09  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2949 bytes --]


harley@pauillac.inria.fr (Robert Harley) writes:

>Shankar Unni <shankar@powertelglobal.com> writes:
>>Yo, Robert (and you, too, "boo@somethingorother.umn.edu"):
>>
>>Richard and Nick have probably forgotten more C than you'll ever learn
>>in your lifetime, OK? Give it a rest; listen and learn. There's a few
>>lifetimes of actual working experience behind these opinions..

>Yo Shankar, their lifetimes of experience hacking primitive Fortrans and
>Lisps in 500BC apparently don't help when talking about ANSI C and C9X.

>Why exactly should we "listen and learn" to people who screw up on
>'const' and admit to not knowing what 'restrict' is, when we're
>shaving cycles off critical numerical code with both of them here and now?

Get your facts straight, buster.  I have _not_ screwed up on 'const',
and I've known exactly what 'restrict' is for a couiple of years.  I
even use every day a C compiler (SPARCompiler C) that supports it.

>Or who claim that:

>>Nested procedures?  Fortran has one level of nesting, C has none.

>when GCC, for instance, has arbitrarily deep nesting with Pascal-style
>lexical scoping?

Hang on, you just said 'talking about ANSI C and C9X'.
There are no nested procedures in ANSI C.
There will be no nested procedures in C9X.

There *are* nested procedures in GNU C, which is a fine language,
but it is not the language I was talking about, and it is not the
language *you* claim to be talking about.

What's more, precisely *because* I care about performance, I have
mostly stopped using GCC.  On a Sun UltraSPARC, Sun's C compiler
can, not surprisingly, run rings around GCC.  *Because* I care
about performance, I *know* I will have to be prepared to switch
compilers at a benchmark's notice, which means I care a *lot* about
what is standard and what is not.  (If gcc knew how to deal with
*.il files, I would be better pleased.)

>I believe that Richard does have a clue, however he also has a very
>obvious bias.  As Mark Twain said:

>  "First get the facts straight,
>   then you are free to distort them at your leisure."

So what exactly do you think this bias is?

Ok, let me tell you.  My real bias is that languages like Sisal and Nesl
and Clean and Mercury are _wonderful_.  (This list includes only languages
known to have matched or bettered C on benchmarks.)  I have also been
raving about Tcl/Tk to anyone who would listen ever since I learned it
about 6 weeks ago.  I am *SICK AND TIRED* of other people's programs
crashing and trashing because the authors thought pointer arithmetic was
cool.  Read
	ftp://grilled.cs.wisc.edu/technical_papers/fuzz-revisited.ps.Z
some time.

If you can point to any fact about standard C (C89), draft standard C
(C9X), draft standard C++ (December 96 draft), or standard Fortran
that I have distorted, point it 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
       [not found]           ` <343AAE5A.A3FCC9D@no.informatik.spam.tu-muenchen.thanks.de>
@ 1997-10-09  4:00             ` Torben AEgidius Mogensen
       [not found]               ` <EHsr7B.Dt8@bit3.com>
  0 siblings, 1 reply; 207+ messages in thread
From: Torben AEgidius Mogensen @ 1997-10-09  4:00 UTC (permalink / raw)



Bernd Paysan <paysan@no.informatik.spam.tu-muenchen.thanks.de> writes:

>If you compare language evolution
>with biologic evolution, we are just in the midth of the carbonic
>explosion of forms. Most languages known today won't survive on the long
>run, but there will be one small and unregarded with an early form of a
>backbone, and this one will take over later.

And the year 2000 problem is the giant meteor that will kill off the
dinosaurs? ;-)

Actually, I think the metaphorical meteor will be something else. As
has been noted earlier in this thread, tehre is a limit to how much
high-level languages can give you: You still have to tell the computer
exactly what you want done, and there is no way this description can
be arbitrarily shortened.

However, a lot of programming time today is taken with tracking down
bugs. Languages that will make this process easier/faster is bound to
win in the long run. One way is to remove sources of common bugs by
restricting the language. Common bugs in C are caused by the use of
integers to represent booleans. This makes mistakes like "if (x=y)"
pass the compiler, when a better type system would detect that an
integer was used in place of a boolean. This is only a simple example,
which b.t.w. many C complers will detect and give a warning (not an
error) about. Other things that a good language with a good comipler
can outlaw or catch are non-exhaustive tests, undefined variables,
out-of-bounds access and many more. We are probably only in the
beginning of an evolution towards languages/compilers that catch
inconsistent behaviours.

The trend today seems to try to reduce the programming effort by
providing HUGE libraries and hope that these will cover the majority
of what programs need. This can make some programs be quite short, but
if what you want isn't in the library, then you are out of luck.
Furthermore, this trend makes it take a long time to use a language
well, as most of the effort is taken by learning the libraries. Even
experienced programmers spend a major fraction of the programming time
reading manuals or searching in libraries. I think this trend will die
under its own weight. Libraries are not bad in themselves, but they
shouldn't dominate.

	Torben Mogensen (torbenm@diku.dk)



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
@ 1997-10-09  4:00 Robert Harley
  0 siblings, 0 replies; 207+ messages in thread
From: Robert Harley @ 1997-10-09  4:00 UTC (permalink / raw)



In the beginning, Paul Demone mentioned a paper about an 8-issue
processor, to which Nick McLaren replied "C sucks".

Somehow this wonderful exchange got bogged down in "Fortran is much
faster", the main arguments appearing to be:

  1) The syntax of C is icky
  2) Bad programmers write bad programs
  3) Today's optimisations might be superceded in a decade or two
  4) I'm offended so I feel like yelling

Point 3 is relevant for some people, depending on what they're doing.
The others are not particularly enlightening.  May I suggest that in
the interest of the SNR around here, followups falling under these
categories be sent to /dev/null?

-- Rob.



^ permalink raw reply	[flat|nested] 207+ 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     ` Richard A. O'Keefe
  1997-10-10  4:00     ` boo
  1997-10-10  4:00     ` Tyson Richard DOWD
  3 siblings, 0 replies; 207+ 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] 207+ 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     ` Tyson Richard DOWD
  1997-10-12  4:00       ` boo
  3 siblings, 1 reply; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-09  4:00   ` Gregg E Economou
@ 1997-10-10  4:00     ` Jan Vorbrueggen
  0 siblings, 0 replies; 207+ 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] 207+ 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-16  4:00       ` Patricia Shanahan
  1997-10-10  4:00     ` David Gould
  1 sibling, 1 reply; 207+ 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] 207+ 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-10  4:00       ` Maynard Handley
  1 sibling, 1 reply; 207+ 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] 207+ 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; 207+ 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] 207+ 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     ` Richard A. O'Keefe
@ 1997-10-10  4:00     ` boo
  1997-10-11  4:00       ` Paul DeMone
                         ` (2 more replies)
  1997-10-10  4:00     ` Tyson Richard DOWD
  3 siblings, 3 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-09  4:00     ` Patrick F. McGehearty
@ 1997-10-10  4:00       ` Richard A. O'Keefe
  1997-10-15  4:00         ` David Chase
  0 siblings, 1 reply; 207+ 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: 5582 bytes --]


Patrick F. McGehearty <patrick@convex.COM> writes:
>All this "my language is best because it is all I know" discussion is not
>very enlightening.  Let's get back on the "language features which will
>aid/hender future architectures generate fast applications" topic.

Given my respect for David Chase, my awareness from the literature that
the kinds of transformations he is talking about _are_ used and _do_
pay off (indeed, I have a student doing a minor thesis on neural nets
trying to see if he can beat Sun's C compiler -- alas, he was unwilling
to learn Fortran --), and also given my strong liking for functional
programming languages like Haskell and Clean, I'm worried.

People in the functional programming community have put a _lot_ of work
into trying to implement functional languages really well.  For example,
on the pseudoknot benchmark, Clean-compiled code ran as fast as C.

There are techniques like loop unrolling that can be applied in functional
languages as well.  Let's take the well-known `member' function:

    member :: a [a] -> Bool | == a
	/* This declaration means that member is a function that will
	   accept homogeneous lists with any element type, as long as
	   that element type has an equality operation, and returns a
	   Boolean result.
	*/
    member x [e:es] = x == e || member x es
    member x []     = False

Clean is a lazy language, but the Clean compiler is able to infer that
this function is strict.  In fact, in the context of the definition

    Start = member 3 [4,1,3,2,5]

the Clean compiler will make an instance member (int) and infer, without
any declarations at all

    member (int) :: Int ![Int] -> Bool

where ! means strict.  So the code that is generated is perfectly ordinary
call-by-value stuff.  In fact, it's pretty much the equivalent of

    template <class T>
    bool member(T const x, list<T> es) {
	for (; es != NULL; es = es->tail)
	    if (es->head == x) return true;
	return false;
    }

This is precisely the kind of code that David Chase decries as intrinsically
inefficient.

There _are_ things that can be done here, and they can be done precisely
because these languages have no mutable data structures and are fairly
straightforward to analyse.  One thing I'd like to discuss _has_ been
implemented, but _not_ as far as I know in the Clean compiler.  That is,
loop unrolling.

Instead of having
    :: list a = Nil | Cons a (list a)
you unroll the type.  Unrolling by 3 would give

    :: list3 a = Nil3 | Cons31 a | Cons32 a a | Cons33 a a a (list3 a)

This would economise on space as well, taking an average of 4/3rds of a
word per element instead of 2 words per element.  A compiler can automatically
rewrite the member function to

    member3 x Cons33 e1 e2 e3 es = x == e1 || x == e2 ||
                                   x == e3 || member3 x es
    member3 x Cons32 e1 e2       = x == e1 || x == e2
    member3 x Cons31 e1          = x == e1
    member3 x Nil3               = False

I must repeat, the Clean compiler does NOT do this transformation, but
there has been published work on a compiler for another functional language
that does.  So this kind of loop unrolling _is_ something that can be
applied to pointer chasing, *provided* the language is a high level one
which makes it impossible for a program to notice any difference, except
in performance.

In pure functional languages, speculative loading in such loops ought to
work very well.  So that's another thing that should help.

The thing that has me worried is that fantastic improvements have been
made in compiler technology for functional languages, but the big money
is in compilers for C, C++, Fortran, and Java, so those languages are
always likely to enjoy a lead that relates to their popularity, not
their potential.  This in turn means that such languages will continue
to predominate in benchmarks, which means that computer architects will 
continue to bias their designs towards such languages, which means that
functional language implementors will have even more catching up to do.
The reason this is sad is that lifecycle costs can be reduced when you
have a language which is otherwise sufficiently expressive but in which
a large proportion of common errors _can't_ be expressed.  (Ericsson
believe this.  They have adopted a mostly-functional language of their
own design called Erlang, sacrificing performance in the interests of
time-to-market and reliability.)

Once upon a time, people used to advocate specialised hardware for
symbolic languages.  The phenomenal price-performance improvements
of commodity hardware have made that a thing of the past, and I expect
that to remain true (although there were some seriously interesting
ideas in the LMI K machine which might still be useful).  These days
systems like Clean and O'CAML and SISAL get _fine_ performance on
stock hardware.  My impression, which is not completely up to date
(I'm trying to get through fifty papers this week, phew!), is that
the limiting factor for functional languages is memory.  (For example,
Clean directly supports arrays of unboxed numbers.)

What I'm wondering, and here I go way beyond any expertise I might
possibly claim, is whether (a) there are patterns of memory use in
functional languages that hardware designers might exploit, without
adverse effect on more conventional languages?  and (b) whether the
hardware designers see any point in worrying about this?

-- 
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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
       [not found]               ` <EHsr7B.Dt8@bit3.com>
@ 1997-10-10  4:00                 ` Torben AEgidius Mogensen
  0 siblings, 0 replies; 207+ messages in thread
From: Torben AEgidius Mogensen @ 1997-10-10  4:00 UTC (permalink / raw)



brianh@bit3.com writes:

>In article <61i74j$8b1@vidar.diku.dk>,
>Torben AEgidius Mogensen <torbenm@diku.dk> wrote:
>>
>>Actually, I think the metaphorical meteor will be something else. As
>>has been noted earlier in this thread, there is a limit to how much
>>high-level languages can give you: You still have to tell the computer
>>exactly what you want done, and there is no way this description can
>>be arbitrarily shortened.

>It depends upon how abstract you want to get.  Inverting a matrix (to pick
>a particularlly well trod example) is ~100 lines of C code, or a couple
>hundred to a few thousand lines of assembler, or simply a call to
>invert_matrix().

Just calling a library function like invert_matrix() only helps you if
it is already there. If you want to do something new, then you must
write it yourself, and there is a limit to how short you can do this.
Libraries rely on the assumption that you rarely want to do something
new, and as long as this is true (and the libraries are not so huge
that it would be faster to write it yourself instead of searching the
libraries), it is fine. But This is not always so.

>>The trend today seems to try to reduce the programming effort by
>>providing HUGE libraries and hope that these will cover the majority
>>of what programs need. This can make some programs be quite short, but
>>if what you want isn't in the library, then you are out of luck.
>>Furthermore, this trend makes it take a long time to use a language
>>well, as most of the effort is taken by learning the libraries. Even
>>experienced programmers spend a major fraction of the programming time
>>reading manuals or searching in libraries. I think this trend will die
>>under its own weight. Libraries are not bad in themselves, but they
>>shouldn't dominate.

>Okay, first off, I don't beleive in manualless programming.  Even for a 
>small, simple language like C I keep both K&R and two books on the standard
>libraries within arms reach when I program, and hot-keyed help on my 
>computer (or man, if I'm on Unix).

I don't object to manuals, I use them too. However, if you use more
time to read manuals than you do on design, then something is wrong.

	Torben Mogensen (torbenm@diku.dk)



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-10  4:00           ` Larry Kilgallen
@ 1997-10-10  4:00             ` Zalman Stern
  1997-10-11  4:00             ` Andrew Cruickshank
  1 sibling, 0 replies; 207+ messages in thread
From: Zalman Stern @ 1997-10-10  4:00 UTC (permalink / raw)



Larry Kilgallen (kilgallen@eisner.decus.org) wrote:
: As I understand it, the reliance on preprocessors is actually
: required by the definition of the C language and it is impossible
: to implement a C compiler which uses precompiled interface definitions
: because one is supposed to be able to add definitions before those
: which are "include"ed and have those added definitions affect the
: "include"ed ones.

Many compiler vendors offer solutions to this problem. (Metrowerks
CodeWarrior and Microsofts Visual C++ to name two.) There are varying
levels of "transparency" involved. As with many things (alias analyisis,
building fast x86 implementations) the solution is difficult, but far from
impossible.

A related problem that often comes up in porting large apps is the
semantics of textual inclusion make the "interface dependencies" of C
programs relatively difficult to determine. And the situation gets worse in
development environments where precompiled header information is passed in
on the command line because the C source code then often lacks any mention
of the headers it depends on. Then there's the "mother include file"
syndrome where every source file starts with an include of a single header
which includes every header than might ever be used in the program.

But salvation is close at hand. I understand Merced will have a "compile C
program" instruction. Its only fair given the CDC STAR "compile Fortran
program" instruction. (Or was it TI ASC? SYMBOL? One of those :-))

-Z-



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-09  4:00     ` Patrick Chase
@ 1997-10-10  4:00       ` boo
  0 siblings, 0 replies; 207+ messages in thread
From: boo @ 1997-10-10  4:00 UTC (permalink / raw)



Patrick Chase wrote:
> I _strongly_ prefer the C programming language to Fortran, but for
> programming straightforward (no fancy I/O and rudimentary UI) quick and
> dirty numerical apps I often use Fortran. The reason is simple: I know
> that doing so will give me the most performance for a minimum level of
> of effort invested.

I would have to agree with you on this. I feel that for serious numerical
work, Fortran probably is the best choice for most people. I just wanted
to add my opinion that it is possible to write extremely efficient
C that can rival Fortran code, in my personal experience.



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-09  4:00         ` William Clodius
@ 1997-10-10  4:00           ` Larry Kilgallen
  1997-10-10  4:00             ` Zalman Stern
  1997-10-11  4:00             ` Andrew Cruickshank
  0 siblings, 2 replies; 207+ messages in thread
From: Larry Kilgallen @ 1997-10-10  4:00 UTC (permalink / raw)



In article <343D64F1.167E@lanl.gov>, William Clodius <wclodius@lanl.gov> writes:
> Fortran currently also lacks a standard defined preprocessor. This may,
> or may not, be viewed as a problem for Fortran. The received wisdom on
> preprocessors is that they can help performance and portability, but
> their effect on code maintenance and legibility may not be worth the
> price.

As for performance I have only seen the C preprocessor to hinder
compilation speeds (presumably run-time performance is not the
issue since some combination of libraries and inlining can make
code from sophisticated compilation equal to that from any sort
of preprocessing).

But as for compilation speed, taking a full set of VMS interface
definitions ("Starlet") and using them from C slows down the
compilation _considerably_ compared to compilers like Bliss,
Pascal and Ada which make use of precompiled libraries.  DEC
releases a new version of VMS only once a year or so, why should
I recompile the interface definitions every time I compile ?

As I understand it, the reliance on preprocessors is actually
required by the definition of the C language and it is impossible
to implement a C compiler which uses precompiled interface definitions
because one is supposed to be able to add definitions before those
which are "include"ed and have those added definitions affect the
"include"ed ones.

Larry Kilgallen



^ permalink raw reply	[flat|nested] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* new languages
  1997-10-10  4:00       ` Maynard Handley
@ 1997-10-11  4:00         ` Preston Briggs
  0 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-10  4:00           ` Larry Kilgallen
  1997-10-10  4:00             ` Zalman Stern
@ 1997-10-11  4:00             ` Andrew Cruickshank
  1997-10-12  4:00               ` Paul D. DeRocco
  1997-10-13  4:00               ` Michael Williams
  1 sibling, 2 replies; 207+ messages in thread
From: Andrew Cruickshank @ 1997-10-11  4:00 UTC (permalink / raw)



Larry Kilgallen wrote:
> 
> In article <343D64F1.167E@lanl.gov>, William Clodius <wclodius@lanl.gov> writes:
> > Fortran currently also lacks a standard defined preprocessor. This may,
> > or may not, be viewed as a problem for Fortran. The received wisdom on
> > preprocessors is that they can help performance and portability, but
> > their effect on code maintenance and legibility may not be worth the
> > price.
> 
> As for performance I have only seen the C preprocessor to hinder
> compilation speeds (presumably run-time performance is not the
> issue since some combination of libraries and inlining can make
> code from sophisticated compilation equal to that from any sort
> of preprocessing).
> 
> But as for compilation speed, taking a full set of VMS interface
> definitions ("Starlet") and using them from C slows down the
> compilation _considerably_ compared to compilers like Bliss,
> Pascal and Ada which make use of precompiled libraries.  DEC
> releases a new version of VMS only once a year or so, why should
> I recompile the interface definitions every time I compile ?
> 
> As I understand it, the reliance on preprocessors is actually
> required by the definition of the C language and it is impossible
> to implement a C compiler which uses precompiled interface definitions
> because one is supposed to be able to add definitions before those
> which are "include"ed and have those added definitions affect the
> "include"ed ones.
> 
> Larry Kilgallen

On PCs pre-compiled header files have been a standard feature for
some time (driven primarily by the requirement to include
Windows header file when Windows 3.0 took off).

The compilers keep a database of precompiled header information
for each source file in a project. If you change the include files
or add definitions ahead of the include files then this is detected
and the precompiled header information is regenerated by the
compiler/preprocessor.

So it's not impossible and it is workable.

-------------------------
Andrew Cruickshank.




^ permalink raw reply	[flat|nested] 207+ 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; 207+ 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] 207+ 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         ` Steve Tate
  1997-10-13  4:00         ` Patricia Shanahan
  0 siblings, 2 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-11  4:00             ` Andrew Cruickshank
@ 1997-10-12  4:00               ` Paul D. DeRocco
  1997-10-13  4:00               ` Michael Williams
  1 sibling, 0 replies; 207+ messages in thread
From: Paul D. DeRocco @ 1997-10-12  4:00 UTC (permalink / raw)



Andrew Cruickshank wrote:
> 
> The compilers keep a database of precompiled header information
> for each source file in a project. If you change the include files
> or add definitions ahead of the include files then this is detected
> and the precompiled header information is regenerated by the
> compiler/preprocessor.

"Precompiled headers" is really a misnomer. It's really a symbol
table cache. One of its somewhat counter-intuitive
characteristics is that it's more efficient, in a multi-module
program, to include the same set of headers in every module,
rather than try to figure out the minimum set needed by each
individual module. But I never liked doing that anyway...

-- 

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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-13  4:00         ` Steve Tate
  1997-10-13  4:00           ` Bernd Paysan
  1997-10-13  4:00           ` boo
@ 1997-10-13  4:00           ` boo
  1997-10-13  4:00             ` Victor Yodaiken
                               ` (3 more replies)
  2 siblings, 4 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-12  4:00       ` boo
  1997-10-13  4:00         ` Steve Tate
@ 1997-10-13  4:00         ` Patricia Shanahan
  1997-10-15  4:00           ` boo
  1 sibling, 1 reply; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-13  4:00         ` Steve Tate
@ 1997-10-13  4:00           ` Bernd Paysan
  1997-10-13  4:00           ` boo
  1997-10-13  4:00           ` boo
  2 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-12  4:00       ` boo
@ 1997-10-13  4:00         ` Steve Tate
  1997-10-13  4:00           ` Bernd Paysan
                             ` (2 more replies)
  1997-10-13  4:00         ` Patricia Shanahan
  1 sibling, 3 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-13  4:00             ` Paul Rubin
  1997-10-13  4:00               ` William Clodius
@ 1997-10-13  4:00               ` Craig Burley
  1997-10-14  4:00               ` Richard A. O'Keefe
  2 siblings, 0 replies; 207+ 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] 207+ 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               ` William Clodius
                                 ` (2 more replies)
  1997-10-13  4:00             ` boo
  1 sibling, 3 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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             ` Jason.Ozolins
                               ` (2 subsequent siblings)
  3 siblings, 0 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-13  4:00             ` Paul Rubin
@ 1997-10-13  4:00               ` William Clodius
  1997-10-13  4:00               ` Craig Burley
  1997-10-14  4:00               ` Richard A. O'Keefe
  2 siblings, 0 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-13  4:00         ` Steve Tate
  1997-10-13  4:00           ` Bernd Paysan
@ 1997-10-13  4:00           ` boo
  1997-10-13  4:00             ` Aaron Spink
  1997-10-13  4:00           ` boo
  2 siblings, 1 reply; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-11  4:00             ` Andrew Cruickshank
  1997-10-12  4:00               ` Paul D. DeRocco
@ 1997-10-13  4:00               ` Michael Williams
  1 sibling, 0 replies; 207+ messages in thread
From: Michael Williams @ 1997-10-13  4:00 UTC (permalink / raw)



In article <343F7D9A.C475526E@openkast.demon.co.uk>,
>The compilers keep a database of precompiled header information
>for each source file in a project. If you change the include files
>or add definitions ahead of the include files then this is detected
>and the precompiled header information is regenerated by the
>compiler/preprocessor.

You would hope so.

One time, however, we found a linkage error in an application, which
was due to a (legacy) C library being linked to C++, where the header
for library didn't include extern "C" declarations. Rather than change
the header (which would have openned up a can of worms), we instead
put extern "C" around the #include. The result - it still didn't work
because VC++ had precompiled the header.

> So it's not impossible and it is workable.

That said, yes it is possible, but when it does go wrong, it takes a
while to understand why!

Mike.



^ permalink raw reply	[flat|nested] 207+ 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                     ` Michael Williams
                                       ` (2 more replies)
  0 siblings, 3 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-13  4:00             ` Paul Rubin
  1997-10-13  4:00               ` William Clodius
  1997-10-13  4:00               ` Craig Burley
@ 1997-10-14  4:00               ` Richard A. O'Keefe
  1997-10-14  4:00                 ` Shankar Unni
                                   ` (2 more replies)
  2 siblings, 3 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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             ` Jason.Ozolins
  1997-10-15  4:00               ` boo
  1997-10-14  4:00             ` Aaron Spink
  1997-10-15  4:00             ` David Chase
  3 siblings, 1 reply; 207+ 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] 207+ 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                 ` Shankar Unni
@ 1997-10-14  4:00                 ` Michael Williams
  1997-10-14  4:00                   ` Richard Black
  1997-10-15  4:00                 ` Paul Hsieh
  2 siblings, 1 reply; 207+ 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] 207+ 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; 207+ 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] 207+ 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             ` Jason.Ozolins
@ 1997-10-14  4:00             ` Aaron Spink
  1997-10-15  4:00             ` David Chase
  3 siblings, 0 replies; 207+ 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] 207+ 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                 ` Shankar Unni
  1997-10-15  4:00                   ` Achim Gratz
  1997-10-15  4:00                   ` Richard A. O'Keefe
  1997-10-14  4:00                 ` Michael Williams
  1997-10-15  4:00                 ` Paul Hsieh
  2 siblings, 2 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-14  4:00                 ` Shankar Unni
  1997-10-15  4:00                   ` Achim Gratz
@ 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, 2 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-14  4:00                   ` Richard Black
@ 1997-10-15  4:00                     ` Michael Williams
  1997-10-15  4:00                       ` Dr. Richard Black
  1997-10-15  4:00                     ` Craig Burley
  1997-10-18  4:00                     ` Bruce Hoult
  2 siblings, 1 reply; 207+ 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] 207+ 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             ` Aaron Spink
@ 1997-10-15  4:00             ` David Chase
  3 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-14  4:00                   ` Richard Black
  1997-10-15  4:00                     ` Michael Williams
@ 1997-10-15  4:00                     ` Craig Burley
  1997-10-18  4:00                     ` Bruce Hoult
  2 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-13  4:00             ` boo
@ 1997-10-15  4:00               ` Craig Burley
  1997-10-16  4:00                 ` Flexible Choice of Language (Nothing to do with: Final kick at the "Merced Guessing Game") Ian Dall
       [not found]                 ` <623ek6$ef5$1@news.iastate.edu>
  0 siblings, 2 replies; 207+ 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] 207+ 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               ` Toon Moene
                                 ` (4 more replies)
  0 siblings, 5 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-14  4:00                 ` Shankar Unni
@ 1997-10-15  4:00                   ` Achim Gratz
  1997-10-15  4:00                   ` Richard A. O'Keefe
  1 sibling, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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                 ` Shankar Unni
  1997-10-14  4:00                 ` Michael Williams
@ 1997-10-15  4:00                 ` Paul Hsieh
  2 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-10  4:00       ` Richard A. O'Keefe
@ 1997-10-15  4:00         ` David Chase
  1997-10-16  4:00           ` William Clodius
  0 siblings, 1 reply; 207+ messages in thread
From: David Chase @ 1997-10-15  4:00 UTC (permalink / raw)



Richard A. O'Keefe wrote:

> Given my respect for David Chase, my awareness from the literature that
> the kinds of transformations he is talking about _are_ used and _do_
> pay off (indeed, I have a student doing a minor thesis on neural nets
> trying to see if he can beat Sun's C compiler -- alas, he was unwilling
> to learn Fortran --), and also given my strong liking for functional
> programming languages like Haskell and Clean, I'm worried.

You've got to be careful here.  Blocking seems to be very hard,
though I would not be surprised if someone's compiler somewhere
did it.  There are algorithms that are intrinsically unblockable,
so I am told my the true experts in the field.  An example of this
is QR factorization using Householder transformations -- you have
to use Givens rotations instead.  No compiler is going to do that
for you.

The advantage of Fortran here is that by-hand cache blocking is
probably sufficient, and the compiler will behave relatively
well with that.  With C, it is likely that you will need to
carry out more extensive by-hand transformations to get the
same performance.

Also, your gradual student had better watch out for what might
euphemistically be termed "targeted optimizations", undiplomatically 
known as benchmark cheating.  Avoid industry-standard benchmarks.

> What I'm wondering, and here I go way beyond any expertise I might
> possibly claim, is whether (a) there are patterns of memory use in
> functional languages that hardware designers might exploit, without
> adverse effect on more conventional languages?  and (b) whether the
> hardware designers see any point in worrying about this?

(a) maybe and (b) not much, though I did loan what I considered
my interesting GC papers to a hardware designer at one time.
I think he was interested in doing no harm, as opposed to actually
helping.

For the time being, I think it makes sense to concentrate on making
functional language implementations resemble Fortran under the hood.
For instance, you could write a garbage collector to take advantage
of the ability to load-w/o-faulting (load first, ask questions about
null pointers later) and also perhaps to prefetch (certainly, in a
copying GC, it would make sense to prefetch/zero cache lines that you
knew you were about to write).

-- 
David Chase, chase@world.std.com



^ permalink raw reply	[flat|nested] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-10  4:00     ` David Gould
@ 1997-10-16  4:00       ` Patricia Shanahan
  0 siblings, 0 replies; 207+ 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] 207+ 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
@ 1997-10-16  4:00                 ` Ian Dall
  1997-10-16  4:00                   ` Craig Burley
  1997-10-17  4:00                   ` Richard A. O'Keefe
       [not found]                 ` <623ek6$ef5$1@news.iastate.edu>
  1 sibling, 2 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-15  4:00             ` boo
@ 1997-10-16  4:00               ` Toon Moene
  1997-10-16  4:00               ` Timothy A. Seufert
                                 ` (3 subsequent siblings)
  4 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-15  4:00             ` boo
  1997-10-16  4:00               ` Toon Moene
@ 1997-10-16  4:00               ` Timothy A. Seufert
  1997-10-16  4:00                 ` boo
  1997-10-17  4:00               ` Richard A. O'Keefe
                                 ` (2 subsequent siblings)
  4 siblings, 1 reply; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-16  4:00                   ` Final kick at the "Merced Guessing Game" Craig Burley
@ 1997-10-16  4:00                     ` SimGraphics
  1997-10-17  4:00                       ` Craig Burley
  0 siblings, 1 reply; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-15  4:00         ` David Chase
@ 1997-10-16  4:00           ` William Clodius
  0 siblings, 0 replies; 207+ messages in thread
From: William Clodius @ 1997-10-16  4:00 UTC (permalink / raw)



David Chase wrote:
> 
> Richard A. O'Keefe wrote:
> <snip>
> > What I'm wondering, and here I go way beyond any expertise I might
> > possibly claim, is whether (a) there are patterns of memory use in
> > functional languages that hardware designers might exploit, without
> > adverse effect on more conventional languages?  and (b) whether the
> > hardware designers see any point in worrying about this?
> 
> (a) maybe and (b) not much, though I did loan what I considered
> my interesting GC papers to a hardware designer at one time.
> I think he was interested in doing no harm, as opposed to actually
> helping.
> 
> <snip>

A minor point, but one aspect in which conventional languages are
starting to resemble functional languages is in the presence of garbage
collectors. While I don't know of any C or C++ implementations that
provide it, the availabiltiy of the Boehm collector and the commercial
add ons is starting to impact the C/C++ community. Several Fortran 90
implementations, (but as far as I know only those from UK vendors) now
provide garbage collection. Java is also having an impact here. However,
whether or not they have a significant impact on architecture design
probably requires the development of a benchmark that benefits from GC,
otherwise the bechmarks will be run with GC turned off.

-- 

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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-15  4:00             ` boo
  1997-10-16  4:00               ` Toon Moene
  1997-10-16  4:00               ` Timothy A. Seufert
@ 1997-10-17  4:00               ` Richard A. O'Keefe
  1997-10-20  4:00               ` Jason.Ozolins
  1997-10-20  4:00               ` [Reposted due to Enlow UCE cancel]: " tgg
  4 siblings, 0 replies; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-17  4:00                       ` Craig Burley
  1997-10-17  4:00                         ` William Clodius
@ 1997-10-17  4:00                         ` David Chase
  1997-10-18  4:00                           ` Victor Yodaiken
  1997-10-18  4:00                         ` Peter L. Montgomery
  2 siblings, 1 reply; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-17  4:00                       ` Craig Burley
@ 1997-10-17  4:00                         ` William Clodius
  1997-10-19  4:00                           ` Craig Burley
  1997-10-17  4:00                         ` David Chase
  1997-10-18  4:00                         ` Peter L. Montgomery
  2 siblings, 1 reply; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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                         ` William Clodius
                                           ` (2 more replies)
  0 siblings, 3 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-17  4:00                       ` Craig Burley
  1997-10-17  4:00                         ` William Clodius
  1997-10-17  4:00                         ` David Chase
@ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* Re: Final kick at the "Merced Guessing Game"
  1997-10-14  4:00                   ` Richard Black
  1997-10-15  4:00                     ` Michael Williams
  1997-10-15  4:00                     ` Craig Burley
@ 1997-10-18  4:00                     ` Bruce Hoult
  2 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

* [Reposted due to Enlow UCE cancel]: Re: Final kick at the "Merced Guessing Game"
  1997-10-15  4:00             ` boo
                                 ` (3 preceding siblings ...)
  1997-10-20  4:00               ` Jason.Ozolins
@ 1997-10-20  4:00               ` tgg
  4 siblings, 0 replies; 207+ 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] 207+ messages in thread

* 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               ` Jason.Ozolins
  1997-10-20  4:00               ` [Reposted due to Enlow UCE cancel]: " tgg
  4 siblings, 0 replies; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ 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; 207+ 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] 207+ messages in thread

end of thread, other threads:[~1997-10-28  5:00 UTC | newest]

Thread overview: 207+ 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 ` David Chase
1997-10-08  4:00 ` William Clodius
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               ` William Clodius
1997-10-13  4:00               ` Craig Burley
1997-10-14  4:00               ` Richard A. O'Keefe
1997-10-14  4:00                 ` Shankar Unni
1997-10-15  4:00                   ` Achim Gratz
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-14  4:00                 ` Michael Williams
1997-10-14  4:00                   ` Richard Black
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-15  4:00                     ` Craig Burley
1997-10-18  4:00                     ` Bruce Hoult
1997-10-15  4:00                 ` Paul Hsieh
1997-10-13  4:00             ` boo
1997-10-15  4:00               ` Craig Burley
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
     [not found]                 ` <623ek6$ef5$1@news.iastate.edu>
1997-10-16  4:00                   ` Final kick at the "Merced Guessing Game" Craig Burley
1997-10-16  4:00                     ` SimGraphics
1997-10-17  4:00                       ` Craig Burley
1997-10-17  4:00                         ` William Clodius
1997-10-19  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-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-09  4:00   ` Gregg E Economou
1997-10-10  4:00     ` Jan Vorbrueggen
     [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     ` Richard A. O'Keefe
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               ` Toon Moene
1997-10-16  4:00               ` Timothy A. Seufert
1997-10-16  4:00                 ` boo
1997-10-17  4:00               ` Richard A. O'Keefe
1997-10-20  4:00               ` Jason.Ozolins
1997-10-20  4:00               ` [Reposted due to Enlow UCE cancel]: " tgg
1997-10-10  4:00     ` Tyson Richard DOWD
1997-10-12  4:00       ` boo
1997-10-13  4:00         ` Steve Tate
1997-10-13  4:00           ` Bernd Paysan
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           ` boo
1997-10-13  4:00             ` Victor Yodaiken
1997-10-14  4:00             ` Jason.Ozolins
1997-10-15  4:00               ` boo
1997-10-14  4:00             ` Aaron Spink
1997-10-15  4:00             ` David Chase
1997-10-13  4:00         ` Patricia Shanahan
1997-10-15  4:00           ` boo
1997-10-15  4:00             ` Patricia Shanahan
     [not found]   ` <EHrwv9.2w3@world.std.com>
1997-10-10  4:00     ` David Gould
1997-10-16  4:00       ` Patricia Shanahan
1997-10-10  4:00     ` David Gould
1997-10-10  4:00       ` Maynard Handley
1997-10-11  4:00         ` new languages Preston Briggs
  -- strict thread matches above, loose matches on Subject: below --
1997-10-09  4:00 Final kick at the "Merced Guessing Game" Robert Harley
1997-10-08  4:00 Robert Harley
1997-10-08  4:00 ` Michael Meissner
1997-10-09  4:00 ` Richard A. O'Keefe
1997-10-08  4:00 Robert Harley
     [not found] ` <343C0387.41C6@lanl.gov>
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` Patrick Chase
1997-10-10  4:00       ` boo
1997-10-09  4:00     ` David Chase
1997-10-08  4:00       ` boo
1997-10-09  4:00       ` William Clodius
1997-10-09  4:00 ` David Chase
1997-10-07  4:00 Robert Harley
1997-10-07  4:00 ` Shankar Unni
1997-10-08  4:00   ` boo
1997-10-09  4:00     ` Patrick F. McGehearty
1997-10-10  4:00       ` Richard A. O'Keefe
1997-10-15  4:00         ` David Chase
1997-10-16  4:00           ` William Clodius
1997-10-07  4:00 ` Nick Maclaren
1997-10-07  4:00 ` Martin Rodgers
1997-10-03  4:00 Robert Harley
1997-10-06  4:00 ` Richard A. O'Keefe
1997-10-06  4:00   ` boo
1997-10-07  4:00     ` Richard A. O'Keefe
1997-10-06  4:00       ` Graham Hughes
1997-10-07  4:00       ` boo
1997-10-07  4:00         ` William Clodius
1997-10-07  4:00       ` William Clodius
     [not found]         ` <y4wwjon203.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>
1997-10-08  4:00           ` William Clodius
1997-10-08  4:00             ` Stanley Chow
1997-10-08  4:00         ` Richard A. O'Keefe
1997-10-08  4:00           ` William Clodius
1997-10-08  4:00           ` William Clodius
1997-10-09  4:00         ` William Clodius
1997-10-10  4:00           ` Larry Kilgallen
1997-10-10  4:00             ` Zalman Stern
1997-10-11  4:00             ` Andrew Cruickshank
1997-10-12  4:00               ` Paul D. DeRocco
1997-10-13  4:00               ` Michael Williams
1997-10-08  4:00       ` Gregg E Economou
1997-10-08  4:00         ` David Chase
1997-10-08  4:00         ` Richard A. O'Keefe
1997-10-07  4:00     ` Serge Pachkovsky
1997-10-07  4:00       ` Martin Rodgers
1997-10-07  4:00         ` Greg Weeks
1997-10-07  4:00           ` Martin Rodgers
     [not found]           ` <343AAE5A.A3FCC9D@no.informatik.spam.tu-muenchen.thanks.de>
1997-10-09  4:00             ` Torben AEgidius Mogensen
     [not found]               ` <EHsr7B.Dt8@bit3.com>
1997-10-10  4:00                 ` Torben AEgidius Mogensen
     [not found]       ` <61cv5e$qn$6@vixen.cso.uiuc.edu>
1997-10-08  4:00         ` William Clodius
1997-10-07  4:00     ` Carlie Coats
1997-10-07  4:00       ` Paul Hsieh
1997-10-07  4:00         ` boo
1997-10-08  4:00           ` Carlie Coats
1997-10-08  4:00     ` James C. Stutts
1997-10-02  4:00 Robert Harley
1997-10-02  4:00 ` Nick Maclaren
1997-10-03  4:00 ` Richard A. O'Keefe
1997-10-02  4:00 Robert Harley
1997-10-02  4:00 ` Nick Maclaren
1997-10-02  4:00   ` Stanley Chow
1997-09-30  4:00 Paul DeMone
1997-09-30  4:00 ` Guy Harris
1997-10-01  4:00   ` Tom Thornhill
1997-10-01  4:00 ` Nick Maclaren
1997-10-01  4:00   ` Paul DeMone
1997-10-01  4:00   ` J. Corbally
1997-10-01  4:00     ` Nick Maclaren
1997-10-01  4:00       ` Ketil Z Malde
1997-10-01  4:00         ` Michael D. Nahas
1997-10-01  4:00           ` Stefan Monnier
1997-10-01  4:00             ` Nick Maclaren
1997-10-01  4:00               ` Allen Kim
1997-10-01  4:00               ` P Murray
1997-10-01  4:00                 ` Nick Maclaren
1997-10-02  4:00                   ` Vesa Karvonen
1997-10-02  4:00                     ` Joseph H Allen
1997-10-02  4:00                       ` Wilco Dijkstra
1997-10-03  4:00                         ` Stefan Monnier
1997-10-03  4:00                         ` Jason.Ozolins
1997-10-03  4:00                           ` Alex Colvin
1997-10-06  4:00                             ` Richard A. O'Keefe
1997-10-08  4:00                               ` Zalman Stern
1997-10-03  4:00                       ` Stefan Monnier
1997-10-02  4:00                   ` Andrew Glew
1997-10-02  4:00                 ` Torben AEgidius Mogensen
1997-10-02  4:00                   ` Patrick F. McGehearty
1997-10-02  4:00                     ` brianh
1997-10-03  4:00                     ` Michael Williams
1997-10-01  4:00               ` John Wilson
1997-10-02  4:00               ` Jon Leech
1997-10-02  4:00               ` Stefan Monnier
1997-10-03  4:00                 ` Richard A. O'Keefe
1997-10-03  4:00               ` Mike Smith
1997-10-03  4:00                 ` Nick Maclaren
1997-10-03  4:00                   ` Rob Barris
1997-10-03  4:00                     ` Andrew Glew
1997-10-05  4:00                       ` Gianni Mariani
1997-10-04  4:00                     ` Nick Maclaren
1997-10-04  4:00                       ` H. Eckert
1997-10-05  4:00                       ` Andy "Krazy" Glew
1997-10-06  4:00                         ` Nick Maclaren
1997-10-01  4:00           ` brianh
1997-10-02  4:00           ` Eric Hildum
1997-10-01  4:00 ` Tom Thornhill
1997-10-01  4:00   ` Paul DeMone
1997-10-01  4:00   ` Jim Hull
1997-10-01  4:00 ` Richard A. Schumacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox