Skip to content

Commit

Permalink
make mpi transform sender conform to p2300
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorostsa committed Jun 10, 2024
1 parent 7dee1a5 commit 7140b85
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
66 changes: 62 additions & 4 deletions libs/core/async_mpi/include/hpx/async_mpi/transform_mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,68 @@ namespace hpx { namespace mpi { namespace experimental {
template <typename Sender, typename F>
struct transform_mpi_sender
{
#ifdef HPX_HAVE_STDEXEC
using is_sender = void;
#endif
HPX_NO_UNIQUE_ADDRESS std::decay_t<Sender> s;
HPX_NO_UNIQUE_ADDRESS std::decay_t<F> f;


#ifdef HPX_HAVE_STDEXEC
using is_sender = void;

template <typename... Args>
struct invoke_function_transformation_helper
{
template <bool IsVoid, typename T>
struct set_value_void_checked
{
using type = hpx::execution::experimental::set_value_t(T);
};

template <typename T>
struct set_value_void_checked<true, T>
{
using type = hpx::execution::experimental::set_value_t();
};

static_assert(hpx::is_invocable_v<F, Args..., MPI_Request*>,
"F not invocable with the value_types specified.");

using result_type =
hpx::util::invoke_result_t<F, Args..., MPI_Request*>;
using set_value_result_type =
typename set_value_void_checked<std::is_void_v<result_type>,
result_type>::type;
using type =
hpx::execution::experimental::completion_signatures<
set_value_result_type>;
};

template <typename... Args>
using invoke_function_transformation =
invoke_function_transformation_helper<Args...>::type;

template <typename Err>
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 <typename Env>
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 <typename Env>
struct generate_completion_signatures
{
Expand Down Expand Up @@ -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<Env>;
-> generate_completion_signatures<Env>;
// clang-format on
#endif

template <typename R>
friend constexpr auto tag_invoke(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7140b85

Please sign in to comment.