[PATCH] New attribute to create target clones
Jeff Law
law@redhat.com
Thu Oct 8 16:39:00 GMT 2015
On 09/22/2015 03:09 PM, Bernd Schmidt wrote:
> On 09/22/2015 09:41 PM, Jeff Law wrote:
>> Essentially it allows us to more easily support
>> per-microarchitecture-optimized versions of functions. You list just
>> have to list the microarchitectures and the compiler handles the rest.
>> Very simple, very easy. I'd think it'd be particularly helpful for
>> vectorization.
>>
>> You could emulate this with compiling the same source multiple times
>> with different flags/defines and wire up on ifunc by hand. But Evgeny's
>> approach is vastly simpler.
>
> As far as I can tell the ifunc is generated automatically (and the
> functionality is documented as such), so the new target_clone doesn't
> buy much. But one thing I didn't was that the existing support is only
> available in C++, while Evgeny's patch works for C. That is probably an
> argument that could be made for its inclusion.
In multi-versioning, you have a distinct source implementation for each
function. ie
__attribute__ ((target ("default")))
int foo ()
{
// The default version of foo.
return 0;
}
__attribute__ ((target ("sse4.2")))
int foo ()
{
// foo version for SSE4.2
return 1;
}
And so-on for each processor version you want to support.
In Evgeny's patch we'd have a single source implementation of foo which
gets compiled multiple times, once for each target specified by the
attribute.
I wasn't aware that multi-versioning was only implemented for C++, that
seems fairly lame. I hope I didn't approve that :-)
Jeff
More information about the Gcc-patches
mailing list