public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xinliang David Li <davidxl@google.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Sriraman Tallam <tmsriram@google.com>,
	reply@codereview.appspotmail.com,        gcc-patches@gcc.gnu.org
Subject: Re: [google] Patch to support calling multi-versioned functions via new GCC builtin. (issue4440078)
Date: Thu, 05 May 2011 17:08:00 -0000	[thread overview]
Message-ID: <BANLkTimJhEMsEfKHjzjK=oEuJFoLfbtSQA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTiks8ud3zzVWEmvyJ0i+W+3-5eSWMA@mail.gmail.com>

On Thu, May 5, 2011 at 2:16 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Thu, May 5, 2011 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>
>>> I can think of some more-or-less obvious high-level forms, one would
>>> for example simply stick a new DISPATCH tree into gimple_call_fn
>>> (similar to how we can have OBJ_TYPE_REF there), the DISPATCH
>>> tree would be of variable length, first operand the selector function
>>> and further operands function addresses.  That would keep the
>>> actual call visible (instead of a fake __builtin_dispatch call), something
>>> I'd really like to see.
>>
>> This sounds like a good long term solution.
>
> Thinking about it again maybe, similar to OBJ_TYPE_REF, have the
> selection itself lowered and only keep the set of functions as
> additional info.  Thus instead of having the selector function as
> first operand have a pointer to the selected function there (that also
> avoids too much knowledge about the return value of the selector).
> Thus,
>
>  sel = selector ();
>  switch (sel)
>   {
>   case A: fn = &bar;
>   case B: fn = &foo;
>   }
>  val = (*DISPATCH (fn, bar, foo)) (...);
>
> that way regular optimizations can apply to the selection, eventually
> discard the dispatch if fn becomes a known direct function (similar
> to devirtualization).  At expansion time the call address is simply
> taken from the first operand and an indirect call is assembled.
>
> Does the above still provide enough knowledge for the IPA path isolation?
>

I like your original proposal (extending call) better because related
information are tied together and is easier to hoist and clean up.

I want propose a more general solution.

1) Generic Annotation Support for gcc IR -- it is used attach to
application/optimization specific annotation to gimple statements and
annotations can be passed around across passes. In gcc, I only see
HISTOGRAM annotation for value profiling, which is not general enough
2) Support of CallInfo for each callsite. This is an annotation, but
more standardized. The callinfo can be used to record information such
as call attributes, call side effects, mod-ref information etc ---
current gimple_call_flags can be folded into this Info structure.

Similarly (not related to this discussion), LoopInfo structure can be
introduced to annotate loop back edge jumps to allow FE to pass useful
information at loop level. For floating pointer operations, things
like the precision constraint, sensitivity to floating environment etc
can be recorded in FPInfo.

T


>>> Restricting ourselves to use the existing target attribute at the
>>> beginning (with a single, compiler-generated selector function)
>>> is probably good enough to get a prototype up and running.
>>> Extending it to arbitrary selector-function, value pairs using a
>>> new attribute is then probably easy (I don't see the exact use-case
>>> for that yet, but I suppose it exists if you say so).
>>
>> For the use cases, CPU model will be looked at instead of just the
>> core architecture -- this will give use more information about the
>> numbrer of cores, size of caches etc. Intel's runtime library does
>> this checkiing at start up time so that the multi-versioned code can
>> look at those and make the appropriate decisions.
>>
>> It will be even more complicated for arm processors -- which can have
>> the same processor cores but configured differently w.r.t VFP, NEON
>> etc.
>
> Ah, indeed.  I hadn't thought about the tuning for different variants
> as opposed to enabling HW features.  So the interface for overloading
> would be sth like
>
> enum X { Foo = 0, Bar = 5 };
>
> enum X select () { return Bar; }
>
> void foo (void) __attribute__((dispatch(select, Bar)));
>

Yes, for overloading -- something like this looks good.

Thanks,

David

  reply	other threads:[~2011-05-05 17:03 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-29  5:03 Sriraman Tallam
2011-04-29 11:59 ` Richard Guenther
2011-04-29 16:55   ` Xinliang David Li
2011-05-02  9:11     ` Richard Guenther
2011-05-02 16:42       ` Xinliang David Li
2011-05-02 19:12         ` Sriraman Tallam
2011-05-02 19:32           ` Xinliang David Li
2011-05-02 20:38             ` Sriraman Tallam
2011-05-02 20:45               ` Eric Botcazou
2011-05-02 20:51                 ` Sriraman Tallam
2011-05-04 19:50               ` Sriraman Tallam
2011-05-04 22:16                 ` Diego Novillo
2011-05-04 22:19                   ` Sriraman Tallam
2011-05-02 21:34         ` Richard Guenther
2011-05-02 23:08           ` Xinliang David Li
2011-05-03 10:00             ` Richard Guenther
2011-05-03 10:07               ` Richard Guenther
2011-05-03 15:21                 ` Mike Stump
2011-05-03 15:34                   ` Joseph S. Myers
2011-05-03 16:50                     ` Mike Stump
2011-05-03 22:05               ` Xinliang David Li
2011-05-04  9:30                 ` Richard Guenther
2011-05-04 22:20                   ` Xinliang David Li
2011-05-05  9:21                     ` Richard Guenther
2011-05-05 17:08                       ` Xinliang David Li [this message]
2011-05-06  9:07                         ` Richard Guenther
2011-05-06 13:38                           ` Diego Novillo
2011-05-06 18:01                           ` Xinliang David Li
2011-05-07 12:48                             ` Richard Guenther
2011-05-07 18:00                               ` Xinliang David Li
2011-05-07 18:11                                 ` Richard Guenther
2011-04-29 18:46   ` Sriraman Tallam
     [not found]   ` <BANLkTim=oXD7egdy7zzMcTMDAhwnMQ=Kyg@mail.gmail.com>
2011-05-02  9:25     ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTimJhEMsEfKHjzjK=oEuJFoLfbtSQA@mail.gmail.com' \
    --to=davidxl@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=reply@codereview.appspotmail.com \
    --cc=richard.guenther@gmail.com \
    --cc=tmsriram@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).