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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.c/] [appendix-a/] [a.19.1.c] - Blame information for rev 735

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 735 jeremybenn
/* { dg-do run } */
2
 
3
int x, *p = &x;
4
extern void abort (void);
5
void
6
f1 (int *q)
7
{
8
  *q = 1;
9
#pragma omp flush
10
  /* x, p, and *q are flushed */
11
  /* because they are shared and accessible */
12
  /* q is not flushed because it is not shared. */
13
}
14
 
15
void
16
f2 (int *q)
17
{
18
#pragma omp barrier
19
  *q = 2;
20
#pragma omp barrier
21
  /*  a barrier implies a flush */
22
  /*  x, p, and *q are flushed */
23
  /*  because they are shared and accessible */
24
  /*  q is not flushed because it is not shared. */
25
}
26
 
27
int
28
g (int n)
29
{
30
  int i = 1, j, sum = 0;
31
  *p = 1;
32
#pragma omp parallel reduction(+: sum) num_threads(2)
33
  {
34
    f1 (&j);
35
    /* i, n and sum were not flushed */
36
    /* because they were not accessible in f1 */
37
    /* j was flushed because it was accessible */
38
    sum += j;
39
    f2 (&j);
40
    /* i, n, and sum were not flushed */
41
    /* because they were not accessible in f2 */
42
    /* j was flushed because it was accessible */
43
    sum += i + j + *p + n;
44
  }
45
  return sum;
46
}
47
 
48
int
49
main ()
50
{
51
  int result = g (10);
52
  if (result != 30)
53
    abort ();
54
  return 0;
55
}

powered by: WebSVN 2.1.0

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