This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1605 - fail to compile for 64bit QNX X86 target
Summary: fail to compile for 64bit QNX X86 target
Status: CLOSED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: General (show other bugs)
Version: 3.3 (current stable)
Hardware: x86 - 64-bit Other UNIX-like
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-01 09:19 UTC by Hui Zhang
Modified: 2019-12-04 17:59 UTC (History)
4 users (show)



Attachments

Description Hui Zhang 2018-10-01 09:19:38 UTC
Eigen 3.3.5 and all past versions can not be cross compiled for 64bit QNX X86 target.But can be compiled for 32bit QNX X86 target.

The error is as below, 

/home/richard/sambashare/Eigen/src/Core/arch/SSE/PacketMath.h:198:41: error: template-id 'padd<Eigen::internal::Packet4f>' for 'Eigen::internal::Packet4f Eigen::internal::padd(const Packet4f&, const Packet4f&)' does not match any template declaration
template<> EIGEN_STRONG_INLINE Packet4f padd<Packet4f>(const Packet4f& a, const Packet4f& b) { return _mm_add_ps(a,b); }
^
/home/richard/sambashare/Eigen/src/Core/arch/SSE/PacketMath.h:403:50: required from here
/home/richard/sambashare/Eigen/src/Core/GenericPacketMath.h:286:9: error: cannot convert 'const __vector(4) float' to 'float' in assignment
{ (*to) = from; }

My program is as below,

#include <Eigen/Dense>
int main(int argc, char **argv) {
return 0;
}

The more detailed info is as below link,

https://forum.kde.org/viewtopic.php?f=74&t=154098&p=404315#p404315
Comment 1 Christoph Hertzberg 2018-10-01 09:30:47 UTC
Not a solution but a possible workaround:

Can you compile with the following?
   -DEIGEN_DONT_VECTORIZE
(assuming QNX takes similar parameters as g++/clang++)

And do simple programs like these compile:

  #include <emmintrin.h>
  int main() {
    __m128 a, b;
    a = _mm_add_ps(a,b);
  }
Comment 2 Gael Guennebaud 2018-10-01 13:51:01 UTC
-DEIGEN_DONT_VECTORIZE should definitely works since it is working in 32 bits mode.

There seems to be something odd in the way __m128 is defined, I'm thinking about two possible workarounds:

1 - try to increase the ABI: -fabi-version=4 (not sure that's possible with QNX and this would only be a local workaround)

2 - in Eigen/src/Core/arch/SSE/PacketMath.h change line 31 from:

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

to

#if ((defined EIGEN_VECTORIZE_AVX) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_MINGW) && (__GXX_ABI_VERSION < 1004)) || EIGEN_OS_QNX

Please even if workaround #1 works for you, try the second solution too (without -fabi-version=4) so that we can patch Eigen accordingly.
Comment 3 Christoph Hertzberg 2018-10-01 14:11:59 UTC
I think `__vector(4) float` has been the definition of `__m128` in gcc since this was supported.

I guess the best solution would be to solve Bug 692 then (this would also make masking "-Wignored-attributes" warnings obsolete).
I'm marking this as dependent, but feel free to remove this if workaround 2 suggested by Gael also works.
Comment 4 Christoph Hertzberg 2018-10-01 14:15:54 UTC
Correction: The definition in gcc (at least in g++-5.4) is:

  typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));

But this also just adds an attribute to `float`
Comment 5 Gael Guennebaud 2018-10-01 14:44:36 UTC
Yes, it's not how __m128 is defined, but rather how it is taken into account by the ABI. On QNX, it seems that __m128 is not distinguishable from float, just like __m128 and __m256 are not distinguishable with __GXX_ABI_VERSION < 1004.
Comment 6 Hui Zhang 2018-10-01 14:51:58 UTC
-DEIGEN_DONT_VECTORIZE
my program works.

any negative effects?

(In reply to Christoph Hertzberg from comment #1)
> Not a solution but a possible workaround:
> 
> Can you compile with the following?
>    -DEIGEN_DONT_VECTORIZE
> (assuming QNX takes similar parameters as g++/clang++)
> 
> And do simple programs like these compile:
> 
>   #include <emmintrin.h>
>   int main() {
>     __m128 a, b;
>     a = _mm_add_ps(a,b);
>   }

(In reply to Christoph Hertzberg from comment #1)
> Not a solution but a possible workaround:
> 
> Can you compile with the following?
>    -DEIGEN_DONT_VECTORIZE
> (assuming QNX takes similar parameters as g++/clang++)
> 
> And do simple programs like these compile:
> 
>   #include <emmintrin.h>
>   int main() {
>     __m128 a, b;
>     a = _mm_add_ps(a,b);
>   }
Comment 7 Hui Zhang 2018-10-01 14:54:11 UTC
solution 1 does not work , same error with previous one.

Solution 2 works.

So should i use solution 2 or just simply add -DEIGEN_DONT_VECTORIZE
which one is better?

(In reply to Gael Guennebaud from comment #2)
> -DEIGEN_DONT_VECTORIZE should definitely works since it is working in 32
> bits mode.
> 
> There seems to be something odd in the way __m128 is defined, I'm thinking
> about two possible workarounds:
> 
> 1 - try to increase the ABI: -fabi-version=4 (not sure that's possible with
> QNX and this would only be a local workaround)
> 
> 2 - in Eigen/src/Core/arch/SSE/PacketMath.h change line 31 from:
> 
> #if (defined EIGEN_VECTORIZE_AVX) && (EIGEN_COMP_GNUC_STRICT ||
> EIGEN_COMP_MINGW) && (__GXX_ABI_VERSION < 1004)
> 
> to
> 
> #if ((defined EIGEN_VECTORIZE_AVX) && (EIGEN_COMP_GNUC_STRICT ||
> EIGEN_COMP_MINGW) && (__GXX_ABI_VERSION < 1004)) || EIGEN_OS_QNX
> 
> Please even if workaround #1 works for you, try the second solution too
> (without -fabi-version=4) so that we can patch Eigen accordingly.
Comment 8 Christoph Hertzberg 2018-10-01 14:58:40 UTC
`-DEIGEN_DONT_VECTORIZE` will disable (explicit) vectorization, so your code will likely run slower (auto vectorization is getting better on newer compilers, though).
So solution 2 from comment #2 is the best (quick) solution.
Comment 10 Hui Zhang 2018-10-02 00:32:04 UTC
Thank you Christoph and Gael for your great support.
Comment 11 Nobody 2019-12-04 17:59:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1605.

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