aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-09-30 13:27:32 +0200
committerTobias Burnus <tobias@codesourcery.com>2022-09-30 13:37:18 +0200
commit10a116104969b3ecc9ea4abdd5436c66fd78d537 (patch)
tree76f910b475ce550a88ea27ec3b95dd1770adbdfb /gcc
parent9b8ffbb8a0cadd68bf7887c5655a29ec04060111 (diff)
downloadgcc-10a116104969b3ecc9ea4abdd5436c66fd78d537.zip
gcc-10a116104969b3ecc9ea4abdd5436c66fd78d537.tar.gz
gcc-10a116104969b3ecc9ea4abdd5436c66fd78d537.tar.bz2
Fortran: Update use_device_ptr for OpenMP 5.1 [PR105318]
OpenMP 5.1 added has_device_addr and relaxed the restrictions for use_device_ptr, including processing non-type(c_ptr) arguments as if has_device_addr was used. (There is a semantic difference.) For completeness, the likewise change was done for 'use_device_ptr', where non-type(c_ptr) arguments now use use_device_addr. Finally, a warning for 'device(omp_{initial,invalid}_device)' was silenced on the way as affecting the new testcase. PR fortran/105318 gcc/fortran/ChangeLog: * openmp.cc (resolve_omp_clauses): Update is_device_ptr restrictions for OpenMP 5.1 and map to has_device_addr where applicable; map use_device_ptr to use_device_addr where applicable. Silence integer-range warning for device(omp_{initial,invalid}_device). libgomp/ChangeLog: * testsuite/libgomp.fortran/is_device_ptr-2.f90: New test. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/is_device_ptr-1.f90: Remove dg-error. * gfortran.dg/gomp/is_device_ptr-2.f90: Likewise. * gfortran.dg/gomp/is_device_ptr-3.f90: Update tree-scan-dump.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/openmp.cc70
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/is_device_ptr-1.f908
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/is_device_ptr-2.f902
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/is_device_ptr-3.f903
4 files changed, 56 insertions, 27 deletions
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 457e983..ce719bd 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -6511,7 +6511,7 @@ static void
resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
gfc_namespace *ns, bool openacc = false)
{
- gfc_omp_namelist *n;
+ gfc_omp_namelist *n, *last;
gfc_expr_list *el;
int list;
int ifc;
@@ -7369,30 +7369,58 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
}
break;
case OMP_LIST_IS_DEVICE_PTR:
- for (n = omp_clauses->lists[list]; n != NULL; n = n->next)
+ last = NULL;
+ for (n = omp_clauses->lists[list]; n != NULL; )
{
- if (!n->sym->attr.dummy)
- gfc_error ("Non-dummy object %qs in %s clause at %L",
- n->sym->name, name, &n->where);
- if (n->sym->attr.allocatable
- || (n->sym->ts.type == BT_CLASS
- && CLASS_DATA (n->sym)->attr.allocatable))
- gfc_error ("ALLOCATABLE object %qs in %s clause at %L",
- n->sym->name, name, &n->where);
- if (n->sym->attr.pointer
- || (n->sym->ts.type == BT_CLASS
- && CLASS_DATA (n->sym)->attr.pointer))
- gfc_error ("POINTER object %qs in %s clause at %L",
- n->sym->name, name, &n->where);
- if (n->sym->attr.value)
- gfc_error ("VALUE object %qs in %s clause at %L",
- n->sym->name, name, &n->where);
+ if (n->sym->ts.type == BT_DERIVED
+ && n->sym->ts.u.derived->ts.is_iso_c
+ && code->op != EXEC_OMP_TARGET)
+ /* Non-TARGET (i.e. DISPATCH) requires a C_PTR. */
+ gfc_error ("List item %qs in %s clause at %L must be of "
+ "TYPE(C_PTR)", n->sym->name, name, &n->where);
+ else if (n->sym->ts.type != BT_DERIVED
+ || !n->sym->ts.u.derived->ts.is_iso_c)
+ {
+ /* For TARGET, non-C_PTR are deprecated and handled as
+ has_device_addr. */
+ gfc_omp_namelist *n2 = n;
+ n = n->next;
+ if (last)
+ last->next = n;
+ else
+ omp_clauses->lists[list] = n;
+ n2->next = omp_clauses->lists[OMP_LIST_HAS_DEVICE_ADDR];
+ omp_clauses->lists[OMP_LIST_HAS_DEVICE_ADDR] = n2;
+ continue;
+ }
+ last = n;
+ n = n->next;
}
break;
case OMP_LIST_HAS_DEVICE_ADDR:
- case OMP_LIST_USE_DEVICE_PTR:
case OMP_LIST_USE_DEVICE_ADDR:
- /* FIXME: Handle OMP_LIST_USE_DEVICE_PTR. */
+ break;
+ case OMP_LIST_USE_DEVICE_PTR:
+ /* Non-C_PTR are deprecated and handled as use_device_ADDR. */
+ last = NULL;
+ for (n = omp_clauses->lists[list]; n != NULL; )
+ {
+ gfc_omp_namelist *n2 = n;
+ if (n->sym->ts.type != BT_DERIVED
+ || !n->sym->ts.u.derived->ts.is_iso_c)
+ {
+ n = n->next;
+ if (last)
+ last->next = n;
+ else
+ omp_clauses->lists[list] = n;
+ n2->next = omp_clauses->lists[OMP_LIST_USE_DEVICE_ADDR];
+ omp_clauses->lists[OMP_LIST_USE_DEVICE_ADDR] = n2;
+ continue;
+ }
+ last = n;
+ n = n->next;
+ }
break;
default:
for (; n != NULL; n = n->next)
@@ -7758,7 +7786,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
&omp_clauses->num_teams_lower->where,
&omp_clauses->num_teams_upper->where);
if (omp_clauses->device)
- resolve_nonnegative_int_expr (omp_clauses->device, "DEVICE");
+ resolve_scalar_int_expr (omp_clauses->device, "DEVICE");
if (omp_clauses->filter)
resolve_nonnegative_int_expr (omp_clauses->filter, "FILTER");
if (omp_clauses->hint)
diff --git a/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-1.f90 b/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-1.f90
index 0eeca0e..1d3a0d8 100644
--- a/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-1.f90
@@ -7,16 +7,16 @@ subroutine test(b,c,d)
integer, target :: a(5)
- !$omp target is_device_ptr(a) ! { dg-error "Non-dummy object .a. in IS_DEVICE_PTR clause" }
+ !$omp target is_device_ptr(a) ! Valid since OpenMP 5.1
!$omp end target
- !$omp target is_device_ptr(b) ! { dg-error "VALUE object .b. in IS_DEVICE_PTR clause" }
+ !$omp target is_device_ptr(b) ! Valid since OpenMP 5.1
!$omp end target
- !$omp target is_device_ptr(c) ! { dg-error "POINTER object .c. in IS_DEVICE_PTR clause" }
+ !$omp target is_device_ptr(c) ! Valid since OpenMP 5.1
!$omp end target
- !$omp target is_device_ptr(d) ! { dg-error "ALLOCATABLE object .d. in IS_DEVICE_PTR clause" }
+ !$omp target is_device_ptr(d) ! Valid since OpenMP 5.1
!$omp end target
!$omp target data map(a) use_device_addr(a) ! Should be okay
diff --git a/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-2.f90 b/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-2.f90
index 7adc6f6..0762e57 100644
--- a/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-2.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-2.f90
@@ -8,7 +8,7 @@ subroutine abc(cc)
!$omp target enter data map(to: cc, dd)
!$omp target data use_device_addr(cc) use_device_ptr(dd)
- !$omp target is_device_ptr(cc, dd) ! { dg-error "Non-dummy object 'dd' in IS_DEVICE_PTR clause at" }
+ !$omp target is_device_ptr(cc, dd) ! Valid since OpenMP 5.1
if (cc /= 131 .or. dd /= 484) stop 1
cc = 44
dd = 45
diff --git a/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-3.f90 b/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-3.f90
index c3de772..7b5b27b 100644
--- a/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-3.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/is_device_ptr-3.f90
@@ -23,5 +23,6 @@ contains
end program main
-! { dg-final { scan-tree-dump "is_device_ptr\\(a\\)" "gimple" } }
+! { dg-final { scan-tree-dump "has_device_addr\\(a\\)" "gimple" } }
+! { dg-final { scan-tree-dump-not "has_device_addr\\(b\\)" "gimple" } }
! { dg-final { scan-tree-dump-not "is_device_ptr\\(b\\)" "gimple" } }