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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c/] [atomic-3.c] - Blame information for rev 856

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

Line No. Rev Author Line
1 273 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-fopenmp -O0" } */
3
 
4
#include <omp.h>
5
#include <stdlib.h>
6
 
7
short e[64];
8
int g;
9
_Complex double d, f;
10
int num_threads;
11
 
12
__attribute__((noinline)) void
13
foo (int x, long long y)
14
{
15
#pragma omp parallel num_threads (4)
16
  {
17
    int i;
18
    #pragma omp barrier
19
    for (i = 0; i < 2400; i++)
20
      {
21
        if (i == 0)
22
          num_threads = omp_get_num_threads ();
23
        #pragma omp atomic
24
          e[0] += x;
25
        #pragma omp atomic
26
          e[16] += x;
27
        #pragma omp atomic
28
          g += y;
29
        #pragma omp atomic
30
          __real__ d += x;
31
        #pragma omp atomic
32
          __imag__ f += x;
33
      }
34
  }
35
}
36
 
37
int
38
main (void)
39
{
40
  int i;
41
  foo (3, 3LL);
42
  if (g != 3 * 2400 * num_threads
43
      || __real__ d != g || __imag__ d != 0
44
      || __real__ f != 0 || __imag__ f != g)
45
    abort ();
46
  for (i = 0; i < 64; i++)
47
    if (e[i] != ((i && i != 16) ? 0 : g))
48
      abort ();
49
  return 0;
50
}

powered by: WebSVN 2.1.0

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