diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-05-19 09:21:09 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-05-19 09:30:03 +0200 |
commit | 780e5d4a2bac6eb7566c966a265961c99449cb55 (patch) | |
tree | 510b86779d95345c176551b89007e22cb017b275 /gcc/c/c-parser.c | |
parent | c6c62ba41d905db5c10f573d0e0faa84656f1731 (diff) | |
download | gcc-780e5d4a2bac6eb7566c966a265961c99449cb55.zip gcc-780e5d4a2bac6eb7566c966a265961c99449cb55.tar.gz gcc-780e5d4a2bac6eb7566c966a265961c99449cb55.tar.bz2 |
openmp: Handle lastprivate on combined target correctly [PR99928]
This patch deals with 2 issues:
1) the gimplifier couldn't differentiate between
#pragma omp parallel master
#pragma omp taskloop simd
and
#pragma omp parallel master taskloop simd
when there is a significant difference for clause handling between
the two; as master construct doesn't have any clauses, we don't currently
represent it during gimplification by an gimplification omp context at all,
so this patch makes sure we don't set OMP_PARALLEL_COMBINED on parallel master
when not combined further. If we ever add a separate master context during
gimplification, we'd use ORT_COMBINED_MASTER vs. ORT_MASTER (or MASKED probably).
2) lastprivate when combined with target should be map(tofrom:) on the target,
this change handles it only when not combined with firstprivate though, that
will need further work (similarly to linear or reduction).
2021-05-19 Jakub Jelinek <jakub@redhat.com>
PR middle-end/99928
gcc/
* tree.h (OMP_MASTER_COMBINED): Define.
* gimplify.c (gimplify_scan_omp_clauses): Rewrite lastprivate
handling for outer combined/composite constructs to a loop.
Handle lastprivate on combined target.
(gimplify_expr): Formatting fix.
gcc/c/
* c-parser.c (c_parser_omp_master): Set OMP_MASTER_COMBINED on
master when combined with taskloop.
(c_parser_omp_parallel): Don't set OMP_PARALLEL_COMBINED on
parallel master when not combined with taskloop.
gcc/cp/
* parser.c (cp_parser_omp_master): Set OMP_MASTER_COMBINED on
master when combined with taskloop.
(cp_parser_omp_parallel): Don't set OMP_PARALLEL_COMBINED on
parallel master when not combined with taskloop.
gcc/testsuite/
* c-c++-common/gomp/pr99928-2.c: Remove all xfails.
* c-c++-common/gomp/pr99928-12.c: New test.
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r-- | gcc/c/c-parser.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index f79b839..b9930d4 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -18826,6 +18826,7 @@ c_parser_omp_master (location_t loc, c_parser *parser, if (ret == NULL_TREE) return ret; ret = c_finish_omp_master (loc, block); + OMP_MASTER_COMBINED (ret) = 1; return ret; } } @@ -19126,7 +19127,16 @@ c_parser_omp_parallel (location_t loc, c_parser *parser, block); if (ret == NULL) return ret; - OMP_PARALLEL_COMBINED (stmt) = 1; + /* master doesn't have any clauses and during gimplification + isn't represented by a gimplification omp context, so for + #pragma omp parallel master don't set OMP_PARALLEL_COMBINED, + so that + #pragma omp parallel master + #pragma omp taskloop simd lastprivate (x) + isn't confused with + #pragma omp parallel master taskloop simd lastprivate (x) */ + if (OMP_MASTER_COMBINED (ret)) + OMP_PARALLEL_COMBINED (stmt) = 1; return stmt; } else if (strcmp (p, "loop") == 0) |