Error compiling with Eigen library

Hi,

Using PGI compiler 19.4.0 on DGX-1 system (Intel(R) Xeon(R) CPU E5-2630 v4), have a code which uses the Eigen library. When compiling I get errors as below relating to the SSE/PacketMath.h file in Eigen. FYI I can compile correctly with 18.4 version of compiler although it runs about 5x slower than the gcc version. I can also compile correctly using PGI 19.4.0 on a Power9 system (which doesn’t use SSE). Any suggestions appreciated.

"/home/username/Eigen/src/Core/arch/SSE/PacketMath.h", line 887: error: function
          "_mm_castpd_ps" has already been defined
  static inline __m128  _mm_castpd_ps   (__m128d x) { return reinterpret_cast<__m128&>(x);  }
                        ^

"/home/username/Eigen/src/Core/arch/SSE/PacketMath.h", line 888: error: function
          "_mm_castpd_si128" has already been defined
  static inline __m128i _mm_castpd_si128(__m128d x) { return reinterpret_cast<__m128i&>(x); }
                        ^

"/home/username/Eigen/src/Core/arch/SSE/PacketMath.h", line 889: error: function
          "_mm_castps_pd" has already been defined
  static inline __m128d _mm_castps_pd   (__m128  x) { return reinterpret_cast<__m128d&>(x); }
                        ^

"/home/username/Eigen/src/Core/arch/SSE/PacketMath.h", line 890: error: function
          "_mm_castps_si128" has already been defined
  static inline __m128i _mm_castps_si128(__m128  x) { return reinterpret_cast<__m128i&>(x); }
                        ^
"/home/username/Eigen/src/Core/arch/SSE/PacketMath.h", line 891: error: function
          "_mm_castsi128_ps" has already been defined
  static inline __m128  _mm_castsi128_ps(__m128i x) { return reinterpret_cast<__m128&>(x);  }
                        ^

"/home/username/Eigen/src/Core/arch/SSE/PacketMath.h", line 892: error: function
          "_mm_castsi128_pd" has already been defined
  static inline __m128d _mm_castsi128_pd(__m128i x) { return reinterpret_cast<__m128d&>(x); }

Hi pgraham,

It looks like Eigen has some work arounds in their code for PGI that are no longer needed since we’ve been working on adding better intrinsic support. In particular, the error you’re seeing is coming from the following in PacketMath.h:

#if EIGEN_COMP_PGI
// PGI++ does not define the following intrinsics in C++ mode.
static inline __m128  _mm_castpd_ps   (__m128d x) { return reinterpret_cast<__m128&>(x);  }
static inline __m128i _mm_castpd_si128(__m128d x) { return reinterpret_cast<__m128i&>(x); }
static inline __m128d _mm_castps_pd   (__m128  x) { return reinterpret_cast<__m128d&>(x); }
static inline __m128i _mm_castps_si128(__m128  x) { return reinterpret_cast<__m128i&>(x); }
static inline __m128  _mm_castsi128_ps(__m128i x) { return reinterpret_cast<__m128&>(x);  }
static inline __m128d _mm_castsi128_pd(__m128i x) { return reinterpret_cast<__m128d&>(x); }
#endif

But now that we do support these intrinsics, you get the redefinition errors.

While I don’t know if there will be other issues, for this problem I was able to work around it by unsetting the “EIGEN_COMP_PGI” macro at line 99 of “Eigen/src/Core/util/Macros.h”

/// \internal EIGEN_COMP_PGI set to 1 if the compiler is Portland Group Compiler
#if defined(__PGI)
  #define EIGEN_COMP_PGI 0  <<< change this to 0
#else
  #define EIGEN_COMP_PGI 0
#endif

Hope this helps,
Mat

1 Like