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

Re: performance for scientific computing




"Andreas Bogk" <andreas@andreas.org> wrote in message
87ofq0f1vx.fsf@teonanacatl.andreas.org">news:87ofq0f1vx.fsf@teonanacatl.andreas.org...
> "Sébastien de Menten" <sdementen@hotmail.com> writes:
>
> > But is it possible to extend Dylan in C or C++ ?
>
> It is, but often enough doesn't make sense. Our tests showed that a
> Sieve of Eathostenes written in Dylan is only 10% slower than one
> written in C.
>
> But I cannot really follow what you want to do. After all, calculation
> of A*A always requires allocation of a matrix holding the
> result. Maybe you should describe your requirements again.
>
That is true for A*A but when we want to compute C=A*A+cos(A), you need only
to allocate memory for C and nothing more:
//    efficient computation
    allocate(C)
    for (i,j,k)
        C(i,j,k) = A(i,j,k)*A(i,j,k) + cos(A(i,j,k))
    end for
//    end efficient computation
and if C is already allocated, you don't need anything...
This is to contrast with what happens when you treat each operator
(+,*,=,cos) sequentially:
//    inefficient computation
    allocate(T1)
    for (i,j,k)
        T1(i,j,k) = A(i,j,k)*A(i,j,k)
    end for
    allocate(T2)
    for (i,j,k)
        T2(i,j,k) = cos(A(i,j,k))
    end for
    allocate(T3)
    for (i,j,k)
        T3(i,j,k) = T1(i,j,k) + T2(i,j,k)
    end for
    allocate(C)
    for (i,j,k)
        C(i,j,k) = T3(i,j,k)
    end for
//    end inefficient computation

Seb





Follow-Ups: References: