Glas :Re: [glas] policy of mapping expressions to backend |
From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2006-01-23 01:48:46
Thus in case the backend to be used is configurable, what policies
should we envision to dispatch expressions to backend?
Suppose we have a BLAS backend, the expression `y+=a*x` will logically
be dispatched to an axpy. But what about the expression `y+=a*x+w` ? Do
we evaluate it with BLAS in two step (`y+=w;y+=a*x`) or do we evaluate
it with the generic backend since there's no _direct_ match with the
BLAS backend.
So which policy should we provide (or both)?
1) Only dispatch to a backend if the whole expressions matches exactly
one expression that is implemented by the backend
2) or should we try to match the whole expression with one or multiple
expressions that are implemented by the backend and thus trying to use
the preferred backend as much as possible.
Policy 1 works fine if we assume that a backend is only good at
evaluating the expressions that it directly supports while policy 2
assumes that one backend is in all cases far superior to another.
On the other hand when using policy 1, the interface to the backend
could be extended with expressions that are not _directly_ implemented
by the backend in case we know that it is nevertheless very good at
evaluating specific expressions. E.g. suppose we now that `y+=a*x+w` is
best evaluated with BLAS in two steps (instead of evaluating the
expression using a generic algo), we might list this expression to be
directly supported by the BLAS backend and thus force the dispatch of
the expression to the BLAS backend. The BLAS backend will on its turn
dispatch it to two BLAS calls.
Wolfgang Bangerth wrote:
>>The first option is that the user asks glas to automatically try to
>>dispatch all expressions to a specific backend. If the backend does not
>>provide a corresponding function, the expression will be evaluated by
>>the fallback (which is the glas implementation itself for instance).
>>For instance: If the user wishes to use BLAS as backend, writing
>>'y+=a*x' will automatically result in a call to axpy.
>
>
> I can't imagine why someone would want to use different backends in the same
> program. I would therefore proposed to take option 1. The way this is
> typically done is to give a switch at configure time:
>
> ./configure --with-backend=blas
> ./configure --with-backend=generic
> etc
>
> W.
>
> -------------------------------------------------------------------------
> Wolfgang Bangerth email: bangerth_at_[hidden]
> www: http://www.math.tamu.edu/~bangerth/
>
> _______________________________________________
> glas mailing list
> glas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/glas
>