From d67cfe697e2609c8ef4c31fc0d193257b663181a Mon Sep 17 00:00:00 2001 From: Allard Hendriksen Date: Fri, 28 Jul 2023 09:32:31 +0200 Subject: [PATCH] Do not move arrival_token in barrier::try_wait_* Take a mutable reference instead. Moving the token into try_wait makes no sense. The caller has to be able to retry the try wait with the same token. For more details and C++ spec, see: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2643r1.html --- .../include/cuda/std/detail/libcxx/include/__cuda/barrier.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcudacxx/include/cuda/std/detail/libcxx/include/__cuda/barrier.h b/libcudacxx/include/cuda/std/detail/libcxx/include/__cuda/barrier.h index 90a13f658f5..9a5de822d4b 100644 --- a/libcudacxx/include/cuda/std/detail/libcxx/include/__cuda/barrier.h +++ b/libcudacxx/include/cuda/std/detail/libcxx/include/__cuda/barrier.h @@ -525,7 +525,7 @@ friend class _CUDA_VSTD::__barrier_poll_tester_parity; template _LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY - bool try_wait_for(arrival_token && __token, const _CUDA_VSTD::chrono::duration<_Rep, _Period>& __dur) { + bool try_wait_for(arrival_token & __token, const _CUDA_VSTD::chrono::duration<_Rep, _Period>& __dur) { auto __nanosec = _CUDA_VSTD::chrono::duration_cast<_CUDA_VSTD::chrono::nanoseconds>(__dur); return __try_wait(_CUDA_VSTD::move(__token), __nanosec); @@ -533,7 +533,7 @@ friend class _CUDA_VSTD::__barrier_poll_tester_parity; template _LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY - bool try_wait_until(arrival_token && __token, const _CUDA_VSTD::chrono::time_point<_Clock, _Duration>& __time) { + bool try_wait_until(arrival_token & __token, const _CUDA_VSTD::chrono::time_point<_Clock, _Duration>& __time) { return try_wait_for(_CUDA_VSTD::move(__token), (__time - _Clock::now())); }