aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2019-11-11 09:19:29 +0000
committerTobias Burnus <tobias@codesourcery.com>2019-11-11 09:19:29 +0000
commit551d91b53bd71cc7fdd80f10ed8ea87d5c835d12 (patch)
tree652752017ebc9459258438136af1d92a63535d0d /libgomp
parent05bfaa31f69370c7e4cfcaa0726ae7ed22345fa1 (diff)
Fortran] Support absent optional args with use_device_{ptr,addr}
2019-11-11 Tobias Burnus <tobias@codesourcery.com> Kwok Cheung Yeung <kcy@codesourcery.com> gcc/ * langhooks-def.h (LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT): Renamed from LANG_HOOKS_OMP_IS_OPTIONAL_ARGUMENT; update define. (LANG_HOOKS_DECLS): Rename also here. * langhooks.h (lang_hooks_for_decls): Rename omp_is_optional_argument to omp_check_optional_argument; take additional bool argument. * omp-general.h (omp_check_optional_argument): Likewise. * omp-general.h (omp_check_optional_argument): Likewise. * omp-low.c (lower_omp_target): Update calls; handle absent Fortran optional arguments with USE_DEVICE_ADDR/USE_DEVICE_PTR. gcc/fortran/ * trans-expr.c (gfc_conv_expr_present): Check for DECL_ARTIFICIAL for the VALUE hidden argument avoiding -fallow-underscore issues. * trans-decl.c (create_function_arglist): Also set GFC_DECL_OPTIONAL_ARGUMENT for per-value arguments. * f95-lang.c (LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT): Renamed from LANG_HOOKS_OMP_IS_OPTIONAL_ARGUMENT; point to gfc_omp_check_optional_argument. * trans.h (gfc_omp_check_optional_argument): Subsitutes gfc_omp_is_optional_argument declaration. * trans-openmp.c (gfc_omp_is_optional_argument): Make static. (gfc_omp_check_optional_argument): New function. libgomp/ * testsuite/libgomp.fortran/use_device_ptr-optional-1.f90: Extend. * testsuite/libgomp.fortran/use_device_ptr-optional-2.f90: New. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@278046 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog6
-rw-r--r--libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f9022
-rw-r--r--libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f9033
3 files changed, 61 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 1fc8c471b6f..2f60d606a88 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-11 Tobias Burnus <tobias@codesourcery.com>
+ Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ * testsuite/libgomp.fortran/use_device_ptr-optional-1.f90: Extend.
+ * testsuite/libgomp.fortran/use_device_ptr-optional-2.f90: New.
+
2019-11-11 Thomas Schwinge <thomas@codesourcery.com>
* testsuite/libgomp.fortran/target9.f90: Specify 'dg-do run'.
diff --git a/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90 b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90
index ac69df559c9..e92ee8bf573 100644
--- a/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90
+++ b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-1.f90
@@ -11,6 +11,9 @@ program test_it
ptr_null => null()
call bar(ptr_null)
+
+ call foo_absent()
+ call bar_absent()
contains
subroutine foo(ii)
integer, pointer, optional :: ii
@@ -34,4 +37,23 @@ contains
if (associated(jj)) stop 8
!$omp end target data
end subroutine bar
+
+ subroutine foo_absent(ii)
+ integer, pointer, optional :: ii
+
+ if (present(ii)) STOP 31
+ !$omp target data map(to:ixx) use_device_ptr(ii)
+ if (present(ii)) STOP 32
+ !$omp end target data
+ end subroutine foo_absent
+
+ ! For bar, it is assumed that a NULL ptr on the host maps to NULL on the device
+ subroutine bar_absent(jj)
+ integer, pointer, optional :: jj
+
+ if (present(jj)) STOP 41
+ !$omp target data map(to:ixx) use_device_ptr(jj)
+ if (present(jj)) STOP 42
+ !$omp end target data
+ end subroutine bar_absent
end program test_it
diff --git a/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f90 b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f90
new file mode 100644
index 00000000000..41abf17eede
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f90
@@ -0,0 +1,33 @@
+! Check whether absent optional arguments are properly
+! handled with use_device_{addr,ptr}.
+program main
+ implicit none (type, external)
+ call foo()
+contains
+ subroutine foo(v, w, x, y, z)
+ integer, target, optional, value :: v
+ integer, target, optional :: w
+ integer, target, optional :: x(:)
+ integer, target, optional, allocatable :: y
+ integer, target, optional, allocatable :: z(:)
+ integer :: d
+
+ !$omp target data map(d) use_device_addr(v, w, x, y, z)
+ if(present(v)) stop 1
+ if(present(w)) stop 2
+ if(present(x)) stop 3
+ if(present(y)) stop 4
+ if(present(z)) stop 5
+ !$omp end target data
+
+! Using 'v' in use_device_ptr gives an ICE
+! TODO: Find out what the OpenMP spec permits for use_device_ptr
+
+ !$omp target data map(d) use_device_ptr(w, x, y, z)
+ if(present(w)) stop 6
+ if(present(x)) stop 7
+ if(present(y)) stop 8
+ if(present(z)) stop 9
+ !$omp end target data
+ end subroutine foo
+end program main