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