octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove all do_inplace* logic from C++


From: John W. Eaton
Subject: Re: Remove all do_inplace* logic from C++
Date: Thu, 16 May 2013 02:25:30 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11

On 05/15/2013 11:36 AM, Jordi GutiƩrrez Hermoso wrote:
Now that I've actually gotten bitten by this, I want to fix it:

     https://savannah.gnu.org/bugs/?38466

But now I remember why I did it this way in the first place. An
erstwhile Octave developer had decided to dubiously optimise Octave's
in-place operators (i.e. "a OP= b" instead of "a = a OP b") to
actually also be written in-place in C++. However, after doing some
testing by compiling with g++ -O2 and decompiling the results, it
looks like gcc is smart enough to compile both "a OP= b" and "a = b OP
a" into the same damn thing. My test was simplistic, but I don't think
there is any actual benefit to using in-place operators in C++, and
they're needlessly cluttering our code:

     http://codepad.org/YtkJflcV

In particular, they're making it more difficult for me to patch
#38466. Note that Octave's in-place operators are meant to be pure
syntactic sugar, and they are supposed to behave exactly like their
expanded versions.

Any objection to completely removing all of the inplace logic from C++?

I thought Jaroslav would have posted some timings related to this change, but as you and I discussed on #octave, I can't seem to find any. OTOH, there is this bug report:

  https://savannah.gnu.org/bugs/?35400

So now I'm a bit confused because the way I read the assignment functions in ov.cc, A op= B is handled by first computing a value (call it V) for A (including any indexing operations), then computing V op B and assigning it to A (again with any indexing that is part of the expression A). So at this point, I'm not sure where the in-place operation is recognized. But apparently it is, because there is some difference in speed as pointed out by bug report 35400.

Also, since Octave is an array language, one thing to keep in mind is that an in-place operation can save the memory allocation of the temporary storage required to hold the RHS value that is the result of computing V op B.

Anyway, what about the bug report 38466 are you trying to fix?

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]