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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c++/] [ctor-1.C] - Blame information for rev 859

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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