212 lines · plain
1! RUN: %flang_fc1 -fdebug-dump-symbols -fopenmp -fopenmp-version=50 %s | FileCheck %s2 3module mm4 implicit none5 type two6 integer(4) :: a, b7 end type two8 9 type three10 integer(8) :: a, b, c11 end type three12 13 type twothree14 type(two) t215 type(three) t316 end type twothree17 18contains19!CHECK-LABEL: Subprogram scope: inittwo20 subroutine inittwo(x,n)21 integer :: n22 type(two) :: x23 x%a=n24 x%b=n25 end subroutine inittwo26 27 subroutine initthree(x,n)28 integer :: n29 type(three) :: x30 x%a=n31 x%b=n32 end subroutine initthree33 34 function add_two(x, y)35 type(two) add_two, x, y, res36 res%a = x%a + y%a37 res%b = x%b + y%b38 add_two = res39 end function add_two40 41 function add_three(x, y)42 type(three) add_three, x, y, res43 res%a = x%a + y%a44 res%b = x%b + y%b45 res%c = x%c + y%c46 add_three = res47 end function add_three48 49!CHECK-LABEL: Subprogram scope: functwo50 function functwo(x, n)51 type(two) functwo52 integer :: n53 type(two) :: x(n)54 type(two) :: res55 integer :: i56 !$omp declare reduction(adder:two:omp_out=add_two(omp_out,omp_in)) initializer(inittwo(omp_priv,0))57!CHECK: adder: UserReductionDetails TYPE(two)58!CHECK OtherConstruct scope59!CHECK: omp_in size=8 offset=0: ObjectEntity type: TYPE(two)60!CHECK: omp_out size=8 offset=8: ObjectEntity type: TYPE(two)61!CHECK OtherConstruct scope62!CHECK: omp_orig size=8 offset=0: ObjectEntity type: TYPE(two)63!CHECK: omp_priv size=8 offset=8: ObjectEntity type: TYPE(two)64 65 66 !$omp simd reduction(adder:res)67 do i=1,n68 res=add_two(res,x(i))69 enddo70 functwo=res71 end function functwo72 73 function functhree(x, n)74 implicit none75 type(three) :: functhree76 type(three) :: x(n)77 type(three) :: res78 integer :: i79 integer :: n80 !$omp declare reduction(adder:three:omp_out=add_three(omp_out,omp_in)) initializer(initthree(omp_priv,1))81 82 !$omp simd reduction(adder:res)83 do i=1,n84 res=add_three(res,x(i))85 enddo86 functhree=res87 end function functhree88 89 function functwothree(x, n)90 type(twothree) :: functwothree91 type(twothree) :: x(n)92 type(twothree) :: res93 type(two) :: res294 type(three) :: res395 integer :: n96 integer :: i97 98 !$omp declare reduction(adder:two:omp_out=add_two(omp_out,omp_in)) initializer(inittwo(omp_priv,0))99 100 !$omp declare reduction(adder:three:omp_out=add_three(omp_out,omp_in)) initializer(initthree(omp_priv,1))101 102!CHECK: adder: UserReductionDetails TYPE(two) TYPE(three)103!CHECK OtherConstruct scope104!CHECK: omp_in size=8 offset=0: ObjectEntity type: TYPE(two)105!CHECK: omp_out size=8 offset=8: ObjectEntity type: TYPE(two)106!CHECK OtherConstruct scope107!CHECK: omp_orig size=8 offset=0: ObjectEntity type: TYPE(two)108!CHECK: omp_priv size=8 offset=8: ObjectEntity type: TYPE(two)109!CHECK OtherConstruct scope110!CHECK: omp_in size=24 offset=0: ObjectEntity type: TYPE(three)111!CHECK: omp_out size=24 offset=24: ObjectEntity type: TYPE(three)112!CHECK OtherConstruct scope113!CHECK: omp_orig size=24 offset=0: ObjectEntity type: TYPE(three)114!CHECK: omp_priv size=24 offset=24: ObjectEntity type: TYPE(three)115 116 !$omp simd reduction(adder:res3)117 do i=1,n118 res3=add_three(res%t3,x(i)%t3)119 enddo120 121 !$omp simd reduction(adder:res2)122 do i=1,n123 res2=add_two(res2,x(i)%t2)124 enddo125 res%t2 = res2126 res%t3 = res3127 functwothree=res128 end function functwothree129 130!CHECK-LABEL: Subprogram scope: funcbtwo131 function funcBtwo(x, n)132 type(two) funcBtwo133 integer :: n134 type(two) :: x(n)135 type(two) :: res136 integer :: i137 !$omp declare reduction(+:two:omp_out=add_two(omp_out,omp_in)) initializer(inittwo(omp_priv,0))138!CHECK: op.+: UserReductionDetails TYPE(two)139!CHECK OtherConstruct scope140!CHECK: omp_in size=8 offset=0: ObjectEntity type: TYPE(two)141!CHECK: omp_out size=8 offset=8: ObjectEntity type: TYPE(two)142!CHECK OtherConstruct scope143!CHECK: omp_orig size=8 offset=0: ObjectEntity type: TYPE(two)144!CHECK: omp_priv size=8 offset=8: ObjectEntity type: TYPE(two)145 146 147 !$omp simd reduction(+:res)148 do i=1,n149 res=add_two(res,x(i))150 enddo151 funcBtwo=res152 end function funcBtwo153 154 function funcBtwothree(x, n)155 type(twothree) :: funcBtwothree156 type(twothree) :: x(n)157 type(twothree) :: res158 type(two) :: res2159 type(three) :: res3160 integer :: n161 integer :: i162 163 !$omp declare reduction(+:two:omp_out=add_two(omp_out,omp_in)) initializer(inittwo(omp_priv,0))164 165 !$omp declare reduction(+:three:omp_out=add_three(omp_out,omp_in)) initializer(initthree(omp_priv,1))166 167!CHECK: op.+: UserReductionDetails TYPE(two) TYPE(three)168!CHECK OtherConstruct scope169!CHECK: omp_in size=8 offset=0: ObjectEntity type: TYPE(two)170!CHECK: omp_out size=8 offset=8: ObjectEntity type: TYPE(two)171!CHECK OtherConstruct scope172!CHECK: omp_orig size=8 offset=0: ObjectEntity type: TYPE(two)173!CHECK: omp_priv size=8 offset=8: ObjectEntity type: TYPE(two)174!CHECK: OtherConstruct scope175!CHECK: omp_in size=24 offset=0: ObjectEntity type: TYPE(three)176!CHECK: omp_out size=24 offset=24: ObjectEntity type: TYPE(three)177!CHECK OtherConstruct scope178!CHECK: omp_orig size=24 offset=0: ObjectEntity type: TYPE(three)179!CHECK: omp_priv size=24 offset=24: ObjectEntity type: TYPE(three)180 181 !$omp simd reduction(+:res3)182 do i=1,n183 res3=add_three(res%t3,x(i)%t3)184 enddo185 186 !$omp simd reduction(+:res2)187 do i=1,n188 res2=add_two(res2,x(i)%t2)189 enddo190 res%t2 = res2191 res%t3 = res3192 funcBtwothree = res193 end function funcBtwothree194 195 !! This is checking a special case, where a reduction is declared inside a196 !! pure function197 198 pure logical function reduction()199!CHECK: reduction size=4 offset=0: ObjectEntity funcResult type: LOGICAL(4)200!CHECK: rr: UserReductionDetails INTEGER(4)201!CHECK: OtherConstruct scope: size=8 alignment=4 sourceRange=0 bytes202!CHECK: omp_in size=4 offset=0: ObjectEntity type: INTEGER(4)203!CHECK: omp_out size=4 offset=4: ObjectEntity type: INTEGER(4)204!CHECK: OtherConstruct scope: size=8 alignment=4 sourceRange=0 bytes205!CHECK: omp_orig size=4 offset=0: ObjectEntity type: INTEGER(4)206!CHECK: omp_priv size=4 offset=4: ObjectEntity type: INTEGER(4)207 !$omp declare reduction (rr : integer : omp_out = omp_out + omp_in) initializer (omp_priv = 0)208 reduction = .false.209 end function reduction210 211end module mm212