Re: [eigen] ei_redux_impl & ei_alignmentOffset |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] ei_redux_impl & ei_alignmentOffset
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Wed, 16 Dec 2009 07:49:15 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=fdcWE0UCdgytDNWajTSj7+f3oNjSbr/d5wQBew5BKdU=; b=OV0ybt/ynXVwigjUFHz8tX9ubpTTxhgBicVaJtbUsuT0cIkxYSpaTt7NyO9KjkNeOZ M6W3v9EcNsXPg7uKeADTSKnYgDDy1CovOt0WgQ3FT6j8+eCsotO87BxI1/Qi7z75JVDh UpYPKW4t5+trQGkzRMbz5xpsW7H5ukzyZ2mFE=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=vgmxZo4ISaVyqACK1Az4ZmcE/rZtfFv53av1HzV++mroxdPqhByDCvLK2sb4NaEzZA TugL7HVDGxudnNTbP+fsH/AkbRSh1fEJ+evkrzgSbV/r6m4WsyVgCLtmW/Ot3nxhOAOq iVxrDzXEPczYV+YKfXcHmbBYIvBHl/w57/KO0=
2009/12/16 Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx>:
> Hi,
>
> I am still every now and then looking at the inlining warnings created by
> MSVC (+1500). Here are some findings regarding a whole bunch of those
> warnings.
>
> Many many warnings we observe on MSVC (W4) are caused by this call here
> (taken from ei_redux_impl<Func, Derived, LinearVectorizedTraversal,
> NoUnrolling>::run)
>
> &mat.const_cast_derived().coeffRef(0)
>
> My most simple example to trigger this warning is
>
> #include <Eigen/Core>
> #include <Eigen/Array>
>
> using namespace Eigen;
>
> void main ()
> {
> typedef Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign>
> MatrixType;
> MatrixType a = MatrixType::Random(50,50);
> a.cwise().abs2().sum();
> }
>
> This call brings us to
>
> ei_redux_impl<Func, Derived, LinearVectorizedTraversal,
> NoUnrolling>::run(...)
>
> triggering the warning while the variable alignedStart is zero. I am
> wondering how I can create an example that actually causes alignedStart != 0
> ?? When I set the DontAlign option, I am ending up in a completely different
> branch.
To produce alignedStart!=0, you could do:
VectorXf v(1000);
v.end(999).sum();
>
> For testing purposes I added this code at the very beginning of the function
>
> const Scalar& s = mat.const_cast_derived().coeffRef(0);
>
> resulting in warning telling me that everything beyond this line is
> unreachable code. That is the case since derived() will end up in an
> infinite loop.
Do you mean const_cast_derived() ?
> Here is why:
>
> - mat is a CwiseUnaryOp< ei_scalar_abs2_op<float>, MatrixXf >
yes,
> - mat.const_cast_derived() calls MatrixBase< CwiseUnaryOp<
> ei_scalar_abs2_op<float>, MatrixXf > >
Yes, it calls MatrixBase::const_cast_derived(),
> and returns a CwiseUnaryOp<
> ei_scalar_abs2_op<float>, MatrixXf >
>
> and here we go - infinite loop.
Why ? Here, MatrixBase::const_cast_derived() is implemented like this:
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<MatrixBase*>(this)); }
So this call doesn't call anything itself, so where is the infinite recursion?
If you have an infinite recursion, you get a stack overflow. Is that
happening? Can you get a backtrace then? If the stack is damaged by
the overflow, try doing an assert() on the call depth using a static
int variable, then you'll get a good stack...
Benoit
> So there is something odd going on and I can
> understand that MSVC complains about inlining. Infinite inlining is rather
> tricky.
>
> Any ideas?
>
> - Hauke
>