Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / shared-1.c
blobf7d4fb2d60f838f8bdb5a7534e9df18d087238a4
1 extern void abort (void);
3 struct Y
5 int l[5][10];
6 };
8 struct X
10 struct Y y;
11 float b[10];
14 void
15 parallel (int a, int b)
17 int i, j;
18 struct X A[10][5];
19 a = b = 3;
21 for (i = 0; i < 10; i++)
22 for (j = 0; j < 5; j++)
23 A[i][j].y.l[3][3] = -10;
25 #pragma omp parallel shared (a, b, A) num_threads (5)
27 int i, j;
29 #pragma omp atomic
30 a += omp_get_num_threads ();
32 #pragma omp atomic
33 b += omp_get_num_threads ();
35 #pragma omp for private (j)
36 for (i = 0; i < 10; i++)
37 for (j = 0; j < 5; j++)
38 A[i][j].y.l[3][3] += 20;
42 for (i = 0; i < 10; i++)
43 for (j = 0; j < 5; j++)
44 if (A[i][j].y.l[3][3] != 10)
45 abort ();
47 if (a != 28)
48 abort ();
50 if (b != 28)
51 abort ();
54 main()
56 parallel (1, 2);
57 return 0;