New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1363 - Compilation error from including headers on
Compilation error from including headers on
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - general
3.3 (current stable)
x86 - AVX Windows
: Normal Compilation Problem
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-12-14 15:41 UTC by Zsbán Ambrus
Modified: 2016-12-15 11:01 UTC (History)
3 users (show)



Attachments
complete error output and hello world executable (105.80 KB, text/plain)
2016-12-14 15:41 UTC, Zsbán Ambrus
no flags Details
All macros defined (as output by g++ with the same compliation options plus -E -dM except sorted) (90.53 KB, text/plain)
2016-12-15 10:00 UTC, Zsbán Ambrus
no flags Details
All macros defined (as output by g++ with the same compliation options plus -E -dM except sorted); ignore previous attachment, that was with the workaround -fabi-version=7 (90.53 KB, text/plain)
2016-12-15 10:01 UTC, Zsbán Ambrus
no flags Details

Description Zsbán Ambrus 2016-12-14 15:41:58 UTC
Created attachment 759 [details]
complete error output and hello world executable

I'm trying to compile a hello world program with gcc to windows x86_64.  I get a thousand line's worth of compilation errors from just including <Eigen/Core>.

The first error message is:

	In file included from ../eigen3/Eigen/Core:362:0,
			 from droppipe.cpp:1:
	../eigen3/Eigen/src/Core/arch/AVX/PacketMath.h:120:108: error: 'Packet Eigen::internal::pset1(const typename Eigen::internal::unpacket_traits<Packet>::type&) [with Packet = __vector(8) float; typename Eigen::internal::unpacket_traits<Packet>::type = float]' conflicts with a previous declaration
	 template<> EIGEN_STRONG_INLINE Packet8f pset1<Packet8f>(const float&  from) { return _mm256_set1_ps(from); }
														    ^
	In file included from ../eigen3/Eigen/Core:359:0,
			 from droppipe.cpp:1:
	../eigen3/Eigen/src/Core/arch/SSE/PacketMath.h:178:41: note: previous declaration 'Packet Eigen::internal::pset1(const typename Eigen::internal::unpacket_traits<Packet>::type&) [with Packet = __vector(4) float; typename Eigen::internal::unpacket_traits<Packet>::type = float]'
	 template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&  from) { return _mm_set_ps1(from); }
						 ^
	In file included from ../eigen3/Eigen/Core:362:0,
			 from droppipe.cpp:1:
	../eigen3/Eigen/src/Core/arch/AVX/PacketMath.h:120:41: note: -fabi-version=6 (or =0) avoids this error with a change in mangling
	 template<> EIGEN_STRONG_INLINE Packet8f pset1<Packet8f>(const float&  from) { return _mm256_set1_ps(from); }
						 ^


The compiler is windows gcc 4.8.3 targetting windows x86_64 with AVX instructions.  The compiler installation binary comes from win-builds 1.5.0 x86_64 windows (see "http://win-builds.org/doku.php").  Note though that win-builds contains multiple versions of gcc, including ones targetting MSYS and Cygwin.  This is the one that "C:\Win-builds\bin\c++.exe" starts.  The complete command line is

	wib g++ -std=c++1y -mtune=corei7-avx -mavx -fno-math-errno -Wall -Wextra -O2 -I ../eigen3 -pthread -o droppipe droppipe.cpp

where wib is a simple wrapper batch file that does set PATH=C:\Win-builds\bin;%PATH% so that the compiler can load its dynamic libraries.  

ChriSopht says the errors are because in this c++ mangling with gcc, __m128 and __m256 types are indistinguishable, but Eigen is supposed to have a workaround for this.

You can find the complete error output and the hello world source file in the attachment.
Comment 1 Gael Guennebaud 2016-12-14 16:15:06 UTC
Our workaround is not enabled for your system. Could you check the values of the following two macros:

EIGEN_COMP_GNUC_STRICT

__GXX_ABI_VERSION


The current check is:

#if (defined EIGEN_VECTORIZE_AVX) && EIGEN_COMP_GNUC_STRICT && (__GXX_ABI_VERSION < 1004)

Then, you should also be able to workaround with -fabi-version=4
Comment 2 Gael Guennebaud 2016-12-14 16:17:36 UTC
Knowing the value of EIGEN_COMP_MINGW might help too.
Comment 3 Christoph Hertzberg 2016-12-14 17:13:04 UTC
I see why I did not find the workaround, I was only looking in the AVX headers (but they are in src/Core/arch/SSE/PacketMath.h).
However, don't we need this workaround for AVX+AVX512 (i.e., Packet8f + Packet16f) as well?
Also, why do we wrap the Packet4f instead of Packet8f? Does this not break ABI compatibility when linking (pure) SSE code with AVX code?
Comment 4 Gael Guennebaud 2016-12-14 17:22:46 UTC
For AVX512 you need a recent compiler that use a higher ABI version by default.

Then regarding ABI compatibility, I don't see how Eigen::internal::Packet objects could be exchanged across binaries.
Comment 5 Zsbán Ambrus 2016-12-14 21:01:11 UTC
Re Christoph Hertzberg
> Also, why do we wrap the Packet4f instead of Packet8f? Does this not break ABI compatibility when linking (pure) SSE code with AVX code?

Re Gael Guennebaud
> Then regarding ABI compatibility, I don't see how Eigen::internal::Packet objects could be exchanged across binaries.

I think the problem is not about exchanging Packet objects.  Rather, it is trying to link two different functions from two different libraries with the same mangled name, one used in an object compiled for SSE code for __mm16, the other in another object compiled for AVX code for __mm32.  The two libraries don't exchange Eigen objects, because the Eigen representation is not the same in the two anyway (some matrix data is aligned differently), but the linker might get confused about the two different functions with the same name.
Comment 6 Zsbán Ambrus 2016-12-15 09:52:14 UTC
I've checked the values of the macros.

EIGEN_COMP_GNUC_STRICT has value 0
__GXX_ABI_VERSION has value 1002
EIGEN_VECTORIZE_AVX expands to empty
EIGEN_COMP_MINGW has value 1
Comment 7 Zsbán Ambrus 2016-12-15 10:00:12 UTC
Created attachment 760 [details]
All macros defined (as output by g++ with the same compliation options plus -E -dM except sorted)
Comment 8 Zsbán Ambrus 2016-12-15 10:01:52 UTC
Created attachment 761 [details]
All macros defined (as output by g++ with the same compliation options plus -E -dM except sorted); ignore previous attachment, that was with the workaround -fabi-version=7

Note You need to log in before you can comment on or make changes to this bug.