This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: autovectorization in gcc
On 09.01.19 10:50, Andrew Haley wrote:
On 1/9/19 9:45 AM, Kyrill Tkachov wrote:
There's plenty of work being done on auto-vectorisation in GCC.
Auto-vectorisation is a performance optimisation and as such is not really
a user-visible feature that absolutely requires user documentation.
I don't agree. Sometimes vectorization is critical. It would be nice
to have a warning which would fire if vectorization failed. That would
surely help the OP.
Further down this thread, some g++ flags were used which produced
meaningful information about vectorization failures, so the facility is
there - maybe it's not very prominent.
When it comes to user visibility, I'd like to add that there are great
differences between different users. I spend most of my time writing
library code, using template metaprogramming in C++. It's essential for
my code to perform well (real-time visualization), but I don't have
intimate compiler knowledge - I'm aiming at writing portable,
standard-compliant code. I'd like the compilers I use to provide
extensive documentation if I need to track down a problem, and I dislike
it if I have to use 'special' commands to get things done. Other users
may produce target-specific code with one specific compiler, and they
have different needs. It's better to have documentation and not need it
than the other way round.
So my idea of a 'contract' regarding vectorization is like this:
- the documentation states the scope of vectorization
- the use of a feature can be forced or disallowed
- or left up to a cost model
- the compiler can be made to produce diagnostic output
Documentation is absolutely essential. If there is lots of development
in autovectorization, not documenting this work in a way users can
simply find is - in my eyes - a grave omission. The text
'Auto-vectorization in GCC' looks like it has last been updated in 2011
(according to the 'Latest News' section). I'm curious to know what new
capabilities have been added since then. It makes my life much easier if
I can write loops to follow a given pattern relying on the
autovectorizer, rather than having to use explicit vector code, having
to rely on a library. There is also another aspect to being dependent on
external libraries. When a new architecture comes around, chances are
the compiler writers will be first to support it. It may take years for
an external library to add a new target ISA, more time until this runs
smoothly, and then more time until it has trickled down to the package
repos of most distributions - if this happens at all. Plus you have the
danger of betting on the wrong horse, and when the very promising
library you've used to code your stuff goes offline or commercial,
you've wasted your precious time. Relying only on the compiler brings
innovation out most reliably and quickly, and is a good strategy to
avoid wasting resources.
Now I may be missing things here because I haven't dug deeply enough to
find documentation about autovectorization in gcc. This was why I have
asked to be pointed to 'where the action is'. I was hoping to maybe get
some helpful hints. My main objective is, after all, to 'deliberately
exploit the compiler's autovectorization facilities by feeding data in
autovectorization-friendly loops'. The code will run, vectorized or not,
but it would be great to have good guidelines what will or will not be
autovectorized with a given compiler, rather than having to look at the
assembler output.
Kay