aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-openmp.cc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-09-05 18:05:24 +0200
committerTobias Burnus <tobias@codesourcery.com>2022-09-05 18:06:06 +0200
commit938cda536019cd6a1bc0dd2346381185b420bbf8 (patch)
tree78f0c5604425d3e2db0576f1a35066187750ea2f /gcc/fortran/trans-openmp.cc
parentb4d8a56a4c62ba8bca55469ae2b841fb4e1334a4 (diff)
downloadgcc-938cda536019cd6a1bc0dd2346381185b420bbf8.zip
gcc-938cda536019cd6a1bc0dd2346381185b420bbf8.tar.gz
gcc-938cda536019cd6a1bc0dd2346381185b420bbf8.tar.bz2
Fortran/openmp: Partial OpenMP 5.2 doacross and omp_cur_iteration support
Add the Fortran support to the ME/C/C++ commit r13-2388-ga651e6d59188da8992f8bfae2df1cb4e6316f9e6 gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle omp_cur_iteration and distinguish doacross/depend. * gfortran.h (enum gfc_omp_depend_doacross_op): Renamed from gfc_omp_depend_op. (enum gfc_omp_depend_doacross_op): Add OMP_DOACROSS_SINK_FIRST, Rename OMP_DEPEND_SINK to OMP_DOACROSS_SINK. (gfc_omp_namelist) Handle renaming, rename depend_op to depend_doacross_op. (struct gfc_omp_clauses): Add doacross_source. * openmp.cc (gfc_match_omp_depend_sink): Renamed to ... (gfc_match_omp_doacross_sink): ... this; handle omp_all_memory. (enum omp_mask2): Add OMP_CLAUSE_DOACROSS. (gfc_match_omp_clauses): Handle 'doacross' and syntax changes to depend. (gfc_match_omp_depobj): Simplify as sink/source are now impossible. (gfc_match_omp_ordered_depend): Request OMP_CLAUSE_DOACROSS. (resolve_omp_clauses): Update sink/source checks. (gfc_resolve_omp_directive): Resolve EXEC_OMP_ORDERED clauses. * parse.cc (decode_omp_directive): Handle 'ordered doacross'. * trans-openmp.cc (gfc_trans_omp_clauses): Handle doacross. (gfc_trans_omp_do): Fix OMP_FOR_ORIG_DECLS handling if 'ordered' clause is present. (gfc_trans_omp_depobj): Update for member name change. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Update doacross/omp_cur_iteration status. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/all-memory-1.f90: Update dg-error. * gfortran.dg/gomp/depend-iterator-2.f90: Likewise. * gfortran.dg/gomp/depobj-2.f90: Likewise. * gfortran.dg/gomp/doacross-5.f90: New test. * gfortran.dg/gomp/doacross-6.f90: New test.
Diffstat (limited to 'gcc/fortran/trans-openmp.cc')
-rw-r--r--gcc/fortran/trans-openmp.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 82c1079..1be7d23 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -2864,15 +2864,18 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
gfc_init_block (&iter_block);
prev = n;
if (list == OMP_LIST_DEPEND
- && n->u.depend_op == OMP_DEPEND_SINK_FIRST)
+ && (n->u.depend_doacross_op == OMP_DOACROSS_SINK_FIRST
+ || n->u.depend_doacross_op == OMP_DEPEND_SINK_FIRST))
{
tree vec = NULL_TREE;
unsigned int i;
+ bool is_depend
+ = n->u.depend_doacross_op == OMP_DEPEND_SINK_FIRST;
for (i = 0; ; i++)
{
tree addend = integer_zero_node, t;
bool neg = false;
- if (n->expr)
+ if (n->sym && n->expr)
{
addend = gfc_conv_constant_to_tree (n->expr);
if (TREE_CODE (addend) == INTEGER_CST
@@ -2883,7 +2886,11 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
TREE_TYPE (addend), addend);
}
}
- t = gfc_trans_omp_variable (n->sym, false);
+
+ if (n->sym == NULL)
+ t = null_pointer_node; /* "omp_cur_iteration - 1". */
+ else
+ t = gfc_trans_omp_variable (n->sym, false);
if (t != error_mark_node)
{
if (i < vec_safe_length (doacross_steps)
@@ -2900,7 +2907,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
OMP_CLAUSE_DOACROSS_SINK_NEGATIVE (vec) = 1;
}
if (n->next == NULL
- || n->next->u.depend_op != OMP_DEPEND_SINK)
+ || n->next->u.depend_doacross_op != OMP_DOACROSS_SINK)
break;
n = n->next;
}
@@ -2910,7 +2917,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
tree node = build_omp_clause (input_location,
OMP_CLAUSE_DOACROSS);
OMP_CLAUSE_DOACROSS_KIND (node) = OMP_CLAUSE_DOACROSS_SINK;
- OMP_CLAUSE_DOACROSS_DEPEND (node) = 1;
+ OMP_CLAUSE_DOACROSS_DEPEND (node) = is_depend;
OMP_CLAUSE_DECL (node) = nreverse (vec);
omp_clauses = gfc_trans_add_clause (node, omp_clauses);
continue;
@@ -2962,7 +2969,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
OMP_CLAUSE_DECL (node) = build_fold_indirect_ref (ptr);
}
if (list == OMP_LIST_DEPEND)
- switch (n->u.depend_op)
+ switch (n->u.depend_doacross_op)
{
case OMP_DEPEND_IN:
OMP_CLAUSE_DEPEND_KIND (node) = OMP_CLAUSE_DEPEND_IN;
@@ -4253,11 +4260,11 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
- if (clauses->depend_source)
+ if (clauses->doacross_source)
{
c = build_omp_clause (gfc_get_location (&where), OMP_CLAUSE_DOACROSS);
OMP_CLAUSE_DOACROSS_KIND (c) = OMP_CLAUSE_DOACROSS_SOURCE;
- OMP_CLAUSE_DOACROSS_DEPEND (c) = 1;
+ OMP_CLAUSE_DOACROSS_DEPEND (c) = clauses->depend_source;
omp_clauses = gfc_trans_add_clause (c, omp_clauses);
}
@@ -5119,7 +5126,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
init = make_tree_vec (collapse);
cond = make_tree_vec (collapse);
incr = make_tree_vec (collapse);
- orig_decls = clauses->orderedc ? make_tree_vec (collapse) : NULL_TREE;
+ orig_decls = clauses->ordered ? make_tree_vec (collapse) : NULL_TREE;
if (pblock == NULL)
{
@@ -5219,6 +5226,10 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
MODIFY_EXPR,
type, dovar,
TREE_VEC_ELT (incr, i));
+ if (orig_decls && !clauses->orderedc)
+ orig_decls = NULL;
+ else if (orig_decls)
+ TREE_VEC_ELT (orig_decls, i) = dovar_decl;
}
else
{
@@ -5259,9 +5270,9 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock,
vec_safe_grow_cleared (doacross_steps, clauses->orderedc, true);
(*doacross_steps)[i] = step;
}
+ if (orig_decls)
+ TREE_VEC_ELT (orig_decls, i) = dovar_decl;
}
- if (orig_decls)
- TREE_VEC_ELT (orig_decls, i) = dovar_decl;
if (dovar_found == 3
&& op == EXEC_OMP_SIMD
@@ -5628,7 +5639,7 @@ gfc_trans_omp_depobj (gfc_code *code)
int k = -1; /* omp_clauses->destroy */
if (!code->ext.omp_clauses->destroy)
switch (code->ext.omp_clauses->depobj_update != OMP_DEPEND_UNSET
- ? code->ext.omp_clauses->depobj_update : n->u.depend_op)
+ ? code->ext.omp_clauses->depobj_update : n->u.depend_doacross_op)
{
case OMP_DEPEND_IN: k = GOMP_DEPEND_IN; break;
case OMP_DEPEND_OUT: k = GOMP_DEPEND_OUT; break;