================
@@ -0,0 +1,83 @@
+! 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
+! 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
+  implicit none
+  integer :: a = 0
+  INTERFACE
+     FUNCTION omp_get_device_num() BIND(C)
+       USE, INTRINSIC :: iso_c_binding, ONLY: C_INT
+       integer :: omp_get_device_num
+     END FUNCTION omp_get_device_num
+  END INTERFACE
+
+  call foo(5, a)
+  print*, "======= FORTRAN Test passed! ======="
+  print*, "foo(5) returned ", a, ", expected 6\n"
+
+  !       stop 0
+  contains
+    subroutine foo(N, r)
+      integer, intent(in) :: N
+      integer, intent(out) :: r
+      integer :: z, i, j, k, accumulator
+      z = 1
+      accumulator = 0
+      ! Spawn 3 threads
+      !$omp parallel num_threads(3)
+
+      ! A single thread will then create two tasks
+      ! One is the 'producer' and potentially slower
+      ! task that updates 'z' to 'N'. The second is an
+      ! offloaded target task that increments 'z'.
+      ! If the depend clauses work properly, the
+      ! target task should wait for the 'producer'
+      ! task to complete before incrementing z
+      ! We use !$omp single here because only
+      ! the depend clause establishes dependencies
+      ! between sibling tasks only. This is the easiest
+      ! way of creating two sibling tasks.
+      !$omp single
+      !$omp task depend(out: z) shared(z)
+      do while (k < 32000)
----------------
skatrak wrote:

Couldn't this loop be written more concisely as `do k=1, 32000 ... end do`? 
Same for the other two loops nested in it.

https://github.com/llvm/llvm-project/pull/93977
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to