C++ SSE g&x2B+;汇编问题
我正试着玩弄SSE内在论。我制作了一个测试程序,只需将两个向量和四个16位元素相加C++ SSE g&x2B+;汇编问题,c++,g++,sse,C++,G++,Sse,我正试着玩弄SSE内在论。我制作了一个测试程序,只需将两个向量和四个16位元素相加 #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.0
#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
这可能是一个很愚蠢的错误,但我不能确定它在哪里。任何帮助都将不胜感激。这是一个简单的打字错误
诸如
\uuu m128
之类的类型以两个下划线开头。像\u mm\u store\u ps
这样的函数只以一个下划线开头。是您编译的程序吗?我在那里没有看到printf
。作为旁注,您知道\uum128
不存储128个浮点数,而只存储4个浮点数(因此是128位),是吗?这与您的问题无关,但从您奇怪的数组声明来看,您似乎没有意识到这一点。@Potatoswatter:是的,这是正确的程序,我只是在提交之前做了一些修改。@Christian Rau:是的。。。那只是从某处复制粘贴的,我仍在努力掌握SSE的窍门。谢谢你的澄清。这花了太长的时间才发现这个问题。谢谢
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