Debian Codegraph @

libgomp/testsuite/libgomp.fortran/imperfect3.f90

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