[Mesa-dev] [PATCH] swr: fix -march flag for AVX

Steven Newbury steve at snewbury.org.uk
Sun Jun 12 08:56:39 UTC 2016


On Fri, 2016-06-10 at 16:05 -0400, Ilia Mirkin wrote:
> On Fri, Jun 10, 2016 at 3:43 PM, Tim Rowley <timothy.o.rowley at intel.c
> om> wrote:
> > 
> > Previously used core-avx-i was for ivybridge;
> > corei7-avx allows sandybridge.
> > ---
> >  src/gallium/drivers/swr/Makefile.am | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/gallium/drivers/swr/Makefile.am
> > b/src/gallium/drivers/swr/Makefile.am
> > index d211f2e..8156cf2 100644
> > --- a/src/gallium/drivers/swr/Makefile.am
> > +++ b/src/gallium/drivers/swr/Makefile.am
> > @@ -124,7 +124,7 @@ COMMON_LDFLAGS = \
> >  lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
> > 
> >  libswrAVX_la_CXXFLAGS = \
> > -       -march=core-avx-i \
> > +       -march=corei7-avx \
> Just wondering if it'd be enough to say like
> 
> -march=x86_64
> -mavx
> 
> and add -mavx2 for libswrAVX2.
> 
> I suspect you've iterated through this 20 times and this has some
> shortcoming I'm not thinking of, but figured I'd point it out just in
> case it helps.
> 
>   -ilia
> 
Maybe I'm the only one who finds it horrible to override -march from
within project build systems.  It causes no end of problems with LTO,
and results in objects being built inappropriately for the target as
specified by the builder.

Why not use function attributes?  Either compile a function
specifically for a particular target, or specifically enable AVX though
"__attribute__ ((__target__ ("avx")))" (ideally with a fall-back
implementation detected at run-time when the instruction set isn't
supported).  Even better, have it also protected at build-time by a
simple check for __AVX__ so the code can be compiled out entirely where
the package builder has specified -march(=native) as a build flag.

> > 
> >         -DKNOB_ARCH=KNOB_ARCH_AVX \
> >         $(COMMON_CXXFLAGS)
> > 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160612/7414ba5b/attachment.sig>


More information about the mesa-dev mailing list