Boost logo

Glas :

[glas] mapping expressions to backend

From: Toon Knapen (toon.knapen_at_[hidden])
Date: 2006-01-17 06:18:24

As stated from the beginning, see , we plan to support
multiple backends. Thus using the glas-interface, the expressions might
be mapped to the glas-implementation but also to BLAS-calls or any other
optimised backend.

And since we are starting to implement expressions, my question now is:
How will the user have to specify the desired backend?

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.

A second option is that the user needs to indicate explicitly the
backend to be used for evaluating a specific expression. For instance by
writing 'y+=mult<blas>(a,x)' or 'y+=blas(a*x)' or 'add_assign<blas>(y,a*x)'

A third option is that the user just calls a high-level binding
directly. For instance 'blas::axpy(y,a,x)'.

The third option is the least ambiguous (in respect to options 1 and 2,
see later) but also the least syntactically transparant. But do we need
syntactic transparancy? And after all, the implementation of 1 and 2
will have to use such a high-level binding anyway.

The first option is syntactically transparant but might result in
ambiguous situations: For instance what if the user writes 'y = a*x +
w'. Should that result in w first being copied to y followed by an axpy
or should that result in an error or should that result in the
expression being evaluated by the fallback implementation?

The main difference between option 1 and 2 is that option 1 requires a
system-wide setting while option 2 requires the backend to be specified
for each and every expression.

What do you prefer?


Toon Knapen
Skype Name: toonknapen
Axis Park Louvain-la-Neuve
rue Emile Francqui, 1
B-1435 Mont-Saint Guibert - BELGIUM
Same telephone, same fax, same mail
Check out our training program on acoustics
and register on-line at