From: Richard Biener <richard.guenther@gmail.com>
To: Nathan Sidwell <nathan@acm.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: OpenACC dimension range propagation optimization
Date: Wed, 04 Nov 2015 14:35:00 -0000 [thread overview]
Message-ID: <CAFiYyc3PLVsLDH3+Y32kJMV=jL9mJegRA2hXp7RoHE48K7R9MA@mail.gmail.com> (raw)
In-Reply-To: <563A0E78.8010700@acm.org>
On Wed, Nov 4, 2015 at 2:56 PM, Nathan Sidwell <nathan@acm.org> wrote:
> On 11/04/15 05:26, Richard Biener wrote:
>>
>> On Tue, Nov 3, 2015 at 7:11 PM, Nathan Sidwell <nathan@acm.org> wrote:
>>>
>>> Richard,
>>> this patch implements VRP for the 2 openacc axis internal fns I've added.
>>> We know the position within a dimension cannot exceed that dimensions
>>> extend. Further, if the extend is dynamic, the target backend may well
>>> know
>>> there's a hardware-mandated maximum value.
>>>
>>> Hence, added a new target hook to allow the backend to specify that upper
>>> bound, and added smarts to extract_range_basic to process the two
>>> internal
>>> functions.
>>>
>>> Incidentally, this was the bit I was working on at the cauldron, which
>>> caused me to work on the min/max range combining.
>>>
>>> ok for trunk?
>>
>>
>> + /* Optimizing these two internal functions helps the loop
>> + optimizer eliminate outer comparisons. Size is [1,N]
>> + and pos is [0,N-1]. */
>> + {
>> + bool is_pos = ifn_code == IFN_GOACC_DIM_POS;
>> + tree attr = get_oacc_fn_attrib (current_function_decl);
>> + tree arg = gimple_call_arg (stmt, 0);
>> + int axis = TREE_INT_CST_LOW (arg);
>> + tree dims = TREE_VALUE (attr);
>> +
>> + for (int ix = axis; ix--;)
>> + dims = TREE_CHAIN (dims);
>> + int size = TREE_INT_CST_LOW (TREE_VALUE (dims));
>> +
>> + if (!size)
>> + /* If it's dynamic, the backend might know a hardware
>> + limitation. */
>> + size = targetm.goacc.dim_limit (axis);
>>
>> this all seems a little bit fragile and relying on implementation details?
>> Is the attribute always present?
>
>
> Yes. The ifns are inserted by a pass (execute_oacc_device_lower) that only
> operates on such functions. (I considered adding an assert, but figured the
> resulting segfault would be loud enough)
>
>> Is the call argument always a constant
>> that fits in a HOST_WIDE_INT (or even int here)?
>
>
> Yes.
>
>
> Are there always enough
>>
>> 'dims' in the tree list?
>
>
> Yes. The oacc_device_lower pass has already validated and canonicalized the
> dimensions.
>
>
> Is the 'dim' value always an INTEGER_CST that
>>
>> fits a HOST_WIDE_INT (or even an int here)?
>
>
> Yes. That's part of the validation. see set_oacc_fn_attrib (omp-low.c)
>
>> I hope all these constraints (esp. 'int' fitting) are verified by the
>> parser.
>
>
> It's an internal function not visible the user. Generation is entirely
> within the compiler
>
>> If so I'd like to see helper functions to hide these implementation
>> details
>> from generic code like this.
>
>
> ok.
>
>>
>> You miss to provide the known lower bound to VRP when size is 0
>> in the end. Just unconditioonally do
>>
>> tree type = TREE_TYPE (gimple_call_lhs (stmt));
>> set_value_range (vr, VR_RANGE,
>> build_int_cst (type, is_pos ? 0 : 1),
>> size
>> ? build_int_cst (type, size - is_pos)
>> : vrp_val_max (type), NULL);
>
>
> I'm confused. If size is zero, we never execute that path, and IIUC
> therefore never specify a range. What you suggest looks like an additional
> improvement though. Is that what you meant?
Yes.
> nathan
next prev parent reply other threads:[~2015-11-04 14:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 18:12 Nathan Sidwell
2015-11-04 10:26 ` Richard Biener
2015-11-04 13:56 ` Nathan Sidwell
2015-11-04 14:35 ` Richard Biener [this message]
2015-11-04 17:29 ` Nathan Sidwell
2015-11-05 11:32 ` Richard Biener
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='CAFiYyc3PLVsLDH3+Y32kJMV=jL9mJegRA2hXp7RoHE48K7R9MA@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nathan@acm.org \
/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).