Mercurial > hg > CbC > CbC_gcc
comparison libgomp/testsuite/libgomp.c++/ctor-5.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 // { dg-do run } | |
2 // { dg-require-effective-target tls_runtime } | |
3 | |
4 #include <omp.h> | |
5 #include <assert.h> | |
6 | |
7 struct B | |
8 { | |
9 static int count; | |
10 static B *expected; | |
11 | |
12 B& operator=(const B &); | |
13 }; | |
14 | |
15 int B::count; | |
16 B * B::expected; | |
17 | |
18 static B thr; | |
19 #pragma omp threadprivate(thr) | |
20 | |
21 B& B::operator= (const B &b) | |
22 { | |
23 assert (&b == expected); | |
24 assert (this != expected); | |
25 #pragma omp atomic | |
26 count++; | |
27 return *this; | |
28 } | |
29 | |
30 static int nthreads; | |
31 | |
32 void foo() | |
33 { | |
34 B::expected = &thr; | |
35 | |
36 #pragma omp parallel copyin(thr) | |
37 { | |
38 #pragma omp master | |
39 nthreads = omp_get_num_threads (); | |
40 } | |
41 } | |
42 | |
43 int main() | |
44 { | |
45 omp_set_dynamic (0); | |
46 omp_set_num_threads (4); | |
47 foo(); | |
48 | |
49 assert (B::count == nthreads-1); | |
50 | |
51 return 0; | |
52 } |