aboutsummaryrefslogtreecommitdiff
path: root/flang/test/Semantics/OpenMP/declare-reduction-mangled.f90
blob: c10976fd2c6ba59132b231aa03227a17309de8ab (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
46
47
48
49
50
51
! RUN: %flang_fc1 -fdebug-dump-symbols -fopenmp -fopenmp-version=50 %s | FileCheck %s

!! Test that the name mangling for min & max (also used for iand, ieor and ior).
module mymod
  type :: tt
     real r
  end type tt
contains
  function mymax(a, b)
    type(tt) :: a, b, mymax
    if (a%r > b%r) then
       mymax = a
    else
       mymax = b
    end if
  end function mymax
end module mymod

program omp_examples
!CHECK-LABEL: MainProgram scope: OMP_EXAMPLES
  use mymod
  implicit none
  integer, parameter :: n = 100
  integer :: i
  type(tt) :: values(n), big, small

  !$omp declare reduction(max:tt:omp_out = mymax(omp_out, omp_in)) initializer(omp_priv%r = 0)
  !$omp declare reduction(min:tt:omp_out%r = min(omp_out%r, omp_in%r)) initializer(omp_priv%r = 1)

!CHECK: min, ELEMENTAL, INTRINSIC, PURE (Function): ProcEntity
!CHECK: mymax (Function): Use from mymax in mymod
!CHECK: op.max: UserReductionDetails TYPE(tt)
!CHECK: op.min: UserReductionDetails TYPE(tt)

  big%r = 0
  !$omp parallel do reduction(max:big)
!CHECK: big (OmpReduction, OmpExplicit): HostAssoc
!CHECK: max, INTRINSIC: ProcEntity
  do i = 1, n
     big = mymax(values(i), big)
  end do

  small%r = 1
  !$omp parallel do reduction(min:small)
!CHECK: small (OmpReduction, OmpExplicit): HostAssoc
  do i = 1, n
     small%r = min(values(i)%r, small%r)
  end do

  print *, "small=", small%r, " big=", big%r
end program omp_examples