| 1 |
/* Trivial test of thread startup. */ |
| 2 |
|
| 3 |
#include <omp.h> |
| 4 |
#include <string.h> |
| 5 |
#include <assert.h> |
| 6 |
#include "libgomp_g.h" |
| 7 |
|
| 8 |
|
| 9 |
static int nthr; |
| 10 |
static int saw[4]; |
| 11 |
|
| 12 |
static void function(void *dummy) |
| 13 |
{ |
| 14 |
int iam = omp_get_thread_num (); |
| 15 |
|
| 16 |
if (iam == 0) |
| 17 |
nthr = omp_get_num_threads (); |
| 18 |
|
| 19 |
saw[iam] = 1; |
| 20 |
} |
| 21 |
|
| 22 |
int main() |
| 23 |
{ |
| 24 |
omp_set_dynamic (0); |
| 25 |
|
| 26 |
GOMP_parallel_start (function, NULL, 2); |
| 27 |
function (NULL); |
| 28 |
GOMP_parallel_end (); |
| 29 |
|
| 30 |
assert (nthr == 2); |
| 31 |
assert (saw[0] != 0); |
| 32 |
assert (saw[1] != 0); |
| 33 |
assert (saw[2] == 0); |
| 34 |
|
| 35 |
memset (saw, 0, sizeof (saw)); |
| 36 |
|
| 37 |
GOMP_parallel_start (function, NULL, 3); |
| 38 |
function (NULL); |
| 39 |
GOMP_parallel_end (); |
| 40 |
|
| 41 |
assert (nthr == 3); |
| 42 |
assert (saw[0] != 0); |
| 43 |
assert (saw[1] != 0); |
| 44 |
assert (saw[2] != 0); |
| 45 |
assert (saw[3] == 0); |
| 46 |
|
| 47 |
return 0; |
| 48 |
} |