[llvm] [OpenMP] Allocatable explicit member mapping fortran offloading tests (PR #113555)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 24 05:37:59 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: None (agozillon)
<details>
<summary>Changes</summary>
This PR is one in a series of 3 that aim to add support for explicit member mapping of allocatable components in derived types within OpenMP+Fortran for Flang.
This PR provides all of the runtime tests that are currently upstreamable, unfortunately some of the other tests would require linking of the fortran runtime for offload which we currently do not do. But regardless, this is plenty to ensure that the mapping is working in most cases.
---
Patch is 86.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/113555.diff
82 Files Affected:
- (modified) offload/test/offloading/fortran/basic-target-region-1D-array-section.f90 (+2-2)
- (modified) offload/test/offloading/fortran/basic-target-region-3D-array-section.f90 (+2-2)
- (modified) offload/test/offloading/fortran/basic-target-region-3D-array.f90 (+2-2)
- (modified) offload/test/offloading/fortran/constant-arr-index.f90 (+2-4)
- (modified) offload/test/offloading/fortran/declare-target-vars-in-target-region.f90 (+3-3)
- (modified) offload/test/offloading/fortran/double-target-call-with-declare-target.f90 (+3-4)
- (modified) offload/test/offloading/fortran/dtype-array-constant-index-map.f90 (+6-14)
- (added) offload/test/offloading/fortran/dtype-member-map-syntax-1.f90 (+109)
- (added) offload/test/offloading/fortran/dtype-member-map-syntax-2.f90 (+176)
- (modified) offload/test/offloading/fortran/dump_map_tables.f90 (+3-3)
- (modified) offload/test/offloading/fortran/local-descriptor-map-regress.f90 (+10-14)
- (modified) offload/test/offloading/fortran/target-depend.f90 (+1-2)
- (modified) offload/test/offloading/fortran/target-map-all-common-block-members.f90 (+2-3)
- (added) offload/test/offloading/fortran/target-map-alloca-dtype-alloca-array-of-dtype.f90 (+36)
- (added) offload/test/offloading/fortran/target-map-alloca-dtype-alloca-array.f90 (+29)
- (added) offload/test/offloading/fortran/target-map-alloca-dtype-and-alloca-array-v2.f90 (+34)
- (added) offload/test/offloading/fortran/target-map-alloca-dtype-and-alloca-array.f90 (+33)
- (added) offload/test/offloading/fortran/target-map-alloca-dtype-array-and-scalar.f90 (+39)
- (added) offload/test/offloading/fortran/target-map-alloca-dtype-array-of-dtype.f90 (+35)
- (modified) offload/test/offloading/fortran/target-map-allocatable-array-section-1d-bounds.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-allocatable-array-section-3d-bounds.f90 (+2-3)
- (added) offload/test/offloading/fortran/target-map-allocatable-dtype.f90 (+31)
- (modified) offload/test/offloading/fortran/target-map-allocatable-map-scopes.f90 (+2-2)
- (modified) offload/test/offloading/fortran/target-map-common-block.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-declare-target-link-common-block.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-derived-type-full-1.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-derived-type-full-2.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-derived-type-full-implicit-1.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-derived-type-full-implicit-2.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-double-large-nested-dtype-multi-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-double-nested-dtype-array-bounds.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-double-nested-dtype-double-array-bounds.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-double-nested-dtype-single-member.f90 (+2-3)
- (added) offload/test/offloading/fortran/target-map-dtype-3d-alloca-array-with-bounds.f90 (+41)
- (added) offload/test/offloading/fortran/target-map-dtype-alloca-and-non-alloca-array.f90 (+36)
- (added) offload/test/offloading/fortran/target-map-dtype-alloca-array-and-non-alloca-dtype.f90 (+44)
- (added) offload/test/offloading/fortran/target-map-dtype-alloca-array-of-dtype.f90 (+34)
- (added) offload/test/offloading/fortran/target-map-dtype-alloca-array-with-bounds.f90 (+29)
- (added) offload/test/offloading/fortran/target-map-dtype-allocatable-array.f90 (+28)
- (added) offload/test/offloading/fortran/target-map-dtype-allocatable-scalar-and-array.f90 (+34)
- (modified) offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit-update.f90 (+3-5)
- (modified) offload/test/offloading/fortran/target-map-dtype-arr-bounds-member-enter-exit.f90 (+3-5)
- (modified) offload/test/offloading/fortran/target-map-dtype-explicit-individual-array-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-3D-member-bounds.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-member-bounds.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-dtype-multi-explicit-array-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-dtype-multi-explicit-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-enter-exit-allocatables.f90 (+2-2)
- (modified) offload/test/offloading/fortran/target-map-enter-exit-array-2.f90 (+2-2)
- (modified) offload/test/offloading/fortran/target-map-enter-exit-array-bounds.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-enter-exit-array.f90 (+2-2)
- (modified) offload/test/offloading/fortran/target-map-enter-exit-scalar.f90 (+1-2)
- (modified) offload/test/offloading/fortran/target-map-first-common-block-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-individual-dtype-member-map.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-large-nested-dtype-multi-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-mix-imp-exp-common-block-members.f90 (+2-4)
- (added) offload/test/offloading/fortran/target-map-multi-alloca-dtypes-with-multi-alloca-members.f90 (+90)
- (added) offload/test/offloading/fortran/target-map-multi-alloca-dtypes-with-multi-mixed-members.f90 (+82)
- (added) offload/test/offloading/fortran/target-map-nested-alloca-dtype-3d-alloca-array-bounds.f90 (+51)
- (added) offload/test/offloading/fortran/target-map-nested-alloca-dtype-alloca-array-bounds.f90 (+43)
- (added) offload/test/offloading/fortran/target-map-nested-dtype-3d-alloca-array-with-bounds.f90 (+50)
- (added) offload/test/offloading/fortran/target-map-nested-dtype-alloca-and-non-alloca-array.f90 (+47)
- (added) offload/test/offloading/fortran/target-map-nested-dtype-alloca-array-and-non-alloca-dtype.f90 (+51)
- (added) offload/test/offloading/fortran/target-map-nested-dtype-alloca-array-with-bounds.f90 (+43)
- (added) offload/test/offloading/fortran/target-map-nested-dtype-alloca-array.f90 (+37)
- (modified) offload/test/offloading/fortran/target-map-nested-dtype-complex-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-nested-dtype-derived-member.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-nested-dtype-multi-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-nested-dtype-single-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-pointer-scopes-enter-exit.f90 (+2-2)
- (modified) offload/test/offloading/fortran/target-map-pointer-target-array-section-3d-bounds.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-pointer-target-scopes.f90 (+2-2)
- (added) offload/test/offloading/fortran/target-map-pointer-to-dtype-allocatable-member.f90 (+45)
- (modified) offload/test/offloading/fortran/target-map-second-common-block-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-two-dtype-explicit-member.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-two-dtype-individual-member-array-1D-bounds.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-two-dtype-mixed-implicit-explicit-capture-1.f90 (+2-3)
- (modified) offload/test/offloading/fortran/target-map-two-dtype-mixed-implicit-explicit-capture-2.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-two-dtype-multi-member-array-1D-bounds.f90 (+2-4)
- (modified) offload/test/offloading/fortran/target-map-two-nested-dtype-member-array-map.f90 (+2-2)
- (modified) offload/test/offloading/fortran/target-nested-target-data.f90 (+1-2)
- (modified) offload/test/offloading/fortran/target-region-implicit-array.f90 (+2-2)
``````````diff
diff --git a/offload/test/offloading/fortran/basic-target-region-1D-array-section.f90 b/offload/test/offloading/fortran/basic-target-region-1D-array-section.f90
index 15795fbcf7f354..61244a965a1b88 100644
--- a/offload/test/offloading/fortran/basic-target-region-1D-array-section.f90
+++ b/offload/test/offloading/fortran/basic-target-region-1D-array-section.f90
@@ -1,5 +1,5 @@
-! Basic offloading test of arrays with provided lower
-! and upper bounds as specified by OpenMP's sectioning
+! Basic offloading test of arrays with provided lower and upper bounds as
+! specified by OpenMP's sectioning
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
diff --git a/offload/test/offloading/fortran/basic-target-region-3D-array-section.f90 b/offload/test/offloading/fortran/basic-target-region-3D-array-section.f90
index ca0364543c20f8..2e1c6a61379c3f 100644
--- a/offload/test/offloading/fortran/basic-target-region-3D-array-section.f90
+++ b/offload/test/offloading/fortran/basic-target-region-3D-array-section.f90
@@ -1,5 +1,5 @@
-! Basic offloading test of a regular array explicitly
-! passed within a target region
+! Basic offloading test of a regular array explicitly passed within a target
+! region
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
diff --git a/offload/test/offloading/fortran/basic-target-region-3D-array.f90 b/offload/test/offloading/fortran/basic-target-region-3D-array.f90
index d575810713895e..61fced35980f41 100644
--- a/offload/test/offloading/fortran/basic-target-region-3D-array.f90
+++ b/offload/test/offloading/fortran/basic-target-region-3D-array.f90
@@ -1,5 +1,5 @@
-! Basic offloading test of a regular array explicitly
-! passed within a target region
+! Basic offloading test of a regular array explicitly passed within a target
+! region
! REQUIRES: flang
! REQUIRES: gpu
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
diff --git a/offload/test/offloading/fortran/constant-arr-index.f90 b/offload/test/offloading/fortran/constant-arr-index.f90
index 80440b6836ac8a..f819f1f0d994df 100644
--- a/offload/test/offloading/fortran/constant-arr-index.f90
+++ b/offload/test/offloading/fortran/constant-arr-index.f90
@@ -1,7 +1,5 @@
-! Basic offloading test with a target region
-! that checks constant indexing on device
-! correctly works (regression test for prior
-! bug).
+! Basic offloading test with a target region that checks constant indexing on
+! device correctly works (regression test for prior bug).
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
diff --git a/offload/test/offloading/fortran/declare-target-vars-in-target-region.f90 b/offload/test/offloading/fortran/declare-target-vars-in-target-region.f90
index c0bc9304b3030d..5410a0681e8e2a 100644
--- a/offload/test/offloading/fortran/declare-target-vars-in-target-region.f90
+++ b/offload/test/offloading/fortran/declare-target-vars-in-target-region.f90
@@ -1,6 +1,6 @@
-! Offloading test with a target region mapping a declare target
-! Fortran array writing some values to it and checking the host
-! correctly receives the updates made on the device.
+! Offloading test with a target region mapping a declare target Fortran array
+! writing some values to it and checking the host correctly receives the
+! updates made on the device.
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
diff --git a/offload/test/offloading/fortran/double-target-call-with-declare-target.f90 b/offload/test/offloading/fortran/double-target-call-with-declare-target.f90
index fa909815757f92..f7fef9583214bd 100644
--- a/offload/test/offloading/fortran/double-target-call-with-declare-target.f90
+++ b/offload/test/offloading/fortran/double-target-call-with-declare-target.f90
@@ -1,7 +1,6 @@
-! Offloading test with two target regions mapping the same
-! declare target Fortran array and writing some values to
-! it before checking the host correctly receives the
-! correct updates made on the device.
+! Offloading test with two target regions mapping the same declare target
+! Fortran array and writing some values to it before checking the host
+! correctly receives the correct updates made on the device.
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
diff --git a/offload/test/offloading/fortran/dtype-array-constant-index-map.f90 b/offload/test/offloading/fortran/dtype-array-constant-index-map.f90
index 7e168b846f858c..e120c95019c602 100644
--- a/offload/test/offloading/fortran/dtype-array-constant-index-map.f90
+++ b/offload/test/offloading/fortran/dtype-array-constant-index-map.f90
@@ -1,17 +1,9 @@
-! Offloading test which maps a specific element of a
-! derived type to the device and then accesses the
-! element alongside an individual element of an array
-! that the derived type contains. In particular, this
-! test helps to check that we can replace the constants
-! within the kernel with instructions and then replace
-! these instructions with the kernel parameters.
-! REQUIRES: flang
-! UNSUPPORTED: nvptx64-nvidia-cuda
-! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
-! UNSUPPORTED: aarch64-unknown-linux-gnu
-! UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
-! UNSUPPORTED: x86_64-unknown-linux-gnu
-! UNSUPPORTED: x86_64-unknown-linux-gnu-LTO
+! Offloading test which maps a specific element of a derived type to the device
+! and then accesses the element alongside an individual element of an array
+! that the derived type contains. In particular, this test helps to check that
+! we can replace the constants within the kernel with instructions and then
+! replace these instructions with the kernel parameters.
+! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
module test_0
diff --git a/offload/test/offloading/fortran/dtype-member-map-syntax-1.f90 b/offload/test/offloading/fortran/dtype-member-map-syntax-1.f90
new file mode 100644
index 00000000000000..fa4f20149c017e
--- /dev/null
+++ b/offload/test/offloading/fortran/dtype-member-map-syntax-1.f90
@@ -0,0 +1,109 @@
+! This test checks a number of more complex derived type member mapping
+! syntaxes utilising a non-allocatable parent derived type.
+
+! REQUIRES: flang, amdgpu
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+ type dtype2
+ integer int
+ real float
+ real float_elements(10)
+ end type dtype2
+
+ type dtype1
+ character (LEN=30) characters
+ character (LEN=1) character
+ type(dtype2) number
+ end type dtype1
+
+ type nonallocatabledtype
+ integer elements(20)
+ type(dtype1) num_chars
+ integer value
+ type(dtype2) internal_dtypes(5)
+ end type nonallocatabledtype
+
+ type (nonallocatabledtype) array_dtype(5)
+
+ !$omp target map(tofrom: array_dtype(5))
+ do i = 1, 20
+ array_dtype(5)%elements(i) = 20 + i
+ end do
+
+ array_dtype(5)%num_chars%number%float_elements(5) = 10
+ array_dtype(5)%value = 40
+ !$omp end target
+
+ print *, array_dtype(5)%elements
+ print *, array_dtype(5)%num_chars%number%float_elements(5)
+ print *, array_dtype(5)%value
+
+ !$omp target map(tofrom: array_dtype(4)%elements(3))
+ array_dtype(4)%elements(3) = 74
+ !$omp end target
+
+ print *, array_dtype(4)%elements(3)
+
+ !$omp target map(tofrom: array_dtype(5)%elements(3:5))
+ do i = 3, 5
+ array_dtype(5)%elements(i) = i + 1
+ end do
+ !$omp end target
+
+ do i = 3, 5
+ print *, array_dtype(5)%elements(i)
+ end do
+
+ !$omp target map(tofrom: array_dtype(3:5))
+ do i = 3, 5
+ array_dtype(i)%value = i + 2
+ end do
+ !$omp end target
+
+ do i = 3, 5
+ print *, array_dtype(i)%value
+ end do
+
+ !$omp target map(tofrom: array_dtype(4)%num_chars%number%float_elements(8))
+ array_dtype(4)%num_chars%number%float_elements(8) = 250
+ !$omp end target
+
+ print *, array_dtype(4)%num_chars%number%float_elements(8)
+
+ !$omp target map(tofrom: array_dtype(4)%num_chars%number%float_elements(5:10))
+ do i = 5, 10
+ array_dtype(4)%num_chars%number%float_elements(i) = i + 3
+ end do
+ !$omp end target
+
+ do i = 5, 10
+ print *, array_dtype(4)%num_chars%number%float_elements(i)
+ end do
+
+ !$omp target map(tofrom: array_dtype(4)%internal_dtypes(3)%float_elements(4))
+ array_dtype(4)%internal_dtypes(3)%float_elements(4) = 200
+ !$omp end target
+
+ print *, array_dtype(4)%internal_dtypes(3)%float_elements(4)
+
+end program main
+
+! CHECK: 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
+! CHECK: 10.
+! CHECK: 40
+! CHECK: 74
+! CHECK: 4
+! CHECK: 5
+! CHECK: 6
+! CHECK: 5
+! CHECK: 6
+! CHECK: 7
+! CHECK: 250.
+! CHECK: 8.
+! CHECK: 9.
+! CHECK: 10.
+! CHECK: 11.
+! CHECK: 12.
+! CHECK: 13.
+! CHECK: 200
diff --git a/offload/test/offloading/fortran/dtype-member-map-syntax-2.f90 b/offload/test/offloading/fortran/dtype-member-map-syntax-2.f90
new file mode 100644
index 00000000000000..8d666360066d9b
--- /dev/null
+++ b/offload/test/offloading/fortran/dtype-member-map-syntax-2.f90
@@ -0,0 +1,176 @@
+! This test checks a number of more complex derived type member mapping
+! syntaxes utilising an allocatable parent derived type and mixed
+! allocatable members.
+
+! REQUIRES: flang, amdgpu
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+ implicit none
+
+ integer :: i
+ integer :: N1, N2
+
+ type :: vertexes
+ integer :: test
+ integer :: testarray(10)
+ integer(4), allocatable :: vertexx(:)
+ integer(4), allocatable :: vertexy(:)
+ end type vertexes
+
+ type testing_tile_type
+ TYPE(vertexes) :: field
+ end type testing_tile_type
+
+ type :: dtype
+ real(4) :: i
+ type(vertexes), allocatable :: vertexes(:)
+ TYPE(testing_tile_type), DIMENSION(:), allocatable :: test_tile
+ integer(4) :: array_i(10)
+ real(4) :: j
+ integer, allocatable :: array_j(:)
+ integer(4) :: k
+ end type dtype
+
+ type(dtype) :: alloca_dtype
+ type(dtype), DIMENSION(:), allocatable :: alloca_dtype_arr
+
+ allocate(alloca_dtype%vertexes(4))
+ allocate(alloca_dtype%vertexes(1)%vertexx(10))
+ allocate(alloca_dtype%vertexes(1)%vertexy(10))
+ allocate(alloca_dtype%vertexes(2)%vertexx(10))
+ allocate(alloca_dtype%vertexes(2)%vertexy(10))
+ allocate(alloca_dtype%vertexes(3)%vertexx(10))
+ allocate(alloca_dtype%vertexes(3)%vertexy(10))
+ allocate(alloca_dtype%vertexes(4)%vertexx(10))
+ allocate(alloca_dtype%vertexes(4)%vertexy(10))
+ allocate(alloca_dtype%test_tile(4))
+ allocate(alloca_dtype%test_tile(1)%field%vertexx(10))
+ allocate(alloca_dtype%test_tile(1)%field%vertexy(10))
+ allocate(alloca_dtype%test_tile(2)%field%vertexx(10))
+ allocate(alloca_dtype%test_tile(2)%field%vertexy(10))
+ allocate(alloca_dtype%test_tile(3)%field%vertexx(10))
+ allocate(alloca_dtype%test_tile(3)%field%vertexy(10))
+ allocate(alloca_dtype%test_tile(4)%field%vertexx(10))
+ allocate(alloca_dtype%test_tile(4)%field%vertexy(10))
+
+ allocate(alloca_dtype_arr(3))
+
+ N1 = 1
+ N2 = 2
+
+!$omp target map(tofrom: alloca_dtype%vertexes(N1)%test)
+ alloca_dtype%vertexes(N1)%test = 3
+!$omp end target
+
+print *, alloca_dtype%vertexes(N1)%test
+
+!$omp target map(tofrom: alloca_dtype%vertexes(N1)%test, alloca_dtype%vertexes(N2)%test)
+ alloca_dtype%vertexes(N1)%test = 5
+ alloca_dtype%vertexes(N2)%test = 10
+!$omp end target
+
+print *, alloca_dtype%vertexes(N1)%test
+print *, alloca_dtype%vertexes(N2)%test
+
+!$omp target map(tofrom: alloca_dtype%test_tile(N1)%field%vertexx, &
+!$omp alloca_dtype%test_tile(N1)%field%vertexy)
+ do i = 1, 10
+ alloca_dtype%test_tile(N1)%field%vertexx(i) = i + 4
+ alloca_dtype%test_tile(N1)%field%vertexy(i) = i + 4
+ end do
+!$omp end target
+
+print *, alloca_dtype%test_tile(N1)%field%vertexx
+print *, alloca_dtype%test_tile(N1)%field%vertexy
+
+!$omp target map(tofrom: alloca_dtype%test_tile(N1)%field%test, &
+!$omp alloca_dtype%test_tile(N2)%field%test, &
+!$omp alloca_dtype%test_tile(N1)%field%vertexy, &
+!$omp alloca_dtype%test_tile(N2)%field%vertexy)
+ alloca_dtype%test_tile(N2)%field%test = 9999
+ alloca_dtype%test_tile(N2)%field%vertexy(2) = 9998
+ alloca_dtype%test_tile(N1)%field%test = 9997
+ alloca_dtype%test_tile(N1)%field%vertexy(2) = 9996
+!$omp end target
+
+print *, alloca_dtype%test_tile(N1)%field%test
+print *, alloca_dtype%test_tile(N2)%field%test
+print *, alloca_dtype%test_tile(N1)%field%vertexy(2)
+print *, alloca_dtype%test_tile(N2)%field%vertexy(2)
+
+!$omp target map(tofrom: alloca_dtype%test_tile(N2)%field%vertexy)
+ alloca_dtype%test_tile(N2)%field%vertexy(2) = 2000
+!$omp end target
+
+!$omp target map(tofrom: alloca_dtype%vertexes(N1)%vertexx, &
+!$omp alloca_dtype%vertexes(N1)%vertexy, &
+!$omp alloca_dtype%vertexes(N2)%vertexx, &
+!$omp alloca_dtype%vertexes(N2)%vertexy)
+ do i = 1, 10
+ alloca_dtype%vertexes(N1)%vertexx(i) = i * 2
+ alloca_dtype%vertexes(N1)%vertexy(i) = i * 2
+ alloca_dtype%vertexes(N2)%vertexx(i) = i * 2
+ alloca_dtype%vertexes(N2)%vertexy(i) = i * 2
+ end do
+!$omp end target
+
+print *, alloca_dtype%vertexes(N1)%vertexx
+print *, alloca_dtype%vertexes(N1)%vertexy
+print *, alloca_dtype%vertexes(N2)%vertexx
+print *, alloca_dtype%vertexes(N2)%vertexy
+
+!$omp target map(tofrom: alloca_dtype%vertexes(N1)%vertexx, &
+!$omp alloca_dtype%vertexes(N1)%vertexy, &
+!$omp alloca_dtype%vertexes(4)%vertexy, &
+!$omp alloca_dtype%vertexes(4)%vertexx, &
+!$omp alloca_dtype%vertexes(N2)%vertexx, &
+!$omp alloca_dtype%vertexes(N2)%vertexy)
+ do i = 1, 10
+ alloca_dtype%vertexes(N1)%vertexx(i) = i * 3
+ alloca_dtype%vertexes(N1)%vertexy(i) = i * 3
+ alloca_dtype%vertexes(4)%vertexx(i) = i * 3
+ alloca_dtype%vertexes(4)%vertexy(i) = i * 3
+ alloca_dtype%vertexes(N2)%vertexx(i) = i * 3
+ alloca_dtype%vertexes(N2)%vertexy(i) = i * 3
+ end do
+!$omp end target
+
+
+ print *, alloca_dtype%vertexes(1)%vertexx
+ print *, alloca_dtype%vertexes(1)%vertexy
+ print *, alloca_dtype%vertexes(4)%vertexx
+ print *, alloca_dtype%vertexes(4)%vertexy
+ print *, alloca_dtype%vertexes(2)%vertexx
+ print *, alloca_dtype%vertexes(2)%vertexy
+
+!$omp target map(tofrom: alloca_dtype_arr(N2)%array_i)
+ do i = 1, 10
+ alloca_dtype_arr(N2)%array_i(i) = i + 2
+ end do
+!$omp end target
+
+print *, alloca_dtype_arr(N2)%array_i
+
+end program main
+
+! CHECK: 3
+! CHECK: 5
+! CHECK: 10
+! CHECK: 5 6 7 8 9 10 11 12 13 14
+! CHECK: 5 6 7 8 9 10 11 12 13 14
+! CHECK: 9997
+! CHECK: 9999
+! CHECK: 9996
+! CHECK: 9998
+! CHECK: 2 4 6 8 10 12 14 16 18 20
+! CHECK: 2 4 6 8 10 12 14 16 18 20
+! CHECK: 2 4 6 8 10 12 14 16 18 20
+! CHECK: 2 4 6 8 10 12 14 16 18 20
+! CHECK: 3 6 9 12 15 18 21 24 27 30
+! CHECK: 3 6 9 12 15 18 21 24 27 30
+! CHECK: 3 6 9 12 15 18 21 24 27 30
+! CHECK: 3 6 9 12 15 18 21 24 27 30
+! CHECK: 3 6 9 12 15 18 21 24 27 30
+! CHECK: 3 6 9 12 15 18 21 24 27 30
+! CHECK: 3 4 5 6 7 8 9 10 11 12
diff --git a/offload/test/offloading/fortran/dump_map_tables.f90 b/offload/test/offloading/fortran/dump_map_tables.f90
index e25b05b9e04db5..efde4ee56ca1a0 100644
--- a/offload/test/offloading/fortran/dump_map_tables.f90
+++ b/offload/test/offloading/fortran/dump_map_tables.f90
@@ -1,6 +1,6 @@
-! Offloading test with runtine call to ompx_dump_mapping_tables
-! Fortran array writing some values and printing the variable mapped to device
-! correctly receives the updates made on the device.
+! Offloading test with runtine call to ompx_dump_mapping_tables Fortran array
+! writing some values and printing the variable mapped to device correctly
+! receives the updates made on the device.
! REQUIRES: flang
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
! UNSUPPORTED: aarch64-unknown-linux-gnu
diff --git a/offload/test/offloading/fortran/local-descriptor-map-regress.f90 b/offload/test/offloading/fortran/local-descriptor-map-regress.f90
index 5f628b8ad8c7af..e6afc4a6fb9b1a 100644
--- a/offload/test/offloading/fortran/local-descriptor-map-regress.f90
+++ b/offload/test/offloading/fortran/local-descriptor-map-regress.f90
@@ -1,17 +1,13 @@
-! Small regression test that checks that we do not cause
-! a runtime map error in cases where we are required to
-! allocate a local variable for the fortran descriptor
-! to store into and then load from it, done so by
-! re-using the temporary local variable across all
-! maps related to the mapped variable and associated
-! local variable to make sure that each map does as
-! it's intended to do with the original data. This
-! prevents blobs of local descriptor data remaining
-! attatched on device long after it's supposed to,
-! which can cause weird map issues later in susbequent
-! function invocations. However, it doesn't avoid a user
-! shooting themselves in the foot by mapping data via enter
-! and then not providing a corresponding exit.
+! Small regression test that checks that we do not cause a runtime map error in
+! cases where we are required to allocate a local variable for the fortran
+! descriptor to store into and then load from it, done so by re-using the
+! temporary local variable across all maps related to the mapped variable and
+! associated local variable to make sure that each map does as it is intended
+! to do with the original data. This prevents blobs of local descriptor data
+! remaining attatched on device long after it's supposed to, which can cause
+! weird map issues later in susbequent function invocations. However, it
+! doesn't avoid a user shooting themselves in the foot by mapping data via
+! enter and then not providing a corresponding exit.
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
diff --git a/offload/test/offloading/fortran/target-depend.f90 b/offload/test/offloading/fortran/target-depend.f90
index 1bb320d6bd93c1..dc9351dd8c20af 100644
--- a/offload/test/offloading/fortran/target-depend.f90
+++ b/offload/test/offloading/fortran/target-depend.f90
@@ -1,5 +1,4 @@
-! Offloading test checking the use of the depend clause on
-! the target construct
+! Offloading test checking the use of the depend clause on the target construct
! REQUIRES: flang, amdgcn-amd-amdhsa
! UNSUPPORTED: nvptx64-nvidia-cuda
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
diff --git a/offload/test/offloading/fortran/target-map-all-common-block-members.f90 b/offload/test/offloading/fortran/target-map-all-common-block-members.f90
index f92e5818a76405..4e78ed1accf3ed 100644
--- a/offload/test/offloading/fortran/target-map-all-common-block-members.f90
+++ b/offload/test/offloading/fortran/target-map-all-common-block-members.f90
@@ -1,6 +1,5 @@
-! Offloading test checking interaction of
-! mapping all the members of a common block
-! to a target region
+! Offloading test checking interaction of mapping all the members of a common
+! block to a target region
! REQUIRES: flang, amdgcn-amd-amdhsa
! UNSUPPORTED: nvptx64-nvidia-cuda
! UNSUPPORTED: nvptx64-nvidia-cuda-LTO
diff --git a/offload/test/offloading/fortran/target-map-alloca-dtype-alloca-array-of-dtype.f90 b/offload/test/offloading/fortran/target-map-alloca-dtype-alloca-array-of-dtype.f90
new file mode 100644
index 00000000000000..c430726cfbe93a
--- /dev/null
+++ b/offload/test/offloading/fortran/target-map-alloca-dtype-alloca-array-of-dtype.f90
@@ -0,0 +1,36 @@
+! Offloading test checking interaction of explicit member mapping of an
+! allocatable array of derived types contained within an allocatable
+! derived type
+! REQUIRES: flang, amdgpu
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+program main
+ type :: nested_dtype
+ real(4) :: i
+ real(4) :: j
+ integer(4) :: array_i(10)
+ integer(4) :: k
+ end type nested_dtype
+
+ type :: dtype
+ real(4) :: i
+ integer(4) :: array_i(10)
+ real(4) :: j
+ type(nested_dtype), allocatable :: array_dtype(:)
+ integer(4) :: k
+ end type dtype
+
+ type(dtype), allocatable :: dty...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/113555
More information about the llvm-commits
mailing list