Don't capture this implicitly
Relax const constraints on the range iterator
This commit is contained in:
parent
dfb4eb06b2
commit
f77e43c6d5
@ -83,7 +83,7 @@ template <class T>
|
|||||||
void STDIndicesStream<T>::mul()
|
void STDIndicesStream<T>::mul()
|
||||||
{
|
{
|
||||||
// b[i] = scalar * c[i];
|
// b[i] = scalar * c[i];
|
||||||
std::transform(exe_policy, range.begin(), range.end(), BEGIN(b), [&, scalar = startScalar](int i) {
|
std::transform(exe_policy, range.begin(), range.end(), BEGIN(b), [this, scalar = startScalar](int i) {
|
||||||
return scalar * c[i];
|
return scalar * c[i];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -92,7 +92,7 @@ template <class T>
|
|||||||
void STDIndicesStream<T>::add()
|
void STDIndicesStream<T>::add()
|
||||||
{
|
{
|
||||||
// c[i] = a[i] + b[i];
|
// c[i] = a[i] + b[i];
|
||||||
std::transform(exe_policy, range.begin(), range.end(), BEGIN(c), [&](int i) {
|
std::transform(exe_policy, range.begin(), range.end(), BEGIN(c), [this](int i) {
|
||||||
return a[i] + b[i];
|
return a[i] + b[i];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ template <class T>
|
|||||||
void STDIndicesStream<T>::triad()
|
void STDIndicesStream<T>::triad()
|
||||||
{
|
{
|
||||||
// a[i] = b[i] + scalar * c[i];
|
// a[i] = b[i] + scalar * c[i];
|
||||||
std::transform(exe_policy, range.begin(), range.end(), BEGIN(a), [&, scalar = startScalar](int i) {
|
std::transform(exe_policy, range.begin(), range.end(), BEGIN(a), [this, scalar = startScalar](int i) {
|
||||||
return b[i] + scalar * c[i];
|
return b[i] + scalar * c[i];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ void STDIndicesStream<T>::nstream()
|
|||||||
// Need to do in two stages with C++11 STL.
|
// Need to do in two stages with C++11 STL.
|
||||||
// 1: a[i] += b[i]
|
// 1: a[i] += b[i]
|
||||||
// 2: a[i] += scalar * c[i];
|
// 2: a[i] += scalar * c[i];
|
||||||
std::transform(exe_policy, range.begin(), range.end(), BEGIN(a), [&, scalar = startScalar](int i) {
|
std::transform(exe_policy, range.begin(), range.end(), BEGIN(a), [this, scalar = startScalar](int i) {
|
||||||
return a[i] + b[i] + scalar * c[i];
|
return a[i] + b[i] + scalar * c[i];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,17 +25,22 @@ public:
|
|||||||
using difference_type = N;
|
using difference_type = N;
|
||||||
using value_type = N;
|
using value_type = N;
|
||||||
using pointer = const N*;
|
using pointer = const N*;
|
||||||
using reference = const N&;
|
using reference = N;
|
||||||
using iterator_category = std::random_access_iterator_tag;
|
using iterator_category = std::random_access_iterator_tag;
|
||||||
|
|
||||||
|
// XXX This is not part of the iterator spec, it gets picked up by oneDPL if enabled.
|
||||||
|
// Without this, the DPL SYCL backend collects the iterator data on the host and copies to the device.
|
||||||
|
// This type is unused for any nother STL impl.
|
||||||
|
using is_passed_directly = std::true_type;
|
||||||
|
|
||||||
reference operator *() const { return i_; }
|
reference operator *() const { return i_; }
|
||||||
const iterator &operator ++() { ++i_; return *this; }
|
iterator &operator ++() { ++i_; return *this; }
|
||||||
iterator operator ++(int) { iterator copy(*this); ++i_; return copy; }
|
iterator operator ++(int) { iterator copy(*this); ++i_; return copy; }
|
||||||
|
|
||||||
const iterator &operator --() { --i_; return *this; }
|
iterator &operator --() { --i_; return *this; }
|
||||||
iterator operator --(int) { iterator copy(*this); --i_; return copy; }
|
iterator operator --(int) { iterator copy(*this); --i_; return copy; }
|
||||||
|
|
||||||
const iterator &operator +=(N by) { i_+=by; return *this; }
|
iterator &operator +=(N by) { i_+=by; return *this; }
|
||||||
|
|
||||||
value_type operator[](const difference_type &i) const { return i_ + i; }
|
value_type operator[](const difference_type &i) const { return i_ + i; }
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user