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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libgomp/] [testsuite/] [libgomp.c/] [pr26943-4.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* PR c++/26943 */
2
/* { dg-do run } */
3
 
4
extern int omp_set_dynamic (int);
5
extern int omp_get_thread_num (void);
6
extern void abort (void);
7
 
8
int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
9
char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
10
volatile int k;
11
 
12
int
13
main (void)
14
{
15
  int i;
16
  omp_set_dynamic (0);
17
  omp_set_nested (1);
18
#pragma omp parallel num_threads (2) reduction (+:l) \
19
                     firstprivate (a, b, c, d, e, f, g, h, j)
20
  if (k == omp_get_thread_num ())
21
    {
22
#pragma omp parallel for shared (a, e) firstprivate (b, f) \
23
                         lastprivate (c, g) private (d, h) \
24
                         schedule (static, 1) num_threads (4) \
25
                         reduction (+:j)
26
      for (i = 0; i < 4; i++)
27
        {
28
          if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
29
            j++;
30
#pragma omp barrier
31
#pragma omp atomic
32
          a += i;
33
          b += i;
34
          c = i;
35
          d = i;
36
#pragma omp atomic
37
          e[0] += i;
38
          f[0] += i;
39
          g[0] = 'g' + i;
40
          h[0] = 'h' + i;
41
#pragma omp barrier
42
          if (a != 8 + 6 || b != 12 + i || c != i || d != i)
43
            j += 8;
44
          if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
45
            j += 64;
46
          if (h[0] != 'h' + i)
47
            j += 512;
48
        }
49
      if (j || a != 8 + 6 || b != 12 || c != 3 || d != 20)
50
        ++l;
51
      if (e[0] != 'a' + 6 || f[0] != 'b' || g[0] != 'g' + 3 || h[0] != 'd')
52
        l += 8;
53
    }
54
  if (l)
55
    abort ();
56
  if (a != 8 || b != 12 || c != 16 || d != 20)
57
    abort ();
58
  if (e[0] != 'a' || f[0] != 'b' || g[0] != 'c' || h[0] != 'd')
59
    abort ();
60
  return 0;
61
}

powered by: WebSVN 2.1.0

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