[gcc/devel/omp/gcc-9] [3/8] Multi-dimensional dynamic array support for OpenACC data clauses, gimplify patch

Thomas Schwinge tschwinge@gcc.gnu.org
Tue Mar 3 12:02:00 GMT 2020


https://gcc.gnu.org/g:a56d5cfffdb1e74989f86363c043f29ce9228486

commit a56d5cfffdb1e74989f86363c043f29ce9228486
Author: Julian Brown <julian@codesourcery.com>
Date:   Tue Feb 5 07:33:25 2019 -0800

    [3/8] Multi-dimensional dynamic array support for OpenACC data clauses, gimplify patch
    
    2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>
    
    	gcc/
    	* gimplify.c (gimplify_scan_omp_clauses): For dynamic array map kinds,
    	make sure bias in each dimension are put into firstprivate variables.
    
    (cherry picked from openacc-gcc-9-branch commit
    a9cde8c122c4dc48bd8aad71e0c543e07b08a4ca)

Diff:
---
 gcc/ChangeLog.omp |  5 +++++
 gcc/gimplify.c    | 24 ++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index f8f55877..d940ae2 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,8 @@
+2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>
+
+	* gimplify.c (gimplify_scan_omp_clauses): For dynamic array map kinds,
+	make sure bias in each dimension are put into firstprivate variables.
+
 2019-01-31  Julian Brown  <julian@codesourcery.com>
 
 	* gimplify.c (gimplify_scan_omp_clauses): Handle array sections on
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 79d0535..dc4531b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -8617,8 +8617,28 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
 	  if (OMP_CLAUSE_SIZE (c) == NULL_TREE)
 	    OMP_CLAUSE_SIZE (c) = DECL_P (decl) ? DECL_SIZE_UNIT (decl)
 				  : TYPE_SIZE_UNIT (TREE_TYPE (decl));
-	  if (gimplify_expr (&OMP_CLAUSE_SIZE (c), pre_p,
-			     NULL, is_gimple_val, fb_rvalue) == GS_ERROR)
+	  if (OMP_CLAUSE_SIZE (c)
+	      && TREE_CODE (OMP_CLAUSE_SIZE (c)) == TREE_LIST
+	      && GOMP_MAP_DYNAMIC_ARRAY_P (OMP_CLAUSE_MAP_KIND (c)))
+	    {
+	      tree dims = OMP_CLAUSE_SIZE (c);
+	      for (tree t = dims; t; t = TREE_CHAIN (t))
+		{
+		  /* If a dimension bias isn't a constant, we have to ensure
+		     that the value gets transferred to the offload target.  */
+		  tree low_bound = TREE_PURPOSE (t);
+		  if (TREE_CODE (low_bound) != INTEGER_CST)
+		    {
+		      low_bound = get_initialized_tmp_var (low_bound, pre_p,
+							   NULL, false);
+		      omp_add_variable (ctx, low_bound,
+					GOVD_FIRSTPRIVATE | GOVD_SEEN);
+		      TREE_PURPOSE (t) = low_bound;
+		    }
+		}
+	    }
+	  else if (gimplify_expr (&OMP_CLAUSE_SIZE (c), pre_p,
+				  NULL, is_gimple_val, fb_rvalue) == GS_ERROR)
 	    {
 	      remove = true;
 	      break;



More information about the Gcc-cvs mailing list