freepooma-devel
[Top][All Lists]
Advanced

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

Re: [Freepooma-devel] A question about code for computation of Tensor de


From: Richard Guenther
Subject: Re: [Freepooma-devel] A question about code for computation of Tensor determinant
Date: Thu, 28 Jan 2010 00:24:58 +0100
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109)

ali rostai wrote:
> Hi Richard,
> Thanks for your useful notes.
> 
> 1. As I know expression templates support is needed
> when we want to loop over elements of an array and don't
> want to use a "for" construct explicitly, So If I stick to using
> usual for construct, is it safe to use t.getIJ<0,0>() instead of
> t(0,0)?

I suppose so.  AFAIK one is just a wrapper for the other.

> 2. Even we keep the t(0,0), the operator() of the class is
> an inline function and the optimizer of gcc probably is able to
> make the result equivalent to t.getIJ<0,0>()?

Yes.

> 3. It has been always a question for me that how can I find
> the compiler has successfully Inlined a function that I have
> marked it as inline?

Well, it's not easy to verify in a large application, but for
example GCC offers diagnostics for missed inlinings for inline
declared functions (-Winline).  You can also always consult
the generated assembly - even though that's a little verbose
and tedious to verify.  GCC also offers dumps of its
intermediate language in several optimization stages - a
dump that is not too bad to look at is that after tree
optimization finished, -fdump-tree-optimized.  Note that
with C++ templated functions are sometimes hard to spot,
the -asmname dump modifier dumps mangled names to assist here.

Richard.

> Regards,
> Ali
> 
> 
> On Wed, Jan 27, 2010 at 1:08 AM, Richard Guenther
> <address@hidden <mailto:address@hidden>> wrote:
> 
>     ali rostai wrote:
>     > Hi,
>     >
>     > In file "Tiny/TensorOperators.h" the following code has
>     > been used for computation of Tensor determinant.
>     > -------------------------------------------------
>     > // Partial specializations for D={1,2,3}
>     > template<class T, class E>
>     > inline T
>     > det(const Tensor<3,T,E>& t)
>     > {
>     >   T result;
>     >   result =
>     >     t(0,0)*(t(1,1)*t(2,2) - t(1,2)*t(2,1)) +
>     >     t(0,1)*(t(1,2)*t(2,0) - t(1,0)*t(2,2)) +
>     >     t(0,2)*(t(1,0)*t(2,1) - t(1,1)*t(2,0));
>     >   return result;
>     > }
>     > ---------------------------------------------------
>     > as I know the t(0,0) is a runtime call,
>     > why  the member function template "getIJ()" has not been
>     > used? I mean a code like this
>     > t.getIJ<0,0>()
> 
>     It is because TensorOperators.h (and other Tiny classes) do not fully
>     use expression templates.  There is a patch on the patch-tracker
>     to fix this up for vectors (if I remember correctly) - the interaction
>     with the Array expression templates is complicated though.
> 
>     It's an area that needs to be reworked a lot.
> 
>     Richard.
> 
>     > Regards
>     > Ali Roustaei
>     >
>     >
>     >
>     ------------------------------------------------------------------------
>     >
>     > _______________________________________________
>     > Freepooma-devel mailing list
>     > address@hidden <mailto:address@hidden>
>     > http://lists.nongnu.org/mailman/listinfo/freepooma-devel
> 
> 





reply via email to

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