gimplify.c (gimplify_scan_omp_clauses): For inscan reductions on worksharing loop...
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Jul 2019 04:56:25 +0000 (06:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Jul 2019 04:56:25 +0000 (06:56 +0200)
* gimplify.c (gimplify_scan_omp_clauses): For inscan reductions
on worksharing loop propagate it as shared clause to containing
combined parallel.

* c-omp.c (c_omp_split_clauses): Put OMP_CLAUSE_REDUCTION_INSCAN
clauses on OMP_FOR rather than OMP_PARALLEL when OMP_FOR is combined
with OMP_PARALLEL.

* c-c++-common/gomp/scan-5.c: New test.

From-SVN: r272957

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-omp.c
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/scan-5.c [new file with mode: 0644]

index 58937b0496b16c52a698ec4ab9d38e14f24de5ca..0f00fce6e38be760b43dc65c85950add3d01a4f3 100644 (file)
@@ -1,5 +1,9 @@
 2019-07-03  Jakub Jelinek  <jakub@redhat.com>
 
+       * gimplify.c (gimplify_scan_omp_clauses): For inscan reductions
+       on worksharing loop propagate it as shared clause to containing
+       combined parallel.
+
        * omp-expand.c (expand_omp_for_static_nochunk,
        expand_omp_for_static_chunk): For nowait worksharing loop with
        conditional lastprivate clause(s), emit GOMP_loop_end_nowait call
index e56bd7a8e35e9788a3134f792551dca1130a3cb8..3907d3a5fffa3dd6a2abfd2a18c6c699a6b3905b 100644 (file)
@@ -1,3 +1,9 @@
+2019-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+       * c-omp.c (c_omp_split_clauses): Put OMP_CLAUSE_REDUCTION_INSCAN
+       clauses on OMP_FOR rather than OMP_PARALLEL when OMP_FOR is combined
+       with OMP_PARALLEL.
+
 2019-07-02  qing zhao  <qing.zhao@oracle.com>
 
        PR preprocessor/90581
index 97206a122d215e3b9380473a5bb42083c69172f6..583305e268b11a1ffcd7560205abfdd789270700 100644 (file)
@@ -1634,7 +1634,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
          break;
        /* Reduction is allowed on simd, for, parallel, sections, taskloop
           and teams.  Duplicate it on all of them, but omit on for or
-          sections if parallel is present.  If taskloop is combined with
+          sections if parallel is present (unless inscan, in that case
+          omit on parallel).  If taskloop is combined with
           parallel, omit it on parallel.  */
        case OMP_CLAUSE_REDUCTION:
          if (OMP_CLAUSE_REDUCTION_TASK (clauses))
@@ -1708,7 +1709,8 @@ c_omp_split_clauses (location_t loc, enum tree_code code,
                  s = C_OMP_CLAUSE_SPLIT_PARALLEL;
                }
              else if ((mask & (OMP_CLAUSE_MASK_1
-                               << PRAGMA_OMP_CLAUSE_NUM_THREADS)) != 0)
+                               << PRAGMA_OMP_CLAUSE_NUM_THREADS)) != 0
+                      && !OMP_CLAUSE_REDUCTION_INSCAN (clauses))
                s = C_OMP_CLAUSE_SPLIT_PARALLEL;
              else
                s = C_OMP_CLAUSE_SPLIT_FOR;
index 5c51f504368923be7f9ad10acb7bd02ee4f1dd74..9e5e4230941254de5eae4777eb9a4aa7ea692308 100644 (file)
@@ -9125,7 +9125,10 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
                          " or private in outer context", DECL_NAME (decl));
            }
        do_notice:
-         if ((region_type & ORT_TASKLOOP) == ORT_TASKLOOP
+         if (((region_type & ORT_TASKLOOP) == ORT_TASKLOOP
+              || (region_type == ORT_WORKSHARE
+                  && OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+                  && OMP_CLAUSE_REDUCTION_INSCAN (c)))
              && outer_ctx
              && outer_ctx->region_type == ORT_COMBINED_PARALLEL
              && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
index 5abcceec60164c0c60e9a554313450d6abb47c05..2e3999ed9ef38f964b162552a36d06c4b78ffddf 100644 (file)
@@ -1,5 +1,7 @@
 2019-07-03  Jakub Jelinek  <jakub@redhat.com>
 
+       * c-c++-common/gomp/scan-5.c: New test.
+
        * c-c++-common/gomp/lastprivate-conditional-5.c: New test.
 
 2019-07-02  Jeff Law  <law@redhat.com>
diff --git a/gcc/testsuite/c-c++-common/gomp/scan-5.c b/gcc/testsuite/c-c++-common/gomp/scan-5.c
new file mode 100644 (file)
index 0000000..92945ba
--- /dev/null
@@ -0,0 +1,13 @@
+int
+foo (int *a, int *b)
+{
+  int r = 0;
+  #pragma omp parallel for reduction (inscan, +:r) default(none) firstprivate (a, b)
+  for (int i = 0; i < 64; i++)
+    {
+      r += a[i];
+      #pragma omp scan inclusive (r)   /* { dg-message "sorry, unimplemented: '#pragma omp scan' not supported yet" } */
+      b[i] = r;
+    }
+  return r;
+}