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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libgomp/] [testsuite/] [libgomp.c++/] [shared-1.C] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
#include 
2
 
3
extern "C" void abort (void);
4
 
5
struct Y
6
{
7
  int l[5][10];
8
};
9
 
10
struct X
11
{
12
  struct Y y;
13
  float b[10];
14
};
15
 
16
void
17
parallel (int a, int b)
18
{
19
  int i, j;
20
  struct X A[10][5];
21
  a = b = 3;
22
 
23
  for (i = 0; i < 10; i++)
24
    for (j = 0; j < 5; j++)
25
      A[i][j].y.l[3][3] = -10;
26
 
27
  #pragma omp parallel shared (a, b, A) num_threads (5)
28
    {
29
      int i, j;
30
 
31
      #pragma omp atomic
32
      a += omp_get_num_threads ();
33
 
34
      #pragma omp atomic
35
      b += omp_get_num_threads ();
36
 
37
      #pragma omp for private (j)
38
      for (i = 0; i < 10; i++)
39
        for (j = 0; j < 5; j++)
40
          A[i][j].y.l[3][3] += 20;
41
 
42
    }
43
 
44
  for (i = 0; i < 10; i++)
45
    for (j = 0; j < 5; j++)
46
      if (A[i][j].y.l[3][3] != 10)
47
        abort ();
48
 
49
  if (a != 28)
50
    abort ();
51
 
52
  if (b != 28)
53
    abort ();
54
}
55
 
56
main()
57
{
58
  parallel (1, 2);
59
  return 0;
60
}

powered by: WebSVN 2.1.0

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