2 ! PR 83064 - this used to give wrong results.
3 ! { dg-options "-O3 -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
= 20000000
12 integer(int64
) :: stride
, low(nsplit
), high(nsplit
), edof(ne
), i
13 real(real64
), dimension(nsplit
) :: pi
20 stride
= ceiling(real(ne
)/nsplit
)
25 low(i
) = high(i
-1) + 1
31 do concurrent (i
= 1:nsplit
)
32 pi(i
) = sum(compute( low(i
), high(i
) ))
34 if (abs (sum(pi
) - atan(1.0d0)) > 1e-5) call abort
38 pure
function compute( low
, high
) result( ttt
)
39 integer(int64
), intent(in
) :: low
, high
40 real(real64
), dimension(nsplit
) :: ttt
41 integer(int64
) :: j
, k
48 ! ttt(k) = ttt(k) + (-1)**(j+1) / real( 2*j-1 )
50 ! ttt(k) = ttt(k) + (-1)**(j+2) / real( 2*j+1 )
52 ! ttt(k) = ttt(k) + (-1)**(j+3) / real( 2*j+3 )
54 ! ttt(k) = ttt(k) + (-1)**(j+4) / real( 2*j+5 )
57 ! Loop with modulo operation
59 ! k = mod( j, nsplit ) + 1
60 ! ttt(k) = ttt(k) + (-1)**(j+1) / real( 2*j-1 )
63 ! Loop with subscripting via host association
66 ttt(k
) = ttt(k
) + (-1.0_real64
)**(j
+1) / real( 2*j
-1 )