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: Richard Guenther
Subject: Re: [pooma-dev] Yes, Vector temporaries do appear in every operation...!!
Date: Fri, 28 May 2004 12:53:57 +0200 (CEST)

On Fri, 28 May 2004, Radek Pecher wrote:

>
> 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.

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.

Or do yoy have different ideas?

Richard.

> 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.
>

--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/

reply via email to

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