|
Ublas : |
From: Ian McCulloch (ianmcc_at_[hidden])
Date: 2005-06-14 20:55:35
christopher diggins wrote:
>> I don't think the tradeoff's work that way. Whether aliases appear in an
>> expression depends purely on how the user writes it,
>
> It also depends on whether the library actually uses aliases in the first
> place.
What does it mean for the library to *use* aliases? How does the library
know whether arguments are aliases (except in some special cases) ?
>
>> the question is
>> whether the library gets the correct answer or not. The choices are:
>> always make a copy of the right-hand-side before assigning to the
>> left-hand-side. This will always give the correct answer, but at a
>> performance cost. This is the way uBLAS works. OR never make a copy of
>> the right-hand-side and require the user to handle potential aliasing
>> issues.
>
> Or never alias anything. Always correct and as I demonstrated, is more
> efficient than ublas for all of the basic operations.
What do you mean by "never alias anything"? How can the *library* choose
that?
>
>> In both cases, the default can be overridden - in the former by
>> providing an alternate syntax to perform the operation with a noalias
>> assumption, and in the latter by choosing a different algorithm (eg, to
>> copy backwards instead of forwards) or making an explicit copy.
>>
>> In one case, the default operation is slow and safe. In the other, the
>> default operation is fast and dangerous. None of the choices is both
>> unsafe and with a performance penalty.
>
> Having a library which uses aliasing doesn't buy you anything except
> saving against the occasional superflous copy (which isn't a problem when
> using blas routines). My point is that the superflous copy is less common
> than the basic operation (like indexing, or scalar multiplication, or
> matrix addition, or matrix multiplication) which I showed alread was more
> efficient doing naively.
Now I am lost: I thought the (often) superfluous copy that uBLAS performs is
what you were arguing against?
Cheers,
Ian