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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c++/] [for-2.C] - Blame information for rev 861

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

Line No. Rev Author Line
1 273 jeremybenn
// { dg-do run }
2
 
3
extern "C" void abort ();
4
 
5
template 
6
class J
7
{
8
public:
9
  J(T x, T y) : b (x), e (y) {}
10
  T begin ();
11
  T end ();
12
private:
13
  T b, e;
14
};
15
 
16
template  T J::begin () { return b; }
17
template  T J::end () { return e; }
18
 
19
int results[2000];
20
 
21
void
22
baz (int i)
23
{
24
  if (i < 0 || i >= 2000)
25
    abort ();
26
  results[i]++;
27
}
28
 
29
void
30
f1 (int x, int y)
31
{
32
#pragma omp parallel for
33
  for (int i = x; i <= y; i += 6)
34
    baz (i);
35
}
36
 
37
void
38
f2 (int x, int y)
39
{
40
  int i;
41
#pragma omp parallel for private(i)
42
  for (i = x; i < y - 1; i = 1 - 6 + 7 + i)
43
    baz (i);
44
}
45
 
46
template 
47
void
48
f3 (int x, int y)
49
{
50
#pragma omp parallel for
51
  for (int i = x; i <= y; i = i + 9 - 8)
52
    baz (i);
53
}
54
 
55
template 
56
void
57
f4 (int x, int y)
58
{
59
  int i;
60
#pragma omp parallel for lastprivate(i)
61
  for (i = x + 2000 - 64; i > y + 10; --i)
62
    baz (i);
63
}
64
 
65
void
66
f5 (int x, int y)
67
{
68
#pragma omp parallel for
69
  for (int i = x + 2000 - 64; i > y + 10L; i -= 10L)
70
    baz (i);
71
}
72
 
73
template 
74
void
75
f6 (int x, int y)
76
{
77
#pragma omp parallel for
78
  for (int i = x + 2000 - 64; i > y + 10L; i = i - 12 + 2L)
79
    baz (i + N);
80
}
81
 
82
template 
83
void
84
f7 (int i, int x, int y)
85
{
86
#pragma omp parallel for
87
  for (i = x - 10; i <= y + 10; i += N)
88
    baz (i);
89
}
90
 
91
template 
92
void
93
f8 (J j)
94
{
95
  int i;
96
#pragma omp parallel for
97
  for (i = j.begin (); i <= j.end () + N; i += 2)
98
    baz (i);
99
}
100
 
101
template 
102
void
103
f9 (T x, T y)
104
{
105
#pragma omp parallel for
106
  for (T i = x; i <= y; i = i + N)
107
    baz (i);
108
}
109
 
110
template 
111
void
112
f10 (T x, T y)
113
{
114
  T i;
115
#pragma omp parallel for
116
  for (i = x; i > y; i = i + N)
117
    baz (i);
118
}
119
 
120
template 
121
void
122
f11 (T x, long y)
123
{
124
#pragma omp parallel
125
  {
126
#pragma omp for nowait
127
    for (T i = x; i <= y; i += 3L)
128
      baz (i);
129
#pragma omp single
130
    baz (y + 3);
131
  }
132
}
133
 
134
template 
135
void
136
f12 (T x, T y)
137
{
138
  T i;
139
#pragma omp parallel for
140
  for (i = x; i > y; --i)
141
    baz (i);
142
}
143
 
144
#define check(expr) \
145
  for (int i = 0; i < 2000; i++)                        \
146
    if (expr)                                           \
147
      {                                                 \
148
        if (results[i] != 1)                            \
149
          abort ();                                     \
150
        results[i] = 0;                                 \
151
      }                                                 \
152
    else if (results[i])                                \
153
      abort ()
154
 
155
int
156
main ()
157
{
158
  f1 (10, 1990);
159
  check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0);
160
  f2 (0, 1999);
161
  check (i < 1998 && (i & 1) == 0);
162
  f3 (20, 1837);
163
  check (i >= 20 && i <= 1837);
164
  f4 (0, 30);
165
  check (i > 40 && i <= 2000 - 64);
166
  f5 (0, 100);
167
  check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0);
168
  f6<-10> (10, 110);
169
  check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0);
170
  f7<6> (0, 12, 1800);
171
  check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0);
172
  f8<121> (J (14, 1803));
173
  check (i >= 14 && i <= 1924 && (i & 1) == 0);
174
  f9 (33, 1967);
175
  check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0);
176
  f10 (1939, 17);
177
  check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0);
178
  f11 (16, 1981);
179
  check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0);
180
  f12 (1761, 37);
181
  check (i > 37 && i <= 1761);
182
}

powered by: WebSVN 2.1.0

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