public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Chung-Lin Tang <cltang@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Thomas Schwinge <thomas@codesourcery.com>,
	Cesar Philippidis	<cesar_philippidis@mentor.com>,
	gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH, OpenACC] Make reduction arguments addressable
Date: Thu, 02 Jun 2016 13:55:00 -0000	[thread overview]
Message-ID: <fe1ec3d1-a2ca-89e1-2cd4-fa7734dae1d3@codesourcery.com> (raw)
In-Reply-To: <20160601133842.GQ28550@tucnak.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1461 bytes --]

On 2016/6/1 09:38 PM, Jakub Jelinek wrote:
>>  	construct_clauses.lists[OMP_LIST_REDUCTION] = NULL;
>> >        oacc_clauses = gfc_trans_omp_clauses (&block, &construct_clauses,
>> >  					    code->loc);
>> > +      for (tree c = oacc_clauses; c; c = OMP_CLAUSE_CHAIN (c))
>> > +	if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ASYNC)
>> > +	  {
>> > +	    for (c = oacc_clauses; c; c = OMP_CLAUSE_CHAIN (c))
>> > +	      if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
>> > +		  && DECL_P (OMP_CLAUSE_DECL (c)))
>> > +		TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1;
>> > +	    break;
>> > +	  }
>> >      }
> These 2 look wrong to me.  1) you really don't need to walk all the clauses
> to find if there is OMP_CLAUSE_ASYNC, you can just test the
> async field of struct gfc_omp_clauses.  And, 2) is there any reason why you
> can't just do this in gfc_trans_omp_clauses instead, when crating
> OMP_CLAUSE_REDUCTION if clauses->async is set?  Or are there some cases
> where on OpenACC constructs you don't want to do this?

Thanks for reminding, I didn't notice there was such a gfc_omp_clauses->async field.

Here's a much more succinct patch that does it inside gfc_trans_omp_clauses.
Again re-tested gfortran and libgomp without regressions.
Is this and the C/C++ patches (and the new testsuite cases) okay for trunk?

Thanks,
Chung-Lin

	fortran/
	* trans-openmp.c (gfc_trans_omp_clauses): Mark OpenACC reduction
	arguments as addressable when async clause exists.


[-- Attachment #2: a.diff --]
[-- Type: text/plain, Size: 715 bytes --]

Index: trans-openmp.c
===================================================================
--- trans-openmp.c	(revision 236845)
+++ trans-openmp.c	(working copy)
@@ -1748,6 +1748,12 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp
 	{
 	case OMP_LIST_REDUCTION:
 	  omp_clauses = gfc_trans_omp_reduction_list (n, omp_clauses, where);
+	  /* An OpenACC async clause indicates the need to set reduction
+	     arguments addressable, to allow asynchronous copy-out.  */
+	  if (clauses->async)
+	    for (c = omp_clauses; c; c = OMP_CLAUSE_CHAIN (c))
+	      if (DECL_P (OMP_CLAUSE_DECL (c)))
+		TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1;
 	  break;
 	case OMP_LIST_PRIVATE:
 	  clause_code = OMP_CLAUSE_PRIVATE;

  reply	other threads:[~2016-06-02 13:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30 18:42 Chung-Lin Tang
2016-05-30 21:43 ` Jakub Jelinek
2016-05-31  9:59   ` Thomas Schwinge
2016-05-31 11:10     ` Chung-Lin Tang
2016-06-01 13:32       ` Chung-Lin Tang
2016-06-01 13:39         ` Jakub Jelinek
2016-06-02 13:55           ` Chung-Lin Tang [this message]
2016-06-02 14:00             ` Jakub Jelinek
2016-06-03  7:13               ` Chung-Lin Tang
2016-06-03  7:15                 ` Jakub Jelinek
2016-06-10 10: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=fe1ec3d1-a2ca-89e1-2cd4-fa7734dae1d3@codesourcery.com \
    --to=cltang@codesourcery.com \
    --cc=cesar_philippidis@mentor.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=thomas@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).