2 // { dg-additional-options "-std=c++17" }
4 typedef __PTRDIFF_TYPE__ ptrdiff_t;
5 extern "C" void abort ();
8 template<typename T> struct tuple_size;
9 template<int, typename> struct tuple_element;
16 typedef ptrdiff_t difference_type;
23 T &operator [] (const difference_type &) const;
24 I &operator = (const I &);
29 I &operator += (const difference_type &);
30 I &operator -= (const difference_type &);
31 I operator + (const difference_type &) const;
32 I operator - (const difference_type &) const;
33 template <typename S> friend bool operator == (I<S> &, I<S> &);
34 template <typename S> friend bool operator == (const I<S> &, const I<S> &);
35 template <typename S> friend bool operator < (I<S> &, I<S> &);
36 template <typename S> friend bool operator < (const I<S> &, const I<S> &);
37 template <typename S> friend bool operator <= (I<S> &, I<S> &);
38 template <typename S> friend bool operator <= (const I<S> &, const I<S> &);
39 template <typename S> friend bool operator > (I<S> &, I<S> &);
40 template <typename S> friend bool operator > (const I<S> &, const I<S> &);
41 template <typename S> friend bool operator >= (I<S> &, I<S> &);
42 template <typename S> friend bool operator >= (const I<S> &, const I<S> &);
43 template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &);
44 template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &);
45 template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &);
49 template <typename T> I<T>::I () : p (0) {}
50 template <typename T> I<T>::~I () {}
51 template <typename T> I<T>::I (T *x) : p (x) {}
52 template <typename T> I<T>::I (const I &x) : p (x.p) {}
53 template <typename T> T &I<T>::operator * () { return *p; }
54 template <typename T> T *I<T>::operator -> () { return p; }
55 template <typename T> T &I<T>::operator [] (const difference_type &x) const { return p[x]; }
56 template <typename T> I<T> &I<T>::operator = (const I &x) { p = x.p; return *this; }
57 template <typename T> I<T> &I<T>::operator ++ () { ++p; return *this; }
58 template <typename T> I<T> I<T>::operator ++ (int) { return I (p++); }
59 template <typename T> I<T> &I<T>::operator -- () { --p; return *this; }
60 template <typename T> I<T> I<T>::operator -- (int) { return I (p--); }
61 template <typename T> I<T> &I<T>::operator += (const difference_type &x) { p += x; return *this; }
62 template <typename T> I<T> &I<T>::operator -= (const difference_type &x) { p -= x; return *this; }
63 template <typename T> I<T> I<T>::operator + (const difference_type &x) const { return I (p + x); }
64 template <typename T> I<T> I<T>::operator - (const difference_type &x) const { return I (p - x); }
65 template <typename T> bool operator == (I<T> &x, I<T> &y) { return x.p == y.p; }
66 template <typename T> bool operator == (const I<T> &x, const I<T> &y) { return x.p == y.p; }
67 template <typename T> bool operator != (I<T> &x, I<T> &y) { return !(x == y); }
68 template <typename T> bool operator != (const I<T> &x, const I<T> &y) { return !(x == y); }
69 template <typename T> bool operator < (I<T> &x, I<T> &y) { return x.p < y.p; }
70 template <typename T> bool operator < (const I<T> &x, const I<T> &y) { return x.p < y.p; }
71 template <typename T> bool operator <= (I<T> &x, I<T> &y) { return x.p <= y.p; }
72 template <typename T> bool operator <= (const I<T> &x, const I<T> &y) { return x.p <= y.p; }
73 template <typename T> bool operator > (I<T> &x, I<T> &y) { return x.p > y.p; }
74 template <typename T> bool operator > (const I<T> &x, const I<T> &y) { return x.p > y.p; }
75 template <typename T> bool operator >= (I<T> &x, I<T> &y) { return x.p >= y.p; }
76 template <typename T> bool operator >= (const I<T> &x, const I<T> &y) { return x.p >= y.p; }
77 template <typename T> typename I<T>::difference_type operator - (I<T> &x, I<T> &y) { return x.p - y.p; }
78 template <typename T> typename I<T>::difference_type operator - (const I<T> &x, const I<T> &y) { return x.p - y.p; }
79 template <typename T> I<T> operator + (typename I<T>::difference_type x, const I<T> &y) { return I<T> (x + y.p); }
85 J(const I<T> &x, const I<T> &y) : b (x), e (y) {}
92 template <typename T> const I<T> &J<T>::begin () { return b; }
93 template <typename T> const I<T> &J<T>::end () { return e; }
101 template <int N> T &get () { if (N == 0) return c; else if (N == 1) return b; return a; }
105 template <typename T> K<T>::K () : a {}, b {}, c {} {}
106 template <typename T> K<T>::~K () {}
107 template <typename T> struct std::tuple_size<K<T>> { static constexpr int value = 3; };
108 template <typename T, int N> struct std::tuple_element<N, K<T>> { using type = T; };
110 template <typename T>
119 template <typename T> L<T>::L () : a {}, b {}, c {} {}
120 template <typename T> L<T>::~L () {}
130 template <typename T>
134 if (*i < 0 || *i >= 2000)
142 if (i < 0 || i >= 2000)
150 #pragma omp parallel for default(none) shared(a)
158 #pragma omp parallel for default(none) shared(a)
169 #pragma omp parallel for collapse(3) default(none) shared(b, c)
171 for (int j = 9; j < 10; j++)
173 if (&i != &b[i] || i < 0 || i >= 40 || j != 9 || k < 0 || k >= 50)
182 #pragma omp parallel for default(none) shared(j, a)
193 #pragma omp parallel for simd default(none) shared(d, results)
195 results[i % 1024] += 2 * ((unsigned) i >> 10) + 1;
201 #pragma omp parallel for default(none) shared(j, e)
202 for (auto & [k, l, m] : j)
203 if (&k != &e[m].c || &l != &e[m].b || &m != &e[m].a || k != m * 3 || l != m * 2)
212 #pragma omp parallel for default(none) shared(j, f)
213 for (auto & [k, l, m] : j)
214 if (&k != &f[k].a || &l != &f[k].b || &m != &f[k].c || l != k * 4 || m != k * 5)
223 #pragma omp parallel for default(none) shared(j)
224 for (auto [k, l, m] : j)
225 if (k != m * 3 || l != m * 2)
234 #pragma omp parallel for default(none) shared(j)
235 for (auto [k, l, m] : j)
236 if (l != k * 4 || m != k * 5)
246 #pragma omp parallel for default(none) shared(a)
255 #pragma omp parallel for default(none) shared(a)
267 #pragma omp parallel for collapse(3) default(none) shared(a, b, c)
269 for (I<int> j = I<int> (&a[9]); j < I<int> (&a[10]); j++)
271 if (&i != &b[i] || i < 0 || i >= 40 || *j != 9 || k < 0 || k >= 50)
277 template <typename T>
281 #pragma omp parallel for default(none) shared(j, a)
293 #pragma omp parallel for simd default(none) shared(d, results)
295 results[i % N] += 2 * ((unsigned) i >> 10) + 1;
298 template <typename T>
302 #pragma omp parallel for default(none) shared(j, e)
303 for (auto & [k, l, m] : j)
304 if (&k != &e[m].c || &l != &e[m].b || &m != &e[m].a || k != m * 3 || l != m * 2)
310 template <typename T>
314 #pragma omp parallel for default(none) shared(j, f)
315 for (auto & [k, l, m] : j)
316 if (&k != &f[k].a || &l != &f[k].b || &m != &f[k].c || l != k * 4 || m != k * 5)
326 #pragma omp parallel for default(none) shared(j)
327 for (auto [k, l, m] : j)
328 if (k != m * 3 || l != m * 2)
338 #pragma omp parallel for default(none) shared(j)
339 for (auto [k, l, m] : j)
340 if (l != k * 4 || m != k * 5)
346 #define check(expr) \
347 for (int i = 0; i < 2000; i++) \
350 if (results[i] != 1) \
354 else if (results[i]) \
360 for (int i = 0; i < 2000; i++)
362 for (int i = 0; i < 40; i++)
364 for (int i = 0; i < 50; i++)
366 for (int i = 0; i < 1024; i++)
368 for (int i = 0; i < 1089; i++)
374 for (int i = 0; i < 1093; i++)
386 f4 (J<int> (&a[14], &a[1803]));
387 check (i >= 14 && i < 1803);
389 check (i >= 0 && i < 1024);
390 f6 (J<K<int>> (&e[19], &e[1029]));
391 check (i >= 19 && i < 1029);
392 f7 (J<L<int>> (&f[15], &f[1091]));
393 check (i >= 15 && i < 1091);
394 f8 (J<K<int>> (&e[27], &e[1037]));
395 check (i >= 27 && i < 1037);
396 f9 (J<L<int>> (&f[1], &f[1012]));
397 check (i >= 1 && i < 1012);
404 f13 (J<int> (&a[24], &a[1703]));
405 check (i >= 24 && i < 1703);
407 check (i >= 0 && i < 1024);
408 f15 (J<K<int>> (&e[39], &e[929]));
409 check (i >= 39 && i < 929);
410 f16 (J<L<int>> (&f[17], &f[1071]));
411 check (i >= 17 && i < 1071);
412 f17 <3> (J<K<int>> (&e[7], &e[1017]));
413 check (i >= 7 && i < 1017);
414 f18 <5> (J<L<int>> (&f[121], &f[1010]));
415 check (i >= 121 && i < 1010);