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; }
97 template <int N> int &get () { if (N == 0) return c; else if (N == 1) return b; return a; }
101 template <> struct std::tuple_size<K> { static constexpr int value = 3; };
102 template <int N> struct std::tuple_element<N, K> { using type = int; };
118 template <typename T>
122 if (*i < 0 || *i >= 2000)
130 if (i < 0 || i >= 2000)
138 #pragma omp distribute parallel for default(none) shared(a)
146 #pragma omp distribute parallel for default(none) shared(a)
157 #pragma omp distribute parallel for collapse(3) default(none) shared(b, c)
159 for (int j = 9; j < 10; j++)
161 if (&i != &b[i] || i < 0 || i >= 40 || j != 9 || k < 0 || k >= 50)
170 #pragma omp distribute parallel for default(none) shared(j, a)
181 #pragma omp distribute parallel for simd default(none) shared(d, results)
183 results[i % 1024] += 2 * ((unsigned) i >> 10) + 1;
189 #pragma omp distribute parallel for default(none) shared(j, e)
190 for (auto & [k, l, m] : j)
191 if (&k != &e[m].c || &l != &e[m].b || &m != &e[m].a || k != m * 3 || l != m * 2)
200 #pragma omp distribute parallel for default(none) shared(j, f)
201 for (auto & [k, l, m] : j)
202 if (&k != &f[k].a || &l != &f[k].b || &m != &f[k].c || l != k * 4 || m != k * 5)
211 #pragma omp distribute parallel for default(none) shared(j)
212 for (auto [k, l, m] : j)
213 if (k != m * 3 || l != m * 2)
222 #pragma omp distribute parallel for default(none) shared(j)
223 for (auto [k, l, m] : j)
224 if (l != k * 4 || m != k * 5)
234 #pragma omp distribute parallel for default(none) shared(a)
243 #pragma omp distribute parallel for default(none) shared(a)
255 #pragma omp distribute parallel for collapse(3) default(none) shared(a, b, c)
257 for (I<int> j = I<int> (&a[9]); j < I<int> (&a[10]); j++)
259 if (&i != &b[i] || i < 0 || i >= 40 || *j != 9 || k < 0 || k >= 50)
265 template <typename T>
269 #pragma omp distribute parallel for default(none) shared(j, a)
281 #pragma omp distribute parallel for simd default(none) shared(d, results)
283 results[i % N] += 2 * ((unsigned) i >> 10) + 1;
286 template <typename T>
290 #pragma omp distribute parallel for default(none) shared(j, e)
291 for (auto & [k, l, m] : j)
292 if (&k != &e[m].c || &l != &e[m].b || &m != &e[m].a || k != m * 3 || l != m * 2)
298 template <typename T>
302 #pragma omp distribute parallel for default(none) shared(j, f)
303 for (auto & [k, l, m] : j)
304 if (&k != &f[k].a || &l != &f[k].b || &m != &f[k].c || l != k * 4 || m != k * 5)
314 #pragma omp distribute parallel for default(none) shared(j)
315 for (auto [k, l, m] : j)
316 if (k != m * 3 || l != m * 2)
326 #pragma omp distribute parallel for default(none) shared(j)
327 for (auto [k, l, m] : j)
328 if (l != k * 4 || m != k * 5)
334 #define check(expr) \
335 for (int i = 0; i < 2000; i++) \
338 if (results[i] != 1) \
342 else if (results[i]) \
348 for (int i = 0; i < 2000; i++)
350 for (int i = 0; i < 40; i++)
352 for (int i = 0; i < 50; i++)
354 for (int i = 0; i < 1024; i++)
356 for (int i = 0; i < 1089; i++)
362 for (int i = 0; i < 1093; i++)
378 f4 (J<int> (&a[14], &a[1803]));
379 check (i >= 14 && i < 1803);
382 check (i >= 0 && i < 1024);
384 f6 (J<K> (&e[19], &e[1029]));
385 check (i >= 19 && i < 1029);
387 f7 (J<L> (&f[15], &f[1091]));
388 check (i >= 15 && i < 1091);
390 f8 (J<K> (&e[27], &e[1037]));
391 check (i >= 27 && i < 1037);
393 f9 (J<L> (&f[1], &f[1012]));
394 check (i >= 1 && i < 1012);
405 f13 (J<int> (&a[24], &a[1703]));
406 check (i >= 24 && i < 1703);
409 check (i >= 0 && i < 1024);
411 f15 (J<K> (&e[39], &e[929]));
412 check (i >= 39 && i < 929);
414 f16 (J<L> (&f[17], &f[1071]));
415 check (i >= 17 && i < 1071);
417 f17 <3> (J<K> (&e[7], &e[1017]));
418 check (i >= 7 && i < 1017);
420 f18 <5> (J<L> (&f[121], &f[1010]));
421 check (i >= 121 && i < 1010);