[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inline array refs?
- To: info-mcl@ministry.cambridge.apple.com
- Subject: Re: inline array refs?
- From: kanderso@wheaton.bbn.com (Ken Anderson)
- Date: 13 May 94 12:18:16
- Followup-to: comp.lang.lisp.mcl
- In-reply-to: poeck@informatik.uni-wuerzburg.de's message of 13 May 1994 10:14:21 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: BBN, Cambridge MA
- References: <poeck-130594113955@wi6a65.informatik.uni-wuerzburg.de>
In article <poeck-130594113955@wi6a65.informatik.uni-wuerzburg.de> poeck@informatik.uni-wuerzburg.de (Karsten Poeck) writes:
Path: info-server.bbn.com!noc.near.net!paperboy.wellfleet.com!news-feed-1.peachnet.edu!news.duke.edu!convex!cs.utexas.edu!howland.reston.ans.net!EU.net!Germany.EU.net!netmbx.de!zrz.TU-Berlin.DE!zib-berlin.de!fauern!winx03!wi6a65.informatik.uni-wuerzburg.de!user
From: poeck@informatik.uni-wuerzburg.de (Karsten Poeck)
Newsgroups: comp.lang.lisp.mcl
Followup-To: comp.lang.lisp.mcl
Date: 13 May 1994 10:14:21 GMT
Organization: University of Wuerzburg
Lines: 56
NNTP-Posting-Host: wi6a65
I translated some code to test iterative repair alogirithms from c to LISP.
The code mainly does fixnum operations and simple-array accesses. By adding
appropriate (the fixnum ...) and (declare (type (simple-array fixnum (*))
array)
I managed to get about half the speed of the corresponding c program
compiled with MPW on the same mac.
I don't know about MCL yet, but in Lucid and Allegro, you should be able to
get the speed to be the same as C, perhaps better. I am looking for pairs
of comparable real programs in Lisp and C, so i'd be glad to help you with
performance issues if your code could be come one of my benchmarks.
The disassembly of the code shows calls to subroutines
(jsr_subprim $SP-GETLONG) and
(jsr_subprim $SP-MKLONG)
I suspect that these calls slow down the programm. Does anybody know what
these routines do and how I could avoid them? I always thought that adding
enough declarations to a MCL program would give me the same speed as a
corresponding c program.
Anyhow I tried to run the same program under LIspWorks 3.2 on a Dec-Alpha
and to my surprise a quadra 650 was more than two times faster than the
alpha, even after declaring fixnum-safety = 0. From looking at the
disassembly I suspect that the arefs are not inlined in LispWorks. Does
anybody know how I could get LispWorks to inline the arefs too?
;test code for the array refs
(defun test (array index)
(declare (optimize (speed 3)(safety 0))
(type (simple-array fixnum (*)) array))
(aref array index))
Unless you need a full 32 bits i recommend using simple-vector's instead.
Although (simple-array fixnum (*)) seems to be what corresponds to int
A[100]; in C, I think it should only be used when full 32 bit integers are
required.
->
0 (SPUSH VSP)
2 (VPUSH D1)
4 (VPUSH D0)
6 (MOVE.L (VSP 4) ATEMP0)
10 (MOVE.L @VSP D1)
12 (ASR.L 1 D1)
14 (MOVE.L (ATEMP0 D1.L 7) D0)
18 (SPOP VSP)
20 (JMP_SUBPRIM $SP-MKLONG)
This looks like a jump to a primative. I don't know if MCL can do any
better.
k
--
Ken Anderson
Internet: kanderson@bbn.com
BBN STC Work Phone: 617-873-3160
10 Moulton St. Home Phone: 617-643-0157
Mail Stop 6/4c FAX: 617-873-3776
Cambridge MA 02138
USA