2

I'm trying to play around with SSE intrinsics. I have made a test program that just adds two vectors with four 16 bit elements together.

#include <xmmintrin.h>
#include <iostream>
using namespace std;

void test_vec_add(){
  const int length = 4;
  float product[128*4]  __attribute__ ((aligned(16)));
  _m128 x = _mm_set_ps(1.0f,2.0f,3.0f,4.0f);
  _m128 y = _mm_set_ps(1.0f,2.0f,3.0f,4.0f);
  _m128 z = _mm_add_ps(x,y);
  _mm_store_ps(product,z);
}
int main(){
  test_vec_add();
}

I'm compiling this code with

g++ -msse3 test_sse.cpp

However, I'm getting the following complication error

test_sse.cpp: In function ‘void test_vec_add()’:
test_sse.cpp:7:3: error: ‘_m128’ was not declared in this scope
test_sse.cpp:7:9: error: expected ‘;’ before ‘x’
test_sse.cpp:8:9: error: expected ‘;’ before ‘y’
test_sse.cpp:9:9: error: expected ‘;’ before ‘z’
test_sse.cpp:10:24: error: ‘z’ was not declared in this scope
test_sse.cpp: In function ‘int main()’:
test_sse.cpp:15:20: error: ‘test_vec_add’ was not declared in this scope

Its probably a really goofy mistake, but I can't put my finger on where it is. Any help would be greatly appreciated.

4
  • 1
    Is that the program you compiled? I don't see a printf in there. Nov 14, 2012 at 7:53
  • 1
    Just as a side note, you know that a __m128 doesn't store 128 floats but only 4 (and thus 128 bit), do you? This has nothing to do with your problem, but from your strange array declaration it seems you're not aware of this. Nov 14, 2012 at 8:29
  • @ Potatoswatter: Yes, its the right program, I just made a couple of modifications before submitting it.
    – mortonjt
    Nov 14, 2012 at 13:22
  • @ Christian Rau: Yeah... That was just copied and pasted from somewhere, I'm still trying to get the hang of SSE. Thanks for the clarifcation
    – mortonjt
    Nov 14, 2012 at 13:24

1 Answer 1

9

It's a simple typo.

The types such as __m128 begins with two underscores. The functions such as _mm_store_ps do begin with only one underscore.

1
  • Damn. That took way too long to find that problem. Thanks!
    – mortonjt
    Nov 14, 2012 at 13:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.