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-11.C] - Blame information for rev 861

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

Line No. Rev Author Line
1 273 jeremybenn
// PR c++/36308
2
// { dg-do run }
3
 
4
#include 
5
#include 
6
 
7
#define N 10
8
 
9
struct B
10
{
11
  static int icount;
12
  static int ccount;
13
  static int dcount;
14
  static int xcount;
15
 
16
  B ();
17
  B (const B &);
18
  virtual ~B ();
19
  B& operator= (const B &);
20
  void doit ();
21
  static void clear () { icount = ccount = dcount = xcount = 0; }
22
};
23
 
24
int B::icount;
25
int B::ccount;
26
int B::dcount;
27
int B::xcount;
28
 
29
B::B ()
30
{
31
  #pragma omp atomic
32
    icount++;
33
}
34
 
35
B::B (const B &)
36
{
37
  #pragma omp atomic
38
    ccount++;
39
}
40
 
41
B::~B ()
42
{
43
  #pragma omp atomic
44
    dcount++;
45
}
46
 
47
void
48
B::doit ()
49
{
50
  #pragma omp atomic
51
    xcount++;
52
}
53
 
54
static int nthreads;
55
 
56
void
57
test1 ()
58
{
59
  B b[N];
60
  #pragma omp parallel private (b)
61
    {
62
      #pragma omp master
63
        nthreads = omp_get_num_threads ();
64
      b[0].doit ();
65
    }
66
}
67
 
68
void
69
test2 ()
70
{
71
  B b;
72
  #pragma omp parallel firstprivate (b)
73
    {
74
      #pragma omp single
75
        nthreads = omp_get_num_threads ();
76
      b.doit ();
77
    }
78
}
79
 
80
int
81
main ()
82
{
83
  omp_set_dynamic (0);
84
  omp_set_num_threads (4);
85
 
86
  B::clear ();
87
  test1 ();
88
  assert (B::xcount == nthreads);
89
  assert (B::ccount == 0);
90
  assert (B::icount == (nthreads + 1) * N);
91
  assert (B::dcount == (nthreads + 1) * N);
92
 
93
  B::clear ();
94
  test2 ();
95
  assert (B::xcount == nthreads);
96
  assert (B::ccount == nthreads);
97
  assert (B::icount == 1);
98
  assert (B::dcount == nthreads + 1);
99
  return 0;
100
}

powered by: WebSVN 2.1.0

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