gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Re: Help


From: Camm Maguire
Subject: Re: [Gcl-devel] Re: Help
Date: 16 Feb 2004 16:51:12 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!  I don't know what your code is (if you post it here
someone might be able to help you optimize it), but consider this
example from the gabriel benchmarks:

(defun tak (x y z)
  (declare (fixnum x y z))
  (cond ((not (< y x)) z)
        (t
         (tak
           (tak (the fixnum (1- x)) y z)
           (tak (the fixnum (1- y)) z x)
           (tak (the fixnum (1- z)) x y)))))

(disassemble 'tak)

Compiling gazonk0.lsp.
End of Pass 1.  

;; Note: Tail-recursive call of TAK was replaced by iteration.
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
Finished compiling gazonk0.lsp.

#include "cmpinclude.h"
#include "gazonk0.h"
void init_gazonk0(){do_init(VV);}
/*      function definition for TAK     */

static void L1()
{register object *base=vs_base;
        register object *sup=base+VM1; VC1
        vs_check;
        {register long V1;
        register long V2;
        register long V3;
        V1=fix(base[0]);
        V2=fix(base[1]);
        V3=fix(base[2]);
        vs_top=sup;
        goto TTL;
TTL:;
        if((V2)<(V1)){
        goto T2;}
        base[3]= CMPmake_fixnum(V3);
        vs_top=(vs_base=base+3)+1;
        return;
        goto T2;
T2:;
        {long V4;
        base[3]= CMPmake_fixnum((long)(V1)-1);
        base[4]= CMPmake_fixnum(V2);
        base[5]= CMPmake_fixnum(V3);
        vs_top=(vs_base=base+3)+3;
        (void) (*Lnk0)();
        vs_top=sup;
        V4= fix(vs_base[0]);
        {long V5;
        base[3]= CMPmake_fixnum((long)(V2)-1);
        base[4]= CMPmake_fixnum(V3);
        base[5]= CMPmake_fixnum(V1);
        vs_top=(vs_base=base+3)+3;
        (void) (*Lnk0)();
        vs_top=sup;
        V5= fix(vs_base[0]);
        base[3]= CMPmake_fixnum((long)(V3)-1);
        base[4]= CMPmake_fixnum(V1);
        base[5]= CMPmake_fixnum(V2);
        vs_top=(vs_base=base+3)+3;
        (void) (*Lnk0)();
        vs_top=sup;
        V3= fix(vs_base[0]);
        V2= V5;
        V1= V4;}}
        goto TTL;
        }
}
static void LnkT0(){ call_or_link(VV[0],(void **)(void *)&Lnk0);} /* TAK */

#ifdef SYSTEM_SPECIAL_INIT
SYSTEM_SPECIAL_INIT
#endif

....


Here you see the while the arithmetic and comparisons are done with
machine integers, arguments are passed via lisp objects.
(CMPmake_fixnum, L1 takes no C arguments, etc.)

Now add

(proclaim '(ftype (function (fixnum fixnum fixnum) fixnum) tak))

NIL

>(disassemble 'tak)

Compiling gazonk0.lsp.
End of Pass 1.  

;; Note: Tail-recursive call of TAK was replaced by iteration.
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
Finished compiling gazonk0.lsp.

#include "cmpinclude.h"
#include "gazonk0.h"
void init_gazonk0(){do_init(VV);}
/*      local entry for function TAK    */

static object LI1(V4,V5,V6)

register long V4;register long V5;register long V6;
{        VMB1 VMS1 VMV1
        goto TTL;
TTL:;
        if((V5)<(V4)){
        goto T2;}
        {long V7 = V6;
        VMR1((object)V7)}
        goto T2;
T2:;
        {long V8;
        V8= (long)(*(LnkLI0))((long)(V4)-1,V5,V6);
        {long V9;
        V9= (long)(*(LnkLI0))((long)(V5)-1,V6,V4);
        V6= (long)(*(LnkLI0))((long)(V6)-1,V4,V5);
        V5= V9;
        V4= V8;}}
        goto TTL;
}
static object  LnkTLI0(object first,...){object V1;va_list 
ap;va_start(ap,first);V1=call_proc_new(VV[0],(void **)(void 
*)&LnkLI0,86275,first,ap);va_end(ap);return V1;} /* TAK */


Here are the timing results I get for (time (tak 28 20 10)) for gcl
2.6.1, clisp and cmucl on the same box.  (I don't know how to do the
equivalent of function prototyping on clisp and cmucl)

         Interpreted      Compiled      Compiled with prototypes
GCL       125.07 sec.     1.73 sec.     0.37 sec.
CLISP     111.22 sec.     7.16 sec.
CMUCL     359.99 sec.     0.64 sec.

Would be nice to auto-prototype via inferencing at some stage.  I
think cmucl does something like this now.

Take care,


Eric <address@hidden> writes:

> --- Eric <address@hidden> wrote:
> > Is there some additional trick required in order to
> > get GCL to run as fast as CLISP?
> 
> Hello Again,
> 
> p.s.: I would even be happy to see a difference in
> runtime between an GCL compiled program with/without
> function prototypes.
> 
> I am to understand that providing function prototypes
> allows the compiler to optimize function calls by
> using the C-stack for passing function parameter
> values, instead of using the heap.
> 
> Am I all washed up on this?
> 
> --Eric
> 
> 
> 
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gcl-devel
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

[Prev in Thread] Current Thread [Next in Thread]