Debian Codegraph @

libgomp/testsuite/libgomp.fortran/imperfect4.f90

raw
1 ! { dg-do run }
2
3 ! Like imperfect2.f90, but includes blocks that are themselves wholly
4 ! intervening code and not containers for nested loops.
5
6 program foo
7 integer, save :: f1count(3), f2count(3), g1count(3), g2count(3)
8
9 f1count(1) = 0
10 f1count(2) = 0
11 f1count(3) = 0
12 f2count(1) = 0
13 f2count(2) = 0
14 f2count(3) = 0
15
16 g1count(1) = 0
17 g1count(2) = 0
18 g1count(3) = 0
19 g2count(1) = 0
20 g2count(2) = 0
21 g2count(3) = 0
22
23 call s1 (3, 4, 5)
24
25 ! All intervening code at the same depth must be executed the same
26 ! number of times.
27 if (f1count(1) /= f2count(1)) error stop 101
28 if (f1count(2) /= f2count(2)) error stop 102
29 if (f1count(3) /= f2count(3)) error stop 103
30 if (g1count(1) /= f1count(1)) error stop 104
31 if (g2count(1) /= f1count(1)) error stop 105
32 if (g1count(2) /= f1count(2)) error stop 106
33 if (g2count(2) /= f1count(2)) error stop 107
34 if (g1count(3) /= f1count(3)) error stop 108
35 if (g2count(3) /= f1count(3)) error stop 109
36
37 ! Intervening code must be executed at least as many times as the loop
38 ! that encloses it.
39 if (f1count(1) < 3) error stop 111
40 if (f1count(2) < 3 * 4) error stop 112
41
42 ! Intervening code must not be executed more times than the number
43 ! of logical iterations.
44 if (f1count(1) > 3 * 4 * 5) error stop 121
45 if (f1count(2) > 3 * 4 * 5) error stop 122
46
47 ! Check that the innermost loop body is executed exactly the number
48 ! of logical iterations expected.
49 if (f1count(3) /= 3 * 4 * 5) error stop 131
50
51 contains
52
53 subroutine f1 (depth, iter)
54 integer :: depth, iter
55 f1count(depth) = f1count(depth) + 1
56 end subroutine
57
58 subroutine f2 (depth, iter)
59 integer :: depth, iter
60 f2count(depth) = f2count(depth) + 1
61 end subroutine
62
63 subroutine g1 (depth, iter)
64 integer :: depth, iter
65 g1count(depth) = g1count(depth) + 1
66 end subroutine
67
68 subroutine g2 (depth, iter)
69 integer :: depth, iter
70 g2count(depth) = g2count(depth) + 1
71 end subroutine
72
73 subroutine s1 (a1, a2, a3)
74 integer :: a1, a2, a3
75 integer :: i, j, k
76
77 !$omp do collapse(3)
78 do i = 1, a1
79 block
80 call f1 (1, i)
81 end block
82 block
83 block
84 call g1 (1, i)
85 end block
86 do j = 1, a2
87 block
88 call f1 (2, j)
89 end block
90 block
91 block
92 call g1 (2, j)
93 end block
94 do k = 1, a3
95 call f1 (3, k)
96 block
97 call g1 (3, k)
98 call g2 (3, k)
99 end block
100 call f2 (3, k)
101 end do
102 block
103 call g2 (2, j)
104 end block
105 end block
106 block
107 call f2 (2, j)
108 end block
109 end do
110 block
111 call g2 (1, i)
112 end block
113 end block
114 block
115 call f2 (1, i)
116 end block
117 end do
118
119 end subroutine
120
121 end program