[eigen] Eigen containers cannot be vectorized |

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

*To*: eigen@xxxxxxxxxxxxxxxxxxx*Subject*: [eigen] Eigen containers cannot be vectorized*From*: Francois Fayard <fayard@xxxxxxxxxxxxx>*Date*: Thu, 8 Dec 2016 14:24:11 +0100

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 PS: I have found that if you change the type to double, it does not get vectorized too, but I have no idea why. |

**Follow-Ups**:**RE: [eigen] Eigen containers cannot be vectorized***From:*Daniel.Vollmer

**Re: [eigen] Eigen containers cannot be vectorized***From:*Joseph Mirabel

**Re: [eigen] Eigen containers cannot be vectorized***From:*Benoit Jacob

**Messages sorted by:**[ date | thread ]- Prev by Date:
**[eigen] Android/ARM** - Next by Date:
**RE: [eigen] Eigen containers cannot be vectorized** - Previous by thread:
**[eigen] Android/ARM** - Next by thread:
**RE: [eigen] Eigen containers cannot be vectorized**

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