cogman
5th December 2009, 23:20
Hey all, I'm an SSE initiate, so go easy on me :). Here is what I'm trying to mimic
int findInts(int* found, int* data, int dataSize, int pattern)
{
int numFound = 0;
for (int i = 0; i < dataSize; ++i)
{
if (data[i] == pattern)
{
found[numFound++] = i;
}
}
return numFound;
}
So basically, I'm trying to search through a random array of integers and find the locations where the integers match a certain value (Actually, I'm going to use to it to search for specific colors).
I'm thinking I could use something like pcmpeqd to get a mask when things match, however, how do I go from that mask to specific matching i values? Especially if the pattern is 0.
If there is another way to do this, or if just not using SSE is better I'd be glad to hear it. (My computer that I'm doing this on only supports SSE2, so no fancy SSE3/4 please :))
int findInts(int* found, int* data, int dataSize, int pattern)
{
int numFound = 0;
for (int i = 0; i < dataSize; ++i)
{
if (data[i] == pattern)
{
found[numFound++] = i;
}
}
return numFound;
}
So basically, I'm trying to search through a random array of integers and find the locations where the integers match a certain value (Actually, I'm going to use to it to search for specific colors).
I'm thinking I could use something like pcmpeqd to get a mask when things match, however, how do I go from that mask to specific matching i values? Especially if the pattern is 0.
If there is another way to do this, or if just not using SSE is better I'd be glad to hear it. (My computer that I'm doing this on only supports SSE2, so no fancy SSE3/4 please :))