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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.c++/] [atomic-8.C] - Rev 810

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

// { dg-do run }

extern "C" void abort ();
int x = 6, cnt;

int
foo ()
{
  return cnt++;
}

int
main ()
{
  int v, *p;
  #pragma omp atomic update
    x = x + 7;
  #pragma omp atomic
    x = x + 7 + 6;
  #pragma omp atomic update
    x = x + 2 * 3;
  #pragma omp atomic
    x = x * (2 - 1);
  #pragma omp atomic read
    v = x;
  if (v != 32)
    abort ();
  #pragma omp atomic write
    x = 0;
  #pragma omp atomic capture
    {
      v = x;
      x = x | 1 ^ 2;
    }
  if (v != 0)
    abort ();
  #pragma omp atomic capture
    {
      v = x;
      x = x | 4 | 2;
    }
  if (v != 3)
    abort ();
  #pragma omp atomic read
    v = x;
  if (v != 7)
    abort ();
  #pragma omp atomic capture
    {
      x = x ^ 6 & 2;
      v = x;
    }
  if (v != 5)
    abort ();
  #pragma omp atomic capture
    { x = x - (6 + 4); v = x; }
  if (v != -5)
    abort ();
  #pragma omp atomic capture
    { v = x; x = x - (1 | 2); }
  if (v != -5)
    abort ();
  #pragma omp atomic read
    v = x;
  if (v != -8)
    abort ();
  #pragma omp atomic
    x = x * -4 / 2;
  #pragma omp atomic read
    v = x;
  if (v != 16)
    abort ();
  p = &x;
  #pragma omp atomic update
    p[foo (), 0] = p[foo (), 0] - 16;
  #pragma omp atomic read
    v = x;
  if (cnt != 2 || v != 0)
    abort ();
  #pragma omp atomic capture
    {
      p[foo (), 0] += 6;
      v = p[foo (), 0];
    }
  if (cnt != 4 || v != 6)
    abort ();
  #pragma omp atomic capture
    {
      v = p[foo (), 0];
      p[foo (), 0] += 6;
    }
  if (cnt != 6 || v != 6)
    abort ();
  #pragma omp atomic read
    v = x;
  if (v != 12)
    abort ();
  #pragma omp atomic capture
    {
      p[foo (), 0] = p[foo (), 0] + 6;
      v = p[foo (), 0];
    }
  if (cnt != 9 || v != 18)
    abort ();
  #pragma omp atomic capture
    {
      v = p[foo (), 0];
      p[foo (), 0] = p[foo (), 0] + 6;
    }
  if (cnt != 12 || v != 18)
    abort ();
  #pragma omp atomic read
    v = x;
  if (v != 24)
    abort ();
  #pragma omp atomic capture
  { v = p[foo (), 0]; p[foo (), 0]++; }
  #pragma omp atomic capture
  { v = p[foo (), 0]; ++p[foo (), 0]; }
  #pragma omp atomic capture
  { p[foo (), 0]++; v = p[foo (), 0]; }
  #pragma omp atomic capture
  { ++p[foo (), 0]; v = p[foo (), 0]; }
  if (cnt != 20 || v != 28)
    abort ();
  #pragma omp atomic capture
  { v = p[foo (), 0]; p[foo (), 0]--; }
  #pragma omp atomic capture
  { v = p[foo (), 0]; --p[foo (), 0]; }
  #pragma omp atomic capture
  { p[foo (), 0]--; v = p[foo (), 0]; }
  #pragma omp atomic capture
  { --p[foo (), 0]; v = p[foo (), 0]; }
  if (cnt != 28 || v != 24)
    abort ();
  return 0;
}

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

powered by: WebSVN 2.1.0

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