comp.lang.ada
 help / color / mirror / Atom feed
From: macrakis@harvard.ARPA (Stavros Macrakis)
Subject: Re: Efficiency of LISP
Date: Mon, 11-Mar-85 19:25:44 EST	[thread overview]
Date: Mon Mar 11 19:25:44 1985
Message-ID: <459@harvard.ARPA> (raw)
In-Reply-To: 6982@watdaisy.UUCP

> > > an informal experiment ... at MIT ... compared MACLISP with other
> > > programming languages [by] translat[ing] FORTRAN into MACLISP. ...
> > > the lisp versions ran faster and took up less memory.
> [If] both compilers were doing their best at optimizing the generated
> code, it's clear that [that] MACLISP compiler was better than [that]
> FORTRAN compiler....  This [doesn't mean] LISP is better than FORTRAN
> for numerical work, [just] that LISP may not be as bad as some
> might think.  -- 	Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy

I didn't make this measurement, but I was there.  The reason the DEC
Fortran code was worse than the Maclisp code was simply that the DEC
standard calling conventions (which Maclisp didn't use) were expensive.
Otherwise, the code was very similar.  Neither compiler produced
impressive code.  There is, of course, no inherent reason that the
inline code produced for numerical calculations in Lisp (assuming
machine arithmetic, not bignums) should be much worse than that produced
for Fortran, C, Pascal, or Basic.  Some technical reasons that a good
Maclisp compiler has to do a bit worse than a good Fortran compiler are
in the Appendix (below).

The BIG concession you make to get the efficiency, of course, is
programming with fixed-type operators (and/or declared variables and, to
my taste, stepping out of the elegant beauty of the core of Lisp (not
that the semantics of Lisp numbers was ever terribly clean).  Note, by
the way, that the MacLisp system's consistency checking is rather
patchwork:  declarations are not processed at all interpretively, and
separately compiled modules are not checked for consistent declarations.
In other words, like many Lisp extensions, numeric processing is
pragmatically useful, but semantically a mess.

The other issue is whether we are talking about `Lisp' at all.  You
could equally well add such features to Snobol and claim Snobol did
efficient numerical processing.  The problem in saying that `Lisp' does
something is that if it doesn't, someone will add it and still call it
`Lisp'!  You might as well call Ada, `Algol'.  I'm all for improvement
over time, but it is unfair to pretend that Common Lisp '85 = MacLisp
'77 = Lisp 1.5.
	-s

Appendix: Some Technical Details

The two restrictions on numerical efficiency in the PDP-10 Maclisp
implementation are 1) that only 5 registers are available for numbers,
because the rest are stack pointers or garbage-collectable and 2) that
arrays can only be referenced indirectly, because they may be relocated
between any two instructions (Maclisp allows interrupts at arbitrary
points).  Consider a loop to take an inner product of two arrays, A and
B, declared as fixed length.  A good Fortran compiler would produce
machine code like the following:
  float a[len], b[len];
  register float *cura = &(a[0]), *curb = &(b[0]);
  register float sum = 0.0; register int count = len;
  while (--count) sum = *(cura++) + *(curb++);
while Maclisp is obligated to produce (at best) something like:
  float *(a,len), *(b,len);
  register int index = 0; register float sum = 0.0;
  while (index < len) sum = *(a,index) + *(a,index);
where *(a,index) has the effect of *(a[index]) but is indivisible--a is
an indirect word.

In DEC Fortran's case, its main efficiency problem seems to be that it
stashes all registers (even ones it doesn't use) over subroutine calls.
A better compiler could fix this without doing any damage to the
definition of Fortran.  I speculate that he callee-saves discipline was
chosen so that small machine-language library routines (sqrt etc.) could
be hand-tuned to save only the registers they care about while not
requiring that a table be kept of which routines clobber what registers.

  parent reply	other threads:[~1985-03-12  0:25 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1985-02-14 15:59 Thus spake the DoD Frederick J Dickey
1985-02-17  1:58 ` Robert Hofkin
1985-02-17 16:36 ` g-frank
1985-02-18  5:18   ` Skef Wholey
1985-02-18 14:33 ` Chuck Hedrick
1985-02-19 19:09   ` Daniel J. Salomon
1985-02-22  2:21     ` LISP &c (re: the DoD...) Thomas M. Breuel
1985-02-25 17:08     ` Thus spake the DoD Jan Steinman
1985-02-26 23:20     ` Stanley Shebs
1985-02-27 19:22       ` Daniel J. Salomon
1985-03-01 19:30         ` Stanley Shebs
1985-03-01 20:13         ` neves
1985-03-02  4:33         ` Thomas M. Breuel
1985-03-02 18:35           ` Efficiency of LISP Marty Sasaki
1985-03-03  0:23         ` Language criticism Greg Davidson
1985-03-06 14:13         ` Thus spake the DoD geb
1985-02-28  3:16       ` David Schachter
1985-03-01 19:00         ` Stanley Shebs
1985-03-03  3:08         ` Joaquim Martillo
1985-03-03  6:12         ` T J Jardine
1985-03-05 16:55           ` Jan Steinman
1985-03-05 21:07           ` Robert A. Pease
1985-03-12  1:47           ` Ed Colbert
1985-03-13 19:35       ` Monique M Taylor
1985-03-17 19:49         ` Jan Steinman
1985-03-21  1:17           ` faustus
1985-03-12  0:25     ` Stavros Macrakis [this message]
1985-03-12  2:11     ` Efficiency of numerical Lisp code (details) Stavros Macrakis
1985-03-13  7:05     ` Chuck Hedrick
1985-03-13 20:00     ` Speed with numbers: PDP-10 Maclisp vs. Fortran (details) Stavros Macrakis
1985-03-14 10:12       ` Tim Maroney
1985-03-15  0:27         ` Bill Henneman
1985-03-16  0:59           ` Tim Maroney
1985-03-17 18:58             ` Bill Henneman
1985-03-18  5:02               ` Multi-language systems Marty Sasaki
1985-03-20 17:01                 ` Tom Slack
1985-03-18 21:24               ` Speed with numbers: PDP-10 Maclisp vs. Fortran (details) Tim Maroney
1985-03-19  6:45                 ` Fortran better than Lisp for numerical code? Barry Margolin
1985-03-19 17:35                   ` Speed of Lisp numerical code Stavros Macrakis
1985-03-20 21:04                   ` Fortran better than Lisp for numerical code? T J Jardine
1985-03-22  2:10                     ` Joe Orost
1985-03-19 16:15                 ` Speed with numbers: PDP-10 Maclisp vs. Fortran (details) Bill Henneman
1985-03-19  3:40               ` Norman Diamond
1985-03-18  3:01             ` Common Lisp and Arrays Joaquim Martillo
1985-02-18 23:49 ` Thus spake the DoD M.Fischer
1985-03-14 20:50 ` Speed with numbers: PDP-10 Maclisp vs. Fortran (details) Stavros Macrakis
1985-03-15 15:42 ` Stanley Shebs
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox