aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/openmp.cc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-05-17 11:01:04 +0200
committerTobias Burnus <tobias@codesourcery.com>2022-05-17 11:01:04 +0200
commit4f94c38a9237b728b3a3f76c169b5b47f6c45187 (patch)
tree2ec7b560f303f268bb602613d6ea0d3eff96e428 /gcc/fortran/openmp.cc
parentebce0e9bd8d714a8607ae24331a3d842b0d11859 (diff)
downloadgcc-4f94c38a9237b728b3a3f76c169b5b47f6c45187.zip
gcc-4f94c38a9237b728b3a3f76c169b5b47f6c45187.tar.gz
gcc-4f94c38a9237b728b3a3f76c169b5b47f6c45187.tar.bz2
OpenMP: Add omp_all_memory support to Fortran
Fortran part to the C/C++/backend implementation r13-337-g7f78783dbedca0183d193e475262ca3c489fd365 gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_namelist): Handle omp_all_memory. * openmp.cc (gfc_match_omp_variable_list, gfc_match_omp_depend_sink, gfc_match_omp_clauses, resolve_omp_clauses): Likewise. * trans-openmp.cc (gfc_trans_omp_clauses, gfc_trans_omp_depobj): Likewise. * resolve.cc (resolve_symbol): Reject it as symbol. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.1): Set omp_all_memory to 'Y'. * testsuite/libgomp.fortran/depend-5.f90: New test. * testsuite/libgomp.fortran/depend-6.f90: New test. * testsuite/libgomp.fortran/depend-7.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/all-memory-1.f90: New test. * gfortran.dg/gomp/all-memory-2.f90: New test. * gfortran.dg/gomp/all-memory-3.f90: New test.
Diffstat (limited to 'gcc/fortran/openmp.cc')
-rw-r--r--gcc/fortran/openmp.cc79
1 files changed, 63 insertions, 16 deletions
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 8643e43..3061e52 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -296,14 +296,17 @@ gfc_find_omp_udr (gfc_namespace *ns, const char *name, gfc_typespec *ts)
}
-/* Match a variable/common block list and construct a namelist from it. */
+/* Match a variable/common block list and construct a namelist from it;
+ if has_all_memory != NULL, *has_all_memory is set and omp_all_memory
+ yields a list->sym NULL entry. */
static match
gfc_match_omp_variable_list (const char *str, gfc_omp_namelist **list,
bool allow_common, bool *end_colon = NULL,
gfc_omp_namelist ***headp = NULL,
bool allow_sections = false,
- bool allow_derived = false)
+ bool allow_derived = false,
+ bool *has_all_memory = NULL)
{
gfc_omp_namelist *head, *tail, *p;
locus old_loc, cur_loc;
@@ -315,7 +318,8 @@ gfc_match_omp_variable_list (const char *str, gfc_omp_namelist **list,
head = tail = NULL;
old_loc = gfc_current_locus;
-
+ if (has_all_memory)
+ *has_all_memory = false;
m = gfc_match (str);
if (m != MATCH_YES)
return m;
@@ -323,7 +327,35 @@ gfc_match_omp_variable_list (const char *str, gfc_omp_namelist **list,
for (;;)
{
cur_loc = gfc_current_locus;
- m = gfc_match_symbol (&sym, 1);
+
+ m = gfc_match_name (n);
+ if (m == MATCH_YES && strcmp (n, "omp_all_memory") == 0)
+ {
+ if (!has_all_memory)
+ {
+ gfc_error ("%<omp_all_memory%> at %C not permitted in this "
+ "clause");
+ goto cleanup;
+ }
+ *has_all_memory = true;
+ p = gfc_get_omp_namelist ();
+ if (head == NULL)
+ head = tail = p;
+ else
+ {
+ tail->next = p;
+ tail = tail->next;
+ }
+ tail->where = cur_loc;
+ goto next_item;
+ }
+ if (m == MATCH_YES)
+ {
+ gfc_symtree *st;
+ if ((m = gfc_get_ha_sym_tree (n, &st) ? MATCH_ERROR : MATCH_YES)
+ == MATCH_YES)
+ sym = st->n.sym;
+ }
switch (m)
{
case MATCH_YES:
@@ -578,6 +610,12 @@ gfc_match_omp_depend_sink (gfc_omp_namelist **list)
tail->sym = sym;
tail->expr = NULL;
tail->where = cur_loc;
+ if (UNLIKELY (strcmp (sym->name, "omp_all_memory") == 0))
+ {
+ gfc_error ("%<omp_all_memory%> used with DEPEND kind "
+ "other than OUT or INOUT at %C");
+ goto cleanup;
+ }
if (gfc_match_char ('+') == MATCH_YES)
{
if (gfc_match_literal_constant (&tail->expr, 0) != MATCH_YES)
@@ -1868,6 +1906,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
if ((mask & OMP_CLAUSE_DEPEND)
&& gfc_match ("depend ( ") == MATCH_YES)
{
+ bool has_omp_all_memory;
gfc_namespace *ns_iter = NULL, *ns_curr = gfc_current_ns;
match m_it = gfc_match_iterator (&ns_iter, false);
if (m_it == MATCH_ERROR)
@@ -1920,21 +1959,27 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
if (m == MATCH_YES)
m = gfc_match_omp_variable_list (" : ",
&c->lists[OMP_LIST_DEPEND],
- false, NULL, &head, true);
+ false, NULL, &head, true,
+ false, &has_omp_all_memory);
+ if (m != MATCH_YES)
+ goto error;
gfc_current_ns = ns_curr;
- if (m == MATCH_YES)
+ if (has_omp_all_memory && depend_op != OMP_DEPEND_INOUT
+ && depend_op != OMP_DEPEND_OUT)
{
- gfc_omp_namelist *n;
- for (n = *head; n; n = n->next)
- {
- n->u.depend_op = depend_op;
- n->u2.ns = ns_iter;
- if (ns_iter)
- ns_iter->refs++;
- }
- continue;
+ gfc_error ("%<omp_all_memory%> used with DEPEND kind "
+ "other than OUT or INOUT at %C");
+ goto error;
}
- break;
+ gfc_omp_namelist *n;
+ for (n = *head; n; n = n->next)
+ {
+ n->u.depend_op = depend_op;
+ n->u2.ns = ns_iter;
+ if (ns_iter)
+ ns_iter->refs++;
+ }
+ continue;
}
if ((mask & OMP_CLAUSE_DETACH)
&& !openacc
@@ -6490,6 +6535,8 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
for (list = 0; list < OMP_LIST_NUM; list++)
for (n = omp_clauses->lists[list]; n; n = n->next)
{
+ if (!n->sym) /* omp_all_memory. */
+ continue;
n->sym->mark = 0;
n->sym->comp_mark = 0;
if (n->sym->attr.flavor == FL_VARIABLE