Skip to content

Commit

Permalink
Replace PIKA_FORWARD with std::forward again
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Nov 11, 2024
1 parent a41e79a commit ba7fcf2
Show file tree
Hide file tree
Showing 71 changed files with 468 additions and 492 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace pika::detail {
template <typename U, typename... Args>
void construct(U* p, Args&&... args)
{
::new ((void*) p) U(PIKA_FORWARD(Args, args)...);
::new ((void*) p) U(std::forward<Args>(args)...);
}

template <typename U>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace pika::detail {
template <typename U, typename... Args>
void construct(U* p, Args&&... args)
{
::new ((void*) p) U(PIKA_FORWARD(Args, args)...);
::new ((void*) p) U(std::forward<Args>( args)...);
}

template <typename U>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace pika::cuda::experimental {
template <typename Receiver_>
operation_state(cuda_scheduler scheduler, Receiver_&& receiver)
: scheduler(std::move(scheduler))
, receiver(PIKA_FORWARD(Receiver_, receiver))
, receiver(std::forward<Receiver_>(receiver))
{
}
operation_state(operation_state&&) = delete;
Expand Down Expand Up @@ -131,14 +131,14 @@ namespace pika::cuda::experimental {
friend operation_state<Receiver> tag_invoke(pika::execution::experimental::connect_t,
cuda_scheduler_sender&& s, Receiver&& receiver)
{
return {std::move(s.scheduler), PIKA_FORWARD(Receiver, receiver)};
return {std::move(s.scheduler), std::forward<Receiver>(receiver)};
}

template <typename Receiver>
friend operation_state<Receiver> tag_invoke(pika::execution::experimental::connect_t,
cuda_scheduler_sender const& s, Receiver&& receiver)
{
return {s.scheduler, PIKA_FORWARD(Receiver, receiver)};
return {s.scheduler, std::forward<Receiver>(receiver)};
}

struct env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ namespace pika::cuda::experimental {
template <typename Shape>
auto shape_size_impl(std::false_type, Shape&& shape)
{
return pika::util::size(PIKA_FORWARD(Shape, shape));
return pika::util::size(std::forward<Shape>(shape));
}

template <typename Shape>
auto shape_size(Shape&& shape)
{
return shape_size_impl(
std::is_integral<std::decay_t<Shape>>{}, PIKA_FORWARD(Shape, shape));
std::is_integral<std::decay_t<Shape>>{}, std::forward<Shape>(shape));
}

#if defined(PIKA_COMPUTE_CODE)
Expand All @@ -65,7 +65,7 @@ namespace pika::cuda::experimental {
PIKA_DEVICE auto shape_dereference(Shape&& shape, int i)
{
return shape_dereference_impl(
std::is_integral<std::decay_t<Shape>>{}, PIKA_FORWARD(Shape, shape), i);
std::is_integral<std::decay_t<Shape>>{}, std::forward<Shape>(shape), i);
}

template <typename F, typename Shape, typename Size, typename... Ts>
Expand Down Expand Up @@ -142,7 +142,7 @@ namespace pika::cuda::experimental {
decltype(auto) tag_invoke(pika::execution::experimental::bulk_t, cuda_scheduler,
Sender&& sender, Shape&& shape, F&& f)
{
return then_with_stream(PIKA_FORWARD(Sender, sender),
detail::bulk_launcher<Shape, F>{PIKA_FORWARD(Shape, shape), PIKA_FORWARD(F, f)});
return then_with_stream(std::forward<Sender>(sender),
detail::bulk_launcher<Shape, F>{std::forward<Shape>(shape), std::forward<F>(f)});
}
} // namespace pika::cuda::experimental
80 changes: 40 additions & 40 deletions libs/pika/async_cuda/include/pika/async_cuda/then_with_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@
namespace pika::cuda::experimental::then_with_stream_detail {
template <typename F, typename... Ts>
auto invoke_with_thread_local_cublas_handle(cuda_scheduler& sched, cuda_stream const& stream,
cublasPointerMode_t pointer_mode, F&& f, Ts&&... ts)
-> decltype(PIKA_INVOKE(
PIKA_FORWARD(F, f), std::declval<cublasHandle_t>(), PIKA_FORWARD(Ts, ts)...))
cublasPointerMode_t pointer_mode, F&& f,
Ts&&... ts) -> decltype(PIKA_INVOKE(std::forward<F>(f), std::declval<cublasHandle_t>(),
std::forward<Ts>(ts)...))
{
auto locked_handle = sched.get_cublas_handle(stream, pointer_mode);
return PIKA_INVOKE(PIKA_FORWARD(F, f), locked_handle.get().get(), PIKA_FORWARD(Ts, ts)...);
return PIKA_INVOKE(std::forward<F>(f), locked_handle.get().get(), std::forward<Ts>(ts)...);
}

template <typename F, typename... Ts>
auto invoke_with_thread_local_cusolver_handle(cuda_scheduler& sched, cuda_stream const& stream,
F&& f, Ts&&... ts) -> decltype(PIKA_INVOKE(PIKA_FORWARD(F, f),
std::declval<cusolverDnHandle_t>(), PIKA_FORWARD(Ts, ts)...))
F&& f, Ts&&... ts) -> decltype(PIKA_INVOKE(std::forward<F>(f),
std::declval<cusolverDnHandle_t>(), std::forward<Ts>(ts)...))
{
auto locked_handle = sched.get_cusolver_handle(stream);
return PIKA_INVOKE(PIKA_FORWARD(F, f), locked_handle.get().get(), PIKA_FORWARD(Ts, ts)...);
return PIKA_INVOKE(std::forward<F>(f), locked_handle.get().get(), std::forward<Ts>(ts)...);
}

template <typename R, typename... Ts>
Expand All @@ -63,11 +63,11 @@ namespace pika::cuda::experimental::then_with_stream_detail {

if (status == whip::success)
{
pika::execution::experimental::set_value(PIKA_FORWARD(R, r), PIKA_FORWARD(Ts, ts)...);
pika::execution::experimental::set_value(std::forward<R>(r), std::forward<Ts>(ts)...);
}
else
{
pika::execution::experimental::set_error(PIKA_FORWARD(R, r),
pika::execution::experimental::set_error(std::forward<R>(r),
std::make_exception_ptr(pika::exception(pika::error::unknown_error,
fmt::format(
"Getting event after CUDA stream transform failed with status {} ({})",
Expand Down Expand Up @@ -137,8 +137,8 @@ namespace pika::cuda::experimental::then_with_stream_detail {

template <typename Sender_, typename F_>
then_with_cuda_stream_sender_type(Sender_&& sender, F_&& f, cuda_scheduler sched)
: sender(PIKA_FORWARD(Sender_, sender))
, f(PIKA_FORWARD(F_, f))
: sender(std::forward<Sender_>(sender))
, f(std::forward<F_>(f))
, sched(std::move(sched))
{
}
Expand Down Expand Up @@ -239,7 +239,7 @@ namespace pika::cuda::experimental::then_with_stream_detail {
then_with_cuda_stream_receiver&& r, Error&& error) noexcept
{
pika::execution::experimental::set_error(
std::move(r.op_state.receiver), PIKA_FORWARD(Error, error));
std::move(r.op_state.receiver), std::forward<Error>(error));
}

friend void tag_invoke(pika::execution::experimental::set_stopped_t,
Expand All @@ -256,7 +256,7 @@ namespace pika::cuda::experimental::then_with_stream_detail {
pika::detail::try_catch_exception_ptr(
[&]() mutable {
using ts_element_type = std::tuple<std::decay_t<Ts>...>;
op_state.ts.template emplace<ts_element_type>(PIKA_FORWARD(Ts, ts)...);
op_state.ts.template emplace<ts_element_type>(std::forward<Ts>(ts)...);
[[maybe_unused]] auto& t = std::get<ts_element_type>(op_state.ts);

if (!op_state.stream)
Expand Down Expand Up @@ -389,16 +389,16 @@ namespace pika::cuda::experimental::then_with_stream_detail {
// matches the argument list").
template <typename... Ts>
friend auto tag_invoke(pika::execution::experimental::set_value_t,
then_with_cuda_stream_receiver&& r, Ts&&... ts) noexcept
-> decltype(r.set_value(PIKA_FORWARD(Ts, ts)...))
then_with_cuda_stream_receiver&& r,
Ts&&... ts) noexcept -> decltype(r.set_value(std::forward<Ts>(ts)...))
{
// nvcc fails to compile this with std::forward<Ts>(ts)... or
// static_cast<Ts&&>(ts)... so we explicitly use
// static_cast<decltype(ts)>(ts)... as a workaround.
#if defined(PIKA_HAVE_CUDA)
r.set_value(static_cast<decltype(ts)&&>(ts)...);
#else
r.set_value(PIKA_FORWARD(Ts, ts)...);
r.set_value(std::forward<Ts>(ts)...);
#endif
}

Expand Down Expand Up @@ -481,11 +481,11 @@ namespace pika::cuda::experimental::then_with_stream_detail {

template <typename Receiver_, typename F_, typename Sender_>
operation_state(Receiver_&& receiver, F_&& f, cuda_scheduler sched, Sender_&& sender)
: receiver(PIKA_FORWARD(Receiver_, receiver))
, f(PIKA_FORWARD(F_, f))
: receiver(std::forward<Receiver_>(receiver))
, f(std::forward<F_>(f))
, sched(std::move(sched))
, op_state(pika::execution::experimental::connect(
PIKA_FORWARD(Sender_, sender), then_with_cuda_stream_receiver{*this}))
std::forward<Sender_>(sender), then_with_cuda_stream_receiver{*this}))
{
}

Expand All @@ -500,7 +500,7 @@ namespace pika::cuda::experimental::then_with_stream_detail {
friend auto tag_invoke(pika::execution::experimental::connect_t,
then_with_cuda_stream_sender_type&& s, Receiver&& receiver)
{
return operation_state<Receiver>(PIKA_FORWARD(Receiver, receiver), std::move(s.f),
return operation_state<Receiver>(std::forward<Receiver>(receiver), std::move(s.f),
std::move(s.sched), std::move(s.sender));
}

Expand All @@ -509,7 +509,7 @@ namespace pika::cuda::experimental::then_with_stream_detail {
then_with_cuda_stream_sender_type const& s, Receiver&& receiver)
{
return operation_state<Receiver>(
PIKA_FORWARD(Receiver, receiver), s.f, s.sched, s.sender);
std::forward<Receiver>(receiver), s.f, s.sched, s.sender);
}

friend auto tag_invoke(pika::execution::experimental::get_env_t,
Expand All @@ -532,7 +532,7 @@ namespace pika::cuda::experimental::then_with_stream_detail {
"cuda_scheduler");

return then_with_stream_detail::then_with_cuda_stream_sender<Sender, F>{
PIKA_FORWARD(Sender, sender), PIKA_FORWARD(F, f), std::move(completion_sched)};
std::forward<Sender>(sender), std::forward<F>(f), std::move(completion_sched)};
}

// This is a wrapper for functions that expect a cudaStream_t in the last
Expand All @@ -546,11 +546,11 @@ namespace pika::cuda::experimental::then_with_stream_detail {
auto operator()(cuda_scheduler&, cuda_stream const& stream, Ts&&... ts)
// nvcc does not compile this correctly with noexcept(...)
#if defined(PIKA_CLANG_VERSION)
noexcept(noexcept(PIKA_INVOKE(f, PIKA_FORWARD(Ts, ts)..., stream.get())))
noexcept(noexcept(PIKA_INVOKE(f, std::forward<Ts>(ts)..., stream.get())))
#endif
-> decltype(PIKA_INVOKE(f, PIKA_FORWARD(Ts, ts)..., stream.get()))
-> decltype(PIKA_INVOKE(f, std::forward<Ts>(ts)..., stream.get()))
{
return PIKA_INVOKE(f, PIKA_FORWARD(Ts, ts)..., stream.get());
return PIKA_INVOKE(f, std::forward<Ts>(ts)..., stream.get());
}
};

Expand All @@ -567,13 +567,13 @@ namespace pika::cuda::experimental::then_with_stream_detail {
// nvcc does not compile this correctly with noexcept(...)
#if defined(PIKA_CLANG_VERSION)
noexcept(noexcept(invoke_with_thread_local_cublas_handle(
sched, stream, pointer_mode, f, PIKA_FORWARD(Ts, ts)...)))
sched, stream, pointer_mode, f, std::forward<Ts>(ts)...)))
#endif
-> decltype(invoke_with_thread_local_cublas_handle(
sched, stream, pointer_mode, f, PIKA_FORWARD(Ts, ts)...))
sched, stream, pointer_mode, f, std::forward<Ts>(ts)...))
{
return invoke_with_thread_local_cublas_handle(
sched, stream, pointer_mode, f, PIKA_FORWARD(Ts, ts)...);
sched, stream, pointer_mode, f, std::forward<Ts>(ts)...);
}
};

Expand All @@ -589,13 +589,13 @@ namespace pika::cuda::experimental::then_with_stream_detail {
// nvcc does not compile this correctly with noexcept(...)
#if defined(PIKA_CLANG_VERSION)
noexcept(noexcept(invoke_with_thread_local_cusolver_handle(
sched, stream, f, PIKA_FORWARD(Ts, ts)...)))
sched, stream, f, std::forward<Ts>(ts)...)))
#endif
-> decltype(invoke_with_thread_local_cusolver_handle(
sched, stream, f, PIKA_FORWARD(Ts, ts)...))
sched, stream, f, std::forward<Ts>(ts)...))
{
return invoke_with_thread_local_cusolver_handle(
sched, stream, f, PIKA_FORWARD(Ts, ts)...);
sched, stream, f, std::forward<Ts>(ts)...);
}
};
} // namespace pika::cuda::experimental::then_with_stream_detail
Expand Down Expand Up @@ -623,15 +623,15 @@ namespace pika::cuda::experimental {
template <typename Sender, typename F>
constexpr PIKA_FORCEINLINE auto PIKA_STATIC_CALL_OPERATOR(Sender&& sender, F&& f)
{
return then_with_stream_detail::then_with_cuda_stream(PIKA_FORWARD(Sender, sender),
then_with_stream_detail::cuda_stream_callable<F>{PIKA_FORWARD(F, f)});
return then_with_stream_detail::then_with_cuda_stream(std::forward<Sender>(sender),
then_with_stream_detail::cuda_stream_callable<F>{std::forward<F>(f)});
}

template <typename F>
constexpr PIKA_FORCEINLINE auto PIKA_STATIC_CALL_OPERATOR(F&& f)
{
return pika::execution::experimental::detail::partial_algorithm<then_with_stream_t, F>{
PIKA_FORWARD(F, f)};
std::forward<F>(f)};
}
} then_with_stream{};

Expand All @@ -649,17 +649,17 @@ namespace pika::cuda::experimental {
constexpr PIKA_FORCEINLINE auto
PIKA_STATIC_CALL_OPERATOR(Sender&& sender, F&& f, cublasPointerMode_t pointer_mode)
{
return then_with_stream_detail::then_with_cuda_stream(PIKA_FORWARD(Sender, sender),
return then_with_stream_detail::then_with_cuda_stream(std::forward<Sender>(sender),
then_with_stream_detail::cublas_handle_callable<F>{
PIKA_FORWARD(F, f), pointer_mode});
std::forward<F>(f), pointer_mode});
}

template <typename F>
constexpr PIKA_FORCEINLINE auto
PIKA_STATIC_CALL_OPERATOR(F&& f, cublasPointerMode_t pointer_mode)
{
return pika::execution::experimental::detail::partial_algorithm<then_with_cublas_t, F,
cublasPointerMode_t>{PIKA_FORWARD(F, f), pointer_mode};
cublasPointerMode_t>{std::forward<F>(f), pointer_mode};
}
} then_with_cublas{};

Expand All @@ -676,15 +676,15 @@ namespace pika::cuda::experimental {
template <typename Sender, typename F>
constexpr PIKA_FORCEINLINE auto PIKA_STATIC_CALL_OPERATOR(Sender&& sender, F&& f)
{
return then_with_stream_detail::then_with_cuda_stream(PIKA_FORWARD(Sender, sender),
then_with_stream_detail::cusolver_handle_callable<F>{PIKA_FORWARD(F, f)});
return then_with_stream_detail::then_with_cuda_stream(std::forward<Sender>(sender),
then_with_stream_detail::cusolver_handle_callable<F>{std::forward<F>(f)});
}

template <typename F>
constexpr PIKA_FORCEINLINE auto PIKA_STATIC_CALL_OPERATOR(F&& f)
{
return pika::execution::experimental::detail::partial_algorithm<then_with_cusolver_t,
F>{PIKA_FORWARD(F, f)};
F>{std::forward<F>(f)};
}
} then_with_cusolver{};
} // namespace pika::cuda::experimental
16 changes: 8 additions & 8 deletions libs/pika/async_mpi/include/pika/async_mpi/dispatch_mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ namespace pika::mpi::experimental::detail {
friend constexpr void
tag_invoke(ex::set_error_t, dispatch_mpi_receiver r, Error&& error) noexcept
{
ex::set_error(std::move(r.op_state.receiver), PIKA_FORWARD(Error, error));
ex::set_error(std::move(r.op_state.receiver), std::forward<Error>(error));
}

friend constexpr void tag_invoke(
Expand Down Expand Up @@ -195,9 +195,9 @@ namespace pika::mpi::experimental::detail {

template <typename Receiver_, typename F_, typename Sender_>
operation_state(Receiver_&& receiver, F_&& f, Sender_&& sender)
: receiver(PIKA_FORWARD(Receiver_, receiver))
, f(PIKA_FORWARD(F_, f))
, op_state(ex::connect(PIKA_FORWARD(Sender_, sender), dispatch_mpi_receiver{*this}))
: receiver(std::forward<Receiver_>(receiver))
, f(std::forward<F_>(f))
, op_state(ex::connect(std::forward<Sender_>(sender), dispatch_mpi_receiver{*this}))
{
PIKA_DETAIL_DP(mpi_tran<5>, debug(str<>("operation_state")));
}
Expand All @@ -212,15 +212,15 @@ namespace pika::mpi::experimental::detail {
friend constexpr auto
tag_invoke(ex::connect_t, dispatch_mpi_sender_type const& s, Receiver&& receiver)
{
return operation_state<Receiver>(PIKA_FORWARD(Receiver, receiver), s.f, s.sender);
return operation_state<Receiver>(std::forward<Receiver>(receiver), s.f, s.sender);
}

template <typename Receiver>
friend constexpr auto
tag_invoke(ex::connect_t, dispatch_mpi_sender_type&& s, Receiver&& receiver)
{
return operation_state<Receiver>(
PIKA_FORWARD(Receiver, receiver), std::move(s.f), std::move(s.sender));
std::forward<Receiver>(receiver), std::move(s.f), std::move(s.sender));
}
};

Expand All @@ -238,15 +238,15 @@ namespace pika::mpi::experimental {
tag_fallback_invoke(dispatch_mpi_t, Sender&& sender, F&& f)
{
auto snd1 = detail::dispatch_mpi_sender<Sender, F>{
PIKA_FORWARD(Sender, sender), PIKA_FORWARD(F, f)};
std::forward<Sender>(sender), std::forward<F>(f)};
return pika::execution::experimental::make_unique_any_sender(std::move(snd1));
}

template <typename F>
friend constexpr PIKA_FORCEINLINE auto tag_fallback_invoke(dispatch_mpi_t, F&& f)
{
return pika::execution::experimental::detail::partial_algorithm<dispatch_mpi_t, F>{
PIKA_FORWARD(F, f)};
std::forward<F>(f)};
}

} dispatch_mpi{};
Expand Down
4 changes: 2 additions & 2 deletions libs/pika/async_mpi/include/pika/async_mpi/mpi_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ namespace pika::mpi::experimental::detail {
static_assert(sizeof...(Ts) <= 1, "Expecting at most one value");
if (mpi_status == MPI_SUCCESS)
{
ex::set_value(PIKA_FORWARD(Receiver, receiver), PIKA_FORWARD(Ts, ts)...);
ex::set_value(std::forward<Receiver>(receiver), std::forward<Ts>(ts)...);
}
else
{
ex::set_error(PIKA_FORWARD(Receiver, receiver),
ex::set_error(std::forward<Receiver>(receiver),
std::make_exception_ptr(mpi::exception(mpi_status, "set_error handler")));
}
}
Expand Down
Loading

0 comments on commit ba7fcf2

Please sign in to comment.