URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 816 |
Rev 826 |
// { dg-do run }
|
// { dg-do run }
|
// Test several constructs within a parallel. At one point in development,
|
// Test several constructs within a parallel. At one point in development,
|
// the critical directive clobbered the shared clause of the parallel.
|
// the critical directive clobbered the shared clause of the parallel.
|
|
|
#include <omp.h>
|
#include <omp.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
|
|
#define N 2000
|
#define N 2000
|
|
|
int main()
|
int main()
|
{
|
{
|
int A[N];
|
int A[N];
|
int nthreads;
|
int nthreads;
|
int i;
|
int i;
|
|
|
#pragma omp parallel shared (A, nthreads)
|
#pragma omp parallel shared (A, nthreads)
|
{
|
{
|
#pragma omp master
|
#pragma omp master
|
nthreads = omp_get_num_threads ();
|
nthreads = omp_get_num_threads ();
|
|
|
#pragma omp for
|
#pragma omp for
|
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
A[i] = 0;
|
A[i] = 0;
|
|
|
#pragma omp critical
|
#pragma omp critical
|
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
A[i] += 1;
|
A[i] += 1;
|
}
|
}
|
|
|
for (i = 0; i < N; i++)
|
for (i = 0; i < N; i++)
|
if (A[i] != nthreads)
|
if (A[i] != nthreads)
|
abort ();
|
abort ();
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.