samedi 7 février 2015

Does homebrew GCC, or any other way of getting GCC on mac work with AVX out of the box?


if someone reading this question has a minute or two, might test the build of the following code:



#include <cstdint>
#include <x86intrin.h>
// some compiler feature tests used by makefile

typedef uint8_t vector_8_16 __attribute__ ((vector_size(16)));

static const vector_8_16 key16 = { 7, 6, 5, 4, 3, 2, 1, 0,
15, 14, 13, 12, 11, 10, 9, 8};

int main() {
vector_8_16 a = key16;
vector_8_16 b, c;

b = reinterpret_cast<vector_8_16>(_mm_shuffle_pd(a, a, 1));
c = _mm_xor_si128(b, a);
c = _mm_cmpeq_epi8(b, a);
c = _mm_andnot_si128(c, a);
return c[2] & 0;
}


with the following invocation:


gcc -std=c++11 -march=corei7-avx -flax-vector-conversions test.cc


At the moment, I tried gcc5 from this site: http://ift.tt/19eFMsm but it just doesn't work:



/var/folders/d8/m9xrbkrs2tj3x6xw_h0nmkn40000gn/T//ccXbpcH7.s:10:no such instruction: `vmovdqa LC0(%rip), %xmm0'
/var/folders/d8/m9xrbkrs2tj3x6xw_h0nmkn40000gn/T//ccXbpcH7.s:11:no such instruction: `vmovaps %xmm0, -16(%rbp)'
/var/folders/d8/m9xrbkrs2tj3x6xw_h0nmkn40000gn/T//ccXbpcH7.s:12:no such instruction: `vmovapd -16(%rbp), %xmm1'
/var/folders/d8/m9xrbkrs2tj3x6xw_h0nmkn40000gn/T//ccXbpcH7.s:13:no such instruction: `vmovapd -16(%rbp), %xmm0'
/var/folders/d8/m9xrbkrs2tj3x6xw_h0nmkn40000gn/T//ccXbpcH7.s:14:no such instruction: `vshufpd $1, %xmm1,%xmm0,%xmm0'


A few years ago, I managed to get gcc 4.7 working, after building from source, and replacing the assembler in /usr/bin/as with the one from gcc. But that endeavour took some days, and I'm not sure if it works with the current OSX and Xcode tools versions. I suspect this one has similar problems, either trying to use the same assembler as the one came with Xcode, and has a misunderstanding with it, or trying to use it's own assembler, which doesn't know about AVX . I'm not sure yet what exactly is the problem, my next hope ( before spending a few days hacking it to use a useful assembler ) is to try the brew GCC package.


Or, if anyone knows an easy way to bring GCC with AVX to life on mac OS X, I'm happy to hear about it. Note: clang I can already use, this question is specifically about GCC





Aucun commentaire:

Enregistrer un commentaire