请问有谁用过SSE指令进行优化吗?
rh386 2004-01-16 09:39:32 请教,有那位用过SSE的intrinsic指令进行C++程序优化吗?
想问个问题:
程序段:
_MM_ALIGN16 float input1[4] = { 1.2f, 3.5f, 1.7f, 2.8f };
_MM_ALIGN16 float input2[4] = { -0.7f, 2.6f, 3.3f, -0.8f }
_MM_ALIGN16 float output[4];
__m128 am,bm,tm;
for(int l = 0; l < 100; l++) {
for(int k = 0; k < 2000; k++) {
for(int j = 0; j < 2000; j++) {
am = _mm_load_ps(input1);
bm = _mm_load_ps(input2);
tm = _mm_mul_ps(am, bm);
_mm_store_ps(output, tm);}}}
和
_MM_ALIGN16 float input1[4] = { 1.2f, 3.5f, 1.7f, 2.8f };
_MM_ALIGN16 float input2[4] = { -0.7f, 2.6f, 3.3f, -0.8f };
_MM_ALIGN16 float output[4];
for(int l = 0; l < 100; l++) {
for(int k = 0; k < 2000; k++) {
for(int j = 0; j < 2000; j++) {
__m128 am = _mm_load_ps(input1);
__m128 bm = _mm_load_ps(input2);
__m128 tm = _mm_mul_ps(am, bm);
_mm_store_ps(output, tm); }}}
相比较只有SSE寄存器声明使用上的差别,但速度却慢得多,什么道理?
另外对SSE寄存器的使用有什么限制(指intrinsic中)?
谢谢