From 7140b857e15849db62d6970ad4ef6f182e270639 Mon Sep 17 00:00:00 2001 From: isidorostsa Date: Mon, 10 Jun 2024 14:23:25 -0500 Subject: [PATCH] make mpi transform sender conform to p2300 --- .../include/hpx/async_mpi/transform_mpi.hpp | 66 +++++++++++++++++-- .../hpx/execution_base/stdexec_forward.hpp | 1 + 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/libs/core/async_mpi/include/hpx/async_mpi/transform_mpi.hpp b/libs/core/async_mpi/include/hpx/async_mpi/transform_mpi.hpp index 6264c273b778..1ee16a310755 100644 --- a/libs/core/async_mpi/include/hpx/async_mpi/transform_mpi.hpp +++ b/libs/core/async_mpi/include/hpx/async_mpi/transform_mpi.hpp @@ -146,12 +146,68 @@ namespace hpx { namespace mpi { namespace experimental { template struct transform_mpi_sender { -#ifdef HPX_HAVE_STDEXEC - using is_sender = void; -#endif HPX_NO_UNIQUE_ADDRESS std::decay_t s; HPX_NO_UNIQUE_ADDRESS std::decay_t f; + +#ifdef HPX_HAVE_STDEXEC + using is_sender = void; + + template + struct invoke_function_transformation_helper + { + template + struct set_value_void_checked + { + using type = hpx::execution::experimental::set_value_t(T); + }; + + template + struct set_value_void_checked + { + using type = hpx::execution::experimental::set_value_t(); + }; + + static_assert(hpx::is_invocable_v, + "F not invocable with the value_types specified."); + + using result_type = + hpx::util::invoke_result_t; + using set_value_result_type = + typename set_value_void_checked, + result_type>::type; + using type = + hpx::execution::experimental::completion_signatures< + set_value_result_type>; + }; + + template + using invoke_function_transformation = + invoke_function_transformation_helper::type; + + template + using default_set_error = + hpx::execution::experimental::completion_signatures< + hpx::execution::experimental::set_error_t(Err)>; + + using no_set_stopped_signature = + hpx::execution::experimental::completion_signatures<>; + + // clang-format off + template + friend auto tag_invoke( + hpx::execution::experimental::get_completion_signatures_t, + transform_mpi_sender const&, Env const&) + -> hpx::execution::experimental::transform_completion_signatures_of< + Sender, Env, + hpx::execution::experimental::completion_signatures< + hpx::execution::experimental::set_error_t(std::exception_ptr) + >, + invoke_function_transformation, + default_set_error, + no_set_stopped_signature + >{}; +#else template struct generate_completion_signatures { @@ -192,7 +248,9 @@ namespace hpx { namespace mpi { namespace experimental { friend auto tag_invoke( hpx::execution::experimental::get_completion_signatures_t, transform_mpi_sender const&, Env) - -> generate_completion_signatures; + -> generate_completion_signatures; + // clang-format on +#endif template friend constexpr auto tag_invoke( diff --git a/libs/core/execution_base/include/hpx/execution_base/stdexec_forward.hpp b/libs/core/execution_base/include/hpx/execution_base/stdexec_forward.hpp index a596c756fe0d..314b0e9c298c 100644 --- a/libs/core/execution_base/include/hpx/execution_base/stdexec_forward.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/stdexec_forward.hpp @@ -211,6 +211,7 @@ namespace hpx::execution::experimental { using stdexec::make_completion_signatures; using stdexec::transform_completion_signatures_of; + using stdexec::transform_completion_signatures; // Transform sender using stdexec::transform_env;