diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2020-05-13 10:06:45 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2020-05-13 10:06:45 +0200 |
commit | f884bef21cccc05d748fd7869cd641cbb4f6b6bb (patch) | |
tree | ed7ca416894ca3fa773b4bb4edebb46e593bb2fe /gcc/fortran | |
parent | 3d96f7b92415b7a277a87e7825efc958030e20b6 (diff) | |
download | gcc-f884bef21cccc05d748fd7869cd641cbb4f6b6bb.zip gcc-f884bef21cccc05d748fd7869cd641cbb4f6b6bb.tar.gz gcc-f884bef21cccc05d748fd7869cd641cbb4f6b6bb.tar.bz2 |
[Fortran] OpenMP - permit lastprivate in distribute + SIMD fixes (PR94690)
gcc/fortran/
2020-05-13 Tobias Burnus <tobias@codesourcery.com>
PR fortran/94690
* openmp.c (OMP_DISTRIBUTE_CLAUSES): Add OMP_CLAUSE_LASTPRIVATE.
(gfc_resolve_do_iterator): Skip the private handling for SIMD as
that is handled by ME code.
* trans-openmp.c (gfc_trans_omp_do): Don't add private/lastprivate
for dovar_found == 0, unless !simple.
libgomp/
2020-05-13 Tobias Burnus <tobias@codesourcery.com>
PR fortran/94690
* testsuite/libgomp.fortran/pr66199-3.f90: New.
* testsuite/libgomp.fortran/pr66199-4.f90: New.
* testsuite/libgomp.fortran/pr66199-5.f90: New.
* testsuite/libgomp.fortran/pr66199-6.f90: New.
* testsuite/libgomp.fortran/pr66199-7.f90: New.
* testsuite/libgomp.fortran/pr66199-8.f90: New.
* testsuite/libgomp.fortran/pr66199-9.f90: New.
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/openmp.c | 27 | ||||
-rw-r--r-- | gcc/fortran/trans-openmp.c | 27 |
3 files changed, 48 insertions, 15 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9f7b60e..9ce70f7 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2020-05-13 Tobias Burnus <tobias@codesourcery.com> + + PR fortran/94690 + * openmp.c (OMP_DISTRIBUTE_CLAUSES): Add OMP_CLAUSE_LASTPRIVATE. + (gfc_resolve_do_iterator): Skip the private handling for SIMD as + that is handled by ME code. + * trans-openmp.c (gfc_trans_omp_do): Don't add private/lastprivate + for dovar_found == 0, unless !simple. + 2020-05-11 Harald Anlauf <anlauf@gmx.de> PR fortran/95053 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 930bca5..310d4e0 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -2595,7 +2595,7 @@ cleanup: | OMP_CLAUSE_SHARED | OMP_CLAUSE_REDUCTION) #define OMP_DISTRIBUTE_CLAUSES \ (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_FIRSTPRIVATE \ - | OMP_CLAUSE_COLLAPSE | OMP_CLAUSE_DIST_SCHEDULE) + | OMP_CLAUSE_LASTPRIVATE | OMP_CLAUSE_COLLAPSE | OMP_CLAUSE_DIST_SCHEDULE) #define OMP_SINGLE_CLAUSES \ (omp_mask (OMP_CLAUSE_PRIVATE) | OMP_CLAUSE_FIRSTPRIVATE) #define OMP_ORDERED_CLAUSES \ @@ -5682,6 +5682,31 @@ gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *sym, bool add_clause) if (omp_current_ctx->sharing_clauses->contains (sym)) return; + if (omp_current_ctx->is_openmp && omp_current_ctx->code->block) + { + /* SIMD is handled differently and, hence, ignored here. */ + gfc_code *omp_code = omp_current_ctx->code->block; + for ( ; omp_code->next; omp_code = omp_code->next) + switch (omp_code->op) + { + case EXEC_OMP_SIMD: + case EXEC_OMP_DO_SIMD: + case EXEC_OMP_PARALLEL_DO_SIMD: + case EXEC_OMP_DISTRIBUTE_SIMD: + case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD: + case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD: + case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD: + case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: + case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD: + case EXEC_OMP_TARGET_PARALLEL_DO_SIMD: + case EXEC_OMP_TARGET_SIMD: + case EXEC_OMP_TASKLOOP_SIMD: + return; + default: + break; + } + } + if (! omp_current_ctx->private_iterators->add (sym) && add_clause) { gfc_omp_clauses *omp_clauses = omp_current_ctx->code->ext.omp_clauses; diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 42ecd0a..8cf851e 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -4262,23 +4262,22 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, break; } } - if (!dovar_found) + if (!dovar_found && op == EXEC_OMP_SIMD) { - if (op == EXEC_OMP_SIMD) + if (collapse == 1) { - if (collapse == 1) - { - tmp = build_omp_clause (input_location, OMP_CLAUSE_LINEAR); - OMP_CLAUSE_LINEAR_STEP (tmp) = step; - OMP_CLAUSE_LINEAR_NO_COPYIN (tmp) = 1; - } - else - tmp = build_omp_clause (input_location, OMP_CLAUSE_LASTPRIVATE); - if (!simple) - dovar_found = 2; + tmp = build_omp_clause (input_location, OMP_CLAUSE_LINEAR); + OMP_CLAUSE_LINEAR_STEP (tmp) = step; + OMP_CLAUSE_LINEAR_NO_COPYIN (tmp) = 1; + OMP_CLAUSE_DECL (tmp) = dovar_decl; + omp_clauses = gfc_trans_add_clause (tmp, omp_clauses); } - else - tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); + if (!simple) + dovar_found = 2; + } + else if (!dovar_found && !simple) + { + tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); OMP_CLAUSE_DECL (tmp) = dovar_decl; omp_clauses = gfc_trans_add_clause (tmp, omp_clauses); } |