comp.lang.ada
 help / color / mirror / Atom feed
From: macrakis@harvard.ARPA (Stavros Macrakis)
Subject: Speed with numbers: PDP-10 Maclisp vs. Fortran (details)
Date: Wed, 13-Mar-85 15:00:45 EST	[thread overview]
Date: Wed Mar 13 15:00:45 1985
Message-ID: <470@harvard.ARPA> (raw)
In-Reply-To: 6982@watdaisy.UUCP

> [perhaps] the original test [was] against the old DEC Fortran
> compiler, F40. .... This particular piece of folklore (that Maclisp
> generates as good code as Fortran) is more widely quoted than you
> might think.  If it isn't true, or if the Fortran compiler is one that
> would now be viewed as substandard, I would very much like to know.

It's not true.  What is true is that in some cases (heavy use of
procedures, light use of arrays), Maclisp can hold its own.  The Fortran
compiler being used was not great, but then the Maclisp compiler is
old-fashioned as far as compiler technology goes, too.

Now for the details: you asked for them....  Inner loop times only.  All
execute the same floating-point instructions, so the number of memory
references plus the number of multiplications (for 2D indexing) is a
good measure of time.

	  Version	Date	Inner prod   Sum up 2d array

F10/Opt	  V.1A	        76	   6	      6
F10	    "		76	   7	      9 + Mul
F40	  F40I V27(360) 76	   8	     10 + Mul
Maclisp	  1135	        83	  23	     16 + Mul

Note that the problems are chosen to emphasize Fortran's strength with
arrays.  In straight-line numerical code, Maclisp will do relatively
better, but still not as well as the Fortrans.  Maclisp has faster
procedure call/return as well: the DEC Fortrans take about 
	11 + 7 * arg + 3 * out-arg
mem refs, while Maclisp can take as little as
	 4 + 1 * arg ,		(if args stay in registers)
although more common is
	 6 + 3 * arg .		(if args are stashed on stack)
It is this advantage in procedure calling that was largely responsible,
if I remember correctly, for the good Lisp results in the Sigsam article
(sorry, I don't have the reference: something like 1977).  Of course,
the Fortran arguments are by-reference, and the Lisp by-value; and the
register conventions differ.  There are other, hidden, overheads in the
Lisp use of arrays, namely that in Maclisp (at least), they can neither
be stack-allocated nor statically-allocated, but rather come out of a
heap, increasing allocate/deallocate overhead.

As always, remember that all languages have their strengths and
weaknesses, that a language may have good implementations and bad, and
that speed is only one consideration.

	-s


Appendix

For your delectation, the Lisp and Fortran code, and F10/opt's output.
Note that the Fortran source is much clearer in this case, too.

Sum up 2d array

	(do ((i 0 (1+ i))) ((>= i 1000))
	    (do ((j 0 (1+ j))) ((>= j 1000))
		(setq sum (+$ sum (a j i)))))

	DO 10 I=1,1000
	  DO 10 J=1,1000
10	    SUM=SUM+A(J,I)

8M:	MOVEI	14,0(15)
	ADD	14,.O0000	; should have put .O0000 in register
	FADR	2,A-13(14)
	AOBJN	15,8M

Inner product

	(do ((i 0 (1+ i))) ((>= i 1000))
	    (setq sum (+$ sum (*$ (b i) (c i)))))

	DO 20 I=1,1000
20	   SUM=SUM+B(I)*C(I)
	END

10M:	MOVE	14,B-1(15)
	FMPR	14,C-1(15)
	FADR	2,14
	AOBJN	15,10M

  parent reply	other threads:[~1985-03-13 20:00 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     ` Efficiency of LISP Stavros Macrakis
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     ` Stavros Macrakis [this message]
1985-03-14 10:12       ` Speed with numbers: PDP-10 Maclisp vs. Fortran (details) 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