aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-05-28 20:42:38 +0200
committerTobias Burnus <tobias@codesourcery.com>2022-05-28 20:42:38 +0200
commite3803f9cbb67efef7462589fe50d00b404356bc9 (patch)
tree69177909510ec7a66615cf34b80c564c261e1a1f /gcc/fortran
parentce1580252ea57de23a595e9804ea87ed4353aa6a (diff)
downloadgcc-e3803f9cbb67efef7462589fe50d00b404356bc9.zip
gcc-e3803f9cbb67efef7462589fe50d00b404356bc9.tar.gz
gcc-e3803f9cbb67efef7462589fe50d00b404356bc9.tar.bz2
OpenMP/Fortran: Add support for enter clause on declare target
Fortran version to C/C++ commit r13-797-g0ccba4ed8571c18c7015413441e971 gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_clauses): Handle OMP_LIST_ENTER. * gfortran.h: Add OMP_LIST_ENTER. * openmp.cc (enum omp_mask2, OMP_DECLARE_TARGET_CLAUSES): Add OMP_CLAUSE_ENTER. (gfc_match_omp_clauses, gfc_match_omp_declare_target, resolve_omp_clauses): Handle 'enter' clause. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Mark 'enter' clause as supported. * testsuite/libgomp.fortran/declare-target-1.f90: Extend to test explicit 'to' and 'enter' clause. * testsuite/libgomp.fortran/declare-target-2.f90: Update accordingly. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/declare-target-2.f90: Add 'enter' clause test. * gfortran.dg/gomp/declare-target-4.f90: Likewise.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/dump-parse-tree.cc1
-rw-r--r--gcc/fortran/gfortran.h1
-rw-r--r--gcc/fortran/openmp.cc65
3 files changed, 45 insertions, 22 deletions
diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index 4e8986b..e3affb8 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -1679,6 +1679,7 @@ show_omp_clauses (gfc_omp_clauses *omp_clauses)
case OMP_LIST_IN_REDUCTION: type = "IN_REDUCTION"; break;
case OMP_LIST_TASK_REDUCTION: type = "TASK_REDUCTION"; break;
case OMP_LIST_DEVICE_RESIDENT: type = "DEVICE_RESIDENT"; break;
+ case OMP_LIST_ENTER: type = "ENTER"; break;
case OMP_LIST_LINK: type = "LINK"; break;
case OMP_LIST_USE_DEVICE: type = "USE_DEVICE"; break;
case OMP_LIST_CACHE: type = "CACHE"; break;
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 5d970bc..0bac865 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1395,6 +1395,7 @@ enum
OMP_LIST_NONTEMPORAL,
OMP_LIST_ALLOCATE,
OMP_LIST_HAS_DEVICE_ADDR,
+ OMP_LIST_ENTER,
OMP_LIST_NUM /* Must be the last. */
};
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index efa62b6..a1aa88c 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -986,6 +986,7 @@ enum omp_mask2
OMP_CLAUSE_ATTACH,
OMP_CLAUSE_NOHOST,
OMP_CLAUSE_HAS_DEVICE_ADDR, /* OpenMP 5.1 */
+ OMP_CLAUSE_ENTER, /* OpenMP 5.2 */
/* This must come last. */
OMP_MASK2_LAST
};
@@ -2101,6 +2102,16 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
}
break;
+ case 'e':
+ if ((mask & OMP_CLAUSE_ENTER))
+ {
+ m = gfc_match_omp_to_link ("enter (", &c->lists[OMP_LIST_ENTER]);
+ if (m == MATCH_ERROR)
+ goto error;
+ if (m == MATCH_YES)
+ continue;
+ }
+ break;
case 'f':
if ((mask & OMP_CLAUSE_FAIL)
&& (m = gfc_match_dupl_check (c->fail == OMP_MEMORDER_UNSET,
@@ -2921,8 +2932,12 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
continue;
if ((mask & OMP_CLAUSE_TO) && (mask & OMP_CLAUSE_LINK))
{
- if (gfc_match_omp_to_link ("to (", &c->lists[OMP_LIST_TO])
- == MATCH_YES)
+ /* Declare target: 'to' is an alias for 'enter';
+ 'to' is deprecated since 5.2. */
+ m = gfc_match_omp_to_link ("to (", &c->lists[OMP_LIST_TO]);
+ if (m == MATCH_ERROR)
+ goto error;
+ if (m == MATCH_YES)
continue;
}
else if ((mask & OMP_CLAUSE_TO)
@@ -3724,7 +3739,8 @@ cleanup:
#define OMP_ORDERED_CLAUSES \
(omp_mask (OMP_CLAUSE_THREADS) | OMP_CLAUSE_SIMD)
#define OMP_DECLARE_TARGET_CLAUSES \
- (omp_mask (OMP_CLAUSE_TO) | OMP_CLAUSE_LINK | OMP_CLAUSE_DEVICE_TYPE)
+ (omp_mask (OMP_CLAUSE_ENTER) | OMP_CLAUSE_LINK | OMP_CLAUSE_DEVICE_TYPE \
+ | OMP_CLAUSE_TO)
#define OMP_ATOMIC_CLAUSES \
(omp_mask (OMP_CLAUSE_ATOMIC) | OMP_CLAUSE_CAPTURE | OMP_CLAUSE_HINT \
| OMP_CLAUSE_MEMORDER | OMP_CLAUSE_COMPARE | OMP_CLAUSE_FAIL \
@@ -4530,7 +4546,7 @@ gfc_match_omp_declare_target (void)
{
c = gfc_get_omp_clauses ();
gfc_current_locus = old_loc;
- m = gfc_match_omp_to_link (" (", &c->lists[OMP_LIST_TO]);
+ m = gfc_match_omp_to_link (" (", &c->lists[OMP_LIST_ENTER]);
if (m != MATCH_YES)
goto syntax;
if (gfc_match_omp_eos () != MATCH_YES)
@@ -4544,38 +4560,40 @@ gfc_match_omp_declare_target (void)
gfc_buffer_error (false);
- for (list = OMP_LIST_TO; list != OMP_LIST_NUM;
- list = (list == OMP_LIST_TO ? OMP_LIST_LINK : OMP_LIST_NUM))
+ static const int to_enter_link_lists[]
+ = { OMP_LIST_TO, OMP_LIST_ENTER, OMP_LIST_LINK };
+ for (size_t listn = 0; listn < ARRAY_SIZE (to_enter_link_lists)
+ && (list = to_enter_link_lists[listn], true); ++listn)
for (n = c->lists[list]; n; n = n->next)
if (n->sym)
n->sym->mark = 0;
else if (n->u.common->head)
n->u.common->head->mark = 0;
- for (list = OMP_LIST_TO; list != OMP_LIST_NUM;
- list = (list == OMP_LIST_TO ? OMP_LIST_LINK : OMP_LIST_NUM))
+ for (size_t listn = 0; listn < ARRAY_SIZE (to_enter_link_lists)
+ && (list = to_enter_link_lists[listn], true); ++listn)
for (n = c->lists[list]; n; n = n->next)
if (n->sym)
{
if (n->sym->attr.in_common)
gfc_error_now ("OMP DECLARE TARGET variable at %L is an "
"element of a COMMON block", &n->where);
+ else if (n->sym->mark)
+ gfc_error_now ("Variable at %L mentioned multiple times in "
+ "clauses of the same OMP DECLARE TARGET directive",
+ &n->where);
else if (n->sym->attr.omp_declare_target
&& n->sym->attr.omp_declare_target_link
&& list != OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET variable at %L previously "
- "mentioned in LINK clause and later in TO clause",
- &n->where);
+ "mentioned in LINK clause and later in %s clause",
+ &n->where, list == OMP_LIST_TO ? "TO" : "ENTER");
else if (n->sym->attr.omp_declare_target
&& !n->sym->attr.omp_declare_target_link
&& list == OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET variable at %L previously "
- "mentioned in TO clause and later in LINK clause",
- &n->where);
- else if (n->sym->mark)
- gfc_error_now ("Variable at %L mentioned multiple times in "
- "clauses of the same OMP DECLARE TARGET directive",
- &n->where);
+ "mentioned in TO or ENTER clause and later in "
+ "LINK clause", &n->where);
else if (gfc_add_omp_declare_target (&n->sym->attr, n->sym->name,
&n->sym->declared_at))
{
@@ -4598,14 +4616,14 @@ gfc_match_omp_declare_target (void)
&& n->u.common->omp_declare_target_link
&& list != OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET COMMON at %L previously "
- "mentioned in LINK clause and later in TO clause",
- &n->where);
+ "mentioned in LINK clause and later in %s clause",
+ &n->where, list == OMP_LIST_TO ? "TO" : "ENTER");
else if (n->u.common->omp_declare_target
&& !n->u.common->omp_declare_target_link
&& list == OMP_LIST_LINK)
gfc_error_now ("OMP DECLARE TARGET COMMON at %L previously "
- "mentioned in TO clause and later in LINK clause",
- &n->where);
+ "mentioned in TO or ENTER clause and later in "
+ "LINK clause", &n->where);
else if (n->u.common->head && n->u.common->head->mark)
gfc_error_now ("COMMON at %L mentioned multiple times in "
"clauses of the same OMP DECLARE TARGET directive",
@@ -4639,7 +4657,10 @@ gfc_match_omp_declare_target (void)
s->attr.omp_device_type = c->device_type;
}
}
- if (c->device_type && !c->lists[OMP_LIST_TO] && !c->lists[OMP_LIST_LINK])
+ if (c->device_type
+ && !c->lists[OMP_LIST_ENTER]
+ && !c->lists[OMP_LIST_TO]
+ && !c->lists[OMP_LIST_LINK])
gfc_warning_now (0, "OMP DECLARE TARGET directive at %L with only "
"DEVICE_TYPE clause is ignored", &old_loc);
@@ -6331,7 +6352,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
"IN_REDUCTION", "TASK_REDUCTION",
"DEVICE_RESIDENT", "LINK", "USE_DEVICE",
"CACHE", "IS_DEVICE_PTR", "USE_DEVICE_PTR", "USE_DEVICE_ADDR",
- "NONTEMPORAL", "ALLOCATE", "HAS_DEVICE_ADDR" };
+ "NONTEMPORAL", "ALLOCATE", "HAS_DEVICE_ADDR", "ENTER" };
STATIC_ASSERT (ARRAY_SIZE (clause_names) == OMP_LIST_NUM);
if (omp_clauses == NULL)