2 ! PR 83064 - this used to give wrong results.
3 ! { dg-additional-options "-O1 -ftree-parallelize-loops=2" }
4 ! Original test case by Christian Felter
7 use, intrinsic :: iso_fortran_env
10 integer, parameter :: nsplit
= 4
11 integer(int64
), parameter :: ne
= 2**20
12 integer(int64
) :: stride
, low(nsplit
), high(nsplit
), i
13 real(real64
), dimension(nsplit
) :: pi
14 integer(int64
), dimension(:), allocatable
:: edof
22 stride
= ceiling(real(ne
)/nsplit
)
27 low(i
) = high(i
-1) + 1
33 do concurrent (i
= 1:nsplit
)
34 pi(i
) = sum(compute( low(i
), high(i
) ))
36 if (abs (sum(pi
) - atan(1.0d0)) > 1e-5) STOP 1
40 pure
function compute( low
, high
) result( ttt
)
41 integer(int64
), intent(in
) :: low
, high
42 real(real64
), dimension(nsplit
) :: ttt
43 integer(int64
) :: j
, k
50 ! ttt(k) = ttt(k) + (-1)**(j+1) / real( 2*j-1 )
52 ! ttt(k) = ttt(k) + (-1)**(j+2) / real( 2*j+1 )
54 ! ttt(k) = ttt(k) + (-1)**(j+3) / real( 2*j+3 )
56 ! ttt(k) = ttt(k) + (-1)**(j+4) / real( 2*j+5 )
59 ! Loop with modulo operation
61 ! k = mod( j, nsplit ) + 1
62 ! ttt(k) = ttt(k) + (-1)**(j+1) / real( 2*j-1 )
65 ! Loop with subscripting via host association
68 ttt(k
) = ttt(k
) + (-1.0_real64
)**(j
+1) / real( 2*j
-1 )