URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 273 |
Rev 338 |
// PR middle-end/27337
|
// PR middle-end/27337
|
// { dg-do run }
|
// { dg-do run }
|
|
|
#include
|
#include
|
|
|
extern "C" void abort (void);
|
extern "C" void abort (void);
|
|
|
struct S
|
struct S
|
{
|
{
|
S ();
|
S ();
|
~S ();
|
~S ();
|
S (const S &);
|
S (const S &);
|
int i;
|
int i;
|
};
|
};
|
|
|
int n[3];
|
int n[3];
|
|
|
S::S () : i(18)
|
S::S () : i(18)
|
{
|
{
|
if (omp_get_thread_num () != 0)
|
if (omp_get_thread_num () != 0)
|
#pragma omp atomic
|
#pragma omp atomic
|
n[0]++;
|
n[0]++;
|
}
|
}
|
|
|
S::~S ()
|
S::~S ()
|
{
|
{
|
if (omp_get_thread_num () != 0)
|
if (omp_get_thread_num () != 0)
|
#pragma omp atomic
|
#pragma omp atomic
|
n[1]++;
|
n[1]++;
|
}
|
}
|
|
|
S::S (const S &x)
|
S::S (const S &x)
|
{
|
{
|
if (x.i != 18)
|
if (x.i != 18)
|
abort ();
|
abort ();
|
i = 118;
|
i = 118;
|
if (omp_get_thread_num () != 0)
|
if (omp_get_thread_num () != 0)
|
#pragma omp atomic
|
#pragma omp atomic
|
n[2]++;
|
n[2]++;
|
}
|
}
|
|
|
S
|
S
|
foo ()
|
foo ()
|
{
|
{
|
int i;
|
int i;
|
S ret;
|
S ret;
|
|
|
#pragma omp parallel for firstprivate (ret) lastprivate (ret) \
|
#pragma omp parallel for firstprivate (ret) lastprivate (ret) \
|
schedule (static, 1) num_threads (4)
|
schedule (static, 1) num_threads (4)
|
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
ret.i += omp_get_thread_num ();
|
ret.i += omp_get_thread_num ();
|
|
|
return ret;
|
return ret;
|
}
|
}
|
|
|
S
|
S
|
bar ()
|
bar ()
|
{
|
{
|
int i;
|
int i;
|
S ret;
|
S ret;
|
|
|
#pragma omp parallel for num_threads (4)
|
#pragma omp parallel for num_threads (4)
|
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
#pragma omp atomic
|
#pragma omp atomic
|
ret.i += omp_get_thread_num () + 1;
|
ret.i += omp_get_thread_num () + 1;
|
|
|
return ret;
|
return ret;
|
}
|
}
|
|
|
S x;
|
S x;
|
|
|
int
|
int
|
main (void)
|
main (void)
|
{
|
{
|
omp_set_dynamic (false);
|
omp_set_dynamic (false);
|
x = foo ();
|
x = foo ();
|
if (n[0] != 0 || n[1] != 3 || n[2] != 3)
|
if (n[0] != 0 || n[1] != 3 || n[2] != 3)
|
abort ();
|
abort ();
|
if (x.i != 118 + 3)
|
if (x.i != 118 + 3)
|
abort ();
|
abort ();
|
x = bar ();
|
x = bar ();
|
if (n[0] != 0 || n[1] != 3 || n[2] != 3)
|
if (n[0] != 0 || n[1] != 3 || n[2] != 3)
|
abort ();
|
abort ();
|
if (x.i != 18 + 0 + 1 + 2 + 3 + 4)
|
if (x.i != 18 + 0 + 1 + 2 + 3 + 4)
|
abort ();
|
abort ();
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.