I discovered recently that there is an asymmetry with how boolean vectors in the VCL are handled before AVX512 and with AVX512. In your manual you write that
conversion from boolean vectors to integer vectors is "Not defined for vectors bigger than 256 bits". I recently adapted my code for AVX512 and had to switch to using the if_add function. However, this function is noticeably slower than converting the boolean vector to an integer vector in my code. I tried compiling with AVX512 converting a boolean vectror to Vec16i and it complies fine (g++ -O3 -mavx512f test3.cpp -Ivectorclass) but I have no hardware to test it. In the code below (which is only a test of what I'm trying to do) it appears I can do d -= Vec16i(c) instead of d = if_add(c,d,1); Do I misunderstand something? It runs correctly with AVX and compiles find with AVX512. include <stdio.h>
#define MAX_VECTOR_SIZE 512
#include "vectorclass.h" int main() {
Vec16f a,b;
float t1[16]; for(int i=0; i<16; i++) t1[i] = 1.0f*i;
float t2[16]; for(int i=0; i<16; i++) t2[i] = 15.0f-1.0f*i;
a.load(t1), b.load(t2);
Vec16fb c = a < b;
//if(!horizontal_or(c)) return 0;
Vec16i d = 7;
//d = if_add(c, d, 1);
d -= Vec16i(c);
for(int i=0; i<16; i++) printf("%.1f ", t1[i]); puts("");
for(int i=0; i<16; i++) printf("%.1f ", t2[i]); puts("");
int t3[16]; d.store(t3);
for(int i=0; i<16; i++) printf("%d ", t3[i]); puts("");
} |