aboutsummaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2019-12-05 15:18:39 +0000
committerTobias Burnus <burnus@gcc.gnu.org>2019-12-05 16:18:39 +0100
commitc3cb71ef35522f46afa6f11ee376cdcb73b893e8 (patch)
tree00586bccd3b51836b13802be9977e0024a9a7476 /libgomp
parent705f02b0ca8e625c4f513a66efe28b403c796c22 (diff)
downloadgcc-c3cb71ef35522f46afa6f11ee376cdcb73b893e8.zip
gcc-c3cb71ef35522f46afa6f11ee376cdcb73b893e8.tar.gz
gcc-c3cb71ef35522f46afa6f11ee376cdcb73b893e8.tar.bz2
OpenMP] Fix use_device_… with absent optional arg
gcc/fortran/ * trans-openmp.c (gfc_omp_is_optional_argument, gfc_omp_check_optional_argument): Handle type(c_ptr),value which uses a hidden argument for the is-present check. gcc/ * omp-low.c (lower_omp_target): For use_device_ptr/use_derice_addr and Fortran's optional arguments, unconditionally add the is-present condition before the libgomp call. libgomp/ * testsuite/libgomp.fortran/use_device_ptr-optional-2.f90: Add 'type(c_ptr), value' test case. Conditionally map the per-value passed arguments. From-SVN: r279004
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f9051
1 files changed, 39 insertions, 12 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f90 b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f90
index 41abf17..6eefbe1 100644
--- a/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f90
+++ b/libgomp/testsuite/libgomp.fortran/use_device_ptr-optional-2.f90
@@ -1,33 +1,60 @@
! Check whether absent optional arguments are properly
! handled with use_device_{addr,ptr}.
program main
+ use iso_c_binding, only: c_ptr, c_loc, c_associated
implicit none (type, external)
call foo()
contains
- subroutine foo(v, w, x, y, z)
+ subroutine foo(v, w, x, y, z, cptr, cptr_in)
integer, target, optional, value :: v
integer, target, optional :: w
integer, target, optional :: x(:)
integer, target, optional, allocatable :: y
integer, target, optional, allocatable :: z(:)
+ type(c_ptr), target, optional, value :: cptr
+ type(c_ptr), target, optional, value, intent(in) :: cptr_in
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
+ ! Need to map per-VALUE arguments, if present
+ if (present(v)) then
+ !$omp target enter data map(to:v)
+ stop 1 ! – but it shall not be present in this test case.
+ end if
+ if (present(cptr)) then
+ !$omp target enter data map(to:cptr)
+ stop 2 ! – but it shall not be present in this test case.
+ end if
+ if (present(cptr_in)) then
+ !$omp target enter data map(to:cptr_in)
+ stop 3 ! – but it shall not be present in this test case.
+ end if
+
+ !$omp target data map(d) use_device_addr(v, w, x, y, z, cptr, cptr_in)
+ if (present(v)) then; v = 5; stop 11; endif
+ if (present(w)) then; w = 5; stop 12; endif
+ if (present(x)) then; x(1) = 5; stop 13; endif
+ if (present(y)) then; y = 5; stop 14; endif
+ if (present(z)) then; z(1) = 5; stop 15; endif
+ if (present(cptr)) then; cptr = c_loc(v); stop 16; endif
+ if (present(cptr_in)) then
+ if (c_associated(cptr_in, c_loc(x))) stop 26
+ stop 27
+ endif
!$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 target data map(d) use_device_ptr(w, x, y, z, cptr, cptr_in)
+ if (present(w)) then; w = 5; stop 21; endif
+ if (present(x)) then; x(1) = 5; stop 22; endif
+ if (present(y)) then; y = 5; stop 23; endif
+ if (present(z)) then; z(1) = 5; stop 24; endif
+ if (present(cptr)) then; cptr = c_loc(x); stop 25; endif
+ if (present(cptr_in)) then
+ if (c_associated(cptr_in, c_loc(x))) stop 26
+ stop 27
+ endif
!$omp end target data
end subroutine foo
end program main