Re: [eigen] Eigen containers cannot be vectorized

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


I don't have my computer with me tonight (writing from an iPad). But I am quite sure that:
#pragma omp simd
should work. As it is also portable, it might be the best solution. But this kind of loop could be vectorized automatically by most compilers and it is too bad it does not work with Eigen.

Let me explain why I have started this conversation. Many people work on numerical analysis in C++. As you know, there is no multidimensional array in the standard library (which is a shame, by the way). Many people around me ask for such a library and they end up with Linear Algebra libraries such as Eigen. Then Tensor module might even push more people into this direction. I know that Eigen has not been designed to be a multidimensional array library, but it does the job pretty well. It also comes with nice pretty printers for gdb, and does not depend on Boost. As far as I know, it is the only mature library that fullfill those requirements.

Unfortunately, it does play nicely with auto-vectorisation. That's why I was suggesting to make this change so make Eigen better on that matter. Unfortunately, the problem seems to be much more difficult to handle. As I have said, I personaly use my own library, but it would be nice to get better auto-vectorisation for those who use Eigen as a multidimensional array package.


On 2016-12-08 21:22, Jeff Hammond wrote:
You might try one of the following pragmas to inform the compiler to
ignore aliasing in the loop nest.  I haven't tested your code, so I
apologize if none of these work.

#pragma ivdep (or #pragma GCC ivdep, in the case of GCC) is supported
by many compilers.  I don't have know the full list
(https://github.com/jeffhammond/nwchem-tce-triples-kernels/blob/master/src/pragma_vendor.h
[5] lists all the ones I knew at some point, and Google tells me MSVC
supports it too).  In any case, it is easy enough to write build
system tests for this sort of thing.

#pragma simd is an Intel compiler keyword.  See
https://software.intel.com/en-us/node/524555 [6] for details.  The
Intel compiler takes this pragma (and the OpenMP equivalent noted
below) seriously and will generate vector code when you use these,
even in cases where the heuristics say it isn't beneficial.

#pragma omp simd is part of OpenMP 4 but you can get it and only it
from GCC and Intel via -fopenmp-simd and -qopenmp-simd, respectively.
See
https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/C-Dialect-Options.html
[7] for details on GCC.

Best,

Jeff




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