2
我想寫它計算在一系列的字節數AC程序a
... c
與下面的代碼:如何使用SSE來計算位於某個範圍內的字節數?
char a[16], b[16], c[16];
int counter = 0;
for(i = 0; i < 16; i++)
{
if((a[i] < b[i]) && (b[i] < c[i]))
counter++;
}
return counter;
我打算做這樣的事情
__m128i result1 = _mm_cmpgt_epi8 (b, a);
__m128i result2 = _mm_cmplt_epi8 (b, c);
unsigned short out1 = _mm_movemask_epi8(result1);
unsigned short out2 = _mm_movemask_epi8(result2);
unsigned short out3 = out1 & out2;
unsigned short out4 = _mm_popcnt_u32(out3);
是我的方法正確嗎?有沒有更好的方法來做到這一點?
你想計算相等字節數嗎?如果是這樣,你應該問它:-) – hirschhornsalz
@drhirsch,我想要計算一些範圍內的字節數(即a&c的範圍)。 – quartz
那你爲什麼不問這個? ;-)我編輯了問題的澄清。 – hirschhornsalz