public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, OpenACC] Make reduction arguments addressable
@ 2016-05-30 18:42 Chung-Lin Tang
  2016-05-30 21:43 ` Jakub Jelinek
  0 siblings, 1 reply; 11+ messages in thread
From: Chung-Lin Tang @ 2016-05-30 18:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek, Cesar Philippidis

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

Hi, a previous patch of Cesar's has made the middle-end omp-lowering
automatically create and insert a tofrom (i.e. present_or_copy) map for
parallel reductions.  This allowed the user to not need explicit
clauses to copy out the reduction result, but because reduction arguments
are not marked addressable, async does not work as expected,
i.e. the asynchronous copy-out results are not used in the compiler generated code.

This patch fixes this in the front-ends, I've tested this patch without
new regressions, and fixes some C++ OpenACC tests that regressed after
my last OpenACC async patch.  Is this okay for trunk?

Thanks,
Chung-Lin

2016-05-30  Chung-Lin Tang  <cltang@codesourcery.com>

	c/
	* c-typeck.c (c_finish_omp_clauses): Mark OpenACC reduction
	arguments as addressable.

	cp/
	* semantics.c (finish_omp_clauses): Mark OpenACC reduction
	arguments as addressable.

	fortran/
	* trans-openmp.c (gfc_trans_oacc_construct): Mark OpenACC reduction
	arguments as addressable.
	(gfc_trans_oacc_combined_directive): Likewise.

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

Index: c/c-typeck.c
===================================================================
--- c/c-typeck.c	(revision 236845)
+++ c/c-typeck.c	(working copy)
@@ -12575,6 +12575,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_reg
 	      remove = true;
 	      break;
 	    }
+	  if (ort & C_ORT_ACC)
+	    c_mark_addressable (t);
 	  type = TREE_TYPE (t);
 	  if (TREE_CODE (t) == MEM_REF)
 	    type = TREE_TYPE (type);
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 236845)
+++ cp/semantics.c	(working copy)
@@ -5827,6 +5827,8 @@ finish_omp_clauses (tree clauses, enum c_omp_regio
 		t = n;
 	      goto check_dup_generic_t;
 	    }
+	  if (ort & C_ORT_ACC)
+	    cxx_mark_addressable (t);
 	  goto check_dup_generic;
 	case OMP_CLAUSE_COPYPRIVATE:
 	  copyprivate_seen = true;
Index: fortran/trans-openmp.c
===================================================================
--- fortran/trans-openmp.c	(revision 236845)
+++ fortran/trans-openmp.c	(working copy)
@@ -2704,6 +2704,10 @@ gfc_trans_oacc_construct (gfc_code *code)
   gfc_start_block (&block);
   oacc_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
 					code->loc);
+  for (tree 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;
   stmt = gfc_trans_omp_code (code->block->next, true);
   stmt = build2_loc (input_location, construct_code, void_type_node, stmt,
 		     oacc_clauses);
@@ -3501,6 +3505,10 @@ gfc_trans_oacc_combined_directive (gfc_code *code)
 	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_REDUCTION
+	    && DECL_P (OMP_CLAUSE_DECL (c)))
+	  TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1;
     }
   if (!loop_clauses.seq)
     pblock = &block;

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-06-10 10:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-30 18:42 [PATCH, OpenACC] Make reduction arguments addressable 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
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

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).