public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Chung-Lin Tang <cltang@codesourcery.com>
To: Thomas Schwinge <thomas@codesourcery.com>
Cc: <gcc-patches@gcc.gnu.org>, Catherine Moore <clm@codesourcery.com>,
	Tobias Burnus <tobias@codesourcery.com>
Subject: Re: [PATCH, OG10, OpenMP 5.0, committed] Implement relaxation of implicit map vs. existing device mappings
Date: Mon, 10 May 2021 17:35:58 +0800	[thread overview]
Message-ID: <463bb1ee-6475-3546-510b-c7d533b47183@codesourcery.com> (raw)
In-Reply-To: <87tuneu3f4.fsf@euler.schwinge.homeip.net>

On 2021/5/7 8:35 PM, Thomas Schwinge wrote:
> On 2021-05-05T23:17:25+0800, Chung-Lin Tang via Gcc-patches<gcc-patches@gcc.gnu.org>  wrote:
>> This patch implements relaxing the requirements when a map with the implicit attribute encounters
>> an overlapping existing map.  [...]
> Oh, oh, these data mapping interfaces/semantics ares getting more and
> more "convoluted"...  %-\ (Not your fault, of course.)
> 
> Haven't looked in too much detail in the patch/implementation (I'm not
> very well-versend in the exact OpenMP semantics anyway), but I suppose we
> should do similar things for OpenACC, too.  I think we even currently do
> have a gimplification-level "hack" to replicate data clauses' array
> bounds for implicit data clauses on compute constructs, if the default
> "complete" mapping is going to clash with a "limited" mapping that's
> specified in an outer OpenACC 'data' directive.  (That, of course,
> doesn't work for the general case of non-lexical scoping, or dynamic
> OpenACC 'enter data', etc., I suppose) I suppose your method could easily
> replace and improve that; we shall look into that later.
> 
> That said, in your patch, is this current implementation (explicitly)
> meant or not meant to be active for OpenACC, too, or just OpenMP (I
> couldn't quickly tell), and/or is it (implicitly?) a no-op for OpenACC?

It appears that I have inadvertently enabled it for OpenACC as well!
But everything was tested together, so I assume it works okay for that mode as well.

The entire set of implicit-specific actions are enabled by the setting of
'OMP_CLAUSE_MAP_IMPLICIT_P (clause) = 1' inside gimplify.c:gimplify_adjust_omp_clauses_1,
so in case you want to disable it for OpenACC again, that's where you need to add the guard condition.

>> Also, another adjustment in this patch is how implicitly created clauses are added to the current
>> clause list in gimplify_adjust_omp_clauses(). Instead of simply appending the new clauses to the end,
>> this patch adds them at the position "after initial non-map clauses, but right before any existing
>> map clauses".
> Probably you haven't been testing such a configuration; I've just pushed
> "Fix up 'c-c++-common/goacc/firstprivate-mappings-1.c' for C, non-LP64"
> to devel/omp/gcc-10 branch in commit
> c51cc3b96f0b562deaffcfbcc51043aed216801a, see attached.

Thanks, I was relying on eyeballing to know where to fix testcases like this;
I did fix another similar case, but missed this one.

> 
>> The reason for this is: when combined with other map clauses, for example:
>>
>>     #pragma omp target map(rec.ptr[:N])
>>     for (int i = 0; i < N; i++)
>>       rec.ptr[i] += 1;
>>
>> There will be an implicit map created for map(rec), because of the access inside the target region.
>> The expectation is that 'rec' is implicitly mapped, and then the pointed array-section part by 'rec.ptr'
>> will be mapped, and then attachment to the 'rec.ptr' field of the mapped 'rec' (in that order).
>>
>> If the implicit 'map(rec)' is appended to the end, instead of placed before other maps, the attachment
>> operation will not find anything to attach to, and the entire region will fail.
> But that doesn't (negatively) affect user-visible semantics (OpenMP, and
> also OpenACC, if applicable), in that more/bigger objects then get mapped
> than were before?  (I suppose not?)

It probably won't affect user level semantics, although we should look out if this change in convention
exposes some other bugs.

Chung-Lin

  reply	other threads:[~2021-05-10  9:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 15:17 Chung-Lin Tang
2021-05-07 12:35 ` Thomas Schwinge
2021-05-10  9:35   ` Chung-Lin Tang [this message]
2021-05-14 13:20   ` [PATCH, OpenMP 5.0] Implement relaxation of implicit map vs. existing device mappings (for mainline trunk) Chung-Lin Tang
2021-06-07 11:28     ` Thomas Schwinge
2021-06-24 15:55     ` Jakub Jelinek
2021-11-05 16:51       ` [PATCH, v2, " Chung-Lin Tang
2021-11-09 15:18         ` Jakub Jelinek
2021-11-24 11:22         ` Thomas Schwinge

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=463bb1ee-6475-3546-510b-c7d533b47183@codesourcery.com \
    --to=cltang@codesourcery.com \
    --cc=clm@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=thomas@codesourcery.com \
    --cc=tobias@codesourcery.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).