diff --git a/src/std-indices/STDIndicesStream.cpp b/src/std-indices/STDIndicesStream.cpp index 4ec9977..7cacde3 100644 --- a/src/std-indices/STDIndicesStream.cpp +++ b/src/std-indices/STDIndicesStream.cpp @@ -83,7 +83,7 @@ template void STDIndicesStream::mul() { // 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]; }); } @@ -92,7 +92,7 @@ template void STDIndicesStream::add() { // 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]; }); } @@ -101,7 +101,7 @@ template void STDIndicesStream::triad() { // 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]; }); } @@ -113,7 +113,7 @@ void STDIndicesStream::nstream() // Need to do in two stages with C++11 STL. // 1: a[i] += b[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]; }); } diff --git a/src/std-indices/STDIndicesStream.h b/src/std-indices/STDIndicesStream.h index 63254cd..a955374 100644 --- a/src/std-indices/STDIndicesStream.h +++ b/src/std-indices/STDIndicesStream.h @@ -25,17 +25,22 @@ public: using difference_type = N; using value_type = N; using pointer = const N*; - using reference = const N&; + using reference = N; 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_; } - const iterator &operator ++() { ++i_; return *this; } + iterator &operator ++() { ++i_; return *this; } 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; } - 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; }