[flang-commits] [flang] [llvm] [Flang][OpenMP] Defer descriptor mapping for assumed dummy argument types (PR #154349)

via flang-commits flang-commits at lists.llvm.org
Fri Aug 22 08:39:59 PDT 2025


================
@@ -0,0 +1,52 @@
+! This test doesn't expect any results, the pass condition is running to completion
+! without any memory access errors on device or mapping issues from descriptor
+! collisions due to local descriptors being placed on device and not being unampped
+! before a subsequent local descriptor residing at the same address is mapped to
+! device.
+! REQUIRES: flang, amdgpu
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+module test
+contains
+  subroutine kernel_1d(array)
+      implicit none
+      real, dimension(:) :: array
+      integer :: i
+
+      print *, 'kernel_1d'
+      !$omp target enter data map(alloc:array)
+      !$omp target teams distribute parallel do
+      do i=1, ubound(array, 1)
+          array(i) = 42.0
+      end do
+  end subroutine
+
+  subroutine kernel_2d(array)
+      implicit none
+      real, dimension(:,:) :: array
+      integer :: i, j
+
+      !$omp target enter data map(alloc:array)
+      !$omp target teams distribute parallel do collapse(2)
+      do j=1, ubound(array, 2)
+          do i=1, ubound(array, 1)
+              array(i,j) = 42.0
+          end do
+      end do
+  end subroutine
+end module
+
+program main
+    use test
+    implicit none
+    integer, parameter :: n = 10
+    real :: array1(n)
+    real :: array2(n,n)
+
+    call kernel_1d(array1)
+    call kernel_2d(array2)
+
+    print *, "PASS"
----------------
agozillon wrote:

Can do, but the point of this test is to see if it even reaches the PASS statement, and if it does it's a success. Prior to this PR this will abort in kernel_2d when it tries to map data and launch the kernel. 

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


More information about the flang-commits mailing list