Conflict overload with __m128, __m256 vector types in GCC

I started playing with AVX instructions on the new Intel Sandy Bridge processor. I am using GCC 4.5.2, TDM-GCC 64 bit version of MinGW64.

I want to overload the <<operator for ostream to be able to print vector types __m256, __m128etc. on the console. But I ran into an overloaded conflict. The second function in the following code generates a "conflict with previous declaration void f(__vector(8) float)" error :

void f(__m128 v) {
cout << 4;
}

void f(__m256 v) {
    cout << 8;
}

It seems that the compiler cannot distinguish between the two types and treats them like that f(float __vector).

Is there any way around this? I could not find anything on the Internet. Any help is appreciated.

+3
source share
2 answers

, . GCC :

-fabi-version=4 .

, , .

ABI (Application Binary Interface) GCC ABI ABI. ABI , . -, ABI- 3, GCC , .

+4

ABI , , . , Eigen - . http://eigen.tuxfamily.org/dox-devel/SSE_2PacketMath_8h_source.html

- :

template <typename T, unsigned RegisterSize>
struct Register
{
    using ValueType = T;
    enum { Size = RegisterSize };

    inline operator T&() { return myValue; }
    inline operator const T&() const { return myValue; }
    inline Register() {}
    inline Register(const T & v) : myValue(v) {} // Not explicit
    inline Register & operator=(const T & v)
    {
        myValue = v;
        return *this;
    }

    T myValue;
};

using Register4 = Register<__m128, 4u>;
using Register8 = Register<__m256, 8u>;
// Could provide more declarations for __m128d, __m128i, etc. if needed

, Register4, Register8 .. , Register, ABI.

0

All Articles