Vector Class Discussion

check if all elements of a vector are zero
Author:  Date: 2013-03-21 11:33
I have implement code to draw the Mandelbrot set using your vectorclass. I use Vec8f to operate on 8 pixels at once and I get significant speed ups doing this. In order to do this create a mask each iteration and I leave the loop when every element of the mask is zero. The way I did this first was using horizontal_add(mask)==0. However, I get better results using the intrinsic _mm_movemask_epi8(mask). Do you have a better recommendation than this?

Vec8i MandelbrotCalculate_vec8(const Vec8f x0, const Vec8f y0, const int maxiter, const float radius {
// iterates z = z + c until |z| >= 2 or maxiter is reached,
// returns the number of iterations.
Vec8f x = x0;
Vec8f y = y0;
Vec8i vn = 0;
for(int n = 0; n<maxiter; n++) {
Vec8i mask = (x*x + y*y) <= radius;
//if(horizontal_add(mask)==0) break;
int test = _mm_movemask_epi8(mask.get_low()) + _mm_movemask_epi8(mask.get_high());
if(test==0) break;
vn += mask;
Vec8f xtemp = x*x - y*y + x0;
y = 2*x*y + y0;
x = xtemp;
}
return -1*vn;
}
 
thread check if all elements of a vector are zero - chad - 2013-03-21
last replythread check if all elements of a vector are zero new - Agner - 2013-03-21
last replythread mathematical library functions new - chad - 2013-03-27
last replythread mathematical library functions new - chad - 2013-03-30
last reply mathematical library functions new - Agner - 2013-04-01