Skip to content

Commit 3758404

Browse files
[SYCL][Reduction][NFCI] Make atomic_ref arg in atomic functor a move (#8194)
This commit changes the first parameter in the AtomicFunctor function object of atomic_combine_impl an rvalue reference and std::move the atomic_ref when calling it. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 5e86a41 commit 3758404

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

sycl/include/sycl/reduction.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ template <class Reducer> class combiner {
238238
auto AtomicRef = sycl::atomic_ref<T, memory_order::relaxed,
239239
getMemoryScope<Space>(), Space>(
240240
address_space_cast<Space, access::decorated::no>(ReduVarPtr)[E]);
241-
Functor(AtomicRef, reducer->getElement(E));
241+
Functor(std::move(AtomicRef), reducer->getElement(E));
242242
}
243243
}
244244

@@ -258,7 +258,7 @@ template <class Reducer> class combiner {
258258
IsPlus<_T, _BinaryOperation>::value>
259259
atomic_combine(_T *ReduVarPtr) const {
260260
atomic_combine_impl<Space>(
261-
ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_add(Val); });
261+
ReduVarPtr, [](auto &&Ref, auto Val) { return Ref.fetch_add(Val); });
262262
}
263263

264264
/// Atomic BITWISE OR operation: *ReduVarPtr |= MValue;
@@ -269,7 +269,7 @@ template <class Reducer> class combiner {
269269
IsBitOR<_T, _BinaryOperation>::value>
270270
atomic_combine(_T *ReduVarPtr) const {
271271
atomic_combine_impl<Space>(
272-
ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_or(Val); });
272+
ReduVarPtr, [](auto &&Ref, auto Val) { return Ref.fetch_or(Val); });
273273
}
274274

275275
/// Atomic BITWISE XOR operation: *ReduVarPtr ^= MValue;
@@ -280,7 +280,7 @@ template <class Reducer> class combiner {
280280
IsBitXOR<_T, _BinaryOperation>::value>
281281
atomic_combine(_T *ReduVarPtr) const {
282282
atomic_combine_impl<Space>(
283-
ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_xor(Val); });
283+
ReduVarPtr, [](auto &&Ref, auto Val) { return Ref.fetch_xor(Val); });
284284
}
285285

286286
/// Atomic BITWISE AND operation: *ReduVarPtr &= MValue;
@@ -293,7 +293,7 @@ template <class Reducer> class combiner {
293293
Space == access::address_space::local_space)>
294294
atomic_combine(_T *ReduVarPtr) const {
295295
atomic_combine_impl<Space>(
296-
ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_and(Val); });
296+
ReduVarPtr, [](auto &&Ref, auto Val) { return Ref.fetch_and(Val); });
297297
}
298298

299299
/// Atomic MIN operation: *ReduVarPtr = sycl::minimum(*ReduVarPtr, MValue);
@@ -305,7 +305,7 @@ template <class Reducer> class combiner {
305305
IsMinimum<_T, _BinaryOperation>::value>
306306
atomic_combine(_T *ReduVarPtr) const {
307307
atomic_combine_impl<Space>(
308-
ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_min(Val); });
308+
ReduVarPtr, [](auto &&Ref, auto Val) { return Ref.fetch_min(Val); });
309309
}
310310

311311
/// Atomic MAX operation: *ReduVarPtr = sycl::maximum(*ReduVarPtr, MValue);
@@ -317,7 +317,7 @@ template <class Reducer> class combiner {
317317
IsMaximum<_T, _BinaryOperation>::value>
318318
atomic_combine(_T *ReduVarPtr) const {
319319
atomic_combine_impl<Space>(
320-
ReduVarPtr, [](auto Ref, auto Val) { return Ref.fetch_max(Val); });
320+
ReduVarPtr, [](auto &&Ref, auto Val) { return Ref.fetch_max(Val); });
321321
}
322322
};
323323
} // namespace detail

0 commit comments

Comments
 (0)