public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Vectorizer size preferences (-mprefer-* on x86)
@ 2018-06-15 11:52 Richard Biener
  2018-06-15 12:02 ` Jan Hubicka
  2018-06-15 15:26 ` Richard Earnshaw (lists)
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Biener @ 2018-06-15 11:52 UTC (permalink / raw)
  To: gcc; +Cc: kirill.yukhin, ubizjak, Jan Hubicka


Hi,

I'm in the process of changing the vectorizer to consider all
vector sizes as advertised by targetm.autovectorize_vector_sizes
and to decide which one to use based on its cost model.

I expect that to make sense for example when choosing between
AVX128 and AVX256 since the latter may have penalties for
cross-lane operations which the former lacks.

Now while the option -mprefer-* and the documentation (to
some extent) suggests that the user communicates a preference
the actual implementation in the x86 backend uses -mprefer-*
to disable the use of larger vector sizes.  That also makes
targetm.preferred_simd_mode somewhat redundant.

In the light of using the cost model to decide on the vector
width used how should we go forward here?

I would suggest to more clearly document that -mprefer-*
will disable the use of larger vector sizes and that smaller
vector sizes might be used if costs tell us to do so (or loops
do not roll enough).  Implementation-wise the size chosen
by targetm.preferred_simd_mode could be used as tie-breaker
in case equal costs are computed.

In the (distant?) future we might want to support mixed-size
vectorization which makes all this even more complicated.
Still having -mprefer-* disabling vector sizes makes sense
here?

Thanks,
Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Vectorizer size preferences (-mprefer-* on x86)
  2018-06-15 11:52 Vectorizer size preferences (-mprefer-* on x86) Richard Biener
@ 2018-06-15 12:02 ` Jan Hubicka
  2018-06-15 12:35   ` Richard Biener
  2018-06-15 15:26 ` Richard Earnshaw (lists)
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2018-06-15 12:02 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc, kirill.yukhin, ubizjak

> 
> Hi,
> 
> I'm in the process of changing the vectorizer to consider all
> vector sizes as advertised by targetm.autovectorize_vector_sizes
> and to decide which one to use based on its cost model.
> 
> I expect that to make sense for example when choosing between
> AVX128 and AVX256 since the latter may have penalties for
> cross-lane operations which the former lacks.
> 
> Now while the option -mprefer-* and the documentation (to
> some extent) suggests that the user communicates a preference
> the actual implementation in the x86 backend uses -mprefer-*
> to disable the use of larger vector sizes.  That also makes
> targetm.preferred_simd_mode somewhat redundant.
> 
> In the light of using the cost model to decide on the vector
> width used how should we go forward here?
> 
> I would suggest to more clearly document that -mprefer-*
> will disable the use of larger vector sizes and that smaller
> vector sizes might be used if costs tell us to do so (or loops
> do not roll enough).  Implementation-wise the size chosen
> by targetm.preferred_simd_mode could be used as tie-breaker
> in case equal costs are computed.

I suppose one useful meaning of -mpreffer would be to overwrite
the decision heuristics to only consider the mode specified.
(it is what we do at the moment anyway, right?)
So one can use it in the case your heuristics makes wrong choice.
But disabling only bigger vector sizes makes sense to me as well.

Honza
> 
> In the (distant?) future we might want to support mixed-size
> vectorization which makes all this even more complicated.
> Still having -mprefer-* disabling vector sizes makes sense
> here?
> 
> Thanks,
> Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Vectorizer size preferences (-mprefer-* on x86)
  2018-06-15 12:02 ` Jan Hubicka
@ 2018-06-15 12:35   ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2018-06-15 12:35 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc, kirill.yukhin, ubizjak

On Fri, 15 Jun 2018, Jan Hubicka wrote:

> > 
> > Hi,
> > 
> > I'm in the process of changing the vectorizer to consider all
> > vector sizes as advertised by targetm.autovectorize_vector_sizes
> > and to decide which one to use based on its cost model.
> > 
> > I expect that to make sense for example when choosing between
> > AVX128 and AVX256 since the latter may have penalties for
> > cross-lane operations which the former lacks.
> > 
> > Now while the option -mprefer-* and the documentation (to
> > some extent) suggests that the user communicates a preference
> > the actual implementation in the x86 backend uses -mprefer-*
> > to disable the use of larger vector sizes.  That also makes
> > targetm.preferred_simd_mode somewhat redundant.
> > 
> > In the light of using the cost model to decide on the vector
> > width used how should we go forward here?
> > 
> > I would suggest to more clearly document that -mprefer-*
> > will disable the use of larger vector sizes and that smaller
> > vector sizes might be used if costs tell us to do so (or loops
> > do not roll enough).  Implementation-wise the size chosen
> > by targetm.preferred_simd_mode could be used as tie-breaker
> > in case equal costs are computed.
> 
> I suppose one useful meaning of -mpreffer would be to overwrite
> the decision heuristics to only consider the mode specified.
> (it is what we do at the moment anyway, right?)

At the moment if we can vectorize using that mode we will use it.
Only if vectorization fails for whatever reason we are trying
alternate modes as speficied by targetm.autovectorize_vector_sizes.

> So one can use it in the case your heuristics makes wrong choice.
> But disabling only bigger vector sizes makes sense to me as well.

Note with the vectorizer update there is no way to tell it
it should not "prefer" any specific size.  The
preferred_simd_mode was there first and only later came
autovectorize_vector_sizes which after recent changes now
has the sizes ordered.  But the vectorizer starts with
the size chosen by preferred_simd_mode, not honoring
the autovectorize_vector_sizes order for the first vector
size but only the following.

Completely overriding the cost comparison and sticking to
the current behavior would require another mechanism.

Maybe we should re-thing the two target hooks currently
used in this area.

Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Vectorizer size preferences (-mprefer-* on x86)
  2018-06-15 11:52 Vectorizer size preferences (-mprefer-* on x86) Richard Biener
  2018-06-15 12:02 ` Jan Hubicka
@ 2018-06-15 15:26 ` Richard Earnshaw (lists)
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Earnshaw (lists) @ 2018-06-15 15:26 UTC (permalink / raw)
  To: Richard Biener, gcc; +Cc: kirill.yukhin, ubizjak, Jan Hubicka

On 15/06/18 12:48, Richard Biener wrote:
> 
> Hi,
> 
> I'm in the process of changing the vectorizer to consider all
> vector sizes as advertised by targetm.autovectorize_vector_sizes
> and to decide which one to use based on its cost model.
> 
> I expect that to make sense for example when choosing between
> AVX128 and AVX256 since the latter may have penalties for
> cross-lane operations which the former lacks.
> 
> Now while the option -mprefer-* and the documentation (to
> some extent) suggests that the user communicates a preference
> the actual implementation in the x86 backend uses -mprefer-*
> to disable the use of larger vector sizes.  That also makes
> targetm.preferred_simd_mode somewhat redundant.
> 
> In the light of using the cost model to decide on the vector
> width used how should we go forward here?
> 
> I would suggest to more clearly document that -mprefer-*
> will disable the use of larger vector sizes and that smaller
> vector sizes might be used if costs tell us to do so (or loops
> do not roll enough).  Implementation-wise the size chosen
> by targetm.preferred_simd_mode could be used as tie-breaker
> in case equal costs are computed.
> 
> In the (distant?) future we might want to support mixed-size
> vectorization which makes all this even more complicated.
> Still having -mprefer-* disabling vector sizes makes sense
> here?
> 
> Thanks,
> Richard.
> 

Could you approximate here what we've done for Arm -mfpu= - add an
'auto' option and make it the default.  Over time you then deprecate
other settings and eventually drop them, leaving only the default.

R.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-15 12:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-15 11:52 Vectorizer size preferences (-mprefer-* on x86) Richard Biener
2018-06-15 12:02 ` Jan Hubicka
2018-06-15 12:35   ` Richard Biener
2018-06-15 15:26 ` Richard Earnshaw (lists)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).