On 5/15/2010 12:59 PM, Mark Rose wrote:
The tree vectorizer spits out this note about the loop I'm particularly
interested in:
for (int k = 1; k< n_topics; k++)
cdf[k] = cdf[k-1] + (dcount[k+d_offset] + alpha)*(wcount[k+w_offset +
beta)/(tcount[k] + wbeta);
note: not vectorized: data ref analysis failed D.8597_92 = *D.8596_91;
I've done hours of googling, playing with restrict keywords, splitting the
cdf[k-1] addition into another loop, and nothing will help. The error message
itself is very poor, as I can't find a decent explanation anywhere online as to
what it means nor how to fix it.
It's a bit much to ask for the message to give a complete discussion of
the concept of vectorization. If you would spend a few minutes studying
this code, it should be clear that you have a lot of performance robbing
stuff here, even without seeing the background. The compiler can't
vectorize, because each value of cdf[k] depends on the preceding one
cdf[k-1]. If the compiler has aliasing concerns not addressed by
restrict which prevent direct use of the preceding value in register,
but requires moving it around in the memory hierarchy, you might
consider using a local temporary, should you know that such concerns can
be ignored.
There's a pretty good chance that code which violates typed aliasing, if
this does so, will disable optimizations, if the compiler doesn't reject
it. It's obscure enough that you should maybe fix it so you can
concentrate on the issues you may be interested in.
--
Tim Prince