diff options
author | Sandra Loosemore <sandra@codesourcery.com> | 2022-05-05 11:37:16 -0700 |
---|---|---|
committer | Sandra Loosemore <sandra@codesourcery.com> | 2022-05-05 11:49:49 -0700 |
commit | 705bcedf6eae2d7c68bd3df2c98dad4f06650fde (patch) | |
tree | d3aa0681b4c9f2bf39db4ea1c4788e946022c210 /gcc/gimplify.cc | |
parent | 982fd4cd765664d737eb4346a2d2400b6a74c4ec (diff) | |
download | gcc-705bcedf6eae2d7c68bd3df2c98dad4f06650fde.zip gcc-705bcedf6eae2d7c68bd3df2c98dad4f06650fde.tar.gz gcc-705bcedf6eae2d7c68bd3df2c98dad4f06650fde.tar.bz2 |
Fortran: Add support for OMP non-rectangular loops.
This patch adds support for OMP 5.1 "canonical loop nest form" to the
Fortran front end, marks non-rectangular loops for processing
by the middle end, and implements missing checks in the gimplifier
for additional prohibitions on non-rectangular loops.
Note that the OMP spec also prohibits non-rectangular loops with the TILE
construct; that construct hasn't been implemented yet, so that error will
need to be filled in later.
gcc/fortran/
* gfortran.h (struct gfc_omp_clauses): Add non_rectangular bit.
* openmp.cc (is_outer_iteration_variable): New function.
(expr_is_invariant): New function.
(bound_expr_is_canonical): New function.
(resolve_omp_do): Replace existing non-rectangularity error with
check for canonical form and setting non_rectangular bit.
* trans-openmp.cc (gfc_trans_omp_do): Transfer non_rectangular
flag to generated tree structure.
gcc/
* gimplify.cc (gimplify_omp_for): Update messages for SCHEDULED
and ORDERED clause conflict errors. Add check for GRAINSIZE and
NUM_TASKS on TASKLOOP.
gcc/testsuite/
* c-c++-common/gomp/loop-6.c (f3): New function to test TASKLOOP
diagnostics.
* gfortran.dg/gomp/collapse1.f90: Update expected messages.
* gfortran.dg/gomp/pr85313.f90: Remove dg-error on non-rectangular
loops that are now accepted.
* gfortran.dg/gomp/non-rectangular-loop.f90: New file.
* gfortran.dg/gomp/canonical-loop-1.f90: New file.
* gfortran.dg/gomp/canonical-loop-2.f90: New file.
Diffstat (limited to 'gcc/gimplify.cc')
-rw-r--r-- | gcc/gimplify.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index f052d9f..822e0cf 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -12509,11 +12509,11 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) OMP_CLAUSE_SCHEDULE)) error_at (EXPR_LOCATION (for_stmt), "%qs clause may not appear on non-rectangular %qs", - "schedule", "for"); + "schedule", lang_GNU_Fortran () ? "do" : "for"); if (omp_find_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_ORDERED)) error_at (EXPR_LOCATION (for_stmt), "%qs clause may not appear on non-rectangular %qs", - "ordered", "for"); + "ordered", lang_GNU_Fortran () ? "do" : "for"); } break; case OMP_DISTRIBUTE: @@ -12528,6 +12528,19 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p) ort = ORT_ACC; break; case OMP_TASKLOOP: + if (OMP_FOR_NON_RECTANGULAR (inner_for_stmt ? inner_for_stmt : for_stmt)) + { + if (omp_find_clause (OMP_FOR_CLAUSES (for_stmt), + OMP_CLAUSE_GRAINSIZE)) + error_at (EXPR_LOCATION (for_stmt), + "%qs clause may not appear on non-rectangular %qs", + "grainsize", "taskloop"); + if (omp_find_clause (OMP_FOR_CLAUSES (for_stmt), + OMP_CLAUSE_NUM_TASKS)) + error_at (EXPR_LOCATION (for_stmt), + "%qs clause may not appear on non-rectangular %qs", + "num_tasks", "taskloop"); + } if (omp_find_clause (OMP_FOR_CLAUSES (for_stmt), OMP_CLAUSE_UNTIED)) ort = ORT_UNTIED_TASKLOOP; else |