Subject: Re: Number crunching in CLISP.

From: [email-masked]
Date: Thu, 18 Aug 94 10:38 +1200

>
>> If my memory serves me correctly, Bruno once told
>> me that CLISP does all floating point operations by itself (i.e. -
>> doesn't use the FPU).  Is this correct?
>
>Yes, on most machines.
>
>> If it does do floating point in software, how hard is it to
>> change this?
>>
>Not very hard: add "#define FAST_DOUBLE" and "#define FAST_FLOAT" to
>lispbibl.d, -fallow-single-precision to the CFLAGS in the makefile
>(need gcc-2.6.0 for this), and recompile.
>
>> Are floating point numbers stored in system format (as a C float)?
>
>Yes, if the floating point operations are done in hardware, the
>system format (i.e. IEEE) is used.
>
>> Is the numerical code well isolated?
>
>Yes, it is a single file called lisparit0.d.
>
>But that won't help you much because while the floating point operations
>are done in hardware, the boxing (allocating storage for the float)
>and the function call and type dispatching overheads remain.
>
>For these kinds of computations, try GCL. You will probably have to add
>many disgusting (DECLARE (DOUBLE-FLOAT ...)) declarations to your program.
>(Linux binaries are in ma2s2.mathematik.uni-karlsruhe.de:/pub/lisp/gcl/.)
>
>
>Btw, your comparison isn't fair since the variable i is a local variable
>in the C and a global (i.e. more expensive) variable in the Lisp version
>of your benchmark.
>
We have just recompiled clisp with these defines included for my 486dx2-66
linux, and the sparc 2's here at varsity and the alpha 2000's and for the
lisp loop given in a previous message (a local version):

(time 
 (do 
  ((i 1.0d0 (* 1.00001d0 i)) (j 0 (1+ j))) 
  ((= j 100000)) 
  (declare (fixnum j))
  (declare (double-float i)) 
 )
)

and the times were:

486-dx2 : Real time: 12.982278 sec.
          Run time: 12.64 sec.
          Space: 1200532 Bytes
          GC: 2, GC time: 0.52 sec.
 
sparc2  : Real time: 31.588968 sec.
          Run time: 31.47 sec.
          Space: 1600552 Bytes
          GC: 3, GC time: 0.7 sec.

alpha   : Real time: 11.301584 sec.
          Run time: 11.261088 sec.
          Space: 1601032 Bytes
          GC: 3, GC time: 0.489952 sec.

These results would seem to say that somehow my PC is as fast as the alphas?
Also it makes the suns look pretty slow?
Is the linux version really using the FPU now? (It is no faster than it was
before I rebuilt the clisp!).

The only thing that we didn't do was use gcc-2.6 (which we don't have :-()
Is this a big bad mistake? (BTW we used gcc-2.5.8)

I've heard that Marcus is investigating GNU IUL for unboxing double-float
arrays for the FFI (foreign function interface), does this mean that we might
get unboxed double-float arrays in CLISP, i.e. faster math?

Well hopefully that's some food for thought.

Richard Shepherd,  Martin Glanvill

---

From: [email-masked] (Marcus Daniels)
Date: Thu, 18 Aug 94 05:08:51 PDT

>>>>> "RLS" == RLS  <[email-masked]> writes:

RLS> I've heard that Marcus is investigating GNU IUL for unboxing
RLS> double-float arrays for the FFI (foreign function interface),
RLS> does this mean that we might get unboxed double-float arrays in
RLS> CLISP, i.e. faster math?

Parc's ILU isn't going to help with boxing overhead for double-arrays.
Since the goal with unboxed double arrays is to avoid copying and
reformatting between LISP and foreign code, there is the assumption
that a shared format is used (e.g. IEEE).  That currently isn't the case.

Much of the cost in these types of loop is byte-interpreter overhead,
not the actual arithmetic.

The Alpha AXP, with unboxed single floats, may give you an idea of
boxing costs.

(defun test-integer (cnt)
  (let ((sum 0))
    (dotimes (x cnt) (incf sum 2))))

(defun test-float (cnt)
  (let ((sum 0.0))
    (dotimes (x cnt) (incf sum 2.0))))

(defun test-double (cnt)
  (let ((sum 0.0d0))
    (dotimes (x cnt) (incf sum 2.0d0))))

(compile 'test-integer)
(compile 'test-float)
(compile 'test-double)
(time (test-integer 1000000))
(time (test-float 1000000))
(time (test-double 1000000))

Alpha AXP:
(integer)
Real time: 16.448345 sec.
Run time: 7.51032 sec.
Space: 0 Bytes
(float)
Real time: 22.088549 sec.
Run time: 8.887456 sec.
Space: 0 Bytes
(double)
Real time: 49.657707 sec.
Run time: 19.948463 sec.
Space: 15999984 Bytes
GC: 27, GC time: 3.202256 sec.