From 1798cbc4a273a6814a617c4a23ade8755a0fdd05 Mon Sep 17 00:00:00 2001 From: isidorostsa Date: Sat, 3 Feb 2024 20:30:42 +0200 Subject: [PATCH 01/47] Add Stdexec to the build system --- CMakeLists.txt | 48 ++++++++++++++++++- cmake/FindStdexec.cmake | 36 ++++++++++++++ cmake/HPX_SetupStdexec.cmake | 34 +++++++++++++ libs/core/execution_base/CMakeLists.txt | 5 ++ .../hpx/execution_base/stdexec_forward.hpp | 15 ++++++ .../execution_base/tests/unit/CMakeLists.txt | 1 + .../execution_base/tests/unit/stdexec.cpp | 24 ++++++++++ 7 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 cmake/FindStdexec.cmake create mode 100644 cmake/HPX_SetupStdexec.cmake create mode 100644 libs/core/execution_base/include/hpx/execution_base/stdexec_forward.hpp create mode 100644 libs/core/execution_base/tests/unit/stdexec.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 996c66ba25e3..28ddc523c66e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -567,6 +567,49 @@ if(HPX_WITH_CUDA AND HPX_WITH_HIP) ) endif() +# ## +# HPX STDEXEC configuration +# ## + +hpx_option( + HPX_WITH_STDEXEC + BOOL + "Use STDEXEC executors instead of native HPX.(default: OFF)" + OFF + CATEGORY "Executor" + ADVANCED +) + +hpx_option( + HPX_WITH_FETCH_STDEXEC + BOOL + "Use FetchContent to fetch STDEXEC.(default: OFF)" + OFF + CATEGORY "Executor" + ADVANCED +) + +# if STDEXEC_ROOT was provided, HPX_WITH_STDEXEC is set to ON +if(STDEXEC_ROOT OR HPX_WITH_FETCH_STDEXEC) + set(HPX_WITH_STDEXEC ON) + + hpx_add_config_define(HPX_HAVE_STDEXEC) +elseif(HPX_WITH_STDEXEC) + hpx_error( + "HPX_WITH_STDEXEC is set to ON, but STDEXEC_ROOT is not provided. Please provide STDEXEC_ROOT or set HPX_WITH_FETCH_STDEXEC to ON." + ) +endif() + +if(HPX_WITH_STDEXEC) + # need cxx20 and over + if(HPX_WITH_CXX_STANDARD LESS 20) + hpx_error( + "HPX_WITH_STDEXEC is set to ON, but HPX_WITH_CXX_STANDARD is less than 20. Please set HPX_WITH_CXX_STANDARD to 20 or higher." + ) + endif() + hpx_info("STDEXEC is enabled.") +endif() + # ############################################################################## # HPX SYCL configuration # ############################################################################## @@ -1308,7 +1351,7 @@ if(HPX_WITH_NETWORKING AND HPX_WITH_PARCELPORT_LCI) endif() endif() -# External libraries/frameworks used by sme of the examples and benchmarks +# External libraries/frameworks used by some of the examples and benchmarks hpx_option( HPX_WITH_EXAMPLES_OPENMP BOOL "Enable examples requiring OpenMP support (default: OFF)." OFF @@ -2228,6 +2271,9 @@ if(HPX_WITH_CUDA OR HPX_WITH_HIP) hpx_add_config_define(HPX_HAVE_GPU_SUPPORT) endif() +# Setup NVIDIA's stdexec if requested +include(HPX_SetupStdexec) + if(HPX_WITH_SANITIZERS) hpx_add_config_define(HPX_HAVE_SANITIZERS) endif() diff --git a/cmake/FindStdexec.cmake b/cmake/FindStdexec.cmake new file mode 100644 index 000000000000..41f463525210 --- /dev/null +++ b/cmake/FindStdexec.cmake @@ -0,0 +1,36 @@ + +if(NOT TARGET STDEXEC::stdexec) + if (STDEXEC_ROOT AND NOT Stdexec_ROOT) + set(Stdexec_ROOT ${STDEXEC_ROOT} CACHE PATH "stdexec base directory") + unset(STDEXEC_ROOT CACHE) + endif() + + find_path( + Stdexec_INCLUDE_DIR + stdexec + HINTS ${Stdexec_ROOT} + ) + + if (Stdexec_INCLUDE_DIR) + file(TO_CMAKE_PATH ${Stdexec_INCLUDE_DIR} Stdexec_INCLUDE_DIR) + else() + message(FATAL_ERROR "stdexec not found") + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( + Stdexec + REQUIRED_VARS Stdexec_INCLUDE_DIR + FOUND_VAR Stdexec_FOUND + VERSION_VAR Stdexec_VERSION + FAIL_MESSAGE "stdexec not found" + ) + + add_library(STDEXEC::stdexec INTERFACE IMPORTED) + target_include_directories(STDEXEC::stdexec SYSTEM INTERFACE ${Stdexec_INCLUDE_DIR}) + + + + + mark_as_advanced(Stdexec_INCLUDE_DIR Stdexec_ROOT) +endif() diff --git a/cmake/HPX_SetupStdexec.cmake b/cmake/HPX_SetupStdexec.cmake new file mode 100644 index 000000000000..840b4887bd68 --- /dev/null +++ b/cmake/HPX_SetupStdexec.cmake @@ -0,0 +1,34 @@ +if(STDEXEC_ROOT AND NOT Stdexec_ROOT) + set(Stdexec_ROOT + ${STDEXEC_ROOT} + CACHE PATH "STDEXEC base directory" + ) + unset(STDEXEC_ROOT CACHE) +endif() + +if(HPX_WITH_FETCH_STDEXEC AND NOT Stdexec_ROOT) + hpx_info( + "HPX_WITH_FETCH_STDEXEC=${HPX_WITH_FETCH_STDEXEC}, Stdexec will be fetched using CMake's FetchContent." + ) + if(UNIX) + include(FetchContent) + FetchContent_Declare( + Stdexec + GIT_REPOSITORY https://github.com/NVIDIA/stdexec.git + GIT_TAG main + ) + FetchContent_MakeAvailable(Stdexec) + endif() + + add_library(STDEXEC::stdexec INTERFACE IMPORTED) + target_include_directories(STDEXEC::stdexec INTERFACE ${stdexec_SOURCE_DIR}/include) + target_link_libraries(STDEXEC::stdexec INTERFACE ${Stdexec_LIBRARY}) +elseif(HPX_WITH_STDEXEC) + find_package(Stdexec REQUIRED) + + if(NOT Stdexec_FOUND) + hpx_error( + "Stdexec could not be found, please specify Stdexec_ROOT to point to the correct location" + ) + endif() +endif() \ No newline at end of file diff --git a/libs/core/execution_base/CMakeLists.txt b/libs/core/execution_base/CMakeLists.txt index 8580bc522ef0..fe36b99d0780 100644 --- a/libs/core/execution_base/CMakeLists.txt +++ b/libs/core/execution_base/CMakeLists.txt @@ -4,6 +4,8 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + set(execution_base_headers hpx/execution_base/agent_base.hpp hpx/execution_base/agent_ref.hpp @@ -19,6 +21,7 @@ set(execution_base_headers hpx/execution_base/receiver.hpp hpx/execution_base/resource_base.hpp hpx/execution_base/sender.hpp + hpx/execution_base/stdexec_forward.hpp hpx/execution_base/this_thread.hpp hpx/execution_base/traits/is_executor.hpp hpx/execution_base/traits/is_executor_parameters.hpp @@ -52,6 +55,8 @@ add_hpx_module( SOURCES ${execution_base_sources} HEADERS ${execution_base_headers} COMPAT_HEADERS ${execution_base_compat_headers} + DEPENDENCIES + STDEXEC::stdexec MODULE_DEPENDENCIES hpx_assertion hpx_config 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 new file mode 100644 index 000000000000..e673b8ac731f --- /dev/null +++ b/libs/core/execution_base/include/hpx/execution_base/stdexec_forward.hpp @@ -0,0 +1,15 @@ +// Copyright (c) 2023 Isidoros Tsaousis-Seiras +// +// SPDX-License-Identifier: BSL-1.0 +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +#if defined(HPX_HAVE_STDEXEC) +#include + +namespace hpx::execution::experimental { + using namespace stdexec; +} +#endif \ No newline at end of file diff --git a/libs/core/execution_base/tests/unit/CMakeLists.txt b/libs/core/execution_base/tests/unit/CMakeLists.txt index 7a2230c7f61a..10d0bfbfbae8 100644 --- a/libs/core/execution_base/tests/unit/CMakeLists.txt +++ b/libs/core/execution_base/tests/unit/CMakeLists.txt @@ -15,6 +15,7 @@ set(tests execution_context get_env execute_may_block_caller + stdexec ) if(HPX_WITH_CXX20_COROUTINES) diff --git a/libs/core/execution_base/tests/unit/stdexec.cpp b/libs/core/execution_base/tests/unit/stdexec.cpp new file mode 100644 index 000000000000..aa173034de5f --- /dev/null +++ b/libs/core/execution_base/tests/unit/stdexec.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2023 Isidoros Tsaousis-Seiras +// +// SPDX-License-Identifier: BSL-1.0 +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +#include + +#include + +using namespace hpx::execution::experimental; + +int main() { + auto x = just(42); + + auto [a] = sync_wait(std::move(x)).value(); + + HPX_TEST(a == 42); + + return hpx::util::report_errors(); +} \ No newline at end of file From f34103ee3335358f4d8481015347e9c1163b6b96 Mon Sep 17 00:00:00 2001 From: isidorostsa Date: Mon, 12 Feb 2024 13:27:10 +0200 Subject: [PATCH 02/47] link against hpx_core --- CMakeLists.txt | 37 ++++++++++++++-------- cmake/FindStdexec.cmake | 8 +++-- cmake/HPX_SetupStdexec.cmake | 59 +++++++++++++++++++----------------- libs/CMakeLists.txt | 9 ++++++ 4 files changed, 70 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28ddc523c66e..bf2e99ebf674 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright (c) 2020 Mikael Simberg # Copyright (c) 2007-2024 Hartmut Kaiser # Copyright (c) 2011-2014 Thomas Heller +# Copyright (c) 2024 Isidoros Tsaousis-Seiras # Copyright (c) 2007-2008 Chirag Dekate # Copyright (c) 2011 Bryce Lelbach # Copyright (c) 2011 Vinay C Amatya @@ -589,25 +590,37 @@ hpx_option( ADVANCED ) -# if STDEXEC_ROOT was provided, HPX_WITH_STDEXEC is set to ON -if(STDEXEC_ROOT OR HPX_WITH_FETCH_STDEXEC) +if(Stdexec_ROOT OR HPX_WITH_FETCH_STDEXEC) + # explicitly enable HPX_WITH_STDEXEC set(HPX_WITH_STDEXEC ON) - hpx_add_config_define(HPX_HAVE_STDEXEC) + # prefer Stdexec_ROOT over HPX_WITH_FETCH_STDEXEC by default + if(Stdexec_ROOT AND HPX_WITH_FETCH_STDEXEC) + set(HPX_WITH_FETCH_STDEXEC OFF) + hpx_warn( + "Both Stdexec_ROOT and HPX_WITH_FETCH_STDEXEC are provided. HPX_WITH_FETCH_STDEXEC is set to OFF." + ) + endif() elseif(HPX_WITH_STDEXEC) hpx_error( - "HPX_WITH_STDEXEC is set to ON, but STDEXEC_ROOT is not provided. Please provide STDEXEC_ROOT or set HPX_WITH_FETCH_STDEXEC to ON." + "HPX_WITH_STDEXEC is set to ON, but Stdexec_ROOT is not provided and HPX_WITH_FETCH_STDEXEC is not enabled. Please provide Stdexec_ROOT or set HPX_WITH_FETCH_STDEXEC to ON." ) endif() -if(HPX_WITH_STDEXEC) - # need cxx20 and over - if(HPX_WITH_CXX_STANDARD LESS 20) - hpx_error( - "HPX_WITH_STDEXEC is set to ON, but HPX_WITH_CXX_STANDARD is less than 20. Please set HPX_WITH_CXX_STANDARD to 20 or higher." - ) - endif() - hpx_info("STDEXEC is enabled.") +# STDEXEC requires C++20 +if(HPX_WITH_STDEXEC AND HPX_WITH_CXX_STANDARD LESS 20) + hpx_error( + "HPX_WITH_STDEXEC is set to ON, but HPX_WITH_CXX_STANDARD is less than 20. Please set HPX_WITH_CXX_STANDARD to 20 or higher." + ) +endif() + +if(HPX_WITH_FETCH_STDEXEC) + hpx_option( + HPX_WITH_STDEXEC_TAG + STRING "STDEXEC repository tag or branch" + "main" + CATEGORY "Executor" + ) endif() # ############################################################################## diff --git a/cmake/FindStdexec.cmake b/cmake/FindStdexec.cmake index 41f463525210..01d843162938 100644 --- a/cmake/FindStdexec.cmake +++ b/cmake/FindStdexec.cmake @@ -1,3 +1,8 @@ +# Copyright (c) 2024 Isidoros Tsaousis-Seiras +# +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) if(NOT TARGET STDEXEC::stdexec) if (STDEXEC_ROOT AND NOT Stdexec_ROOT) @@ -29,8 +34,5 @@ if(NOT TARGET STDEXEC::stdexec) add_library(STDEXEC::stdexec INTERFACE IMPORTED) target_include_directories(STDEXEC::stdexec SYSTEM INTERFACE ${Stdexec_INCLUDE_DIR}) - - - mark_as_advanced(Stdexec_INCLUDE_DIR Stdexec_ROOT) endif() diff --git a/cmake/HPX_SetupStdexec.cmake b/cmake/HPX_SetupStdexec.cmake index 840b4887bd68..28af68810e74 100644 --- a/cmake/HPX_SetupStdexec.cmake +++ b/cmake/HPX_SetupStdexec.cmake @@ -1,34 +1,37 @@ -if(STDEXEC_ROOT AND NOT Stdexec_ROOT) - set(Stdexec_ROOT - ${STDEXEC_ROOT} - CACHE PATH "STDEXEC base directory" - ) - unset(STDEXEC_ROOT CACHE) -endif() +# Copyright (c) 2024 Isidoros Tsaousis-Seiras +# +# SPDX-License-Identifier: BSL-1.0 +# Distributed under the Boost Software License, Version 1.0. (See accompanying +# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -if(HPX_WITH_FETCH_STDEXEC AND NOT Stdexec_ROOT) - hpx_info( - "HPX_WITH_FETCH_STDEXEC=${HPX_WITH_FETCH_STDEXEC}, Stdexec will be fetched using CMake's FetchContent." - ) - if(UNIX) - include(FetchContent) - FetchContent_Declare( - Stdexec - GIT_REPOSITORY https://github.com/NVIDIA/stdexec.git - GIT_TAG main +if(HPX_WITH_STDEXEC AND NOT TARGET STDEXEC::stdexec) + hpx_add_config_define(HPX_HAVE_STDEXEC) + + if(HPX_WITH_FETCH_STDEXEC) + hpx_info( + "HPX_WITH_FETCH_STDEXEC=${HPX_WITH_FETCH_STDEXEC}, Stdexec will be fetched using CMake's FetchContent." ) - FetchContent_MakeAvailable(Stdexec) - endif() + if(UNIX) + include(FetchContent) + message("FETCHING STDEXEC") + FetchContent_Declare( + Stdexec + GIT_REPOSITORY https://github.com/NVIDIA/stdexec.git + GIT_TAG ${HPX_WITH_STDEXEC_TAG} + ) + FetchContent_MakeAvailable(Stdexec) + endif() - add_library(STDEXEC::stdexec INTERFACE IMPORTED) - target_include_directories(STDEXEC::stdexec INTERFACE ${stdexec_SOURCE_DIR}/include) - target_link_libraries(STDEXEC::stdexec INTERFACE ${Stdexec_LIBRARY}) -elseif(HPX_WITH_STDEXEC) - find_package(Stdexec REQUIRED) + # add_library(STDEXEC::stdexec INTERFACE IMPORTED) + # target_include_directories(STDEXEC::stdexec INTERFACE ${stdexec_SOURCE_DIR}) + # target_link_libraries(STDEXEC::stdexec INTERFACE ${Stdexec_LIBRARY}) + else() + find_package(Stdexec REQUIRED) - if(NOT Stdexec_FOUND) - hpx_error( - "Stdexec could not be found, please specify Stdexec_ROOT to point to the correct location" - ) + if(NOT Stdexec_FOUND) + hpx_error( + "Stdexec could not be found, please specify Stdexec_ROOT to point to the correct location" + ) + endif() endif() endif() \ No newline at end of file diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 3f5e4546c3ec..e7340db5bdd5 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -113,6 +113,11 @@ if(TARGET APEX::apex) target_link_libraries(hpx_full INTERFACE APEX::apex) endif() +# Do I need this here? +# if(TARGET STDEXEC::stdexec) +# target_link_libraries(hpx_full INTERFACE STDEXEC::stdexec) +# endif() + if(TARGET Gperftools::gperftools) target_link_libraries(hpx_full PRIVATE Gperftools::gperftools) endif() @@ -376,6 +381,10 @@ if(HPX_WITH_ITTNOTIFY) target_link_libraries(hpx_core PUBLIC Amplifier::amplifier) endif() +if(TARGET STDEXEC::stdexec) + target_link_libraries(hpx_core INTERFACE STDEXEC::stdexec) +endif() + if(HPX_WITH_PARCELPORT_GASNET AND GASNET_LIBRARY_DIRS) target_link_directories(hpx_core PUBLIC ${GASNET_LIBRARY_DIRS}) endif() From cc03efd608973e0357496076a2faa5283b1f18d5 Mon Sep 17 00:00:00 2001 From: isidorostsa Date: Sat, 17 Feb 2024 17:40:07 +0200 Subject: [PATCH 03/47] move code to HPX_SetupStdexec --- CMakeLists.txt | 24 ------------------------ cmake/HPX_SetupStdexec.cmake | 24 ++++++++++++++++++++++++ libs/CMakeLists.txt | 5 ----- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf2e99ebf674..2f6b73ae5af9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -590,30 +590,6 @@ hpx_option( ADVANCED ) -if(Stdexec_ROOT OR HPX_WITH_FETCH_STDEXEC) - # explicitly enable HPX_WITH_STDEXEC - set(HPX_WITH_STDEXEC ON) - - # prefer Stdexec_ROOT over HPX_WITH_FETCH_STDEXEC by default - if(Stdexec_ROOT AND HPX_WITH_FETCH_STDEXEC) - set(HPX_WITH_FETCH_STDEXEC OFF) - hpx_warn( - "Both Stdexec_ROOT and HPX_WITH_FETCH_STDEXEC are provided. HPX_WITH_FETCH_STDEXEC is set to OFF." - ) - endif() -elseif(HPX_WITH_STDEXEC) - hpx_error( - "HPX_WITH_STDEXEC is set to ON, but Stdexec_ROOT is not provided and HPX_WITH_FETCH_STDEXEC is not enabled. Please provide Stdexec_ROOT or set HPX_WITH_FETCH_STDEXEC to ON." - ) -endif() - -# STDEXEC requires C++20 -if(HPX_WITH_STDEXEC AND HPX_WITH_CXX_STANDARD LESS 20) - hpx_error( - "HPX_WITH_STDEXEC is set to ON, but HPX_WITH_CXX_STANDARD is less than 20. Please set HPX_WITH_CXX_STANDARD to 20 or higher." - ) -endif() - if(HPX_WITH_FETCH_STDEXEC) hpx_option( HPX_WITH_STDEXEC_TAG diff --git a/cmake/HPX_SetupStdexec.cmake b/cmake/HPX_SetupStdexec.cmake index 28af68810e74..58a9cf03a069 100644 --- a/cmake/HPX_SetupStdexec.cmake +++ b/cmake/HPX_SetupStdexec.cmake @@ -4,6 +4,30 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +if(Stdexec_ROOT OR HPX_WITH_FETCH_STDEXEC) + # explicitly enable HPX_WITH_STDEXEC + set(HPX_WITH_STDEXEC ON) + + # prefer Stdexec_ROOT over HPX_WITH_FETCH_STDEXEC by default + if(Stdexec_ROOT AND HPX_WITH_FETCH_STDEXEC) + set(HPX_WITH_FETCH_STDEXEC OFF) + hpx_warn( + "Both Stdexec_ROOT and HPX_WITH_FETCH_STDEXEC are provided. HPX_WITH_FETCH_STDEXEC is set to OFF." + ) + endif() +elseif(HPX_WITH_STDEXEC) + hpx_error( + "HPX_WITH_STDEXEC is set to ON, but Stdexec_ROOT is not provided and HPX_WITH_FETCH_STDEXEC is not enabled. Please provide Stdexec_ROOT or set HPX_WITH_FETCH_STDEXEC to ON." + ) +endif() + +# STDEXEC requires C++20 +if(HPX_WITH_STDEXEC AND HPX_WITH_CXX_STANDARD LESS 20) + hpx_error( + "HPX_WITH_STDEXEC is set to ON, but HPX_WITH_CXX_STANDARD is less than 20. Please set HPX_WITH_CXX_STANDARD to 20 or higher." + ) +endif() + if(HPX_WITH_STDEXEC AND NOT TARGET STDEXEC::stdexec) hpx_add_config_define(HPX_HAVE_STDEXEC) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index e7340db5bdd5..cc4381550257 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -113,11 +113,6 @@ if(TARGET APEX::apex) target_link_libraries(hpx_full INTERFACE APEX::apex) endif() -# Do I need this here? -# if(TARGET STDEXEC::stdexec) -# target_link_libraries(hpx_full INTERFACE STDEXEC::stdexec) -# endif() - if(TARGET Gperftools::gperftools) target_link_libraries(hpx_full PRIVATE Gperftools::gperftools) endif() From 3e5bee67222c6ce19ab73142aca84c502b440e6a Mon Sep 17 00:00:00 2001 From: isidorostsa Date: Tue, 27 Feb 2024 16:46:52 +0200 Subject: [PATCH 04/47] recognize STDEXEC & Stdexec --- cmake/HPX_SetupStdexec.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/HPX_SetupStdexec.cmake b/cmake/HPX_SetupStdexec.cmake index 58a9cf03a069..05a3a7e3d943 100644 --- a/cmake/HPX_SetupStdexec.cmake +++ b/cmake/HPX_SetupStdexec.cmake @@ -4,10 +4,18 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +if(STDEXEC_ROOT AND NOT Stdexec_ROOT) + set(Stdexec_ROOT ${STDEXEC_ROOT}) + # remove STDEXEC_ROOT from the cache + unset(STDEXEC_ROOT CACHE) +endif() + if(Stdexec_ROOT OR HPX_WITH_FETCH_STDEXEC) # explicitly enable HPX_WITH_STDEXEC set(HPX_WITH_STDEXEC ON) + message("HERE") + # prefer Stdexec_ROOT over HPX_WITH_FETCH_STDEXEC by default if(Stdexec_ROOT AND HPX_WITH_FETCH_STDEXEC) set(HPX_WITH_FETCH_STDEXEC OFF) From 3abc290292b0fa539f4beb1867be935dd483124e Mon Sep 17 00:00:00 2001 From: isidorostsa Date: Mon, 11 Mar 2024 17:07:37 -0500 Subject: [PATCH 05/47] added pika's changes --- cmake/FindStdexec.cmake | 42 +++++++++---------- .../include/hpx/execution/algorithms/bulk.hpp | 7 ++++ .../execution/algorithms/ensure_started.hpp | 7 ++++ .../hpx/execution/algorithms/execute.hpp | 7 ++++ .../include/hpx/execution/algorithms/just.hpp | 7 ++++ .../hpx/execution/algorithms/let_error.hpp | 7 ++++ .../hpx/execution/algorithms/let_value.hpp | 6 +++ .../execution/algorithms/schedule_from.hpp | 7 ++++ .../hpx/execution/algorithms/split.hpp | 7 ++++ .../execution/algorithms/start_detached.hpp | 7 ++++ .../hpx/execution/algorithms/sync_wait.hpp | 5 +++ .../include/hpx/execution/algorithms/then.hpp | 6 +++ .../hpx/execution/algorithms/transfer.hpp | 6 +++ .../execution/algorithms/transfer_just.hpp | 6 +++ .../hpx/execution/algorithms/when_all.hpp | 5 +++ .../execution/algorithms/when_all_vector.hpp | 15 ++++++- libs/core/execution_base/CMakeLists.txt | 9 +++- .../execution_base/completion_scheduler.hpp | 36 ++++++++++++++++ .../execution_base/completion_signatures.hpp | 5 +++ .../hpx/execution_base/operation_state.hpp | 12 ++++++ .../include/hpx/execution_base/receiver.hpp | 29 +++++++++++++ .../include/hpx/execution_base/sender.hpp | 34 +++++++++++++++ .../execution_base/tests/unit/stdexec.cpp | 6 ++- 23 files changed, 252 insertions(+), 26 deletions(-) diff --git a/cmake/FindStdexec.cmake b/cmake/FindStdexec.cmake index 01d843162938..edce11ea4c33 100644 --- a/cmake/FindStdexec.cmake +++ b/cmake/FindStdexec.cmake @@ -10,29 +10,29 @@ if(NOT TARGET STDEXEC::stdexec) unset(STDEXEC_ROOT CACHE) endif() - find_path( - Stdexec_INCLUDE_DIR - stdexec - HINTS ${Stdexec_ROOT} - ) + find_path( + Stdexec_INCLUDE_DIR + stdexec + HINTS ${Stdexec_ROOT} + ) - if (Stdexec_INCLUDE_DIR) - file(TO_CMAKE_PATH ${Stdexec_INCLUDE_DIR} Stdexec_INCLUDE_DIR) - else() - message(FATAL_ERROR "stdexec not found") - endif() + if (Stdexec_INCLUDE_DIR) + file(TO_CMAKE_PATH ${Stdexec_INCLUDE_DIR} Stdexec_INCLUDE_DIR) + else() + message(FATAL_ERROR "stdexec not found") + endif() - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args( - Stdexec - REQUIRED_VARS Stdexec_INCLUDE_DIR - FOUND_VAR Stdexec_FOUND - VERSION_VAR Stdexec_VERSION - FAIL_MESSAGE "stdexec not found" - ) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( + Stdexec + REQUIRED_VARS Stdexec_INCLUDE_DIR + FOUND_VAR Stdexec_FOUND + VERSION_VAR Stdexec_VERSION + FAIL_MESSAGE "stdexec not found" + ) - add_library(STDEXEC::stdexec INTERFACE IMPORTED) - target_include_directories(STDEXEC::stdexec SYSTEM INTERFACE ${Stdexec_INCLUDE_DIR}) + add_library(STDEXEC::stdexec INTERFACE IMPORTED) + target_include_directories(STDEXEC::stdexec SYSTEM INTERFACE ${Stdexec_INCLUDE_DIR}) - mark_as_advanced(Stdexec_INCLUDE_DIR Stdexec_ROOT) + mark_as_advanced(Stdexec_INCLUD`E_DIR Stdexec_ROOT) endif() diff --git a/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp b/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp index b2716fe6dd4a..5d9bc539cec6 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp @@ -8,6 +8,10 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else #include #include #include @@ -28,6 +32,7 @@ #include #include + namespace hpx::execution::experimental { /////////////////////////////////////////////////////////////////////////// @@ -252,3 +257,5 @@ namespace hpx::execution::experimental { } } bulk{}; } // namespace hpx::execution::experimental + +#endif \ No newline at end of file diff --git a/libs/core/execution/include/hpx/execution/algorithms/ensure_started.hpp b/libs/core/execution/include/hpx/execution/algorithms/ensure_started.hpp index 86edc8671891..e5e5ea81c7c5 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/ensure_started.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/ensure_started.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -155,3 +160,5 @@ namespace hpx::execution::experimental { } } ensure_started{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/execute.hpp b/libs/core/execution/include/hpx/execution/algorithms/execute.hpp index 242df7534aee..7b90f2501f33 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/execute.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/execute.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -45,3 +50,5 @@ namespace hpx::execution::experimental { } } execute{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/just.hpp b/libs/core/execution/include/hpx/execution/algorithms/just.hpp index 3f1e97ff78a7..d13daff587a5 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/just.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/just.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -191,3 +196,5 @@ namespace hpx::execution::experimental { } } just_stopped{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/let_error.hpp b/libs/core/execution/include/hpx/execution/algorithms/let_error.hpp index 3af337ffcb2a..a24b9a587370 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/let_error.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/let_error.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -469,3 +474,5 @@ namespace hpx::execution::experimental { } } let_error{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/let_value.hpp b/libs/core/execution/include/hpx/execution/algorithms/let_value.hpp index f0a63f5932cd..598b49b0e5b5 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/let_value.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/let_value.hpp @@ -8,6 +8,10 @@ #pragma once #include +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -486,3 +490,5 @@ namespace hpx::execution::experimental { } } let_value{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/schedule_from.hpp b/libs/core/execution/include/hpx/execution/algorithms/schedule_from.hpp index 7ada4dc53fad..181edc4d99e5 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/schedule_from.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/schedule_from.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -365,3 +370,5 @@ namespace hpx::execution::experimental { } } schedule_from{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/split.hpp b/libs/core/execution/include/hpx/execution/algorithms/split.hpp index 03a22fb4da24..3f0ad957a1be 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/split.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/split.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -699,3 +704,5 @@ namespace hpx::execution::experimental { } } split{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/start_detached.hpp b/libs/core/execution/include/hpx/execution/algorithms/start_detached.hpp index a5a64786e084..b4b03279c57f 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/start_detached.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/start_detached.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -293,3 +298,5 @@ namespace hpx::execution::experimental { } } start_detached{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/sync_wait.hpp b/libs/core/execution/include/hpx/execution/algorithms/sync_wait.hpp index 8c44918b155e..e4c4f303fc3a 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/sync_wait.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/sync_wait.hpp @@ -9,6 +9,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#endif + #include #include #include diff --git a/libs/core/execution/include/hpx/execution/algorithms/then.hpp b/libs/core/execution/include/hpx/execution/algorithms/then.hpp index 30fbaa5dab73..a2fc0a5dcf9d 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/then.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/then.hpp @@ -8,6 +8,10 @@ #pragma once #include +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -242,3 +246,5 @@ namespace hpx::execution::experimental { } } then{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/transfer.hpp b/libs/core/execution/include/hpx/execution/algorithms/transfer.hpp index 8417df496def..024b3fc8aba2 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/transfer.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/transfer.hpp @@ -8,6 +8,10 @@ #pragma once #include +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include @@ -86,3 +90,5 @@ namespace hpx::execution::experimental { } } transfer{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp b/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp index 713cb5b1c5ad..406d1eeae1ff 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp @@ -8,6 +8,10 @@ #pragma once #include +#ifdef HPX_HAVE_STDEXEC +#include +#endif + #include #include #include @@ -38,3 +42,5 @@ namespace hpx::execution::experimental { } } transfer_just{}; } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp b/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp index e6e58915783e..adb04e7c8633 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp @@ -8,6 +8,9 @@ #pragma once #include +#ifdef HPX_HAVE_STDEXEC +#include +#else #include #include #include @@ -577,3 +580,5 @@ namespace hpx::execution::experimental { HPX_FORWARD(F, f)); } } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp b/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp index 3e1d5ac934a1..2eaa5b1a22b7 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp @@ -8,6 +8,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#endif + #include #include #include @@ -330,8 +335,14 @@ namespace hpx::when_all_vector_detail { } else { - hpx::execution::experimental::set_stopped( - HPX_MOVE(receiver)); +#ifdef HPX_HAVE_STDEXEC + if constexpr (hpx::execution::experimental::sends_stopped) { +#endif + hpx::execution::experimental::set_stopped( + HPX_MOVE(receiver)); +#ifdef HPX_HAVE_STDEXEC + } else { HPX_UNREACHABLE; } +#endif } } } diff --git a/libs/core/execution_base/CMakeLists.txt b/libs/core/execution_base/CMakeLists.txt index fe36b99d0780..cfa952e5293c 100644 --- a/libs/core/execution_base/CMakeLists.txt +++ b/libs/core/execution_base/CMakeLists.txt @@ -48,6 +48,12 @@ set(execution_base_sources agent_ref.cpp any_sender.cpp spinlock_deadlock_detection.cpp this_thread.cpp ) +set(optional_dependencies) + +if(TARGET STDEXEC::stdexec) + set(optional_dependencies STDEXEC::stdexec) +endif() + include(HPX_AddModule) add_hpx_module( core execution_base @@ -55,8 +61,7 @@ add_hpx_module( SOURCES ${execution_base_sources} HEADERS ${execution_base_headers} COMPAT_HEADERS ${execution_base_compat_headers} - DEPENDENCIES - STDEXEC::stdexec + DEPENDENCIES ${optional_dependencies} MODULE_DEPENDENCIES hpx_assertion hpx_config diff --git a/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp b/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp index 033f8277dfbe..e7db5f8f76e2 100644 --- a/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp @@ -8,6 +8,40 @@ #pragma once #include + +#if defined(HPX_HAVE_STDEXEC) +#include +#include +#include + +namespace hpx::execution::experimental::detail { + template + struct has_completion_scheduler_impl : std::false_type + { + }; + + template + struct has_completion_scheduler_impl + : hpx::execution::experimental::is_scheduler< + hpx::functional::tag_invoke_result_t, + std::decay_t const&>> + { + }; + + template + struct has_completion_scheduler + : has_completion_scheduler_impl, + std::decay_t const&>, CPO, Sender> + { + }; + + template + inline constexpr bool has_completion_scheduler_v = has_completion_scheduler::value; +} // namespace hpx::execution::experimental::detail + +#else + + #include #include #include @@ -159,3 +193,5 @@ namespace hpx::execution::experimental { AlgorithmCPO, Ts...>::value; } // namespace detail } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp b/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp index 7e26205bed5a..9546158ed3ad 100644 --- a/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp @@ -7,6 +7,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#else + #include #include #include diff --git a/libs/core/execution_base/include/hpx/execution_base/operation_state.hpp b/libs/core/execution_base/include/hpx/execution_base/operation_state.hpp index 5dde54377342..0e0cf2f4bb27 100644 --- a/libs/core/execution_base/include/hpx/execution_base/operation_state.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/operation_state.hpp @@ -7,6 +7,17 @@ #pragma once +#include + +#ifdef HPX_HAVE_STDEXEC +#include + +namespace hpx::execution::experimental { + template + inline constexpr bool is_operation_state_v = operation_state; +} // namespace hpx::execution::experimental +#else + #include #include #include @@ -101,3 +112,4 @@ namespace hpx::execution::experimental { inline constexpr bool is_operation_state_v = meta::value>; } // namespace hpx::execution::experimental +#endif diff --git a/libs/core/execution_base/include/hpx/execution_base/receiver.hpp b/libs/core/execution_base/include/hpx/execution_base/receiver.hpp index 61965b969ebb..96f94b87d969 100644 --- a/libs/core/execution_base/include/hpx/execution_base/receiver.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/receiver.hpp @@ -7,6 +7,33 @@ #pragma once +#include + +#ifdef HPX_HAVE_STDEXEC +#include +#include + +namespace hpx::execution::experimental { + template + struct is_receiver : std::bool_constant> + { + }; + + template + inline constexpr bool is_receiver_v = is_receiver::value; + + template + struct is_receiver_of : std::bool_constant> + { + }; + + template + inline constexpr bool is_receiver_of_v = is_receiver_of::value; + +} // namespace hpx::execution::experimental + +#else + #include #include #include @@ -304,3 +331,5 @@ namespace hpx::execution::experimental { inline constexpr bool is_receiver_cpo_v = is_receiver_cpo::value; } // namespace detail } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution_base/include/hpx/execution_base/sender.hpp b/libs/core/execution_base/include/hpx/execution_base/sender.hpp index e9da414662f5..58bfcb5cc9fe 100644 --- a/libs/core/execution_base/include/hpx/execution_base/sender.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/sender.hpp @@ -7,6 +7,38 @@ #pragma once +#include + +#ifdef HPX_HAVE_STDEXEC +#include + +namespace hpx::execution::experimental { + template + struct is_scheduler : std::bool_constant> + { + }; + + template + inline constexpr bool is_scheduler_v = is_scheduler::value; + + template + struct is_sender : std::bool_constant> + { + }; + + template + inline constexpr bool is_sender_v = is_sender::value; + + template + struct is_sender_to : std::bool_constant> + { + }; + + template + inline constexpr bool is_sender_to_v = is_sender_to::value; +} // namespace hpx::execution::experimental +#else + #include #include #include @@ -193,3 +225,5 @@ namespace hpx::execution::experimental { }; } // namespace detail } // namespace hpx::execution::experimental + +#endif diff --git a/libs/core/execution_base/tests/unit/stdexec.cpp b/libs/core/execution_base/tests/unit/stdexec.cpp index aa173034de5f..28e2cfa86312 100644 --- a/libs/core/execution_base/tests/unit/stdexec.cpp +++ b/libs/core/execution_base/tests/unit/stdexec.cpp @@ -11,6 +11,7 @@ #include +#ifdef HPX_HAVE_STDEXEC using namespace hpx::execution::experimental; int main() { @@ -21,4 +22,7 @@ int main() { HPX_TEST(a == 42); return hpx::util::report_errors(); -} \ No newline at end of file +} +#else +int main() {} +#endif \ No newline at end of file From 45dbae680be3e13e853bf809b80b3fdbd3138cea Mon Sep 17 00:00:00 2001 From: isidorostsa Date: Thu, 14 Mar 2024 17:31:03 -0500 Subject: [PATCH 06/47] Re-added removed functionallities + more forwards --- .../include/hpx/execution/algorithms/bulk.hpp | 3 + .../execution/algorithms/transfer_just.hpp | 4 +- .../hpx/execution/algorithms/when_all.hpp | 2 +- .../execution/algorithms/when_all_vector.hpp | 2 +- .../include/hpx/execution/queries/read.hpp | 9 +- libs/core/execution_base/CMakeLists.txt | 4 +- .../execution_base/completion_scheduler.hpp | 34 +++++- .../execution_base/completion_signatures.hpp | 103 ++++++++++++++++++ .../include/hpx/execution_base/get_env.hpp | 2 + .../include/hpx/execution_base/receiver.hpp | 16 +++ .../include/hpx/execution_base/sender.hpp | 14 ++- .../executors/thread_pool_scheduler_bulk.hpp | 5 + 12 files changed, 182 insertions(+), 16 deletions(-) diff --git a/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp b/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp index 5d9bc539cec6..41179170a1f5 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/bulk.hpp @@ -12,6 +12,9 @@ #ifdef HPX_HAVE_STDEXEC #include #else +#endif + +#if 1 #include #include #include diff --git a/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp b/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp index 406d1eeae1ff..237c4f8ea785 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/transfer_just.hpp @@ -9,8 +9,8 @@ #include #ifdef HPX_HAVE_STDEXEC -#include -#endif +#include +#else #include #include diff --git a/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp b/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp index adb04e7c8633..5c04374238d5 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/when_all.hpp @@ -9,7 +9,7 @@ #include #ifdef HPX_HAVE_STDEXEC -#include +#include #else #include #include diff --git a/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp b/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp index 2eaa5b1a22b7..b5505989a6d2 100644 --- a/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp +++ b/libs/core/execution/include/hpx/execution/algorithms/when_all_vector.hpp @@ -10,7 +10,7 @@ #include #ifdef HPX_HAVE_STDEXEC -#include +#include #endif #include diff --git a/libs/core/execution/include/hpx/execution/queries/read.hpp b/libs/core/execution/include/hpx/execution/queries/read.hpp index 6e23b8f21385..91957ae87f30 100644 --- a/libs/core/execution/include/hpx/execution/queries/read.hpp +++ b/libs/core/execution/include/hpx/execution/queries/read.hpp @@ -7,6 +7,11 @@ #pragma once #include + +#ifdef HPX_HAVE_STDEXEC +#include +#endif + #include #include #include @@ -87,7 +92,7 @@ namespace hpx::execution::experimental { template friend auto tag_invoke( get_completion_signatures_t, read_sender, no_env) - -> dependent_completion_signatures; + -> std::execution::dependent_completion_signatures; // clang-format off template @@ -110,7 +115,7 @@ namespace hpx::execution::experimental { } else { - return dependent_completion_signatures{}; + return std::execution::dependent_completion_signatures{}; } } // clang-format on diff --git a/libs/core/execution_base/CMakeLists.txt b/libs/core/execution_base/CMakeLists.txt index cfa952e5293c..29e7c4790b95 100644 --- a/libs/core/execution_base/CMakeLists.txt +++ b/libs/core/execution_base/CMakeLists.txt @@ -51,7 +51,7 @@ set(execution_base_sources agent_ref.cpp any_sender.cpp set(optional_dependencies) if(TARGET STDEXEC::stdexec) - set(optional_dependencies STDEXEC::stdexec) + set(execution_base_optional_dependencies STDEXEC::stdexec) endif() include(HPX_AddModule) @@ -61,7 +61,7 @@ add_hpx_module( SOURCES ${execution_base_sources} HEADERS ${execution_base_headers} COMPAT_HEADERS ${execution_base_compat_headers} - DEPENDENCIES ${optional_dependencies} + DEPENDENCIES ${execution_base_optional_dependencies} MODULE_DEPENDENCIES hpx_assertion hpx_config diff --git a/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp b/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp index e7db5f8f76e2..9a1369b9a29f 100644 --- a/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/completion_scheduler.hpp @@ -23,25 +23,47 @@ namespace hpx::execution::experimental::detail { template struct has_completion_scheduler_impl : hpx::execution::experimental::is_scheduler< - hpx::functional::tag_invoke_result_t, - std::decay_t const&>> + hpx::functional::tag_invoke_result_t< + get_completion_scheduler_t, std::decay_t const&>> { }; template struct has_completion_scheduler - : has_completion_scheduler_impl, - std::decay_t const&>, CPO, Sender> + : has_completion_scheduler_impl< + hpx::functional::is_tag_invocable_v, + std::decay_t const&>, + CPO, Sender> { }; template - inline constexpr bool has_completion_scheduler_v = has_completion_scheduler::value; + inline constexpr bool has_completion_scheduler_v = + has_completion_scheduler::value; + + template + struct is_completion_scheduler_tag_invocable + : std::bool_constant && + hpx::functional::is_tag_invocable_v, + Sender>, + Sender, Ts...>> + { + }; + + template + inline constexpr bool is_completion_scheduler_tag_invocable_v = + is_completion_scheduler_tag_invocable::value; + } // namespace hpx::execution::experimental::detail #else - #include #include #include diff --git a/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp b/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp index 9546158ed3ad..0f1d46dc471f 100644 --- a/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp +++ b/libs/core/execution_base/include/hpx/execution_base/completion_signatures.hpp @@ -10,7 +10,108 @@ #ifdef HPX_HAVE_STDEXEC #include +#include +#include +#include +#include +#include + +namespace hpx::execution::experimental { +// template +// struct completion_signatures_of_is_valid : std::false_type +// { +// }; +// +// template +// struct completion_signatures_of_is_valid(), std::declval()))>> : std::true_type +// { +// }; +// + struct empty_variant + { + empty_variant() = delete; + }; + + namespace detail { + // use this remove_cv_ref instead of std::decay to avoid + // decaying function types, e.g. set_value_t() -> set_value_t(*)() + template + struct remove_cv_ref + { + using type = std::remove_cv_t>; + }; + + template + using remove_cv_ref_t = meta::type>; + + // If sizeof...(Ts) is greater than zero, variant-or-empty names + // the type variant where Us... is the pack decay_t... with + // duplicate types removed. + template