I am compiling my code using following command:
gcc -O3 -ftree-vectorizer-verbose=6 -msse4.1 -ffast-math
With this all the optimizations are enabled.
But I want to disable vectorization while keeping the other optimizations.
The v4 series of the gcc compiler can automatically vectorize loops using the SIMD processor on some modern CPUs, such as the AMD Athlon or Intel Pentium/Core chips.
A vectorizing compiler transforms such loops into sequences of vector operations. These vector operations perform additions on blocks of elements from the arrays a , b and c . Automatic vectorization is a major research topic in computer science.
Vectorization is the process of converting an algorithm from operating on a single value at a time to operating on a set of values (vector) at one time. Modern CPUs provide direct support for vector operations where a single instruction is applied to multiple data (SIMD).
The SLP Vectorizer The goal of SLP vectorization (a.k.a. superword-level parallelism) is to combine similar independent instructions into vector instructions. Memory accesses, arithmetic operations, comparison operations, PHI-nodes, can all be vectorized using this technique.
Most of the GCC switches can be used with a no
prefix to disable their behavior. Try with -fno-tree-vectorize
(after -O3
on the command line).
you can also selectively enable and disable vectorization with the optimize function attributes or pragmas
http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
http://gcc.gnu.org/onlinedocs/gcc/Function-Specific-Option-Pragmas.html
e.g.
__attribute__((optimize("no-tree-vectorize")))
void f(double * restrict a, double * restrict b)
{
for (int i = 0; i < 256; i++)
a[i] += b[i];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With