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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc4/] [libgomp/] [testsuite/] [libgomp.c/] [appendix-a/] [a.2.1.c] - Diff between revs 273 and 519

Only display areas with differences | Details | Blame | View Log

Rev 273 Rev 519
/* { dg-do run } */
/* { dg-do run } */
 
 
#include <stdio.h>
#include <stdio.h>
#include <omp.h>
#include <omp.h>
extern void abort (void);
extern void abort (void);
int
int
main ()
main ()
{
{
  int bad, x;
  int bad, x;
  x = 2;
  x = 2;
  bad = 0;
  bad = 0;
#pragma omp parallel num_threads(2) shared(x, bad)
#pragma omp parallel num_threads(2) shared(x, bad)
  {
  {
    if (omp_get_thread_num () == 0)
    if (omp_get_thread_num () == 0)
      {
      {
        volatile int i;
        volatile int i;
        for (i = 0; i < 100000000; i++)
        for (i = 0; i < 100000000; i++)
          x = 5;
          x = 5;
      }
      }
    else
    else
      {
      {
        /* Print 1: the following read of x has a race */
        /* Print 1: the following read of x has a race */
        if (x != 2 && x != 5)
        if (x != 2 && x != 5)
          bad = 1;
          bad = 1;
      }
      }
#pragma omp barrier
#pragma omp barrier
    if (omp_get_thread_num () == 0)
    if (omp_get_thread_num () == 0)
      {
      {
        /* x must be 5 now.  */
        /* x must be 5 now.  */
        if (x != 5)
        if (x != 5)
          bad = 1;
          bad = 1;
      }
      }
    else
    else
      {
      {
        /* x must be 5 now.  */
        /* x must be 5 now.  */
        if (x != 5)
        if (x != 5)
          bad = 1;
          bad = 1;
      }
      }
  }
  }
 
 
  if (bad)
  if (bad)
    abort ();
    abort ();
 
 
  return 0;
  return 0;
}
}
 
 

powered by: WebSVN 2.1.0

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