Boost logo

Ublas :

From: Ian McCulloch (ianmcc_at_[hidden])
Date: 2005-06-14 17:04:41


christopher diggins wrote:

> If I wrote a patch it would involve creating a new namespace:
>
> boost::numeric::ublas::unaliased
>
> and writing unaliased versions of all the library. I would then move the
> existing library into a boost::numeric::ublas::aliased namespace and
> petition for the unaliased namespace to become the default version of the
> library when aliased/unaliased is not specified.
>
> I wonder if the community would actually support such a bold action? This
> way people can stop telling new users "in order to get acceptable
> performance out of basic operations you must somehow assure aliasing isn't
> occuring and then write noalias(x)". What offends me most off about people
> recommending noalias(x), is the misguided idea that knowing when it is
> safe to use noalias is a trivial task for a casual user of the library.

I don't understand that: are you arguing that it is too hard for casual
users to determine aliasing constraints, while at the same time arguing
that unaliased should become the default?

FWIW, I have pretty much come to the conclusion that noalias should be the
default, but my reasons are (1) I think it IS easy, in *most* cases, to
determine when incorrect aliasing occurs - I guess Fortran programmers
learn very quickly, and (2) even if there is an aliasing problem, it is not
necessarily most efficient to copy the final expression. There are some
cases where making a copy of a subexpression would suffice. And (3) in
debug mode, the assignment operators can compute the expression both ways
and assert that the result is the same.

Cheers,
Ian