Debian Codegraph @

libgomp/testsuite/libgomp.c-c++-common/imperfect-transform-2.c

raw
1 /* { dg-do run } */
2
3 /* Like imperfect1.c, but also includes loop transforms. */
4
5 static int f1count[3], f2count[3];
6
7 int
8 f1 (int depth, int iter)
9 {
10 f1count[depth]++;
11 return iter;
12 }
13
14 int
15 f2 (int depth, int iter)
16 {
17 f2count[depth]++;
18 return iter;
19 }
20
21 void
22 s1 (int a1, int a2, int a3)
23 {
24 int i, j, k;
25
26 #pragma omp for collapse(2) private (j, k)
27 for (i = 0; i < a1; i++)
28 {
29 f1 (0, i);
30 for (j = 0; j < a2; j++)
31 {
32 f1 (1, j);
33 #pragma omp tile sizes(5)
34 for (k = 0; k < a3; k++)
35 {
36 f1 (2, k);
37 f2 (2, k);
38 }
39 f2 (1, j);
40 }
41 f2 (0, i);
42 }
43 }
44
45 int
46 main ()
47 {
48 f1count[0] = 0;
49 f1count[1] = 0;
50 f1count[2] = 0;
51 f2count[0] = 0;
52 f2count[1] = 0;
53 f2count[2] = 0;
54
55 s1 (3, 4, 5);
56
57 /* All intervening code at the same depth must be executed the same
58 number of times. */
59 if (f1count[0] != f2count[0]) __builtin_abort ();
60 if (f1count[1] != f2count[1]) __builtin_abort ();
61 if (f1count[2] != f2count[2]) __builtin_abort ();
62
63 /* Intervening code must be executed at least as many times as the loop
64 that encloses it. */
65 if (f1count[0] < 3) __builtin_abort ();
66 if (f1count[1] < 3 * 4) __builtin_abort ();
67
68 /* Intervening code must not be executed more times than the number
69 of logical iterations. */
70 if (f1count[0] > 3 * 4 * 5) __builtin_abort ();
71 if (f1count[1] > 3 * 4 * 5) __builtin_abort ();
72
73 /* Check that the innermost loop body is executed exactly the number
74 of logical iterations expected. */
75 if (f1count[2] != 3 * 4 * 5) __builtin_abort ();
76 }