gcc/libgomp/testsuite/libgomp.c/pr26943-3.c
Marek Polacek 44a0c6cbeb affinity-1.c: Fix implicit declarations.
* testsuite/libgomp.c/affinity-1.c: Fix implicit declarations.
	* testsuite/libgomp.c/nqueens-1.c: Likewise.
	* testsuite/libgomp.c/pr26943-3.c: Likewise.
	* testsuite/libgomp.c/pr26943-4.c: Likewise.
	* testsuite/libgomp.c/pr36802-2.c: Likewise.
	* testsuite/libgomp.c/pr36802-3.c: Likewise.
	* testsuite/libgomp.c/thread-limit-1.c: Likewise.
	* testsuite/libgomp.c/thread-limit-2.c: Likewise.
	* testsuite/libgomp.c/appendix-a/a.15.1.c: Include <omp.h>.
	* testsuite/libgomp.c/omp-loop02.c: Fix defaulting to int.
	* testsuite/libgomp.c/omp-parallel-for.c: Likewise.
	* testsuite/libgomp.c/omp-parallel-if.c: Likewise.
	* testsuite/libgomp.c/omp-single-1.c: Likewise.
	* testsuite/libgomp.c/omp-single-2.c: Likewise.
	* testsuite/libgomp.c/omp_matvec.c: Likewise.
	* testsuite/libgomp.c/omp_workshare3.c: Likewise.
	* testsuite/libgomp.c/omp_workshare4.c: Likewise.
	* testsuite/libgomp.c/shared-1.c: Fix defaulting to int.  Fix implicit
	declarations.

From-SVN: r215922
2014-10-06 10:20:45 +00:00

59 lines
1.3 KiB
C

/* PR c++/26943 */
/* { dg-do run } */
extern int omp_set_dynamic (int);
extern void omp_set_nested (int);
extern int omp_get_thread_num (void);
extern void abort (void);
extern void GOMP_barrier (void);
int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
volatile int k;
int
main (void)
{
int i;
omp_set_dynamic (0);
omp_set_nested (1);
#pragma omp parallel num_threads (2) reduction (+:l)
if (k == omp_get_thread_num ())
{
#pragma omp parallel for shared (a, e) firstprivate (b, f) \
lastprivate (c, g) private (d, h) \
schedule (static, 1) num_threads (4) \
reduction (+:j)
for (i = 0; i < 4; i++)
{
if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
j++;
GOMP_barrier ();
#pragma omp atomic
a += i;
b += i;
c = i;
d = i;
#pragma omp atomic
e[0] += i;
f[0] += i;
g[0] = 'g' + i;
h[0] = 'h' + i;
GOMP_barrier ();
if (a != 8 + 6 || b != 12 + i || c != i || d != i)
j += 8;
if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
j += 64;
if (h[0] != 'h' + i)
j += 512;
}
if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20)
++l;
if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd')
l += 8;
}
if (l)
abort ();
return 0;
}