|
Boost : |
Subject: Re: [boost] [xint] Boost.XInt formal review (concrete complaint)
From: Ryo IGARASHI (rigarash_at_[hidden])
Date: 2011-03-07 03:04:27
Hi,
I would like to comment only on the issue with Expression Template (ET).
On Mon, Mar 7, 2011 at 4:29 PM, Chad Nelson
<chad.thecomfychair_at_[hidden]> wrote:
>>>> Whether you make one unneeded allocation or two is a less important
>>>> consideration than whether you make one or zero since 2/1 is a lot
>>>> smaller than 1/0. If a temporary is generated by the user's code
>>>> they have already pessimized their code. I am sorry, but you
>>>> cannot avoid allocation with a return by value semantic, only
>>>> expression templates allows you to reuse the storage on the left
>>>> hand side of the assignment operator. [...]
>>>
>>> I'm not familiar with a use of expression templates that would allow
>>> that. Can you point me to something explaining it?
>>
>> Expression templates would allow you to tell the compiler, when it
>> sees
>>
>> x = a + b,
>>
>> to generate code that replaces x's digits with the sum of a's and b's
>> digits, one at a time. [...]
>
> How would the expression's code know anything about x, or have access
> to its allocated memory? If the template is operator+, you'd have to
> pass x to it somehow. If it's not, operator+ would have to allocate
> some memory for a temporary, wouldn't it?
>
>> google "c++ expression templates" and/or look at Boost.Proto and
>> libraries that use Boost.Proto.
>
> I haven't looked at Boost.Proto yet, but I did look at a couple hits
> from Google on the subject in the last couple days. Maybe I'm missing
> it, but I didn't see anything that would allow that.
As Xint is an numerical library and you are the author of it,
you may be familiar with ET usage in Boost.uBLAS than Boost.Proto
(the latter is very generic). Eliminating temporaries from multiple
huge matrix addition
and multiple "big integer" addition seems similar thing to me.
uBLAS library also takes advantage of splitting interface over
internal data structure
(of matrix elements), since you can easily think of internal storage
(dence, triangular, sparse, etc.), and many of them are implemented
can be easily
passed to external linear algebra library (BLAS, LAPACK, etc.)
Best regards,
-- Ryo IGARASHI, Ph.D. rigarash_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk