Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

67 lines
2.3 KiB
Fortran

! 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: x86_64-unknown-linux-gnu
! 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, 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 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 i=1, 32766
! dumb loop nest to slow down the update of 'z'.
! Adding a function call slows down the producer to the point
! that removing the depend clause from the target construct below
! frequently results in the wrong answer.
accumulator = accumulator + omp_get_device_num()
end do
z = N
!$omp end task
! z is 5 now. Increment z to 6.
!$omp target map(tofrom: z) depend(in:z)
z = z + 1
!$omp end target
!$omp end single
!$omp end parallel
! Use 'accumulator' so it is not optimized away by the compiler.
print *, accumulator
r = z
end subroutine foo
!CHECK: ======= FORTRAN Test passed! =======
!CHECK: foo(5) returned 6 , expected 6
end program main