Dead
[official-gcc.git] / gomp-20050608-branch / libgomp / testsuite / libgomp.c / parallel-1.c
blob031f5bf881201c6326c1bac6efd6a48c2b3d3ab3
1 /* Trivial test of thread startup. */
3 #include <omp.h>
4 #include <string.h>
5 #include <assert.h>
6 #include "libgomp_g.h"
9 static int nthr;
10 static int saw[4];
12 static void function(void *dummy)
14 int iam = omp_get_thread_num ();
16 if (iam == 0)
17 nthr = omp_get_num_threads ();
19 saw[iam] = 1;
22 int main()
24 omp_set_dynamic (0);
26 GOMP_parallel_start (function, NULL, 2);
27 function (NULL);
28 GOMP_parallel_end ();
30 assert (nthr == 2);
31 assert (saw[0] != 0);
32 assert (saw[1] != 0);
33 assert (saw[2] == 0);
35 memset (saw, 0, sizeof (saw));
37 GOMP_parallel_start (function, NULL, 3);
38 function (NULL);
39 GOMP_parallel_end ();
41 assert (nthr == 3);
42 assert (saw[0] != 0);
43 assert (saw[1] != 0);
44 assert (saw[2] != 0);
45 assert (saw[3] == 0);
47 return 0;