Files
gcc-reflection/libgomp/testsuite/libgomp.fortran/target-allocatable-1-1.f90
Thomas Schwinge 3dc9eedd95 libgomp: Add a few more OpenMP/USM test cases
... where there are clear differences in behavior for OpenMP/USM run-time
configurations.

We shall further clarify all the intended semantics, once the implementation
begins to differentiate OpenMP 'requires unified_shared_memory' vs.
'requires self_maps'.

	libgomp/
	* testsuite/libgomp.c-c++-common/map-arrayofstruct-2-usm.c: New.
	* testsuite/libgomp.c-c++-common/map-arrayofstruct-3-usm.c:
	Likewise.
	* testsuite/libgomp.c-c++-common/struct-elem-5-usm.c: Likewise.
	* testsuite/libgomp.c-c++-common/target-present-1-usm.c: Likewise.
	* testsuite/libgomp.c-c++-common/target-present-2-usm.c: Likewise.
	* testsuite/libgomp.c-c++-common/target-present-3-usm.c: Likewise.
	* testsuite/libgomp.fortran/map-subarray-5-usm.f90: Likewise.
	* testsuite/libgomp.fortran/map-subarray-6-usm.f90: Likewise.
	* testsuite/libgomp.fortran/map-subarray-7-usm.f90: Likewise.
	* testsuite/libgomp.fortran/target-allocatable-1-1-usm.f90:
	Likewise.
	* testsuite/libgomp.fortran/target-allocatable-1-2-usm.f90:
	Likewise.
	* testsuite/libgomp.fortran/target-enter-data-2-usm.F90: Likewise.
	* testsuite/libgomp.fortran/target-present-1-usm.f90: Likewise.
	* testsuite/libgomp.fortran/target-present-2-usm.f90: Likewise.
	* testsuite/libgomp.fortran/target-present-3-usm.f90: Likewise.
	* testsuite/libgomp.fortran/target-allocatable-1-1.f90: Adjust.
	* testsuite/libgomp.fortran/target-allocatable-1-2.f90: Likewise.
	* testsuite/libgomp.fortran/target-present-1.f90: Likewise.
	* testsuite/libgomp.fortran/target-present-2.f90: Likewise.
	* testsuite/libgomp.fortran/target-present-3.f90: Likewise.
2026-01-14 16:00:56 +01:00

74 lines
1.5 KiB
Fortran

! Test 'allocatable' with OpenMP 'target' 'map' clauses.
! See also '../libgomp.oacc-fortran/allocatable-1-1.f90'.
! { dg-do run }
! { dg-additional-options "-cpp" }
! { dg-additional-options "-DMEM_SHARED" { target offload_device_shared_as } }
program main
implicit none
#ifdef OMP_USM
!$omp requires unified_shared_memory self_maps
#endif
integer, allocatable :: a, b, c, d, e
allocate (a)
a = 11
b = 25 ! Implicit allocation.
c = 52 ! Implicit allocation.
!No 'allocate (d)' here.
!No 'allocate (e)' here.
!$omp target map(to: a) map(tofrom: b, c, d) map(from: e)
if (.not. allocated (a)) stop 1
if (a .ne. 11) stop 2
a = 33
if (.not. allocated (b)) stop 3
if (b .ne. 25) stop 4
if (.not. allocated (c)) stop 5
if (c .ne. 52) stop 6
c = 10
if (allocated (d)) stop 7
d = 42 ! Implicit allocation, but on device only.
if (.not. allocated (d)) stop 8
deallocate (d) ! OpenMP requires must be "unallocated upon exit from the region".
if (allocated (e)) stop 9
e = 24 ! Implicit allocation, but on device only.
if (.not. allocated (e)) stop 10
deallocate (e) ! OpenMP requires must be "unallocated upon exit from the region".
!$omp end target
if (.not. allocated (a)) stop 20
#ifdef MEM_SHARED
if (a .ne. 33) stop 21
#else
if (a .ne. 11) stop 22
#endif
deallocate (a)
if (.not. allocated (b)) stop 23
if (b .ne. 25) stop 24
deallocate (b)
if (.not. allocated (c)) stop 25
if (c .ne. 10) stop 26
deallocate (c)
if (allocated (d)) stop 27
if (allocated (e)) stop 28
end program main