gcl-devel
[Top][All Lists]
Advanced

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

Re: [Gcl-devel] Re: Compiling floating point loops to blas calls


From: Raymond Toy
Subject: Re: [Gcl-devel] Re: Compiling floating point loops to blas calls
Date: 24 Jul 2002 14:40:40 -0400
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.5 (broccoflower)

>>>>> "Camm" == Camm Maguire <address@hidden> writes:

    Camm> Greetings!
    Camm> Raymond Toy <address@hidden> writes:

    >> >>>>> "Camm" == Camm Maguire <address@hidden> writes:
    >> 
    Camm> 1) What are the "top" five ways a lisp programmer would write a matrix
    Camm> multiply?
    >> 
    >> If I have a small matrix and don't want the baggage of matlisp, I just
    >> write it out.  But if I need something more like an inverse, or solve
    >> a system of equations, I'd use matlisp.
    >> 

    Camm> OK.  I know this is embarrasing, but how would you as a working lisp
    Camm> programmer 'write it out'?  Do you use dotimes? dolist? loop? sloop?
    Camm> What is the most conventional way to refer to the elements of a 2d
    Camm> array?  (aref .... (+ (* lda r) c)), or something else? 

For the quick and dirty, I'd use "real" 2D arrays (and not the "fake
2D arrays via 1D arrays" thing), and I'd probably use dotimes for the
loop counters, but loop would be ok too.

    Camm> 3) How much lisp code is out there using numerical floating point?
    Camm> How much is "open source"?
    >> 
    >> Well, if you allow using f2cl to convert Fortran to Lisp, then there's
    >> a lot of code out there. :-) Otherwise, I think it's fairly limited
    >> and certainly not like the Fortran or even C numerical libraries.
    >> 

    Camm> OK, so it seems this project should be on the back burner.  Though it
    Camm> really would show off the power of a lisp compiler, I'd think, and
    Camm> without all the overhead of writing the optimized blas directly, as
    Camm> its already widely available via atlas.

Actually, I think you can still show off the power of Lisp by
appropriate use of macros:

        ;; x = a*b+c
        (mat-assign x (mat-add (mat-mul a b) c))

A bit messy, but what this could do is, at compile time, mat-assign
could look at the rhs (2nd arg) and grovel over that and see that this
could be converted to a single blas call (I think).  Or if you somehow
knew the dimensions at compile time,

        ;; x = a*b*c
        (mat-assign x (mat-mul a (mat-mul b c))

could be rearranged so that the multiplies could be done in some
optimal fashion.  (On the other hand, since FP arithmetic is not
associative, you may not really want this.)  I guess this could also
be done at run-time with some performance hit for the checking with
the hopes of really big payoffs doing the multiplications in the right
order.

I think the C++ package newmat does some of these things reasonably
neatly.

There are lots of things like this that can be done.  Unfortunately,
I'm not smart enough to do these.

Ray



reply via email to

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