OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.c++/] [ctor-2.C] - Blame information for rev 735

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 735 jeremybenn
// { dg-do run }
2
 
3
#include 
4
#include 
5
 
6
struct B
7
{
8
  static int ccount;
9
  static int dcount;
10
  static int xcount;
11
  static B *expected;
12
 
13
  B();
14
  B(int);
15
  B(const B &);
16
  ~B();
17
  B& operator=(const B &);
18
  void doit();
19
};
20
 
21
int B::ccount;
22
int B::dcount;
23
int B::xcount;
24
B * B::expected;
25
 
26
B::B(int)
27
{
28
  expected = this;
29
}
30
 
31
B::B(const B &b)
32
{
33
  #pragma omp atomic
34
    ccount++;
35
  assert (&b == expected);
36
}
37
 
38
B::~B()
39
{
40
  #pragma omp atomic
41
    dcount++;
42
}
43
 
44
void B::doit()
45
{
46
  #pragma omp atomic
47
    xcount++;
48
  assert (this != expected);
49
}
50
 
51
static int nthreads;
52
 
53
void foo()
54
{
55
  B b(0);
56
 
57
  #pragma omp parallel firstprivate(b)
58
    {
59
      #pragma omp master
60
        nthreads = omp_get_num_threads ();
61
      b.doit();
62
    }
63
}
64
 
65
int main()
66
{
67
  omp_set_dynamic (0);
68
  omp_set_num_threads (4);
69
  foo();
70
 
71
  assert (B::xcount == nthreads);
72
  assert (B::ccount == nthreads);
73
  assert (B::dcount == nthreads+1);
74
 
75
  return 0;
76
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.