URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 38 |
Rev 154 |
// { dg-do run }
|
// { dg-do run }
|
// { dg-require-effective-target tls_runtime }
|
// { dg-require-effective-target tls_runtime }
|
|
|
#include
|
#include
|
#include
|
#include
|
|
|
#define N 10
|
#define N 10
|
#define THR 4
|
#define THR 4
|
|
|
struct B
|
struct B
|
{
|
{
|
B();
|
B();
|
B(const B &);
|
B(const B &);
|
~B();
|
~B();
|
B& operator=(const B &);
|
B& operator=(const B &);
|
void doit();
|
void doit();
|
};
|
};
|
|
|
static B *base;
|
static B *base;
|
static B *threadbase;
|
static B *threadbase;
|
static unsigned cmask[THR];
|
static unsigned cmask[THR];
|
static unsigned dmask[THR];
|
static unsigned dmask[THR];
|
|
|
#pragma omp threadprivate(threadbase)
|
#pragma omp threadprivate(threadbase)
|
|
|
B::B()
|
B::B()
|
{
|
{
|
assert (base == 0);
|
assert (base == 0);
|
}
|
}
|
|
|
B::B(const B &b)
|
B::B(const B &b)
|
{
|
{
|
unsigned index = &b - base;
|
unsigned index = &b - base;
|
assert (index < N);
|
assert (index < N);
|
cmask[omp_get_thread_num()] |= 1u << index;
|
cmask[omp_get_thread_num()] |= 1u << index;
|
}
|
}
|
|
|
B::~B()
|
B::~B()
|
{
|
{
|
if (threadbase)
|
if (threadbase)
|
{
|
{
|
unsigned index = this - threadbase;
|
unsigned index = this - threadbase;
|
assert (index < N);
|
assert (index < N);
|
dmask[omp_get_thread_num()] |= 1u << index;
|
dmask[omp_get_thread_num()] |= 1u << index;
|
}
|
}
|
}
|
}
|
|
|
void foo()
|
void foo()
|
{
|
{
|
B b[N];
|
B b[N];
|
|
|
base = b;
|
base = b;
|
|
|
#pragma omp parallel firstprivate(b)
|
#pragma omp parallel firstprivate(b)
|
{
|
{
|
assert (omp_get_num_threads () == THR);
|
assert (omp_get_num_threads () == THR);
|
threadbase = b;
|
threadbase = b;
|
}
|
}
|
|
|
threadbase = 0;
|
threadbase = 0;
|
}
|
}
|
|
|
int main()
|
int main()
|
{
|
{
|
omp_set_dynamic (0);
|
omp_set_dynamic (0);
|
omp_set_num_threads (THR);
|
omp_set_num_threads (THR);
|
foo();
|
foo();
|
|
|
for (int i = 0; i < THR; ++i)
|
for (int i = 0; i < THR; ++i)
|
{
|
{
|
unsigned xmask = (1u << N) - 1;
|
unsigned xmask = (1u << N) - 1;
|
assert (cmask[i] == xmask);
|
assert (cmask[i] == xmask);
|
assert (dmask[i] == xmask);
|
assert (dmask[i] == xmask);
|
}
|
}
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.