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.2.1.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 735 jeremybenn
/* { dg-do run } */
2
 
3
#include <stdio.h>
4
#include <omp.h>
5
extern void abort (void);
6
int
7
main ()
8
{
9
  int bad, x;
10
  x = 2;
11
  bad = 0;
12
#pragma omp parallel num_threads(2) shared(x, bad)
13
  {
14
    if (omp_get_thread_num () == 0)
15
      {
16
        volatile int i;
17
        for (i = 0; i < 100000000; i++)
18
          x = 5;
19
      }
20
    else
21
      {
22
        /* Print 1: the following read of x has a race */
23
        if (x != 2 && x != 5)
24
          bad = 1;
25
      }
26
#pragma omp barrier
27
    if (omp_get_thread_num () == 0)
28
      {
29
        /* x must be 5 now.  */
30
        if (x != 5)
31
          bad = 1;
32
      }
33
    else
34
      {
35
        /* x must be 5 now.  */
36
        if (x != 5)
37
          bad = 1;
38
      }
39
  }
40
 
41
  if (bad)
42
    abort ();
43
 
44
  return 0;
45
}

powered by: WebSVN 2.1.0

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