[eigen] ei_redux_impl & ei_alignmentOffset

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


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.

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. Here is why:

- mat is a CwiseUnaryOp< ei_scalar_abs2_op<float>, MatrixXf >
- mat.const_cast_derived() calls MatrixBase< CwiseUnaryOp< ei_scalar_abs2_op<float>, MatrixXf > > and returns a CwiseUnaryOp< ei_scalar_abs2_op<float>, MatrixXf >

and here we go - infinite loop. So there is something odd going on and I can understand that MSVC complains about inlining. Infinite inlining is rather tricky.

Any ideas?

- Hauke


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/