freepooma-devel
[Top][All Lists]
Advanced

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

Re: [pooma-dev] Yes, Vector temporaries do appear in every operation...!


From: Radek Pecher
Subject: Re: [pooma-dev] Yes, Vector temporaries do appear in every operation...!!
Date: Fri, 28 May 2004 12:20:18 +0100
User-agent: KMail/1.5.4

| Note that without your debugging stuff in the constructors, these
| get inlined and optimized away by the optimizer.  Of course one
| could argue creating the copies should be avoided in the first
| place, but I cannot see how this can be done, as, f.i. for
| BinaryOp<Vector1, Vector2, OpMultiply>::operator() we clearly need
| to return a _new_ Vector as result.  To avoid this one would have
| to expression-template the vector itself, so only primitive
| variable types are ever copied.  But I don't think this will work
| or pay off.


I actually compiled the code with the original (unmodified) version of 
Vector.h first and used GDB to run it and disassemble it. Without 
much analysing, I noticed several looping jumps at the place of the 
algebraic expression which only confirms that the optimising compiler 
did not produce the required code:
v2(0) = v1(0)*v1(0) + v1(0)*v1(0);
v2(1) = v1(1)*v1(1) + v1(1)*v1(1);
as was supposed to. (And I also tried several other optimisation 
configurations, of course.)

As to the need for the return of a Vector, I suppose that
Vector<2, double, BinaryVectorOp<...> > is all is needed (with the 
references to its two operands). There is no need at all to take this 
object and make its Full-engine copy for any subsequent operations.

reply via email to

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