URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 273 |
Rev 338 |
// { dg-do run }
|
// { dg-do run }
|
|
|
#include
|
#include
|
#include
|
#include
|
|
|
struct B
|
struct B
|
{
|
{
|
static int ccount;
|
static int ccount;
|
static int dcount;
|
static int dcount;
|
static int xcount;
|
static int xcount;
|
static B *expected;
|
static B *expected;
|
|
|
B();
|
B();
|
B(int);
|
B(int);
|
B(const B &);
|
B(const B &);
|
~B();
|
~B();
|
B& operator=(const B &);
|
B& operator=(const B &);
|
void doit();
|
void doit();
|
};
|
};
|
|
|
int B::ccount;
|
int B::ccount;
|
int B::dcount;
|
int B::dcount;
|
int B::xcount;
|
int B::xcount;
|
B * B::expected;
|
B * B::expected;
|
|
|
B::B(int)
|
B::B(int)
|
{
|
{
|
expected = this;
|
expected = this;
|
}
|
}
|
|
|
B::B(const B &b)
|
B::B(const B &b)
|
{
|
{
|
#pragma omp atomic
|
#pragma omp atomic
|
ccount++;
|
ccount++;
|
assert (&b == expected);
|
assert (&b == expected);
|
}
|
}
|
|
|
B::~B()
|
B::~B()
|
{
|
{
|
#pragma omp atomic
|
#pragma omp atomic
|
dcount++;
|
dcount++;
|
}
|
}
|
|
|
void B::doit()
|
void B::doit()
|
{
|
{
|
#pragma omp atomic
|
#pragma omp atomic
|
xcount++;
|
xcount++;
|
assert (this != expected);
|
assert (this != expected);
|
}
|
}
|
|
|
static int nthreads;
|
static int nthreads;
|
|
|
void foo()
|
void foo()
|
{
|
{
|
B b(0);
|
B b(0);
|
|
|
#pragma omp parallel firstprivate(b)
|
#pragma omp parallel firstprivate(b)
|
{
|
{
|
#pragma omp master
|
#pragma omp master
|
nthreads = omp_get_num_threads ();
|
nthreads = omp_get_num_threads ();
|
b.doit();
|
b.doit();
|
}
|
}
|
}
|
}
|
|
|
int main()
|
int main()
|
{
|
{
|
omp_set_dynamic (0);
|
omp_set_dynamic (0);
|
omp_set_num_threads (4);
|
omp_set_num_threads (4);
|
foo();
|
foo();
|
|
|
assert (B::xcount == nthreads);
|
assert (B::xcount == nthreads);
|
assert (B::ccount == nthreads);
|
assert (B::ccount == nthreads);
|
assert (B::dcount == nthreads+1);
|
assert (B::dcount == nthreads+1);
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.