RE: [eigen] Eigen containers cannot be vectorized

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


Hi Francois,


Isn't that something where one would rather use (non-standard) __restrict__?


Best regards

Daniel Vollmer

--------------------------
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
German Aerospace Center
Institute of Aerodynamics and Flow Technology | Lilienthalplatz 7 | 38108 Braunschweig | Germany

Daniel Vollmer | AS C²A²S²E
www.DLR.de

Von: Francois Fayard [fayard@xxxxxxxxxxxxx]
Gesendet: Donnerstag, 8. Dezember 2016 14:24
An: eigen@xxxxxxxxxxxxxxxxxxx
Betreff: [eigen] Eigen containers cannot be vectorized

Hi,

I have found that Eigen containers cannot be vectorized. For instance, the following code:

#include <Eigen/Dense>

void f(Eigen::Matrix<Eigen::Index, Eigen::Dynamic, Eigen::Dynamic>& A) {
  for (Eigen::Index j = 0; j < A.cols(); ++j) {
    for(Eigen::Index i = 0; i < A.rows(); ++i) {
      A(i, j) = i + j;
    }
  }
}

is not vectorized by the Intel compiler. It says that the iteration count cannot be computed before the execution of the loop.

It is due to the fact that A is made of:
Eigen::Index* data_;
Eigen::Index cols_;
Eigen::Index rows_;
The compiler has no way of knowing that data_ does not point to rows_. As a consequence, it does not know that the operation A(i, j) = i + j does not change the number of rows of A. As a consequence, the loop is not countable and cannot be vectorized.

One way to fix this, would be to store the number of columns as a pointer. If cols_ becomes a Eigen::Index* such that the number of columns is cols_ - data_, the problems get fixed, and compilers can know vectorize the inner loop.

Best regards,

François Fayard
Founder & Consultant - Inside Loop
Applied Mathematics & High Performance Computing
Tel: +33 (0)6 01 44 06 93
Web: www.insideloop.io

PS: I have found that if you change the type to double, it does not get vectorized too, but I have no idea why.


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