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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c/] [pr33880.c] - Blame information for rev 320

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

Line No. Rev Author Line
1 273 jeremybenn
/* PR middle-end/33880 */
2
/* { dg-do run } */
3
 
4
extern void abort (void);
5
 
6
void
7
test1 (void)
8
{
9
  int i = 0, j = 0;
10
  void bar (void)
11
  {
12
    i++;
13
    j++;
14
  }
15
  bar ();
16
  #pragma omp parallel for num_threads(4)
17
    for (i = 0; i < 100; i++)
18
      #pragma omp atomic
19
        j += 1;
20
  if (j != 101)
21
    abort ();
22
  #pragma omp parallel for lastprivate(i) num_threads(2)
23
    for (i = 0; i < 100; i++)
24
      #pragma omp atomic
25
        j += 1;
26
  if (i != 100)
27
    abort ();
28
  i = 3;
29
  bar ();
30
  if (j != 202)
31
    abort ();
32
  if (i != 4)
33
    abort ();
34
}
35
 
36
void
37
test2 (void)
38
{
39
  int i = -1, j = 99, k, l = 9, m = 0;
40
  void bar (void)
41
  {
42
    i++;
43
    j++;
44
    l++;
45
    m++;
46
  }
47
  bar ();
48
  #pragma omp parallel for num_threads(4)
49
    for (k = i; k < j; k += l)
50
      #pragma omp atomic
51
        m += 1;
52
  bar ();
53
  if (i != 1 || j != 101 || l != 11 || m != 12)
54
    abort ();
55
}
56
 
57
void
58
test3 (void)
59
{
60
  int i, j, k, l, m;
61
  void bar (void)
62
  {
63
  #pragma omp parallel for num_threads(4)
64
    for (i = j; i < k; i += l)
65
      #pragma omp atomic
66
        m += 1;
67
  }
68
  void baz (void)
69
  {
70
  #pragma omp parallel for num_threads(2) lastprivate(i)
71
    for (i = j; i < k * 2; i += l / 2)
72
      #pragma omp atomic
73
        m += 1;
74
  }
75
  i = 7;
76
  j = 0;
77
  k = 100;
78
  l = 2;
79
  m = 0;
80
  bar ();
81
  if (j != 0 || k != 100 || l != 2 || m != 50)
82
    abort ();
83
  baz ();
84
  if (i != 200 || j != 0 || k != 100 || l != 2 || m != 250)
85
    abort ();
86
}
87
 
88
void
89
test4 (void)
90
{
91
  int i, j, k, l, m = 0;
92
  int foo (void)
93
  {
94
    return j;
95
  }
96
  int bar (void)
97
  {
98
    return k;
99
  }
100
  int baz (void)
101
  {
102
    return l;
103
  }
104
  j = 0;
105
  k = 1000;
106
  l = 2;
107
  #pragma omp parallel for num_threads(8) lastprivate(i)
108
  for (i = foo (); i < bar (); i += baz ())
109
    #pragma omp atomic
110
      m += 1;
111
  if (i != 1000 || m != 500 || j != 0 || k != 1000 || l != 2)
112
    abort ();
113
}
114
 
115
int
116
main (void)
117
{
118
  test1 ();
119
  test2 ();
120
  test3 ();
121
  test4 ();
122
  return 0;
123
}

powered by: WebSVN 2.1.0

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