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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libgomp/] [testsuite/] [libgomp.c/] [critical-2.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
// { dg-do run }
2
// Test several constructs within a parallel.  At one point in development,
3
// the critical directive clobbered the shared clause of the parallel.
4
 
5
#include <omp.h>
6
#include <stdlib.h>
7
 
8
#define N       2000
9
 
10
int main()
11
{
12
  int A[N];
13
  int nthreads;
14
  int i;
15
 
16
#pragma omp parallel shared (A, nthreads)
17
  {
18
    #pragma omp master
19
      nthreads = omp_get_num_threads ();
20
 
21
    #pragma omp for
22
      for (i = 0; i < N; i++)
23
        A[i] = 0;
24
 
25
    #pragma omp critical
26
      for (i = 0; i < N; i++)
27
        A[i] += 1;
28
  }
29
 
30
  for (i = 0; i < N; i++)
31
    if (A[i] != nthreads)
32
      abort ();
33
 
34
  return 0;
35
}

powered by: WebSVN 2.1.0

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