Automatic Vectorisation in GCC 4.0

boyfarrell

Registered
I found this in Apple's site High Performance Computing In Tiger. This bit caught by eye:
GCC 4.0—an auto-vectorizing compiler that enables out-of-the-box open source or
in-house code to take advantage of vector capabilities of a processor without tying
the application to a specific processor architecture.
Does this mean there is no point in using the accelerate framework? Does the compiler automatically access the AlitVec?

Sounds to good to be true ...
 
Auto vectorization does happen to a certain extent in GCC 4.0. However, it is far from perfect, since it is much more difficult for the compiler to detect blocks of code that can be vectorized. That is why the Accelerate Framework is there, to enable programmers to vectorize their code since they can do it better than the compiler can. To enable this, add the flag -ftree-vectorize to your CFLAGS. To see what gets vectorized, add the flag -ftree-vectorizer-verbose=5. You'll be amazed at how little is vectorized. The GCC developers claim that 4.1 will contain better routines for vectorizing code.

On a side note, on the PowerPC with Altivec, only single precision floating point (i.e. float) operations can be vectorized. If you're doing any simulation work, you're most likely using double precision (i.e. double), thus in order to vectorize your code, you need to convert all instances of double precision operations to single precision operations. On Intel platforms, double precision operations can be vectorized, which may be one good thing about the move to Intel.
 
Back
Top