Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSE4.1 intrinsics compilation error on Mac

I'm having some trouble using SSE4.1 intrinsics on hardware that (I think) supports it. Can anyone tell me if I've missed something?

Building the following code on a MacBookPro5,4 (Penryn):

>g++ -msse sse4.cpp -S -o sse4.asm

#include <stdio.h>
#include <smmintrin.h>

int main ()
{
    __m128 a, b;
    const int mask = 0x55;

    a.m128_f32[0] = 1.5;
    a.m128_f32[1] = 10.25;
    a.m128_f32[2] = -11.0625;
    a.m128_f32[3] = 81.0;
    b.m128_f32[0] = -1.5;
    b.m128_f32[1] = 3.125;
    b.m128_f32[2] = -50.5;
    b.m128_f32[3] = 100.0;

    __m128 res = _mm_dp_ps(a, b, mask);

    printf_s("Original a: %f\t%f\t%f\t%f\nOriginal b: %f\t%f\t%f\t%f\n",
                a.m128_f32[0], a.m128_f32[1], a.m128_f32[2], a.m128_f32[3],
                b.m128_f32[0], b.m128_f32[1], b.m128_f32[2], b.m128_f32[3]);
    printf_s("Result res: %f\t%f\t%f\t%f\n",
                res.m128_f32[0], res.m128_f32[1], res.m128_f32[2], res.m128_f32[3]);

    return 0;
}

Generates the following error:

/usr/lib/gcc/i686-apple-darwin10/4.2.1/include/smmintrin.h:35:3: error: #error "SSE4.1 instruction set not enabled"
like image 800
Justicle Avatar asked Sep 20 '10 18:09

Justicle


2 Answers

Change:

g++ -msse sse4.cpp -S -o sse4.asm

to:

g++ -msse4.1 sse4.cpp -S -o sse4.asm

like image 75
Paul R Avatar answered Sep 19 '22 03:09

Paul R


Did you try g++ -msse4.1 ?

like image 25
Pascal Cuoq Avatar answered Sep 18 '22 03:09

Pascal Cuoq