Re: [eigen] Eigen containers cannot be vectorized

[ Thread Index | Date Index | More Archives ]

Hi Joseph,

what about this:

#include <Eigen/Dense>

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

I was too quick to reply. It does not work, compiled with

icpc -c -std=c++11 -O3 -xHost -DNDEBUG

I can’t really explain what is going on. I have tried to walk the accessor (A(i, j)) through the debugger, and it is not straightforward code for the compiler. There is a pointer cast that might disconnect any optimizer. So, I can’t easily provide you with a solution.

I was also surprised to see that in debug mode, bounds checking is done with: assert(i >=0 && i < n). This can be optimized into assert(static_cast<std::size_t>(i) < static_cast<std::size_t>(n)).

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

Mail converted by MHonArc 2.6.19+