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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.c++/] [for-1.C] - Blame information for rev 830

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

Line No. Rev Author Line
1 735 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 () {}
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
void
101
f1 (const I &x, const I &y)
102
{
103
#pragma omp parallel for
104
  for (I i = x; i <= y; i += 6)
105
    baz (i);
106
}
107
 
108
void
109
f2 (const I &x, const I &y)
110
{
111
  I i;
112
#pragma omp parallel for private(i)
113
  for (i = x; i < y - 1; i = 1 - 6 + 7 + i)
114
    baz (i);
115
}
116
 
117
template 
118
void
119
f3 (const I &x, const I &y)
120
{
121
#pragma omp parallel for
122
  for (I i = x; i <= y; i = i + 9 - 8)
123
    baz (i);
124
}
125
 
126
template 
127
void
128
f4 (const I &x, const I &y)
129
{
130
  I i;
131
#pragma omp parallel for lastprivate(i)
132
  for (i = x + 2000 - 64; i > y + 10; --i)
133
    baz (i);
134
}
135
 
136
void
137
f5 (const I &x, const I &y)
138
{
139
#pragma omp parallel for
140
  for (I i = x + 2000 - 64; i > y + 10; i -= 10)
141
    baz (i);
142
}
143
 
144
template 
145
void
146
f6 (const I &x, const I &y)
147
{
148
#pragma omp parallel for
149
  for (I i = x + 2000 - 64; i > y + 10; i = i - 12 + 2)
150
    {
151
      I j = i + N;
152
      baz (j);
153
    }
154
}
155
 
156
template 
157
void
158
f7 (I i, const I &x, const I &y)
159
{
160
#pragma omp parallel for
161
  for (i = x - 10; i <= y + 10; i += N)
162
    baz (i);
163
}
164
 
165
template 
166
void
167
f8 (J j)
168
{
169
  I i;
170
#pragma omp parallel for
171
  for (i = j.begin (); i <= j.end () + N; i += 2)
172
    baz (i);
173
}
174
 
175
template 
176
void
177
f9 (const I &x, const I &y)
178
{
179
#pragma omp parallel for
180
  for (I i = x; i <= y; i = i + N)
181
    baz (i);
182
}
183
 
184
template 
185
void
186
f10 (const I &x, const I &y)
187
{
188
  I i;
189
#pragma omp parallel for
190
  for (i = x; i > y; i = i + N)
191
    baz (i);
192
}
193
 
194
template 
195
void
196
f11 (const T &x, const T &y)
197
{
198
#pragma omp parallel
199
  {
200
#pragma omp for nowait
201
    for (T i = x; i <= y; i += 3)
202
      baz (i);
203
#pragma omp single
204
    {
205
      T j = y + 3;
206
      baz (j);
207
    }
208
  }
209
}
210
 
211
template 
212
void
213
f12 (const T &x, const T &y)
214
{
215
  T i;
216
#pragma omp parallel for
217
  for (i = x; i > y; --i)
218
    baz (i);
219
}
220
 
221
template 
222
struct K
223
{
224
  template 
225
  static void
226
  f13 (const T &x, const T &y)
227
  {
228
#pragma omp parallel for
229
    for (T i = x; i <= y + N; i += N)
230
      baz (i);
231
  }
232
};
233
 
234
#define check(expr) \
235
  for (int i = 0; i < 2000; i++)                        \
236
    if (expr)                                           \
237
      {                                                 \
238
        if (results[i] != 1)                            \
239
          abort ();                                     \
240
        results[i] = 0;                                 \
241
      }                                                 \
242
    else if (results[i])                                \
243
      abort ()
244
 
245
int
246
main ()
247
{
248
  int a[2000];
249
  long b[2000];
250
  for (int i = 0; i < 2000; i++)
251
    {
252
      a[i] = i;
253
      b[i] = i;
254
    }
255
  f1 (&a[10], &a[1990]);
256
  check (i >= 10 && i <= 1990 && (i - 10) % 6 == 0);
257
  f2 (&a[0], &a[1999]);
258
  check (i < 1998 && (i & 1) == 0);
259
  f3 (&a[20], &a[1837]);
260
  check (i >= 20 && i <= 1837);
261
  f4 (&a[0], &a[30]);
262
  check (i > 40 && i <= 2000 - 64);
263
  f5 (&a[0], &a[100]);
264
  check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0);
265
  f6<-10> (&a[10], &a[110]);
266
  check (i >= 116 && i <= 2000 - 64 && (i - 116) % 10 == 0);
267
  f7<6> (I (), &a[12], &a[1800]);
268
  check (i >= 2 && i <= 1808 && (i - 2) % 6 == 0);
269
  f8<121> (J (&a[14], &a[1803]));
270
  check (i >= 14 && i <= 1924 && (i & 1) == 0);
271
  f9 (&a[33], &a[1967]);
272
  check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0);
273
  f10 (&a[1939], &a[17]);
274
  check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0);
275
  f11 > (&a[16], &a[1981]);
276
  check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0);
277
  f12 > (&a[1761], &a[37]);
278
  check (i > 37 && i <= 1761);
279
  K<5>::f13 > (&a[1], &a[1935]);
280
  check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0);
281
  f9 (&b[33], &b[1967]);
282
  check (i >= 33 && i <= 1967 && (i - 33) % 7 == 0);
283
  f10 (&b[1939], &b[17]);
284
  check (i >= 21 && i <= 1939 && (i - 21) % 7 == 0);
285
  f11 > (&b[16], &b[1981]);
286
  check (i >= 16 && i <= 1984 && (i - 16) % 3 == 0);
287
  f12 > (&b[1761], &b[37]);
288
  check (i > 37 && i <= 1761);
289
  K<5>::f13 > (&b[1], &b[1935]);
290
  check (i >= 1 && i <= 1936 && (i - 1) % 5 == 0);
291
}

powered by: WebSVN 2.1.0

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