Debian Codegraph @

libgomp/testsuite/libgomp.fortran/imperfect-transform-2.f90

raw
1 ! { dg-do run }
2
3 ! Like imperfect1.f90, but also includes loop transforms.
4
5 program foo
6 integer, save :: f1count(3), f2count(3)
7
8 f1count(1) = 0
9 f1count(2) = 0
10 f1count(3) = 0
11 f2count(1) = 0
12 f2count(2) = 0
13 f2count(3) = 0
14
15 call s1 (3, 4, 5)
16
17 ! All intervening code at the same depth must be executed the same
18 ! number of times.
19 if (f1count(1) /= f2count(1)) error stop 101
20 if (f1count(2) /= f2count(2)) error stop 102
21 if (f1count(3) /= f2count(3)) error stop 103
22
23 ! Intervening code must be executed at least as many times as the loop
24 ! that encloses it.
25 if (f1count(1) < 3) error stop 111
26 if (f1count(2) < 3 * 4) error stop 112
27
28 ! Intervening code must not be executed more times than the number
29 ! of logical iterations.
30 if (f1count(1) > 3 * 4 * 5) error stop 121
31 if (f1count(2) > 3 * 4 * 5) error stop 122
32
33 ! Check that the innermost loop body is executed exactly the number
34 ! of logical iterations expected.
35 if (f1count(3) /= 3 * 4 * 5) error stop 131
36
37 contains
38
39 subroutine f1 (depth, iter)
40 integer :: depth, iter
41 f1count(depth) = f1count(depth) + 1
42 end subroutine
43
44 subroutine f2 (depth, iter)
45 integer :: depth, iter
46 f2count(depth) = f2count(depth) + 1
47 end subroutine
48
49 subroutine s1 (a1, a2, a3)
50 integer :: a1, a2, a3
51 integer :: i, j, k
52
53 !$omp do collapse(2) private (j, k)
54 do i = 1, a1
55 call f1 (1, i)
56 do j = 1, a2
57 call f1 (2, j)
58 !$omp tile sizes(5)
59 do k = 1, a3
60 call f1 (3, k)
61 call f2 (3, k)
62 end do
63 call f2 (2, j)
64 end do
65 call f2 (1, i)
66 end do
67
68 end subroutine
69
70 end program