summaryrefslogtreecommitdiff
path: root/offload/test/offloading/fortran/optional-mapped-arguments-3.f90
blob: cf82a854b547467650a203a7dd259a5dc1063a5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
! OpenMP offloading test that checks we do not cause a segfault when mapping
! optional function arguments (present or otherwise). No results requiring
! checking other than that the program compiles and runs to completion with no
! error. This particular variation checks that we're correctly emitting the
! load/store in both branches mapping the input array.
! REQUIRES: flang, amdgpu

! RUN: %libomptarget-compile-fortran-run-and-check-generic
module reproducer_mod
contains
   subroutine branching_target_call(dt, switch)
      implicit none
      real(4), dimension(:), intent(inout) :: dt
      logical, intent(in) :: switch
      integer :: dim, idx

      dim = size(dt)
      if (switch) then
!$omp target teams distribute parallel do
         do idx = 1, dim
            dt(idx) = 20
         end do
      else
!$omp target teams distribute parallel do
         do idx = 1, dim
            dt(idx) = 30
         end do
      end if
   end subroutine branching_target_call
end module reproducer_mod

program reproducer
   use reproducer_mod
   implicit none
   real(4), dimension(:), allocatable :: dt
   integer :: n = 21312
   integer :: i

   allocate (dt(n))
   call branching_target_call(dt, .FALSE.)
   call branching_target_call(dt, .TRUE.)
   print *, "PASSED"
end program reproducer

! CHECK: PASSED