]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[3/8] Multi-dimensional dynamic array support for OpenACC data clauses, gimplify...
authorJulian Brown <julian@codesourcery.com>
Tue, 5 Feb 2019 15:33:25 +0000 (07:33 -0800)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 3 Mar 2020 11:12:21 +0000 (12:12 +0100)
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)

gcc/ChangeLog.omp
gcc/gimplify.c

index f8f5587779aec182e98b010ff3232ebfd2b7b35b..d940ae222e5056bb0b34389e4869d0a3406df3b4 100644 (file)
@@ -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
index 79d0535c50a8276e0c9f71f375c70ceb9e862fdd..dc4531bc2d3064b59a7bf3df8bdb28cf58efab84 100644 (file)
@@ -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;