Tuesday 2 January 2018

c++ - SSE optimisation for a loop that finds zeros in an array and toggles a flag + updates another array

A piece of C++ code determines the occurances of zero and
keeps a binary flag variable for each number that is checked. The value of the flag
toggles between 0 and 1 each time a zero is encountered in a 1 dimensional array.



I am attempting to use SSE to speed it up, but
I am unsure of how to go about this. Evaluating the individual fields of __m128i is
inefficient, I've read.



The code in C++
is:




int flag =
0;
int var_num2[1000];
for(int i = 0; i<1000; i++)
{

if (var[i] == 0)
{
var_num2[i] = flag;
flag
= !flag; //toggle value upon encountering a 0

}

}


How
should I go about this using SSE intrinsics?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...