public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Cesar Philippidis <cesar_philippidis@mentor.com>
Subject: Re: OpenACC Firstprivate
Date: Mon, 09 Nov 2015 14:46:00 -0000	[thread overview]
Message-ID: <5640B1B4.2070701@acm.org> (raw)
In-Reply-To: <20151109141034.GS5675@tucnak.redhat.com>

On 11/09/15 09:10, Jakub Jelinek wrote:
> On Mon, Nov 09, 2015 at 08:59:15AM -0500, Nathan Sidwell wrote:
>>> This I'm afraid performs often two copies rather than just one (one to copy
>>> the host value to the present_copyin mapped value, another one in the
>>> region),
>>
>> I don't think that can be avoided.  The host doesn't have control over when
>> the CTAs (a gang) start -- they may even be serialized onto the same
>> physical HW. So each gang has to initialize its own instance.  Or did you
>> mean something else?
>
> So, what is the scope of the private and firstprivate vars in OpenACC?
> In OpenMP if a variable is private or firstprivate on the target construct,
> unless further privatized in inner constructs it is really shared among all
> the threads in all the teams (ro one var per all CTAs/workers in PTX terms).
> Is that the case for OpenACC too, or are the vars e.g. private to each CTA
> already or to each thread in each CTA, something different?
> If they are shared by all CTAs, then you should hopefully be able to use the
> GOMP_MAP_FIRSTPRIVATE{,_INT}, if not, then I'd say you should at least use
> those to provide you the initializer data to initialize your private vars
> from as a cheaper alternative to mapping.

I'm going to try and get clarification, but I think the intent is to initialize 
with the value seen on the device.  Consider:


int foo = 0;
#pragma acc data copyin(foo)
{
   #pragma acc parallel present(foo)
   {
     foo = 2;
   }

   if (expr){
     #pragma update host (foo)
   }

   #pragma acc parallel firstprivate (foo)
   {
   // which initialization value?
   }
}

Here we copy data to the device, then set it a distinct value there.  We 
conditionally update the host's instance from the device.

My thinking is that the intent of the firstprivate is to initialize with the 
value known on the device (and behave as-if copyin, if it's not there).  Not the 
value most recently seen on the host -- the update clause could change that, and 
may well be being used as a debugging aide, so it seems bizarre that it can 
change program semantics in such a way.

  reply	other threads:[~2015-11-09 14:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-07 13:50 Nathan Sidwell
2015-11-09 13:46 ` Jakub Jelinek
2015-11-09 13:59   ` Nathan Sidwell
2015-11-09 14:06     ` Nathan Sidwell
2015-11-09 14:10     ` Jakub Jelinek
2015-11-09 14:46       ` Nathan Sidwell [this message]
2015-11-10 14:13         ` Nathan Sidwell
2015-11-11  8:05           ` Jakub Jelinek
2015-11-11 13:44             ` Nathan Sidwell
2015-11-12  9:00               ` Thomas Schwinge
2015-11-11 13:52             ` [gomp4] Rework gimplifyier region flags Nathan Sidwell

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=5640B1B4.2070701@acm.org \
    --to=nathan@acm.org \
    --cc=cesar_philippidis@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).