[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inline array refs?
- To: firstname.lastname@example.org
- Subject: Re: inline array refs?
- From: email@example.com (Ken Anderson)
- Date: 13 May 94 12:18:16
- Followup-to: comp.lang.lisp.mcl
- In-reply-to: firstname.lastname@example.org's message of 13 May 1994 10:14:21 GMT
- Newsgroups: comp.lang.lisp.mcl
- Organization: BBN, Cambridge MA
- References: <email@example.com>
In article <firstname.lastname@example.org> email@example.com (Karsten Poeck) writes:
From: firstname.lastname@example.org (Karsten Poeck)
Date: 13 May 1994 10:14:21 GMT
Organization: University of Wuerzburg
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 (*))
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
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; in C, I think it should only be used when full 32 bit integers are
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
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