3 // { dg-additional-options "-std=c++17" }
5 typedef __PTRDIFF_TYPE__ ptrdiff_t;
6 extern "C" void abort ();
8 #pragma omp declare target
13 typedef ptrdiff_t difference_type;
20 T &operator [] (const difference_type &) const;
21 I &operator = (const I &);
26 I &operator += (const difference_type &);
27 I &operator -= (const difference_type &);
28 I operator + (const difference_type &) const;
29 I operator - (const difference_type &) const;
30 template <typename S> friend bool operator == (I<S> &, I<S> &);
31 template <typename S> friend bool operator == (const I<S> &, const I<S> &);
32 template <typename S> friend bool operator < (I<S> &, I<S> &);
33 template <typename S> friend bool operator < (const I<S> &, const I<S> &);
34 template <typename S> friend bool operator <= (I<S> &, I<S> &);
35 template <typename S> friend bool operator <= (const I<S> &, const I<S> &);
36 template <typename S> friend bool operator > (I<S> &, I<S> &);
37 template <typename S> friend bool operator > (const I<S> &, const I<S> &);
38 template <typename S> friend bool operator >= (I<S> &, I<S> &);
39 template <typename S> friend bool operator >= (const I<S> &, const I<S> &);
40 template <typename S> friend typename I<S>::difference_type operator - (I<S> &, I<S> &);
41 template <typename S> friend typename I<S>::difference_type operator - (const I<S> &, const I<S> &);
42 template <typename S> friend I<S> operator + (typename I<S>::difference_type , const I<S> &);
46 template <typename T> I<T>::I () : p (0) {}
47 template <typename T> I<T>::~I () {}
48 template <typename T> I<T>::I (T *x) : p (x) {}
49 template <typename T> I<T>::I (const I &x) : p (x.p) {}
50 template <typename T> T &I<T>::operator * () { return *p; }
51 template <typename T> T *I<T>::operator -> () { return p; }
52 template <typename T> T &I<T>::operator [] (const difference_type &x) const { return p[x]; }
53 template <typename T> I<T> &I<T>::operator = (const I &x) { p = x.p; return *this; }
54 template <typename T> I<T> &I<T>::operator ++ () { ++p; return *this; }
55 template <typename T> I<T> I<T>::operator ++ (int) { return I (p++); }
56 template <typename T> I<T> &I<T>::operator -- () { --p; return *this; }
57 template <typename T> I<T> I<T>::operator -- (int) { return I (p--); }
58 template <typename T> I<T> &I<T>::operator += (const difference_type &x) { p += x; return *this; }
59 template <typename T> I<T> &I<T>::operator -= (const difference_type &x) { p -= x; return *this; }
60 template <typename T> I<T> I<T>::operator + (const difference_type &x) const { return I (p + x); }
61 template <typename T> I<T> I<T>::operator - (const difference_type &x) const { return I (p - x); }
62 template <typename T> bool operator == (I<T> &x, I<T> &y) { return x.p == y.p; }
63 template <typename T> bool operator == (const I<T> &x, const I<T> &y) { return x.p == y.p; }
64 template <typename T> bool operator != (I<T> &x, I<T> &y) { return !(x == y); }
65 template <typename T> bool operator != (const I<T> &x, const I<T> &y) { return !(x == y); }
66 template <typename T> bool operator < (I<T> &x, I<T> &y) { return x.p < y.p; }
67 template <typename T> bool operator < (const I<T> &x, const I<T> &y) { return x.p < y.p; }
68 template <typename T> bool operator <= (I<T> &x, I<T> &y) { return x.p <= y.p; }
69 template <typename T> bool operator <= (const I<T> &x, const I<T> &y) { return x.p <= y.p; }
70 template <typename T> bool operator > (I<T> &x, I<T> &y) { return x.p > y.p; }
71 template <typename T> bool operator > (const I<T> &x, const I<T> &y) { return x.p > y.p; }
72 template <typename T> bool operator >= (I<T> &x, I<T> &y) { return x.p >= y.p; }
73 template <typename T> bool operator >= (const I<T> &x, const I<T> &y) { return x.p >= y.p; }
74 template <typename T> typename I<T>::difference_type operator - (I<T> &x, I<T> &y) { return x.p - y.p; }
75 template <typename T> typename I<T>::difference_type operator - (const I<T> &x, const I<T> &y) { return x.p - y.p; }
76 template <typename T> I<T> operator + (typename I<T>::difference_type x, const I<T> &y) { return I<T> (x + y.p); }
82 J(const I<T> &x, const I<T> &y) : b (x), e (y) {}
89 template <typename T> const I<T> &J<T>::begin () { return b; }
90 template <typename T> const I<T> &J<T>::end () { return e; }
98 if (*i < 0 || *i >= 2000)
106 if (i < 0 || i >= 2000)
114 #pragma omp distribute parallel for default(none)
115 for (I<int> i = j.begin (); i < j.end (); i += 3)
123 #pragma omp distribute parallel for default(none)
124 for (i = j.begin (); i < j.end (); ++i)
132 #pragma omp distribute parallel for default(none)
133 for (I<int> i = j.begin (); i < j.end (); i += 6)
142 #pragma omp distribute parallel for default(none)
143 for (i = j.begin (); i < j.end (); i += 9)
147 template <typename T>
151 #pragma omp distribute parallel for default(none)
152 for (I<T> i = j.begin (); i < j.end (); i += 4)
156 template <typename T>
161 #pragma omp distribute parallel for default(none)
162 for (i = j.begin (); i < j.end (); i += 7)
166 #pragma omp end declare target
168 #define check(expr) \
169 for (int i = 0; i < 2000; i++) \
172 if (results[i] != 1) \
176 else if (results[i]) \
183 for (int i = 0; i < 2000; i++)
185 #pragma omp target data map (to: a)
187 #pragma omp target teams map (always, tofrom: results)
189 J<int> j (&a[75], &a[1945]);
192 check (i >= 75 && i < 1945 && (i - 75) % 3 == 0);
193 #pragma omp target teams map (always, tofrom: results)
195 J<int> j (&a[63], &a[1949]);
198 check (i >= 63 && i < 1949);
199 #pragma omp target teams map (always, tofrom: results)
201 J<int> j (&a[58], &a[1979]);
204 check (i >= 58 && i < 1979 && (i - 58) % 6 == 0);
205 #pragma omp target teams map (always, tofrom: results)
207 J<int> j (&a[59], &a[1981]);
210 check (i >= 59 && i < 1981 && (i - 59) % 9 == 0);
211 #pragma omp target teams map (always, tofrom: results)
213 J<int> j (&a[52], &a[1972]);
216 check (i >= 52 && i < 1972 && (i - 52) % 4 == 0);
217 #pragma omp target teams map (always, tofrom: results)
219 J<int> j (&a[31], &a[1827]);
222 check (i >= 31 && i < 1827 && (i - 31) % 7 == 0);