RE: Function Multiversioning in GCC6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Victor,

Ah! That looks pretty cool. I'll have to try it out on Open vSwitch.

I don't know if I'll get the chance to use it right away but when I do I'll let you know how I got on.

Thanks,
Billy. 

> -----Original Message-----
> From: Victor Rodriguez [mailto:vm.rod25@xxxxxxxxx]
> Sent: Monday, April 10, 2017 10:43 PM
> To: O Mahony, Billy <billy.o.mahony@xxxxxxxxx>
> Cc: Evgeny Stupachenko <evstupac@xxxxxxxxx>; Xi Ruoyao
> <ryxi@xxxxxxxxxxxxxxxxx>; gcc-help@xxxxxxxxxxx
> Subject: Re: Function Multiversioning in GCC6
> 
> On Thu, Apr 6, 2017 at 5:04 AM, O Mahony, Billy <billy.o.mahony@xxxxxxxxx>
> wrote:
> >
> >
> >> -----Original Message-----
> >> From: Victor Rodriguez [mailto:vm.rod25@xxxxxxxxx]
> >> Sent: Wednesday, April 5, 2017 8:09 PM
> >> To: O Mahony, Billy <billy.o.mahony@xxxxxxxxx>; Evgeny Stupachenko
> >> <evstupac@xxxxxxxxx>
> >> Cc: Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>; gcc-help@xxxxxxxxxxx
> >> Subject: Re: Function Multiversioning in GCC6
> >>
> >> On Tue, Apr 4, 2017 at 4:18 AM, O Mahony, Billy
> >> <billy.o.mahony@xxxxxxxxx>
> >> wrote:
> >> > Hi Victor,
> >> >
> >> >> -----Original Message-----
> >> >> From: Victor Rodriguez [mailto:vm.rod25@xxxxxxxxx]
> >> >> Sent: Monday, April 3, 2017 10:29 PM
> >> >> To: O Mahony, Billy <billy.o.mahony@xxxxxxxxx>
> >> >> Cc: Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>; gcc-help@xxxxxxxxxxx
> >> >> Subject: Re: Function Multiversioning in GCC6
> >> >>
> >> >> On Thu, Mar 30, 2017 at 3:59 AM, O Mahony, Billy
> >> >> <billy.o.mahony@xxxxxxxxx> wrote:
> >> >> > Hi Victor,
> >> >> >
> >> >> > Thanks to you and  Abraham Duenas, and Evgeny Stupachenko for
> >> >> > your
> >> >> work on FMV - it's a very neat feature and from my own
> >> >> investigations so far it works with minimal overhead even when
> >> >> used with inlined
> >> functions.
> >> >> >
> >> >> Welcome :)
> >> >>
> >> >> > One thing that could be stated explicitly in the article is that
> >> >> > use of the 'target' attribute with identically named functions
> >> >> > (i.e. the first code sample in the lwn article) is still
> >> >> > C++-only in gcc-6
> >> >>
> >> >> yes
> >> >>
> >> >> and if you want to do this with C you need to create your own
> >> >> ifunc resolver and have several differently named functions.
> >> >> >
> >> >>
> >> >> The idea is that you use one single funtion with just atributes ,
> >> >> instead of multiple funtions
> >> >>
> >> >> Why do you need old implementation of C++ FMV in C ?
> >> >
> >> > [[BO'M]]
> >> > I'm working on a code base that already has different definitions
> >> > of
> >> functions optimized for specific cpu instruction sets. One definition
> >> is picked by macro at compile time based on make flags.
> >> >
> >> Sounds interesting, If something is not optimized for particular
> >> target  you should file a bugzilla report. if is proper for your
> >> code, then as you mention FMV is not the best option. However try to
> >> reevaluate if this is the best approach for your application. Maybe
> >> is a good time to rewrite it and make more compact and understandable.
> >>
> >> > In my experiments with FMV I've looked at a hashing function. There
> >> > are
> >> two definitions - a pure C definition and one that uses sse42
> >> intrinsics. The pure C impl is really a set of inlined functions as I
> >> pulled it out of a suite of hashing functions (hash32, hash64,
> >> hash32_array, etc etc) for the purposes of the experiment.
> >> >
> >> > I'm assuming that, sophisticated as compilers are now, it won't
> >> > replace the
> >> several layers of  inlined C functions with single sse42 intrinsic
> >> call just because I specify "sse42" as one of the list of
> >> target_clones. So I stuck with the several definitions solution.
> >>
> >> Is your code open source ? so we can tak ea look ?
> > [[BO'M]] Hi Victor,
> > I'm looking at this wrt to Open vSwitch code
> > https://github.com/openvswitch/ovs
> >
> > As an experiment I was compiling a test program with both the sse42 and
> default versions of hash_words_inline function which are both in lib/hash.h.
> Currently one implementation or the other is chosen by compile time #def.
> >
> You can use our code to generate the FMV patch:
> 
> https://github.com/clearlinux/make-fmv-patch
> 
> You just need to build with -fopt-info-vec
> 
> The idea is to generate the patch automatically and then you can choose
> which patch to apply based on the functions you consider relevant for FMV
> 
> > It looks like ifunc is supported by the latest version of clang. Do you know if
> it is supported by BSD and Windows.
> 
> it is not as far as I know
> 
> Hope it helps
> 
> Regards
> Victor
> 
> >
> > Thanks,
> > Billy.
> >
> >>
> >> >
> >> >
> >> >>
> >> >> Regards
> >> >>
> >> >> > Thanks,
> >> >> > Billy.
> >> >> >
> >> >> >
> >> >> >
> >> >> >> -----Original Message-----
> >> >> >> From: Victor Rodriguez [mailto:vm.rod25@xxxxxxxxx]
> >> >> >> Sent: Thursday, March 30, 2017 1:10 AM
> >> >> >> To: O Mahony, Billy <billy.o.mahony@xxxxxxxxx>
> >> >> >> Cc: Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>; gcc-help@xxxxxxxxxxx
> >> >> >> Subject: Re: Function Multiversioning in GCC6
> >> >> >>
> >> >> >> On Thu, Mar 23, 2017 at 4:45 AM, O Mahony, Billy
> >> >> >> <billy.o.mahony@xxxxxxxxx> wrote:
> >> >> >> >
> >> >> >> > Hi Xi,
> >> >> >> >
> >> >> >> > Thanks for the clarification/confirmation.
> >> >> >> >
> >> >> >> > Regards,
> >> >> >> > Billy.
> >> >> >> >
> >> >> >> > > -----Original Message-----
> >> >> >> > > From: Xi Ruoyao [mailto:ryxi@xxxxxxxxxxxxxxxxx]
> >> >> >> > > Sent: Thursday, March 23, 2017 9:21 AM
> >> >> >> > > To: O Mahony, Billy <billy.o.mahony@xxxxxxxxx>
> >> >> >> > > Cc: ryxi@xxxxxxxxxxxxxxxxx; gcc-help@xxxxxxxxxxx
> >> >> >> > > Subject: Re: Function Multiversioning in GCC6
> >> >> >> > >
> >> >> >> > > On 2017-03-22 10:51 +0000, O Mahony, Billy wrote:
> >> >> >> > >
> >> >> >> > > > However when I compile the first example in this LWN
> >> >> >> > > > article https://lwn.net/Articles/691932/ with gcc-6 C
> >> >> >> > > > compiler it fails with
> >> >> >> > > > (error: redefinition of
> >> >> >> > > > 'foo'...) .
> >> >> >> > >
> >> >> >> > > The document
> >> >> >> > > <https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Function-
> >> >> >> > > Multiversioning.html> said:
> >> >> >> > >
> >> >> >> > >     With the GNU *C++* front end, for x86 targets, you may
> >> >> >> > > specify multiple versions of the function.
> >> >> >> > >
> >> >> >> > > FMV doesn't work with C FE.  In C,
> >> >> >> > > __attribute__((target("sse4.2"))) just means to compile
> >> >> >> > > this function with -msse4.2, see
> >> >> >> > > <https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Common-Functi
> >> >> >> > > on-
> >> >> >> > > Attributes.html>.
> >> >> >> > >
> >> >> >> > > --
> >> >> >> > > Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx> School of Aerospace
> >> >> >> > > Science and Technology, Xidian University
> >> >> >> >
> >> >> >>
> >> >> >> You can also read this LWN article:
> >> >> >>
> >> >> >> https://lwn.net/Articles/691932/




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux