xfail scan-tree-dump-not throw in g++.dg/pr99966.C on hppa*64*-*-*
[official-gcc.git] / libgomp / testsuite / libgomp.c-c++-common / target-imperfect3.c
blobddcfcf4b7ebc3d7a4da97e474f604f38caf7f89d
1 /* { dg-do run } */
3 /* Like imperfect3.c, but enables offloading. */
5 static int f1count[3], f2count[3];
6 static int g1count[3], g2count[3];
7 #pragma omp declare target enter (f1count, f2count)
8 #pragma omp declare target enter (g1count, g2count)
10 #ifndef __cplusplus
11 extern void abort (void);
12 #else
13 extern "C" void abort (void);
14 #endif
16 int f1 (int depth, int iter)
18 #pragma omp atomic
19 f1count[depth]++;
20 return iter;
23 int f2 (int depth, int iter)
25 #pragma omp atomic
26 f2count[depth]++;
27 return iter;
30 int g1 (int depth, int iter)
32 #pragma omp atomic
33 g1count[depth]++;
34 return iter;
37 int g2 (int depth, int iter)
39 #pragma omp atomic
40 g2count[depth]++;
41 return iter;
44 void s1 (int a1, int a2, int a3)
46 int i, j, k;
48 #pragma omp target parallel for collapse(3) map(always, tofrom:f1count, f2count, g1count, g2count)
49 for (i = 0; i < a1; i++)
51 int local0 = 0;
52 f1 (local0, i);
54 g1 (local0, i);
55 for (j = 0; j < a2; j++)
57 int local1 = 1;
58 f1 (local1, j);
60 g1 (local1, j);
61 for (k = 0; k < a3; k++)
63 int local2 = 2;
64 f1 (local2, k);
66 g1 (local2, k);
67 g2 (local2, k);
69 f2 (local2, k);
71 g2 (local1, j);
73 f2 (local1, j);
75 g2 (local0, i);
77 f2 (local0, i);
81 int
82 main (void)
84 f1count[0] = 0;
85 f1count[1] = 0;
86 f1count[2] = 0;
87 f2count[0] = 0;
88 f2count[1] = 0;
89 f2count[2] = 0;
91 g1count[0] = 0;
92 g1count[1] = 0;
93 g1count[2] = 0;
94 g2count[0] = 0;
95 g2count[1] = 0;
96 g2count[2] = 0;
98 s1 (3, 4, 5);
100 /* All intervening code at the same depth must be executed the same
101 number of times. */
102 if (f1count[0] != f2count[0]) abort ();
103 if (f1count[1] != f2count[1]) abort ();
104 if (f1count[2] != f2count[2]) abort ();
105 if (g1count[0] != f1count[0]) abort ();
106 if (g2count[0] != f1count[0]) abort ();
107 if (g1count[1] != f1count[1]) abort ();
108 if (g2count[1] != f1count[1]) abort ();
109 if (g1count[2] != f1count[2]) abort ();
110 if (g2count[2] != f1count[2]) abort ();
112 /* Intervening code must be executed at least as many times as the loop
113 that encloses it. */
114 if (f1count[0] < 3) abort ();
115 if (f1count[1] < 3 * 4) abort ();
117 /* Intervening code must not be executed more times than the number
118 of logical iterations. */
119 if (f1count[0] > 3 * 4 * 5) abort ();
120 if (f1count[1] > 3 * 4 * 5) abort ();
122 /* Check that the innermost loop body is executed exactly the number
123 of logical iterations expected. */
124 if (f1count[2] != 3 * 4 * 5) abort ();