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

Subversion Repositories openrisc

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

Go to most recent revision | 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 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
}

powered by: WebSVN 2.1.0

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