From c8bc33ec8e666450838a984136de319177e1819f Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Mon, 18 Nov 2024 17:05:47 +0100 Subject: [PATCH] Revert "Merge pull request #1321 from msimberg/transform-mpi-lifetimes" This reverts commit 6c9fdf1b6da3f170e64f05ded15205cb50708828, reversing changes made to 22d5654bd575bb66e3750c2bf5b4dc5e90e3a04c. --- .../include/pika/async_mpi/dispatch_mpi.hpp | 3 +- .../include/pika/async_mpi/transform_mpi.hpp | 17 ++++------- .../tests/unit/algorithm_transform_mpi.cpp | 30 ++----------------- .../include/pika/config/compiler_specific.hpp | 10 ++----- 4 files changed, 12 insertions(+), 48 deletions(-) diff --git a/libs/pika/async_mpi/include/pika/async_mpi/dispatch_mpi.hpp b/libs/pika/async_mpi/include/pika/async_mpi/dispatch_mpi.hpp index a1bc641e1..dc8a6ba63 100644 --- a/libs/pika/async_mpi/include/pika/async_mpi/dispatch_mpi.hpp +++ b/libs/pika/async_mpi/include/pika/async_mpi/dispatch_mpi.hpp @@ -237,8 +237,9 @@ namespace pika::mpi::experimental { friend constexpr PIKA_FORCEINLINE auto tag_fallback_invoke(dispatch_mpi_t, Sender&& sender, F&& f) { - return detail::dispatch_mpi_sender{ + auto snd1 = detail::dispatch_mpi_sender{ PIKA_FORWARD(Sender, sender), PIKA_FORWARD(F, f)}; + return pika::execution::experimental::make_unique_any_sender(std::move(snd1)); } template diff --git a/libs/pika/async_mpi/include/pika/async_mpi/transform_mpi.hpp b/libs/pika/async_mpi/include/pika/async_mpi/transform_mpi.hpp index 7472b6925..7fd6137c6 100644 --- a/libs/pika/async_mpi/include/pika/async_mpi/transform_mpi.hpp +++ b/libs/pika/async_mpi/include/pika/async_mpi/transform_mpi.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -53,7 +52,6 @@ namespace pika::mpi::experimental { using pika::execution::experimental::just; using pika::execution::experimental::let_value; using pika::execution::experimental::unique_any_sender; - using pika::execution::experimental::unpack; // get mpi completion mode settings auto mode = get_completion_mode(); @@ -80,19 +78,14 @@ namespace pika::mpi::experimental { if (requests_inline) { - return std::forward(sender) | - let_value([=, f = std::forward(f)](auto&... args) mutable { - return just(std::forward_as_tuple(args...)) | ex::unpack() | - dispatch_mpi(std::move(f)) | let_value(completion_snd); - }); + return dispatch_mpi_sender{PIKA_MOVE(sender), PIKA_FORWARD(F, f)} | + let_value(completion_snd); } else { - return std::forward(sender) | continues_on(mpi_pool_scheduler(p)) | - let_value([=, f = std::forward(f)](auto&... args) mutable { - return just(std::forward_as_tuple(args...)) | ex::unpack() | - dispatch_mpi(std::move(f)) | let_value(completion_snd); - }); + auto snd0 = PIKA_FORWARD(Sender, sender) | continues_on(mpi_pool_scheduler(p)); + return dispatch_mpi_sender{PIKA_MOVE(snd0), PIKA_FORWARD(F, f)} | + let_value(completion_snd); } } diff --git a/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp b/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp index dd69e2ff2..c4093ede9 100644 --- a/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp +++ b/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp @@ -200,38 +200,14 @@ int pika_main() PIKA_TEST_EQ(data, 42); } - // Values passed to transform_mpi should be kept alive by transform_mpi itself - { - int count = 1 << 20; - auto s = ex::just(std::vector{count, 0}, datatype, 0, comm) | - ex::drop_operation_state() | - mpi::transform_mpi([](auto& data, MPI_Datatype datatype, int i, MPI_Comm comm, - MPI_Request* request) { - MPI_Ibcast(data.data(), data.size(), datatype, i, comm, request); - }); - tt::sync_wait(PIKA_MOVE(s)); - } - - { - auto s = ex::just(custom_type_non_default_constructible_non_copyable{42}, datatype, - 0, comm) | - ex::drop_operation_state() | - mpi::transform_mpi([](auto& data, MPI_Datatype datatype, int i, MPI_Comm comm, - MPI_Request* request) { - MPI_Ibcast(&data.x, 1, datatype, i, comm, request); - }); - tt::sync_wait(PIKA_MOVE(s)); - } - // transform_mpi should be able to handle reference types (by copying // them to the operation state) { int data = 0, count = 1; if (rank == 0) { data = 42; } - auto s = mpi::transform_mpi(const_reference_sender{count}, - [&](int& count_transform_mpi, MPI_Request* request) { - PIKA_TEST(&count_transform_mpi != &count); - MPI_Ibcast(&data, count_transform_mpi, datatype, 0, comm, request); + auto s = mpi::transform_mpi( + const_reference_sender{count}, [&](int& count, MPI_Request* request) { + MPI_Ibcast(&data, count, datatype, 0, comm, request); }); tt::sync_wait(PIKA_MOVE(s)); PIKA_TEST_EQ(data, 42); diff --git a/libs/pika/config/include/pika/config/compiler_specific.hpp b/libs/pika/config/include/pika/config/compiler_specific.hpp index 2b851fa98..1526da789 100644 --- a/libs/pika/config/include/pika/config/compiler_specific.hpp +++ b/libs/pika/config/include/pika/config/compiler_specific.hpp @@ -162,20 +162,14 @@ #endif // clang-format on -# if !defined(__has_feature) -# define PIKA_HAS_FEATURE(x) 0 -# else -# define PIKA_HAS_FEATURE(x) __has_feature(x) -# endif - # if defined(PIKA_HAVE_SANITIZERS) -# if defined(__SANITIZE_ADDRESS__) || PIKA_HAS_FEATURE(address_sanitizer) +# if defined(__SANITIZE_ADDRESS__) || (defined(__has_feature) && __has_feature(address_sanitizer)) # define PIKA_HAVE_ADDRESS_SANITIZER # if defined(PIKA_GCC_VERSION) || defined(PIKA_CLANG_VERSION) # define PIKA_NO_SANITIZE_ADDRESS __attribute__((no_sanitize("address"))) # endif # endif -# if defined(__SANITIZE_THREAD__) || PIKA_HAS_FEATURE(thread_sanitizer) +# if defined(__SANITIZE_THREAD__) || (defined(__has_feature) && __has_feature(thread_sanitizer)) # define PIKA_HAVE_THREAD_SANITIZER # if defined(PIKA_GCC_VERSION) || defined(PIKA_CLANG_VERSION) # define PIKA_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))