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-5.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
typedef __PTRDIFF_TYPE__ ptrdiff_t;
4
extern "C" void abort ();
5
 
6
template 
7
class I
8
{
9
public:
10
  typedef ptrdiff_t difference_type;
11
  I ();
12
  ~I ();
13
  I (T *);
14
  I (const I &);
15
  T &operator * ();
16
  T *operator -> ();
17
  T &operator [] (const difference_type &) const;
18
  I &operator = (const I &);
19
  I &operator ++ ();
20
  I operator ++ (int);
21
  I &operator -- ();
22
  I operator -- (int);
23
  I &operator += (const difference_type &);
24
  I &operator -= (const difference_type &);
25
  I operator + (const difference_type &) const;
26
  I operator - (const difference_type &) const;
27
  template  friend bool operator == (I &, I &);
28
  template  friend bool operator == (const I &, const I &);
29
  template  friend bool operator < (I &, I &);
30
  template  friend bool operator < (const I &, const I &);
31
  template  friend bool operator <= (I &, I &);
32
  template  friend bool operator <= (const I &, const I &);
33
  template  friend bool operator > (I &, I &);
34
  template  friend bool operator > (const I &, const I &);
35
  template  friend bool operator >= (I &, I &);
36
  template  friend bool operator >= (const I &, const I &);
37
  template  friend typename I::difference_type operator - (I &, I &);
38
  template  friend typename I::difference_type operator - (const I &, const I &);
39
  template  friend I operator + (typename I::difference_type , const I &);
40
private:
41
  T *p;
42
};
43
template  I::I () : p (0) {}
44
template  I::~I () { p = (T *) 0; }
45
template  I::I (T *x) : p (x) {}
46
template  I::I (const I &x) : p (x.p) {}
47
template  T &I::operator * () { return *p; }
48
template  T *I::operator -> () { return p; }
49
template  T &I::operator [] (const difference_type &x) const { return p[x]; }
50
template  I &I::operator = (const I &x) { p = x.p; return *this; }
51
template  I &I::operator ++ () { ++p; return *this; }
52
template  I I::operator ++ (int) { return I (p++); }
53
template  I &I::operator -- () { --p; return *this; }
54
template  I I::operator -- (int) { return I (p--); }
55
template  I &I::operator += (const difference_type &x) { p += x; return *this; }
56
template  I &I::operator -= (const difference_type &x) { p -= x; return *this; }
57
template  I I::operator + (const difference_type &x) const { return I (p + x); }
58
template  I I::operator - (const difference_type &x) const { return I (p - x); }
59
template  bool operator == (I &x, I &y) { return x.p == y.p; }
60
template  bool operator == (const I &x, const I &y) { return x.p == y.p; }
61
template  bool operator != (I &x, I &y) { return !(x == y); }
62
template  bool operator != (const I &x, const I &y) { return !(x == y); }
63
template  bool operator < (I &x, I &y) { return x.p < y.p; }
64
template  bool operator < (const I &x, const I &y) { return x.p < y.p; }
65
template  bool operator <= (I &x, I &y) { return x.p <= y.p; }
66
template  bool operator <= (const I &x, const I &y) { return x.p <= y.p; }
67
template  bool operator > (I &x, I &y) { return x.p > y.p; }
68
template  bool operator > (const I &x, const I &y) { return x.p > y.p; }
69
template  bool operator >= (I &x, I &y) { return x.p >= y.p; }
70
template  bool operator >= (const I &x, const I &y) { return x.p >= y.p; }
71
template  typename I::difference_type operator - (I &x, I &y) { return x.p - y.p; }
72
template  typename I::difference_type operator - (const I &x, const I &y) { return x.p - y.p; }
73
template  I operator + (typename I::difference_type x, const I &y) { return I (x + y.p); }
74
 
75
template 
76
class J
77
{
78
public:
79
  J(const I &x, const I &y) : b (x), e (y) {}
80
  const I &begin ();
81
  const I &end ();
82
private:
83
  I b, e;
84
};
85
 
86
template  const I &J::begin () { return b; }
87
template  const I &J::end () { return e; }
88
 
89
int results[2000];
90
 
91
template 
92
void
93
baz (I &i)
94
{
95
  if (*i < 0 || *i >= 2000)
96
    abort ();
97
  results[*i]++;
98
}
99
 
100
I
101
f1 (const I &x, const I &y)
102
{
103
  I i;
104
#pragma omp parallel shared (i)
105
  {
106
  #pragma omp for lastprivate (i) schedule(runtime)
107
    for (i = x; i < y - 1; ++i)
108
      baz (i);
109
  #pragma omp single
110
    i += 3;
111
  }
112
  return I (i);
113
}
114
 
115
I
116
f2 (const I &x, const I &y)
117
{
118
  I i;
119
#pragma omp parallel for lastprivate (i)
120
  for (i = x; i < y - 1; i = 1 - 6 + 7 + i)
121
    baz (i);
122
  return I (i);
123
}
124
 
125
template 
126
I
127
f3 (const I &x, const I &y)
128
{
129
  I i;
130
#pragma omp parallel
131
  #pragma omp for lastprivate (i)
132
    for (i = x + 1000 - 64; i <= y - 10; i++)
133
      baz (i);
134
  return i;
135
}
136
 
137
template 
138
I
139
f4 (const I &x, const I &y)
140
{
141
  I i;
142
#pragma omp parallel for lastprivate (i)
143
  for (i = x + 2000 - 64; i > y + 10; --i)
144
    baz (i);
145
  return I (i);
146
}
147
 
148
template 
149
I
150
f5 (const I &x, const I &y)
151
{
152
  I i;
153
#pragma omp parallel for lastprivate (i)
154
  for (i = x; i > y + T (6); i--)
155
    baz (i);
156
  return i;
157
}
158
 
159
template 
160
I
161
f6 (const I &x, const I &y)
162
{
163
  I i;
164
#pragma omp parallel for lastprivate (i)
165
  for (i = x - T (7); i > y; i -= T (2))
166
    baz (i);
167
  return I (i);
168
}
169
 
170
template 
171
I
172
f7 (I i, const I &x, const I &y)
173
{
174
#pragma omp parallel for lastprivate (i)
175
  for (i = x - 10; i <= y + 10; i += N)
176
    baz (i);
177
  return I (i);
178
}
179
 
180
template 
181
I
182
f8 (J j)
183
{
184
  I i;
185
#pragma omp parallel shared (i)
186
  #pragma omp for lastprivate (i)
187
    for (i = j.begin (); i <= j.end () + N; i += 2)
188
      baz (i);
189
  return i;
190
}
191
 
192
I i9;
193
 
194
template 
195
I &
196
f9 (J j)
197
{
198
#pragma omp parallel for lastprivate (i9)
199
  for (i9 = j.begin () + N; i9 <= j.end () - N; i9 = i9 - N)
200
    baz (i9);
201
  return i9;
202
}
203
 
204
template 
205
I
206
f10 (const I &x, const I &y)
207
{
208
  I i;
209
#pragma omp parallel for lastprivate (i)
210
  for (i = x; i > y; i = i + N)
211
    baz (i);
212
  return i;
213
}
214
 
215
template 
216
T
217
f11 (T i, const T &x, const T &y)
218
{
219
#pragma omp parallel
220
  #pragma omp for lastprivate (i)
221
  for (i = x + U (2); i <= y + U (1); i = U (2) + U (3) + i)
222
    baz (i);
223
  return T (i);
224
}
225
 
226
template 
227
T
228
f12 (const T &x, const T &y)
229
{
230
  T i;
231
#pragma omp parallel for lastprivate (i)
232
  for (i = x; i > y; --i)
233
    baz (i);
234
  return i;
235
}
236
 
237
#define check(expr) \
238
  for (int i = 0; i < 2000; i++)                        \
239
    if (expr)                                           \
240
      {                                                 \
241
        if (results[i] != 1)                            \
242
          abort ();                                     \
243
        results[i] = 0;                                 \
244
      }                                                 \
245
    else if (results[i])                                \
246
      abort ()
247
 
248
int
249
main ()
250
{
251
  int a[2000];
252
  long b[2000];
253
  for (int i = 0; i < 2000; i++)
254
    {
255
      a[i] = i;
256
      b[i] = i;
257
    }
258
  if (*f1 (&a[10], &a[1873]) != 1875)
259
    abort ();
260
  check (i >= 10 && i < 1872);
261
  if (*f2 (&a[0], &a[1998]) != 1998)
262
    abort ();
263
  check (i < 1997 && (i & 1) == 0);
264
  if (*f3 (&a[10], &a[1971]) != 1962)
265
    abort ();
266
  check (i >= 946 && i <= 1961);
267
  if (*f4 (&a[0], &a[30]) != 40)
268
    abort ();
269
  check (i > 40 && i <= 2000 - 64);
270
  if (*f5 (&a[1931], &a[17]) != 23)
271
    abort ();
272
  check (i > 23 && i <= 1931);
273
  if (*f6 (&a[1931], &a[17]) != 16)
274
    abort ();
275
  check (i > 17 && i <= 1924 && (i & 1) == 0);
276
  if (*f7<6> (I (), &a[12], &a[1800]) != 1814)
277
    abort ();
278
  check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0);
279
  if (*f8<121> (J (&a[14], &a[1803])) != 1926)
280
    abort ();
281
  check (i >= 14 && i <= 1924 && (i & 1) == 0);
282
  if (*f9<-3L> (J (&a[27], &a[1761])) != 1767)
283
    abort ();
284
  check (i >= 24 && i <= 1764 && (i % 3) == 0);
285
  if (*f10 (&a[1939], &a[17]) != 14)
286
    abort ();
287
  check (i >= 21 && i <= 1939 && i % 7 == 0);
288
  if (*f11, short> (I (), &a[71], &a[1941]) != 1943)
289
    abort ();
290
  check (i >= 73 && i <= 1938 && (i - 73) % 5 == 0);
291
  if (*f12 > (&a[1761], &a[37]) != 37)
292
    abort ();
293
  check (i > 37 && i <= 1761);
294
  if (*f10 (&b[1939], &b[17]) != 14)
295
    abort ();
296
  check (i >= 21 && i <= 1939 && i % 7 == 0);
297
  if (*f11, short> (I (), &b[71], &b[1941]) != 1943)
298
    abort ();
299
  check (i >= 73 && i <= 1938 && (i - 73) % 5 == 0);
300
  if (*f12 > (&b[1761], &b[37]) != 37)
301
    abort ();
302
  check (i > 37 && i <= 1761);
303
}

powered by: WebSVN 2.1.0

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