[Openmp-commits] [openmp] [Flang][OpenMP] Derived type member map fortran offload runtime tests (PR #82850)

via Openmp-commits openmp-commits at lists.llvm.org
Wed Apr 24 15:19:58 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-offload

Author: None (agozillon)

<details>
<summary>Changes</summary>

This is a large series of runtime tests that help to add coverage for the specific cases intended to be supported by the PR stack
that extends derived type map support in Flang+OpenMP. Primarily this will add functionality coverage, there's cases where
things may work, but not optimally (or at least similarly to the status quo in Clang), addiitonal IR tests are added in the
relevant segments of the related PRs to test for breakages like that.


---

Patch is 46.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/82850.diff


30 Files Affected:

- (added) offload/test/offloading/fortran/target-map-derived-type-full-1.f90 (+45) 
- (added) offload/test/offloading/fortran/target-map-derived-type-full-2.f90 (+60) 
- (added) offload/test/offloading/fortran/target-map-derived-type-full-implicit-1.f90 (+46) 
- (added) offload/test/offloading/fortran/target-map-derived-type-full-implicit-2.f90 (+61) 
- (added) offload/test/offloading/fortran/target-map-double-large-nested-dtype-multi-member.f90 (+101) 
- (added) offload/test/offloading/fortran/target-map-double-nested-dtype-array-bounds.f90 (+47) 
- (added) offload/test/offloading/fortran/target-map-double-nested-dtype-double-array-bounds.f90 (+47) 
- (added) offload/test/offloading/fortran/target-map-double-nested-dtype-single-member.f90 (+47) 
- (added) offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit-update.f90 (+49) 
- (added) offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit.f90 (+49) 
- (added) offload/test/offloading/fortran/target-map-dtype-explicit-individual-array-member.f90 (+33) 
- (added) offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-3D-member-bounds.f90 (+45) 
- (added) offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-member-bounds.f90 (+38) 
- (added) offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-member.f90 (+39) 
- (added) offload/test/offloading/fortran/target-map-dtype-multi-explicit-member.f90 (+33) 
- (modified) offload/test/offloading/fortran/target-map-enter-exit-array-2.f90 (-2) 
- (modified) offload/test/offloading/fortran/target-map-enter-exit-array-bounds.f90 (-2) 
- (modified) offload/test/offloading/fortran/target-map-enter-exit-scalar.f90 (-1) 
- (added) offload/test/offloading/fortran/target-map-individual-dtype-member-map.f90 (+33) 
- (added) offload/test/offloading/fortran/target-map-large-nested-dtype-multi-member.f90 (+83) 
- (added) offload/test/offloading/fortran/target-map-nested-dtype-complex-member.f90 (+55) 
- (added) offload/test/offloading/fortran/target-map-nested-dtype-derived-member.f90 (+51) 
- (added) offload/test/offloading/fortran/target-map-nested-dtype-multi-member.f90 (+47) 
- (added) offload/test/offloading/fortran/target-map-nested-dtype-single-member.f90 (+40) 
- (added) offload/test/offloading/fortran/target-map-two-dtype-explicit-member.f90 (+35) 
- (added) offload/test/offloading/fortran/target-map-two-dtype-individual-member-array-1D-bounds.f90 (+39) 
- (added) offload/test/offloading/fortran/target-map-two-dtype-mixed-implicit-explicit-capture-1.f90 (+35) 
- (added) offload/test/offloading/fortran/target-map-two-dtype-mixed-implicit-explicit-capture-2.f90 (+41) 
- (added) offload/test/offloading/fortran/target-map-two-dtype-multi-member-array-1D-bounds.f90 (+51) 
- (added) offload/test/offloading/fortran/target-map-two-nested-dtype-member-array-map.f90 (+56) 


``````````diff
diff --git a/offload/test/offloading/fortran/target-map-derived-type-full-1.f90 b/offload/test/offloading/fortran/target-map-derived-type-full-1.f90
new file mode 100644
index 00000000000000..cb03708554fed0
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-derived-type-full-1.f90
@@ -0,0 +1,45 @@
+! Offloading test checking interaction of an
+! explicit derived type mapping when mapped 
+! to target and assinging one derived type
+! to another
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: scalar
+    integer(4) :: ix = 0
+    real(4) :: rx = 0.0
+    complex(4) :: zx = (0,0)
+    end type scalar  
+  
+    type(scalar) :: in
+    type(scalar) :: out
+    in%ix = 10
+    in%rx = 2.0
+    in%zx = (2, 10)
+  
+  !$omp target map(from:out) map(to:in)
+      out = in 
+  !$omp end target
+  
+    print*, in%ix
+    print*, in%rx
+    write (*,*) in%zx
+  
+    print*, out%ix
+    print*, out%rx
+    write (*,*)  out%zx
+end program main
+
+!CHECK: 10
+!CHECK: 2.
+!CHECK: (2.,10.)
+!CHECK: 10
+!CHECK: 2.
+!CHECK: (2.,10.)
diff --git a/offload/test/offloading/fortran/target-map-derived-type-full-2.f90 b/offload/test/offloading/fortran/target-map-derived-type-full-2.f90
new file mode 100644
index 00000000000000..0095b0fdf86a66
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-derived-type-full-2.f90
@@ -0,0 +1,60 @@
+! Offloading test checking interaction of an
+! explicit derived type mapping when mapped to 
+! target and assigning to individual members
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: scalar
+    integer(4) :: ix = 0
+    real(4) :: rx = 0.0
+    complex(4) :: zx = (0,0)
+    integer(4) :: array(5)
+    end type scalar 
+  
+    type(scalar) :: out
+    type(scalar) :: in
+  
+    in%ix = 10
+    in%rx = 2.0
+    in%zx = (2, 10)
+  
+    do i = 1, 5
+      in%array(i) = i
+    end do 
+  
+  !$omp target map(from:out) map(to:in)
+    out%ix = in%ix
+    out%rx = in%rx
+    out%zx = in%zx
+  
+    do i = 1, 5
+      out%array(i) = in%array(i)
+    end do 
+  !$omp end target
+  
+    print*, in%ix
+    print*, in%rx
+    print*, in%array
+    write (*,*) in%zx
+
+    print*, out%ix
+    print*, out%rx
+    print*, out%array
+    write (*,*)  out%zx
+end program main
+
+!CHECK: 10
+!CHECK: 2.
+!CHECK: 1 2 3 4 5
+!CHECK: (2.,10.)
+!CHECK: 10
+!CHECK: 2.
+!CHECK: 1 2 3 4 5
+!CHECK: (2.,10.)
diff --git a/offload/test/offloading/fortran/target-map-derived-type-full-implicit-1.f90 b/offload/test/offloading/fortran/target-map-derived-type-full-implicit-1.f90
new file mode 100644
index 00000000000000..f57e2c70d155e9
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-derived-type-full-implicit-1.f90
@@ -0,0 +1,46 @@
+! Offloading test checking interaction of an
+! implicit derived type mapping when mapped 
+! to target and assinging one derived type
+! to another
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: scalar
+    integer(4) :: ix = 0
+    real(4) :: rx = 0.0
+    complex(4) :: zx = (0,0)
+    end type scalar  
+  
+    type(scalar) :: in
+    type(scalar) :: out
+    in%ix = 10
+    in%rx = 2.0
+    in%zx = (2, 10)
+  
+  !$omp target map(from:out)
+      out = in 
+  !$omp end target
+  
+    print*, in%ix
+    print*, in%rx
+    write (*,*) in%zx
+
+    print*, out%ix
+    print*, out%rx
+    write (*,*)  out%zx
+  end program main
+
+!CHECK: 10
+!CHECK: 2.
+!CHECK: (2.,10.)
+!CHECK: 10
+!CHECK: 2.
+!CHECK: (2.,10.)
+  
\ No newline at end of file
diff --git a/offload/test/offloading/fortran/target-map-derived-type-full-implicit-2.f90 b/offload/test/offloading/fortran/target-map-derived-type-full-implicit-2.f90
new file mode 100644
index 00000000000000..92d3454d462a7d
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-derived-type-full-implicit-2.f90
@@ -0,0 +1,61 @@
+! Offloading test checking interaction of an
+! explicit derived type mapping when mapped 
+! to target and assinging one derived type
+! to another
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: scalar
+    integer(4) :: ix = 0
+    real(4) :: rx = 0.0
+    complex(4) :: zx = (0,0)
+    integer(4) :: array(5)
+    end type scalar 
+  
+    type(scalar) :: out
+    type(scalar) :: in
+  
+    in%ix = 10
+    in%rx = 2.0
+    in%zx = (2, 10)
+  
+    do i = 1, 5
+      in%array(i) = i
+    end do 
+  
+  !$omp target
+    out%ix = in%ix
+    out%rx = in%rx
+    out%zx = in%zx
+  
+    do i = 1, 5
+      out%array(i) = in%array(i)
+    end do 
+  !$omp end target
+  
+    print*, in%ix
+    print*, in%rx
+    print*, in%array
+    write (*,*) in%zx
+
+    print*, out%ix
+    print*, out%rx
+    print*, out%array
+    write (*,*)  out%zx
+end program main
+
+!CHECK: 10
+!CHECK: 2.
+!CHECK: 1 2 3 4 5
+!CHECK: (2.,10.)
+!CHECK: 10
+!CHECK: 2.
+!CHECK: 1 2 3 4 5
+!CHECK: (2.,10.)
diff --git a/offload/test/offloading/fortran/target-map-double-large-nested-dtype-multi-member.f90 b/offload/test/offloading/fortran/target-map-double-large-nested-dtype-multi-member.f90
new file mode 100644
index 00000000000000..31774be1914638
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-double-large-nested-dtype-multi-member.f90
@@ -0,0 +1,101 @@
+! Offloading test checking interaction of an
+! explicit member map from two large nested
+! derived types
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: bottom_layer1
+    real(4) :: i4
+    real(4) :: j4
+    real(4) :: k4
+    end type bottom_layer1
+
+    type :: bottom_layer2
+      integer(4) :: i3
+      integer(4) :: j3
+      integer(4) :: k3
+    end type bottom_layer2 
+
+    type :: middle_layer
+     real(4) :: array_i2(10)
+     real(4) :: i2
+     real(4) :: array_j2(10)
+     type(bottom_layer1) :: nest 
+     type(bottom_layer2) :: nest2 
+    end type middle_layer
+
+    type :: top_layer
+    real(4) :: i
+    integer(4) :: array_i(10)
+    real(4) :: j
+    integer, allocatable :: array_j(:)
+    integer(4) :: k
+    type(middle_layer) :: nested
+    end type top_layer
+    
+    type(top_layer) :: top_dtype
+    type(top_layer) :: top_dtype2
+
+    top_dtype2%nested%nest%i4 = 10
+    top_dtype2%nested%nest%j4 = 12
+    top_dtype2%nested%nest%k4 = 54
+    
+    top_dtype2%nested%nest2%i3 = 20
+    top_dtype2%nested%nest2%j3 = 40
+    top_dtype2%nested%nest2%k3 = 60
+    
+    top_dtype2%nested%i2 = 200
+
+      do i = 1, 10
+        top_dtype2%array_i(i) = i
+      end do
+
+!$omp target map(from: top_dtype%nested%nest%j4, top_dtype%nested%nest%i4, top_dtype%nested%nest%k4) &
+!$omp map(from: top_dtype%array_i, top_dtype%nested%nest2%i3, top_dtype%nested%i2) &
+!$omp map(from: top_dtype%nested%nest2%k3, top_dtype%nested%nest2%j3) &
+!$omp map(to: top_dtype2%nested%nest%j4, top_dtype2%nested%nest%i4, top_dtype2%nested%nest%k4) &
+!$omp map(to: top_dtype2%array_i, top_dtype2%nested%nest2%i3, top_dtype2%nested%i2) &
+!$omp map(to: top_dtype2%nested%nest2%k3, top_dtype2%nested%nest2%j3)
+    top_dtype%nested%nest%i4 = top_dtype2%nested%nest%i4
+    top_dtype%nested%nest%j4 = top_dtype2%nested%nest%j4 
+    top_dtype%nested%nest%k4 = top_dtype2%nested%nest%k4
+    
+    top_dtype%nested%nest2%i3 = top_dtype2%nested%nest2%i3
+    top_dtype%nested%nest2%j3 = top_dtype2%nested%nest2%j3
+    top_dtype%nested%nest2%k3 = top_dtype2%nested%nest2%k3
+    
+    top_dtype%nested%i2 = top_dtype2%nested%i2
+
+    do i = 1, 10
+      top_dtype%array_i(i) = top_dtype2%array_i(i)
+    end do
+!$omp end target
+  
+  print *, top_dtype%nested%nest%i4
+  print *, top_dtype%nested%nest%j4
+  print *, top_dtype%nested%nest%k4
+
+  print *, top_dtype%nested%nest2%i3
+  print *, top_dtype%nested%nest2%j3
+  print *, top_dtype%nested%nest2%k3
+  
+  print *, top_dtype%nested%i2
+
+  print *, top_dtype%array_i 
+end program main
+
+!CHECK: 10.
+!CHECK: 12.
+!CHECK: 54.
+!CHECK: 20
+!CHECK: 40
+!CHECK: 60
+!CHECK: 200.
+!CHECK: 1 2 3 4 5 6 7 8 9 10
diff --git a/offload/test/offloading/fortran/target-map-double-nested-dtype-array-bounds.f90 b/offload/test/offloading/fortran/target-map-double-nested-dtype-array-bounds.f90
new file mode 100644
index 00000000000000..cecfb9e84a59d6
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-double-nested-dtype-array-bounds.f90
@@ -0,0 +1,47 @@
+! Offloading test checking interaction of two
+! explicit arrau member maps with bounds from 
+! two nested derived types 
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: bottom_layer
+      real(8) :: i2
+      real(4) :: array_i2(10)
+      real(4) :: array_j2(10)
+    end type bottom_layer
+
+    type :: top_layer
+      real(4) :: i
+      integer(4) :: array_i(10)
+      real(4) :: j
+      type(bottom_layer) :: nested
+      integer, allocatable :: array_j(:)
+      integer(4) :: k
+    end type top_layer
+    
+    type(top_layer) :: top_dtype
+    type(top_layer) :: top_dtype2
+
+!$omp target map(tofrom: top_dtype%nested%array_i2(4:8), top_dtype2%nested%array_j2(4:8))
+    do i = 4, 8 
+      top_dtype%nested%array_i2(i) = i * 2
+    end do 
+
+    do i = 4, 8 
+      top_dtype2%nested%array_j2(i) = i * 2
+    end do 
+!$omp end target
+  
+  print *, top_dtype%nested%array_i2
+  print *, top_dtype2%nested%array_j2
+end program main
+
+!CHECK: 0. 0. 0. 8. 10. 12. 14. 16. 0. 0.
+!CHECK: 0. 0. 0. 8. 10. 12. 14. 16. 0. 0.
diff --git a/offload/test/offloading/fortran/target-map-double-nested-dtype-double-array-bounds.f90 b/offload/test/offloading/fortran/target-map-double-nested-dtype-double-array-bounds.f90
new file mode 100644
index 00000000000000..a8762a0829cc1d
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-double-nested-dtype-double-array-bounds.f90
@@ -0,0 +1,47 @@
+! Offloading test checking interaction of two
+! explicit array member maps with array bounds 
+! from two nested derived types 
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: bottom_layer
+      real(8) :: i2
+      real(4) :: array_i2(10)
+      real(4) :: array_j2(10)
+    end type bottom_layer
+
+    type :: top_layer
+      real(4) :: i
+      integer(4) :: array_i(10)
+      real(4) :: j
+      type(bottom_layer) :: nested
+      integer, allocatable :: array_j(:)
+      integer(4) :: k
+    end type top_layer
+    
+    type(top_layer) :: top_dtype
+    type(top_layer) :: top_dtype2
+
+!$omp target map(tofrom: top_dtype%nested%array_i2(4:8), top_dtype2%nested%array_j2(4:8))
+    do i = 4, 8 
+      top_dtype%nested%array_i2(i) = i * 2
+    end do 
+
+    do i = 4, 8 
+      top_dtype2%nested%array_j2(i) = i * 2
+    end do 
+!$omp end target
+  
+  print *, top_dtype%nested%array_i2
+  print *, top_dtype2%nested%array_j2
+end program main
+
+!CHECK: 0. 0. 0. 8. 10. 12. 14. 16. 0. 0
+!CHECK: 0. 0. 0. 8. 10. 12. 14. 16. 0. 0
diff --git a/offload/test/offloading/fortran/target-map-double-nested-dtype-single-member.f90 b/offload/test/offloading/fortran/target-map-double-nested-dtype-single-member.f90
new file mode 100644
index 00000000000000..9ecb394dbe4629
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-double-nested-dtype-single-member.f90
@@ -0,0 +1,47 @@
+! Offloading test checking interaction of an
+! explicit derived type member mapping of two
+! derived types for a single array member each
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: bottom_layer
+      real(8) :: i2
+      real(4) :: array_i2(10)
+      real(4) :: array_j2(10)
+    end type bottom_layer
+
+    type :: top_layer
+      real(4) :: i
+      integer(4) :: array_i(10)
+      real(4) :: j
+      type(bottom_layer) :: nested
+      integer, allocatable :: array_j(:)
+      integer(4) :: k
+    end type top_layer
+    
+    type(top_layer) :: top_dtype
+    type(top_layer) :: top_dtype2
+
+!$omp target map(tofrom: top_dtype%nested%array_i2, top_dtype2%nested%array_j2)
+    do i = 1, 10 
+      top_dtype%nested%array_i2(i) = i * 2
+    end do 
+
+    do i = 1, 10 
+      top_dtype2%nested%array_j2(i) = i * 2
+    end do 
+!$omp end target
+
+  print *, top_dtype%nested%array_i2
+  print *, top_dtype2%nested%array_j2
+end program main
+
+!CHECK: 2. 4. 6. 8. 10. 12. 14. 16. 18. 20.
+!CHECK: 2. 4. 6. 8. 10. 12. 14. 16. 18. 20.
diff --git a/offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit-update.f90 b/offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit-update.f90
new file mode 100644
index 00000000000000..3b3ec96b9babfd
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit-update.f90
@@ -0,0 +1,49 @@
+! Offloading test checking interaction of an
+! explicit derived type member mapping of 
+! an array with bounds when mapped to 
+! target using a combination of update,
+! enter and exit directives.
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: scalar_array
+        integer(4) :: array(10)
+    end type scalar_array
+
+    type(scalar_array) :: scalar_arr
+
+    do I = 1, 10
+        scalar_arr%array(I) = I + I
+    end do
+
+  !$omp target enter data map(to: scalar_arr%array(3:6))
+
+    ! overwrite our target data with an update.  
+    do I = 1, 10
+        scalar_arr%array(I) = 10
+    end do
+
+  !$omp target update to(scalar_arr%array(3:6))
+
+  ! The compiler/runtime is less friendly about read/write out of 
+  ! bounds when using enter and exit, we have to specifically loop
+  ! over the correct range
+   !$omp target
+    do i=3,6
+        scalar_arr%array(i) = scalar_arr%array(i) + i
+    end do
+  !$omp end target 
+
+  !$omp target exit data map(from: scalar_arr%array(3:6))
+  
+  print*, scalar_arr%array
+end program
+
+!CHECK: 10 10 13 14 15 16 10 10 10 10
diff --git a/offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit.f90 b/offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit.f90
new file mode 100644
index 00000000000000..5f7e9f94682659
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit.f90
@@ -0,0 +1,49 @@
+! Offloading test checking interaction of an
+! explicit derived type member mapping of 
+! an array with bounds when mapped to 
+! target using a combination of enter and 
+! exit directives.
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: scalar_array
+        integer(4) :: array(10)
+    end type scalar_array
+
+    type(scalar_array) :: scalar_arr
+
+    do I = 1, 10
+        scalar_arr%array(I) = I + I
+    end do
+
+    !$omp target enter data map(to: scalar_arr%array(3:6))
+    
+    ! Shouldn't overwrite data already locked in
+    ! on target via enter, which will then be 
+    ! overwritten by our exit
+    do I = 1, 10
+        scalar_arr%array(I) = 10
+    end do
+
+  ! The compiler/runtime is less friendly about read/write out of 
+  ! bounds when using enter and exit, we have to specifically loop
+  ! over the correct range
+   !$omp target
+    do i=3,6
+        scalar_arr%array(i) = scalar_arr%array(i) + i
+    end do
+  !$omp end target 
+
+  !$omp target exit data map(from: scalar_arr%array(3:6))
+  
+  print*, scalar_arr%array
+end program
+
+!CHECK: 10 10 9 12 15 18 10 10 10 10
diff --git a/offload/test/offloading/fortran/target-map-dtype-explicit-individual-array-member.f90 b/offload/test/offloading/fortran/target-map-dtype-explicit-individual-array-member.f90
new file mode 100644
index 00000000000000..907b16ffedf524
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-dtype-explicit-individual-array-member.f90
@@ -0,0 +1,33 @@
+! Offloading test checking interaction of an
+! explicit derived type member mapping of 
+! an array when mapped to target
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+type :: scalar_array
+    real(4) :: break_0
+    real(4) :: array_x(10)
+    real(4) :: break_1
+    real(4) :: array_y(10)
+    real(4) :: break_3
+end type scalar_array
+  
+   type(scalar_array) :: scalar_arr
+    
+  !$omp target map(tofrom:scalar_arr%array_y)
+    do i = 1, 10
+      scalar_arr%array_y(i) = i
+    end do
+  !$omp end target
+
+  print *, scalar_arr%array_y
+end program main
+
+!CHECK: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
diff --git a/offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-3D-member-bounds.f90 b/offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-3D-member-bounds.f90
new file mode 100644
index 00000000000000..110fb648980cdc
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-3D-member-bounds.f90
@@ -0,0 +1,45 @@
+! Offloading test checking interaction of an
+! explicit derived type member mapping of 
+! two arrays with explicit bounds when 
+! mapped to target
+! REQUIRES: flang, amdgcn-amd-amdhsa
+! UNSUPPORTED: nvptx64-nvidia-cuda
+! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
+! UNSUPPORTED: aarch64-unknown-linux-gnu
+! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+! UNSUPPORTED: x86_64-pc-linux-gnu
+! UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+    type :: scalar_array
+    real(4) :: break_0
+    integer(4) :: array_x(3,3,3)
+    real(4) :: brea...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/82850


More information about the Openmp-commits mailing list