Consider this generic code:
#include <cstdlib>
#include <ctime>
#include <algorithm> // std::copy
int main() {
const int n=1024;
float a1[n],a2[n];
std::srand(std::time(0));
for(int i=0;i<n;i++) a2[i]=std::rand()/(float)RAND_MAX;
std::copy(a2,a2+n,a1);
}
when I compile this with g++/gcc 4.8.1and the flag -O3 -march=native -mtune=nativein Ubuntu, I get that the line corresponding to the copy cannot be put down because:
note: not vectorized: not enough data-refs in basic block.
If i use
for(int i=0;i<n;i++) a1[i]=a2[i];
I also get the same compiler message. I am a little puzzled. Intuitively, I would think a copy between two non-overlapping arrays should be highly vectorial. Can someone explain why this is not the case (and, ultimately, admittedly, this is not a bottleneck in my code, I basically ask you to understand what this error message means.
source
share