diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2022-11-28 11:08:32 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2022-11-28 11:10:31 +0100 |
commit | 091b6dbc48177fa3ef15d62ea280ef6cb61c05b2 (patch) | |
tree | 7c35223e5916d2a9bb840ee6ef8ab3c19b02c1b3 /gcc/fortran/openmp.cc | |
parent | 5dd4d2e93e3de60d4ef1068b6dfd06b6b9fff16e (diff) | |
download | gcc-091b6dbc48177fa3ef15d62ea280ef6cb61c05b2.zip gcc-091b6dbc48177fa3ef15d62ea280ef6cb61c05b2.tar.gz gcc-091b6dbc48177fa3ef15d62ea280ef6cb61c05b2.tar.bz2 |
OpenMP/Fortran: Permit end-clause on directive
gcc/fortran/ChangeLog:
* openmp.cc (OMP_DO_CLAUSES, OMP_SCOPE_CLAUSES,
OMP_SECTIONS_CLAUSES): Add 'nowait'.
(OMP_SINGLE_CLAUSES): Add 'nowait' and 'copyprivate'.
(gfc_match_omp_distribute_parallel_do,
gfc_match_omp_distribute_parallel_do_simd,
gfc_match_omp_parallel_do,
gfc_match_omp_parallel_do_simd,
gfc_match_omp_parallel_sections,
gfc_match_omp_teams_distribute_parallel_do,
gfc_match_omp_teams_distribute_parallel_do_simd): Disallow 'nowait'.
(gfc_match_omp_workshare): Match 'nowait' clause.
(gfc_match_omp_end_single): Use clause matcher for 'nowait'.
(resolve_omp_clauses): Reject 'nowait' + 'copyprivate'.
* parse.cc (decode_omp_directive): Break too long line.
(parse_omp_do, parse_omp_structured_block): Diagnose duplicated
'nowait' clause.
libgomp/ChangeLog:
* libgomp.texi (OpenMP 5.2): Mark end-directive as Y.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/copyprivate-1.f90: New test.
* gfortran.dg/gomp/copyprivate-2.f90: New test.
* gfortran.dg/gomp/nowait-2.f90: Move dg-error tests ...
* gfortran.dg/gomp/nowait-4.f90: ... to this new file.
* gfortran.dg/gomp/nowait-5.f90: New test.
* gfortran.dg/gomp/nowait-6.f90: New test.
* gfortran.dg/gomp/nowait-7.f90: New test.
* gfortran.dg/gomp/nowait-8.f90: New test.
Diffstat (limited to 'gcc/fortran/openmp.cc')
-rw-r--r-- | gcc/fortran/openmp.cc | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index e0e3b52..862c649 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -4173,17 +4173,19 @@ cleanup: (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_FIRSTPRIVATE \ | OMP_CLAUSE_LASTPRIVATE | OMP_CLAUSE_REDUCTION \ | OMP_CLAUSE_SCHEDULE | OMP_CLAUSE_ORDERED | OMP_CLAUSE_COLLAPSE \ - | OMP_CLAUSE_LINEAR | OMP_CLAUSE_ORDER | OMP_CLAUSE_ALLOCATE) + | OMP_CLAUSE_LINEAR | OMP_CLAUSE_ORDER | OMP_CLAUSE_ALLOCATE \ + | OMP_CLAUSE_NOWAIT) #define OMP_LOOP_CLAUSES \ (omp_mask (OMP_CLAUSE_BIND) | OMP_CLAUSE_COLLAPSE | OMP_CLAUSE_ORDER \ | OMP_CLAUSE_PRIVATE | OMP_CLAUSE_LASTPRIVATE | OMP_CLAUSE_REDUCTION) #define OMP_SCOPE_CLAUSES \ (omp_mask (OMP_CLAUSE_PRIVATE) |OMP_CLAUSE_FIRSTPRIVATE \ - | OMP_CLAUSE_REDUCTION | OMP_CLAUSE_ALLOCATE) + | OMP_CLAUSE_REDUCTION | OMP_CLAUSE_ALLOCATE | OMP_CLAUSE_NOWAIT) #define OMP_SECTIONS_CLAUSES \ (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_FIRSTPRIVATE \ - | OMP_CLAUSE_LASTPRIVATE | OMP_CLAUSE_REDUCTION | OMP_CLAUSE_ALLOCATE) + | OMP_CLAUSE_LASTPRIVATE | OMP_CLAUSE_REDUCTION \ + | OMP_CLAUSE_ALLOCATE | OMP_CLAUSE_NOWAIT) #define OMP_SIMD_CLAUSES \ (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_LASTPRIVATE \ | OMP_CLAUSE_REDUCTION | OMP_CLAUSE_COLLAPSE | OMP_CLAUSE_SAFELEN \ @@ -4233,7 +4235,7 @@ cleanup: | OMP_CLAUSE_ORDER | OMP_CLAUSE_ALLOCATE) #define OMP_SINGLE_CLAUSES \ (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_FIRSTPRIVATE \ - | OMP_CLAUSE_ALLOCATE) + | OMP_CLAUSE_ALLOCATE | OMP_CLAUSE_NOWAIT | OMP_CLAUSE_COPYPRIVATE) #define OMP_ORDERED_CLAUSES \ (omp_mask (OMP_CLAUSE_THREADS) | OMP_CLAUSE_SIMD) #define OMP_DECLARE_TARGET_CLAUSES \ @@ -4247,7 +4249,8 @@ cleanup: (omp_mask (OMP_CLAUSE_FILTER)) #define OMP_ERROR_CLAUSES \ (omp_mask (OMP_CLAUSE_AT) | OMP_CLAUSE_MESSAGE | OMP_CLAUSE_SEVERITY) - +#define OMP_WORKSHARE_CLAUSES \ + omp_mask (OMP_CLAUSE_NOWAIT) static match @@ -4458,8 +4461,8 @@ gfc_match_omp_distribute_parallel_do (void) return match_omp (EXEC_OMP_DISTRIBUTE_PARALLEL_DO, (OMP_DISTRIBUTE_CLAUSES | OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES) - & ~(omp_mask (OMP_CLAUSE_ORDERED)) - & ~(omp_mask (OMP_CLAUSE_LINEAR))); + & ~(omp_mask (OMP_CLAUSE_ORDERED) + | OMP_CLAUSE_LINEAR | OMP_CLAUSE_NOWAIT)); } @@ -4469,7 +4472,7 @@ gfc_match_omp_distribute_parallel_do_simd (void) return match_omp (EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD, (OMP_DISTRIBUTE_CLAUSES | OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES | OMP_SIMD_CLAUSES) - & ~(omp_mask (OMP_CLAUSE_ORDERED))); + & ~(omp_mask (OMP_CLAUSE_ORDERED) | OMP_CLAUSE_NOWAIT)); } @@ -5770,7 +5773,8 @@ match gfc_match_omp_parallel_do (void) { return match_omp (EXEC_OMP_PARALLEL_DO, - OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES); + (OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES) + & ~(omp_mask (OMP_CLAUSE_NOWAIT))); } @@ -5778,7 +5782,8 @@ match gfc_match_omp_parallel_do_simd (void) { return match_omp (EXEC_OMP_PARALLEL_DO_SIMD, - OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES | OMP_SIMD_CLAUSES); + (OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES | OMP_SIMD_CLAUSES) + & ~(omp_mask (OMP_CLAUSE_NOWAIT))); } @@ -5834,7 +5839,8 @@ match gfc_match_omp_parallel_sections (void) { return match_omp (EXEC_OMP_PARALLEL_SECTIONS, - OMP_PARALLEL_CLAUSES | OMP_SECTIONS_CLAUSES); + (OMP_PARALLEL_CLAUSES | OMP_SECTIONS_CLAUSES) + & ~(omp_mask (OMP_CLAUSE_NOWAIT))); } @@ -6320,8 +6326,8 @@ gfc_match_omp_teams_distribute_parallel_do (void) return match_omp (EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO, (OMP_TEAMS_CLAUSES | OMP_DISTRIBUTE_CLAUSES | OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES) - & ~(omp_mask (OMP_CLAUSE_ORDERED)) - & ~(omp_mask (OMP_CLAUSE_LINEAR))); + & ~(omp_mask (OMP_CLAUSE_ORDERED) + | OMP_CLAUSE_LINEAR | OMP_CLAUSE_NOWAIT)); } @@ -6331,7 +6337,8 @@ gfc_match_omp_teams_distribute_parallel_do_simd (void) return match_omp (EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD, (OMP_TEAMS_CLAUSES | OMP_DISTRIBUTE_CLAUSES | OMP_PARALLEL_CLAUSES | OMP_DO_CLAUSES - | OMP_SIMD_CLAUSES) & ~(omp_mask (OMP_CLAUSE_ORDERED))); + | OMP_SIMD_CLAUSES) + & ~(omp_mask (OMP_CLAUSE_ORDERED) | OMP_CLAUSE_NOWAIT)); } @@ -6347,14 +6354,7 @@ gfc_match_omp_teams_distribute_simd (void) match gfc_match_omp_workshare (void) { - if (gfc_match_omp_eos () != MATCH_YES) - { - gfc_error ("Unexpected junk after $OMP WORKSHARE statement at %C"); - return MATCH_ERROR; - } - new_st.op = EXEC_OMP_WORKSHARE; - new_st.ext.omp_clauses = gfc_get_omp_clauses (); - return MATCH_YES; + return match_omp (EXEC_OMP_WORKSHARE, OMP_WORKSHARE_CLAUSES); } @@ -6658,14 +6658,8 @@ match gfc_match_omp_end_single (void) { gfc_omp_clauses *c; - if (gfc_match ("% nowait") == MATCH_YES) - { - new_st.op = EXEC_OMP_END_NOWAIT; - new_st.ext.omp_bool = true; - return MATCH_YES; - } - if (gfc_match_omp_clauses (&c, omp_mask (OMP_CLAUSE_COPYPRIVATE)) - != MATCH_YES) + if (gfc_match_omp_clauses (&c, omp_mask (OMP_CLAUSE_COPYPRIVATE) + | OMP_CLAUSE_NOWAIT) != MATCH_YES) return MATCH_ERROR; new_st.op = EXEC_OMP_END_SINGLE; new_st.ext.omp_clauses = c; @@ -7406,6 +7400,9 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, } break; case OMP_LIST_COPYPRIVATE: + if (omp_clauses->nowait) + gfc_error ("NOWAIT clause must not be used with COPYPRIVATE " + "clause at %L", &n->where); for (; n != NULL; n = n->next) { if (n->sym->as && n->sym->as->type == AS_ASSUMED_SIZE) |