2012-11-14 10 views
1

SSE 내장 함수를 가지고 놀고 싶습니다. 필자는 4 개의 16 비트 요소가있는 두 개의 벡터를 추가하는 테스트 프로그램을 만들었습니다.SSE g ++ 컴파일 문제

#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(); 
} 

나는 내가 할 수없는 아마 정말 바보 같은 실수를 다음과 같은 합병증 오류

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 

그 받고 있어요, 그러나

g++ -msse3 test_sse.cpp 

이 코드를 컴파일 만하고있어 내 손가락을 어디에 두 었는지. 어떤 도움이라도 대단히 감사하겠습니다.

+1

컴파일 한 프로그램입니까? 거기에'printf'가 보이지 않습니다. – Potatoswatter

+1

부수적으로,'__m128'는 128 개의 부동 소수점을 저장하지만 4 (128 비트) 만 저장한다는 것을 알고 있습니까? 이것은 당신의 문제와는 아무런 상관이 없지만 이상한 배열 선언에서 당신은 이것을 알지 못하고있는 것처럼 보입니다. –

+0

@ Potatoswatter : 예, 올바른 프로그램입니다. 제출하기 전에 몇 가지 수정을했습니다. – mortonjt

답변

6

단순한 오타입니다.

__m128과 같은 형식은 두 개의 밑줄로 시작됩니다. _mm_store_ps과 같은 함수는 하나의 밑줄로 시작합니다.

+0

젠장. 그 문제를 발견하기에는 너무 오랜 시간이 걸렸습니다. 감사! – mortonjt