Mercurial > hg > CbC > CbC_gcc
comparison libgomp/testsuite/libgomp.c/single-1.c @ 0:a06113de4d67
first commit
author | kent <kent@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Jul 2009 14:47:48 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a06113de4d67 |
---|---|
1 /* Trivial test of single. */ | |
2 | |
3 /* { dg-require-effective-target sync_int_long } */ | |
4 | |
5 #include <omp.h> | |
6 #include <sys/time.h> | |
7 #include <unistd.h> | |
8 #include <assert.h> | |
9 #include "libgomp_g.h" | |
10 | |
11 | |
12 static int test; | |
13 | |
14 static void f_nocopy (void *dummy) | |
15 { | |
16 if (GOMP_single_start ()) | |
17 { | |
18 int iam = omp_get_thread_num (); | |
19 int old = __sync_lock_test_and_set (&test, iam); | |
20 assert (old == -1); | |
21 } | |
22 } | |
23 | |
24 static void f_copy (void *dummy) | |
25 { | |
26 int *x = GOMP_single_copy_start (); | |
27 if (x == NULL) | |
28 { | |
29 int iam = omp_get_thread_num (); | |
30 int old = __sync_lock_test_and_set (&test, iam); | |
31 assert (old == -1); | |
32 GOMP_single_copy_end (&test); | |
33 } | |
34 else | |
35 assert (x == &test); | |
36 } | |
37 | |
38 int main() | |
39 { | |
40 omp_set_dynamic (0); | |
41 | |
42 test = -1; | |
43 GOMP_parallel_start (f_nocopy, NULL, 3); | |
44 f_nocopy (NULL); | |
45 GOMP_parallel_end (); | |
46 | |
47 test = -1; | |
48 GOMP_parallel_start (f_copy, NULL, 3); | |
49 f_copy (NULL); | |
50 GOMP_parallel_end (); | |
51 | |
52 return 0; | |
53 } |