genericsimd / generic_simd

Generic SIMD intrinsic to allow for portable SIMD intrinsic programming
Other
42 stars 7 forks source link

Q: operator== returning an index, not vec<bool>? #9

Closed cruppstahl closed 10 years ago

cruppstahl commented 10 years ago

Hi,

i was not able to find a mailing list, sorry that i'm posting my question here.

I want to use sse2 instructions to search an array of 32bit integers for a specific number - like a linear search. It should return the index of the matching element. However, the svec_equal function returns a svec<4,bool> instead.

i.e. instead of {0, 0, 1, 0} i want to have 2 as a return code.

I know that i could simply search through the returned booleans, but this would require an additional loop with several conditions, and i would like to avoid this overhead.

Is there any way for me to avoid this?

Thanks and kind regards Christoph

igtanase commented 10 years ago

Hi Christoph, I am glad you took the time to ask and not give up :) Looking at the mandelbrot example I see we have the following call : /**

However if you check the specification of _mm_movemask_ps() you will see that it sets certain bits in the output boolean based on which field in teh input vector register was true;

http://msdn.microsoft.com/en-us/library/4490ys29(v=vs.90).aspx

Let me know if it work for you, --Gabriel

cruppstahl commented 10 years ago

Hi Gabriel,

thanks for taking the time and answering my question! i think _mm_movemask_ps will work fine.

Thanks for the great library! Christoph