From 00631022d83c44777b37f168831eb64142737cbe Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 30 May 2016 23:36:24 +0200 Subject: [PATCH] re PR c++/71349 (Combined async target clause parsing issues) PR c++/71349 * c-parser.c (c_parser_omp_for): Don't disallow nowait clause when combined with target construct. * parser.c (cp_parser_omp_for): Don't disallow nowait clause when combined with target construct. (cp_parser_omp_parallel): Pass cclauses == NULL as last argument to cp_parser_omp_all_clauses. * c-omp.c (c_omp_split_clauses): Put OMP_CLAUSE_DEPEND to C_OMP_CLAUSE_SPLIT_TARGET. Put OMP_CLAUSE_NOWAIT to C_OMP_CLAUSE_SPLIT_TARGET if combined with target construct, instead of C_OMP_CLAUSE_SPLIT_FOR. * c-c++-common/gomp/clauses-1.c (bar): Add dd argument. Add nowait depend(inout: dd[0]) clauses where permitted. From-SVN: r236900 --- gcc/c-family/ChangeLog | 8 +++++++ gcc/c-family/c-omp.c | 14 +++++++++++- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 4 +++- gcc/cp/ChangeLog | 8 +++++++ gcc/cp/parser.c | 7 ++++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/c-c++-common/gomp/clauses-1.c | 24 +++++++++++---------- 8 files changed, 62 insertions(+), 15 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7f0ca2d8057..f2f98c5c863 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2016-05-30 Jakub Jelinek + + PR c++/71349 + * c-omp.c (c_omp_split_clauses): Put OMP_CLAUSE_DEPEND to + C_OMP_CLAUSE_SPLIT_TARGET. Put OMP_CLAUSE_NOWAIT to + C_OMP_CLAUSE_SPLIT_TARGET if combined with target construct, + instead of C_OMP_CLAUSE_SPLIT_FOR. + 2016-05-24 Richard Biener PR middle-end/70434 diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index be401bbb6b4..1691c40f11a 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -983,6 +983,7 @@ c_omp_split_clauses (location_t loc, enum tree_code code, case OMP_CLAUSE_MAP: case OMP_CLAUSE_IS_DEVICE_PTR: case OMP_CLAUSE_DEFAULTMAP: + case OMP_CLAUSE_DEPEND: s = C_OMP_CLAUSE_SPLIT_TARGET; break; case OMP_CLAUSE_NUM_TEAMS: @@ -998,7 +999,6 @@ c_omp_split_clauses (location_t loc, enum tree_code code, s = C_OMP_CLAUSE_SPLIT_PARALLEL; break; case OMP_CLAUSE_ORDERED: - case OMP_CLAUSE_NOWAIT: s = C_OMP_CLAUSE_SPLIT_FOR; break; case OMP_CLAUSE_SCHEDULE: @@ -1333,6 +1333,18 @@ c_omp_split_clauses (location_t loc, enum tree_code code, else s = C_OMP_CLAUSE_SPLIT_FOR; break; + case OMP_CLAUSE_NOWAIT: + /* Nowait clause is allowed on target, for and sections, but + is not allowed on parallel for or parallel sections. Therefore, + put it on target construct if present, because that can only + be combined with parallel for{, simd} and not with for{, simd}, + otherwise to the worksharing construct. */ + if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) + != 0) + s = C_OMP_CLAUSE_SPLIT_TARGET; + else + s = C_OMP_CLAUSE_SPLIT_FOR; + break; default: gcc_unreachable (); } diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index f7d1a6d582e..d2a8947d1b3 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-05-30 Jakub Jelinek + + PR c++/71349 + * c-parser.c (c_parser_omp_for): Don't disallow nowait clause + when combined with target construct. + 2016-05-26 Jakub Jelinek * c-parser.c (c_parser_omp_clause_schedule): Warn if diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index fda2df8e44e..bca8653f8d8 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -15113,7 +15113,9 @@ c_parser_omp_for (location_t loc, c_parser *parser, strcat (p_name, " for"); mask |= OMP_FOR_CLAUSE_MASK; - if (cclauses) + /* parallel for{, simd} disallows nowait clause, but for + target {teams distribute ,}parallel for{, simd} it should be accepted. */ + if (cclauses && (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) == 0) mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT); /* Composite distribute parallel for{, simd} disallows ordered clause. */ if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 84d7e0ac7ff..1e4ca0c3471 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2016-05-30 Jakub Jelinek + + PR c++/71349 + * parser.c (cp_parser_omp_for): Don't disallow nowait clause + when combined with target construct. + (cp_parser_omp_parallel): Pass cclauses == NULL as last argument + to cp_parser_omp_all_clauses. + 2016-05-30 Paolo Carlini PR c++/71238 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c6c2c0cf948..29a1b804e73 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -33919,7 +33919,9 @@ cp_parser_omp_for (cp_parser *parser, cp_token *pragma_tok, strcat (p_name, " for"); mask |= OMP_FOR_CLAUSE_MASK; - if (cclauses) + /* parallel for{, simd} disallows nowait clause, but for + target {teams distribute ,}parallel for{, simd} it should be accepted. */ + if (cclauses && (mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_MAP)) == 0) mask &= ~(OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT); /* Composite distribute parallel for{, simd} disallows ordered clause. */ if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DIST_SCHEDULE)) != 0) @@ -34258,7 +34260,8 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok, } } - clauses = cp_parser_omp_all_clauses (parser, mask, p_name, pragma_tok); + clauses = cp_parser_omp_all_clauses (parser, mask, p_name, pragma_tok, + cclauses == NULL); if (cclauses) { cp_omp_split_clauses (loc, OMP_PARALLEL, mask, clauses, cclauses); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4859224ed56..d9ef789ba1f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-05-30 Jakub Jelinek + + PR c++/71349 + * c-c++-common/gomp/clauses-1.c (bar): Add dd argument. Add + nowait depend(inout: dd[0]) clauses where permitted. + 2016-05-30 Paolo Carlini PR c++/71238 diff --git a/gcc/testsuite/c-c++-common/gomp/clauses-1.c b/gcc/testsuite/c-c++-common/gomp/clauses-1.c index 91aed3960f6..fe90c2428e0 100644 --- a/gcc/testsuite/c-c++-common/gomp/clauses-1.c +++ b/gcc/testsuite/c-c++-common/gomp/clauses-1.c @@ -34,7 +34,7 @@ foo (int d, int m, int i1, int i2, int p, int *idp, int s, void bar (int d, int m, int i1, int i2, int p, int *idp, int s, - int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q) + int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q, int *dd) { #pragma omp for simd \ private (p) firstprivate (f) lastprivate (l) linear (ll:1) reduction(+:r) schedule(static, 4) collapse(1) nowait \ @@ -63,29 +63,30 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, } #pragma omp target parallel \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ - if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) + if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \ + nowait depend(inout: dd[0]) ; #pragma omp target parallel for \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \ - lastprivate (l) linear (ll:1) ordered schedule(static, 4) collapse(1) + lastprivate (l) linear (ll:1) ordered schedule(static, 4) collapse(1) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target parallel for simd \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \ lastprivate (l) linear (ll:1) schedule(static, 4) collapse(1) \ - safelen(8) simdlen(4) aligned(q: 32) + safelen(8) simdlen(4) aligned(q: 32) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target teams \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ - shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) + shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) nowait depend(inout: dd[0]) ; #pragma omp target teams distribute \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ - collapse(1) dist_schedule(static, 16) + collapse(1) dist_schedule(static, 16) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ; #pragma omp target teams distribute parallel for \ @@ -93,7 +94,7 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ collapse(1) dist_schedule(static, 16) \ if (parallel: i2) num_threads (nth) proc_bind(spread) \ - lastprivate (l) schedule(static, 4) + lastprivate (l) schedule(static, 4) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target teams distribute parallel for simd \ @@ -102,19 +103,20 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, collapse(1) dist_schedule(static, 16) \ if (parallel: i2) num_threads (nth) proc_bind(spread) \ lastprivate (l) schedule(static, 4) \ - safelen(8) simdlen(4) aligned(q: 32) + safelen(8) simdlen(4) aligned(q: 32) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target teams distribute simd \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ collapse(1) dist_schedule(static, 16) \ - safelen(8) simdlen(4) aligned(q: 32) + safelen(8) simdlen(4) aligned(q: 32) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target simd \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ - safelen(8) simdlen(4) lastprivate (l) linear(ll: 1) aligned(q: 32) reduction(+:r) + safelen(8) simdlen(4) lastprivate (l) linear(ll: 1) aligned(q: 32) reduction(+:r) \ + nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp taskloop simd \ @@ -128,7 +130,7 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, safelen(8) simdlen(4) linear(ll: 1) aligned(q: 32) reduction(+:r) for (int i = 0; i < 64; i++) ll++; - #pragma omp target + #pragma omp target nowait depend(inout: dd[0]) #pragma omp teams distribute \ private(p) firstprivate (f) shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ collapse(1) dist_schedule(static, 16) -- 2.30.2