[flang-commits] [flang] [openmp] [flang] Changes to map variables in link clause of declare target (PR #83643)

via flang-commits flang-commits at lists.llvm.org
Mon Mar 4 12:56:53 PST 2024


================
@@ -11,23 +11,59 @@
 ! RUN: %libomptarget-compile-fortran-run-and-check-generic
 module test_0
     implicit none
-    INTEGER :: sp(10) = (/0,0,0,0,0,0,0,0,0,0/)
-    !$omp declare target link(sp)
+    INTEGER :: arr1(10) = (/0,0,0,0,0,0,0,0,0,0/)
+    INTEGER :: arr2(10) = (/0,0,0,0,0,0,0,0,0,0/)
+    !$omp declare target link(arr1) enter(arr2)
 end module test_0
 
-program main
+subroutine test_with_array_link_and_tofrom()
     use test_0
     integer :: i = 1
     integer :: j = 11
-!$omp target map(tofrom:sp, i, j)
+!$omp target map(tofrom:arr1, i, j)
     do while (i <= j)
-        sp(i) = i;
+        arr1(i) = i;
         i = i + 1
     end do
 !$omp end target
 
-PRINT *, sp(:)
+! CHECK: 1 2 3 4 5 6 7 8 9 10
+PRINT *, arr1(:)
+end subroutine test_with_array_link_and_tofrom
 
-end program
+subroutine test_with_array_link_only()
+use test_0
+integer :: i = 1
+integer :: j = 11
+!$omp target map(i, j)
----------------
agozillon wrote:

Thank you for the new test! I think it's good, however, it may have been better to add a test with an implicitly captured scalar that had been marked declare target link, the array would have already been marked with the correct To>From marking as it's the default behavior! I think your PR will primarily fix the scalars getting the incorrect mapping when used in conjunction with declare target. But in any case, that's me splitting hairs and I don't mind if you're happy with the test!

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


More information about the flang-commits mailing list