[llvm-branch-commits] [flang] [llvm] [mlir] [Flang][OpenMP][MLIR] Initial declare target to for variables implementation (PR #119589)
Sergio Afonso via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Aug 11 07:37:16 PDT 2025
================
@@ -0,0 +1,52 @@
+! Test that checks an allocatable array can be marked declare target to and
+! functions without issue.
+! REQUIRES: flang, amdgpu
+
+! RUN: %libomptarget-compile-fortran-run-and-check-generic
+module test
+ implicit none
+ integer, allocatable, dimension(:) :: alloca_arr
+ !$omp declare target(alloca_arr)
+ end module test
+
+ program main
+ use test
+ implicit none
+ integer :: cycle, i
+
+ allocate(alloca_arr(10))
+
+ do i = 1, 10
+ alloca_arr(i) = 0
+ end do
+
+!$omp target data map(to:alloca_arr)
+
+ do cycle = 1, 2
+
+ !$omp target
+ do i = 1, 10
+ alloca_arr(i) = alloca_arr(i) + i
+ end do
+ !$omp end target
+
+! NOTE: Technically doesn't affect the results, but there is a
+! regression case that'll cause a runtime crash if this is
+! invoked more than once, so this checks for that.
+!$omp target update from(alloca_arr)
+ end do
+
+!$omp end target data
+
+ print *, alloca_arr
+
+ do i = 1, 10
+ if (alloca_arr(i) /= i + i) then
+ print *, "======= FORTRAN Test Failed! ======="
+ end if
+ end do
+
+ print *, "======= FORTRAN Test Passed! ======="
----------------
skatrak wrote:
Nit: Do we need this? It seems the print above + the CHECK comment should be enough.
https://github.com/llvm/llvm-project/pull/119589
More information about the llvm-branch-commits
mailing list