Yes, Vector temporaries do appear in every operation...!!
Radek Pecher
radek.pecher at eng.ox.ac.uk
Fri May 28 10:34:52 UTC 2004
I installed the latest GCC (v 3.4) and ran again the test described in
my previous email titled "Temporary copies do appear...??"
(using the optimisation flags from /config/arch/LINUXgcc.conf).
To my disappointment, the temporary Full-engine copies of the three
subexpressions in the Vector expression v1*v1 + v1*v1 do get created.
Here is an excerpt of the main code and the output from Vector.h which
was modified by replacing {} of all the Vector-constructors by
{PrintTypeName(this);} :
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Vector<2> v1(1, 2), v2;
v2 = v1*v1 + v1*v1;
====================================================================
Vector<2, double, Full>*
Vector<2, double, Full>*
Vector<2, double, BinaryVectorOp<Vector<2, double, Full>,
Vector<2, double, Full>, OpMultiply> >*
Vector<2, double, Full>*
Vector<2, double, BinaryVectorOp<Vector<2, double, Full>,
Vector<2, double, Full>, OpMultiply> >*
Vector<2, double, Full>*
Vector<2, double, BinaryVectorOp<Vector<2, double, Full>,
Vector<2, double, Full>, OpAdd> >*
Vector<2, double, Full>*
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
I also tried the same test for the class Array; the corresponding code
and output follow:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Array<1> a1(2, ModelElement<double>(10)), a2(2);
a2 = a1*a1 + a1*a1;
====================================================================
Array<1, double, Brick>*
Array<1, double, Brick>*
Array<1, double, ExpressionTag<BinaryNode<OpMultiply,
Reference<Array<1, double, Brick> >, Reference<Array<1,
double, Brick> > > > >*
Array<1, double, ExpressionTag<BinaryNode<OpMultiply,
Reference<Array<1, double, Brick> >, Reference<Array<1,
double, Brick> > > > >*
Array<1, double, ExpressionTag<BinaryNode<OpAdd,
BinaryNode<OpMultiply, Reference<Array<1, double, Brick> >,
Reference<Array<1, double, Brick> > >, BinaryNode<OpMultiply,
Reference<Array<1, double, Brick> >, Reference<Array<1,
double, Brick> > > > > >*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, ExpressionTag<BinaryNode<OpAdd,
BinaryNode<OpMultiply, Array<1, double, BrickView>,
Array<1, double, BrickView> >, BinaryNode<OpMultiply,
Array<1, double, BrickView>, Array<1, double,
BrickView> > > > >*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, BrickView>*
Array<1, double, ExpressionTag<BinaryNode<OpAdd,
BinaryNode<OpMultiply, Array<1, double, BrickView>,
Array<1, double, BrickView> >, BinaryNode<OpMultiply,
Array<1, double, BrickView>, Array<1, double,
BrickView> > > > >*
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Clearly, for the Array-case, there are no instantiations in between
the ExpressionTag-based Array-constructors (although there are a
number of BrickView-based calls later, these represent references,
not copies; the only full-memory arrays are those with engine Brick).
Unlike the Array-case, however, the Vector-case does exhibit
Full-engine instantiations between the BinaryVectorOp-based calls.
That may indicate a serious flaw in the design of the tiny classes...
As to myself, I am going to write my own PETE-based tiny classes (the
POOMA versions seem to me unnecessarily too complicated for their
actual purpose). Nevertheless, if someone knows how to prevent such
odd behaviour (which clearly defies one of the main POOMA goals, i.e.
to get rid of unnecessary memory copying), it would be appreciated.
More information about the pooma-dev
mailing list