Re: [eigen] Eigen containers cannot be vectorized |

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

*To*: eigen <eigen@xxxxxxxxxxxxxxxxxxx>*Subject*: Re: [eigen] Eigen containers cannot be vectorized*From*: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>*Date*: Thu, 8 Dec 2016 09:21:37 -0500*Dkim-signature*: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=mpQuHjqsrLFUZji0KvT9N2X11W/MfbpGcyR08hby18A=; b=q8sX7G/iGjGqmqOvJubliSg9bClihVE3dDQK0I0bbGo4ke77PHZbC1xG0Isjw+W2x+ yY13Bopv8LuT9NY02Ev9NDD6Zz+lDBvu9FPRKncVQAWSRpV3kNFy4JsMsitosgpOi4ee KVbD5LsgDNVtjQoTVfc5vBmyUvp2UXu1nH8cVMODsE6Eujo0rBuns17U3kglrQsh9GmB jJFML9frVG89Yvlx8Mk0BoGjY3NycEV2BBs5deXgCN8znnzU8nyk7UkEkvyy3G7jyf3g hknBPOLRjfkKe8OzaFWuIqGNgIpffTxmNFUoXn4dt940A11Fa080fPMD94Y219pzQVLh weSw==

2016-12-08 8:24 GMT-05:00 Francois Fayard <fayard@xxxxxxxxxxxxx>:

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.

Interesting analysis!

I would draw a different conclusion from it though: compiler auto-vectorization is hopeless :-)

Which is why explicitly-vectorized code like Eigen exists :-)

Cheers,

Benoit

Best regards,François Fayard

Founder & Consultant - Inside LoopPS: 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:*Francois Fayard

**Re: [eigen] Eigen containers cannot be vectorized***From:*Matthieu Brucher

**References**:**[eigen] Eigen containers cannot be vectorized***From:*Francois Fayard

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

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