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:45:23 -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=3YI8UflDnWoYTKi/6Z3jty0SCceX1cV3wjvEvgQmDws=; b=fVsIlENc/WVStrW99iOGDfP2Cs9vS3vsp1pjOUZbO9C73hlpOp+W9BtkdBUiJm0GKH Gsor5egSeonBZV85cRgUatYOAEgbzL0TknRdj8UoiS596DHjQ+Lgn57uPc7Y573IZwlz c80as/dZngtPNSsSBR61X0WIoeGG49hiEqFWhvhxQzhQU/Brokj2xIlKQXQcR3QOFdxZ i/12IMFT0BQKNhZmOyNgrL3ZBkpLWw6+PZvr9g4WRTpu2HRYTAAtsFvtVI5AN/vgA+79 Ai12mrVvQiNUMJNZORYWkjOll59TlDPo3jlPnM6M+MLfXyCHgoUt/8/ogIWSSnWryJ/g L5QQ==

2016-12-08 9:33 GMT-05:00 Francois Fayard <fayard@xxxxxxxxxxxxx>:

On Dec 8, 2016, at 3:21 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxxx> wrote:

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,BenoitHi Benoit.Automatic vectorization is difficult, but not hopeless. I agree that the compiler needs help from time to time, especially in C/C++ because of pointer aliasing. But Intel compilers do a lot with automatic vectorization. Since you look french, here is a video I have done for Intel showing the optimization of a code that relies completely on automatic vectorization : https://www.youtube.com/watch?v=pJbo6Z4NrgM&feature= . Sorry, I don’t have any english version yet.youtu.be

Thanks for the links! I'll watch it.

(Side note - pretty sure you were the math teacher of my younger brother Pierre at Janson-de-Sailly ;-) )

I'm serious though about how your analysis here is a pretty solid piece of evidence /against/ compiler auto-vectorization. Having to change the basic representation of the number or rows/columns to be pointers instead of integers would be a very intrusive change to make; regardless of the compatibility issue raised by Christoph, it simply isn't the way that the human programmer /wants/ to represent a matrix.

Also a question about your original email:

void f(Eigen::Matrix<Eigen::Index, Eigen::Dynamic, Eigen::Dynamic>& A)

void f(Eigen::Matrix<Eigen::Index, Eigen::Dynamic, Eigen::Dynamic>& A)

here you set the Scalar type to be the same as the Index type. That's a highly unusual usage pattern. The Index type is a pointer-sized integer, while in most applications the Scalar type is either floating-point or a narrower integer type. Do I understand correctly that the whole issue being discussed here is specific to this special case?

If one wanted to ensure that the Scalar type is a different C++ type from the Index type even when they both are integer types of the same size and signedness, one could wrap that integer type into a class providing the right arithmetic operators, and use that scalar type with Eigen::Matrix --- which supports arbitrary scalar types given the right interface:

https://eigen.tuxfamily.org/dox-devel/TopicCustomizing_CustomScalar.html

https://eigen.tuxfamily.org/dox-devel/TopicCustomizing_CustomScalar.html

François Fayard

Founder & Consultant - Inside Loop

**Follow-Ups**:**Re: [eigen] Eigen containers cannot be vectorized***From:*Francois Fayard

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

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

**Re: [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/ |