Reputation: 14328
In the context of evaluating negative-log-likelihoods, I have to perform a bunch of operations that could benefit from vectorization:
for (i = 1...n) { a[i] = 0; } // but this I think
std::fill( a.begin(), a.end(), 0 )
is already optimal
for (i = 1...n) { a[i] += b * c[i]; }
sum = 0; for (i = 1 .. n) { sum += a[i] * log( b[i] / c ); }
Do you know if there is any hope to get GCC 434 to do auto-vectorization, and how should I code the loop to help him (e.g. using indices vs using iterators, should I break up (2) in simpler loops, ...)? Up to now I am using doubles, have to check if I can move to floats at least for (1).
Upvotes: 3
Views: 376
Reputation: 2434
For autovectorization of floating point reductions like 2) you need to enable -funsafe-math-optimizations
On i386 like targets you also need to add -mfpmath=sse
Upvotes: 0
Reputation: 598
http://gcc.gnu.org/projects/tree-ssa/vectorization.html
Use the required options, -O3 -msse2
For more options, read the documentation above.
Upvotes: 2