From 532d4fd458efdcd0626e803ddb38401fd96864f9 Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Tue, 26 Mar 2024 09:25:27 -0500 Subject: [PATCH] Revert "Always return outermost thread id" --- .circleci/config.yml | 46 +------ .../iostreams/src/server/output_stream.cpp | 11 +- .../server/cancelable_action.hpp | 17 +-- .../include/hpx/config/threads_stack.hpp | 20 ++- .../include/hpx/coroutines/thread_enums.hpp | 8 +- libs/core/execution/tests/unit/bulk_async.cpp | 35 ++--- .../tests/unit/minimal_async_executor.cpp | 93 ++++++------- .../detail/hierarchical_spawning.hpp | 20 ++- .../executors/detail/index_queue_spawning.hpp | 7 +- .../executors/thread_pool_scheduler_bulk.hpp | 3 +- .../executors/tests/unit/created_executor.cpp | 54 +++----- .../tests/unit/parallel_executor.cpp | 55 +++----- .../unit/parallel_executor_parameters.cpp | 39 ++---- .../tests/unit/parallel_policy_executor.cpp | 57 ++++---- .../tests/unit/shared_parallel_executor.cpp | 29 ++--- .../unit/standalone_thread_pool_executor.cpp | 33 ++--- .../futures/src/detail/execute_thread.cpp | 8 +- .../local_priority_queue_scheduler.hpp | 4 +- .../local_workrequesting_scheduler.hpp | 4 +- .../include/hpx/threading/thread.hpp | 63 ++++----- libs/core/threading/src/thread.cpp | 80 ++++++------ .../hpx/threading_base/thread_data.hpp | 8 +- .../threading_base/thread_data_stackful.hpp | 4 +- .../hpx/threading_base/threading_base_fwd.hpp | 15 +-- .../src/set_thread_state_timed.cpp | 4 +- libs/core/threading_base/src/thread_data.cpp | 18 ++- .../threading_base/src/thread_helpers.cpp | 6 +- .../regressions/thread_stacksize_current.cpp | 16 +-- .../unit/minimal_timed_async_executor.cpp | 56 +++----- .../counter_interface.hpp | 8 +- .../detail/counter_interface_functions.hpp | 8 +- .../src/counter_interface.cpp | 8 +- .../performance_counters/src/counters.cpp | 2 +- .../detail/counter_interface_functions.cpp | 9 +- .../stubs/runtime_support.hpp | 47 ++++--- .../src/runtime_support.cpp | 18 +-- .../src/server/runtime_support_server.cpp | 35 ++--- .../src/stubs/runtime_support_stubs.cpp | 123 +++++++++--------- .../threads/main_thread_exit_callbacks.cpp | 3 +- 39 files changed, 445 insertions(+), 629 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4887c607fcd1..014765077dda 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -490,39 +490,6 @@ jobs: - ./build tests.unit.algorithms: - <<: *defaults - steps: - - attach_workspace: - at: /hpx - - run: - name: Building Unit Tests (Algorithms) - command: | - ninja -j 1 -k 0 \ - tests.unit.modules.algorithms.algorithms - - run: - name: Running Unit Tests - when: always - command: | - ulimit -c unlimited - ctest \ - --timeout 120 \ - -T test \ - --no-compress-output \ - --output-on-failure \ - --tests-regex \ - "tests.unit.modules.algorithms.algorithms" - - run: - <<: *convert_xml - - run: - <<: *move_core_dump - - run: - <<: *move_debug_log - - store_test_results: - path: tests.unit.algorithms - - store_artifacts: - path: tests.unit.algorithms - - tests.unit.algorithms.block: <<: *defaults steps: - attach_workspace: @@ -531,7 +498,9 @@ jobs: name: Building Unit Tests (Algorithms) command: | ninja -j2 -k 0 \ + tests.unit.modules.algorithms.algorithms \ tests.unit.modules.algorithms.block +# tests.unit.modules.algorithms.datapar_algorithms - run: name: Running Unit Tests when: always @@ -543,7 +512,9 @@ jobs: --no-compress-output \ --output-on-failure \ --tests-regex \ - "tests.unit.modules.algorithms.block" + "tests.unit.modules.algorithms.algorithms|\ + tests.unit.modules.algorithms.block" +# "|tests.unit.modules.algorithms.datapar_algorithms" - run: <<: *convert_xml - run: @@ -551,9 +522,9 @@ jobs: - run: <<: *move_debug_log - store_test_results: - path: tests.unit.algorithms.block + path: tests.unit.algorithms - store_artifacts: - path: tests.unit.algorithms.block + path: tests.unit.algorithms tests.unit.container_algorithms: <<: *defaults @@ -942,8 +913,6 @@ workflows: <<: *core_dependency - tests.unit.algorithms: <<: *core_dependency - - tests.unit.algorithms.block: - <<: *core_dependency - tests.unit.container_algorithms: <<: *core_dependency - tests.unit.segmented_algorithms: @@ -1001,7 +970,6 @@ workflows: - core - tests.examples - tests.unit.algorithms - - tests.unit.algorithms.block - tests.unit.container_algorithms - tests.unit.segmented_algorithms - tests.unit1 diff --git a/components/iostreams/src/server/output_stream.cpp b/components/iostreams/src/server/output_stream.cpp index 2658f2c592b2..dd0a519b27f8 100644 --- a/components/iostreams/src/server/output_stream.cpp +++ b/components/iostreams/src/server/output_stream.cpp @@ -34,7 +34,7 @@ namespace hpx::iostreams::detail { ar << valid; if (valid) { - ar & data_; + ar& data_; } } @@ -44,7 +44,7 @@ namespace hpx::iostreams::detail { ar >> valid; if (valid) { - ar & data_; + ar& data_; } } } // namespace hpx::iostreams::detail @@ -89,9 +89,10 @@ namespace hpx::iostreams::server { { // {{{ // Perform the IO in another OS thread. detail::buffer in(buf_in); - hpx::get_thread_pool("io_pool")->get_io_service().post(hpx::bind_front( - &output_stream::call_write_sync, this, locality_id, count, - std::ref(in), threads::thread_id_ref_type(threads::get_self_id()))); + hpx::get_thread_pool("io_pool")->get_io_service().post( + hpx::bind_front(&output_stream::call_write_sync, this, locality_id, + count, std::ref(in), + threads::thread_id_ref_type(threads::get_outer_self_id()))); // Sleep until the worker thread wakes us up. this_thread::suspend(threads::thread_schedule_state::suspended, diff --git a/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp b/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp index 2042103cf06a..9c131d256650 100644 --- a/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp +++ b/examples/cancelable_action/cancelable_action/server/cancelable_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -63,9 +63,6 @@ namespace examples::server { } ~reset_id() { - auto const mtx = outer_.mtx_; - std::lock_guard l(*mtx); - [[maybe_unused]] hpx::thread::id const old_value = outer_.id_; outer_.id_ = hpx::thread::id(); HPX_ASSERT(old_value != hpx::thread::id()); @@ -107,15 +104,9 @@ namespace examples::server { }); auto const mtx = mtx_; - - std::unique_lock l(*mtx); - auto const id = id_; - - if (id != hpx::thread::id()) - { - l.unlock(); - hpx::thread::interrupt(id); - } + std::lock_guard l(*mtx); + HPX_ASSERT(id_ != hpx::thread::id()); + hpx::thread::interrupt(id_); } HPX_DEFINE_COMPONENT_ACTION(cancelable_action, do_it, do_it_action) diff --git a/libs/core/config/include/hpx/config/threads_stack.hpp b/libs/core/config/include/hpx/config/threads_stack.hpp index 67f4101e442c..f2e0507fbe75 100644 --- a/libs/core/config/include/hpx/config/threads_stack.hpp +++ b/libs/core/config/include/hpx/config/threads_stack.hpp @@ -40,22 +40,20 @@ #endif #if !defined(HPX_SMALL_STACK_SIZE) -# if !defined(HPX_SMALL_STACK_SIZE_TARGET) -# if defined(HPX_WINDOWS) && !defined(HPX_HAVE_GENERIC_CONTEXT_COROUTINES) -# define HPX_SMALL_STACK_SIZE_TARGET 0x4000 // 16kByte +# if defined(HPX_WINDOWS) && !defined(HPX_HAVE_GENERIC_CONTEXT_COROUTINES) +# define HPX_SMALL_STACK_SIZE_TARGET 0x4000 // 16kByte +# else +# if defined(HPX_DEBUG) +# define HPX_SMALL_STACK_SIZE_TARGET 0x20000 // 128kByte # else -# if defined(HPX_DEBUG) -# define HPX_SMALL_STACK_SIZE_TARGET 0x20000 // 128kByte +# if defined(__powerpc__) || defined(__INTEL_COMPILER) +# define HPX_SMALL_STACK_SIZE_TARGET 0x20000 // 128kByte # else -# if defined(__powerpc__) || defined(__INTEL_COMPILER) -# define HPX_SMALL_STACK_SIZE_TARGET 0x20000 // 128kByte -# else -# define HPX_SMALL_STACK_SIZE_TARGET 0x10000 // 64kByte -# endif +# define HPX_SMALL_STACK_SIZE_TARGET 0x10000 // 64kByte # endif # endif # endif -# + # if HPX_SMALL_STACK_SIZE_TARGET < (2 * HPX_THREADS_STACK_OVERHEAD) # define HPX_SMALL_STACK_SIZE (2 * HPX_THREADS_STACK_OVERHEAD) # else diff --git a/libs/core/coroutines/include/hpx/coroutines/thread_enums.hpp b/libs/core/coroutines/include/hpx/coroutines/thread_enums.hpp index 2ab5bef47cdc..7abf67d5c3d6 100644 --- a/libs/core/coroutines/include/hpx/coroutines/thread_enums.hpp +++ b/libs/core/coroutines/include/hpx/coroutines/thread_enums.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -425,12 +425,6 @@ namespace hpx::threads { runs_as_child_mode_bits = static_cast(bits); } - void schedule_hint(std::int16_t core) noexcept - { - mode = thread_schedule_hint_mode::thread; - hint = core; - } - /// The hint associated with the mode. The interpretation of this hint /// depends on the given mode. std::int16_t hint = -1; diff --git a/libs/core/execution/tests/unit/bulk_async.cpp b/libs/core/execution/tests/unit/bulk_async.cpp index 8f7e5b359825..ee5e54cd876d 100644 --- a/libs/core/execution/tests/unit/bulk_async.cpp +++ b/libs/core/execution/tests/unit/bulk_async.cpp @@ -1,5 +1,4 @@ // Copyright (c) 2015 Daniel Bourgeois -// Copyright (c) 2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -17,8 +16,8 @@ #include //////////////////////////////////////////////////////////////////////////////// -int bulk_test(hpx::thread::id const& tid, int value, bool is_par, - int passed_through) //-V813 +int bulk_test( + hpx::thread::id tid, int value, bool is_par, int passed_through) //-V813 { HPX_TEST_EQ(is_par, (tid != hpx::this_thread::get_id())); HPX_TEST_EQ(passed_through, 42); @@ -26,7 +25,7 @@ int bulk_test(hpx::thread::id const& tid, int value, bool is_par, } template -void test_bulk_sync(Executor&& exec) +void test_bulk_sync(Executor& exec) { hpx::thread::id tid = hpx::this_thread::get_id(); @@ -36,15 +35,14 @@ void test_bulk_sync(Executor&& exec) using hpx::placeholders::_1; using hpx::placeholders::_2; - std::vector results = - hpx::parallel::execution::bulk_sync_execute(HPX_FORWARD(Executor, exec), - hpx::bind(&bulk_test, tid, _1, false, _2), v, 42); + std::vector results = hpx::parallel::execution::bulk_sync_execute( + exec, hpx::bind(&bulk_test, tid, _1, false, _2), v, 42); HPX_TEST(std::equal(std::begin(results), std::end(results), std::begin(v))); } template -void test_bulk_async(Executor&& exec) +void test_bulk_async(Executor& exec) { hpx::thread::id tid = hpx::this_thread::get_id(); @@ -56,8 +54,7 @@ void test_bulk_async(Executor&& exec) std::vector> results = hpx::parallel::execution::bulk_async_execute( - HPX_FORWARD(Executor, exec), - hpx::bind(&bulk_test, tid, _1, true, _2), v, 42); + exec, hpx::bind(&bulk_test, tid, _1, true, _2), v, 42); HPX_TEST(std::equal(std::begin(results), std::end(results), std::begin(v), [](hpx::future& lhs, const int& rhs) { @@ -65,33 +62,23 @@ void test_bulk_async(Executor&& exec) })); } -template -decltype(auto) disable_run_as_child(Executor&& exec) -{ - auto hint = hpx::execution::experimental::get_hint(exec); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - - return hpx::experimental::prefer(hpx::execution::experimental::with_hint, - HPX_FORWARD(Executor, exec), hint); -} - //////////////////////////////////////////////////////////////////////////////// int hpx_main() { hpx::execution::sequenced_executor seq_exec; - test_bulk_sync(disable_run_as_child(seq_exec)); + test_bulk_sync(seq_exec); hpx::execution::parallel_executor par_exec; hpx::execution::parallel_executor par_fork_exec(hpx::launch::fork); - test_bulk_async(disable_run_as_child(par_exec)); - test_bulk_async(disable_run_as_child(par_fork_exec)); + test_bulk_async(par_exec); + test_bulk_async(par_fork_exec); return hpx::local::finalize(); } int main(int argc, char* argv[]) { - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/core/execution/tests/unit/minimal_async_executor.cpp b/libs/core/execution/tests/unit/minimal_async_executor.cpp index 3e099db189fe..f9c5db8453a0 100644 --- a/libs/core/execution/tests/unit/minimal_async_executor.cpp +++ b/libs/core/execution/tests/unit/minimal_async_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -36,8 +36,7 @@ void apply_test(hpx::latch& l, hpx::thread::id& id, int passed_through) l.count_down(1); } -void async_bulk_test( - int, hpx::thread::id const& tid, int passed_through) //-V813 +void async_bulk_test(int, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST_NEQ(tid, hpx::this_thread::get_id()); HPX_TEST_EQ(passed_through, 42); @@ -58,14 +57,14 @@ void test_apply(Executor& exec) } template -void test_sync(Executor&& exec) +void test_sync(Executor& exec) { HPX_TEST(hpx::parallel::execution::sync_execute(exec, &async_test, 42) != hpx::this_thread::get_id()); } template -void test_async(Executor&& exec) +void test_async(Executor& exec) { HPX_TEST( hpx::parallel::execution::async_execute(exec, &async_test, 42).get() != @@ -73,7 +72,7 @@ void test_async(Executor&& exec) } template -void test_bulk_sync(Executor&& exec) +void test_bulk_sync(Executor& exec) { hpx::thread::id tid = hpx::this_thread::get_id(); @@ -90,7 +89,7 @@ void test_bulk_sync(Executor&& exec) } template -void test_bulk_async(Executor&& exec) +void test_bulk_async(Executor& exec) { hpx::thread::id tid = hpx::this_thread::get_id(); @@ -154,21 +153,17 @@ struct test_async_executor1 test_async_executor1 const&, F&& f, Ts&&... ts) { ++count_async; - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - - return hpx::async(policy, std::forward(f), std::forward(ts)...); + return hpx::async( + hpx::launch::async, std::forward(f), std::forward(ts)...); } }; -template <> -struct hpx::parallel::execution::is_two_way_executor - : std::true_type -{ -}; +namespace hpx::parallel::execution { + template <> + struct is_two_way_executor : std::true_type + { + }; +} // namespace hpx::parallel::execution struct test_async_executor2 : test_async_executor1 { @@ -179,22 +174,18 @@ struct test_async_executor2 : test_async_executor1 test_async_executor2 const&, F&& f, Ts&&... ts) { ++count_sync; - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - - return hpx::async(policy, std::forward(f), std::forward(ts)...) + return hpx::async( + hpx::launch::async, std::forward(f), std::forward(ts)...) .get(); } }; -template <> -struct hpx::parallel::execution::is_two_way_executor - : std::true_type -{ -}; +namespace hpx::parallel::execution { + template <> + struct is_two_way_executor : std::true_type + { + }; +} // namespace hpx::parallel::execution struct test_async_executor3 : test_async_executor1 { @@ -206,26 +197,21 @@ struct test_async_executor3 : test_async_executor1 test_async_executor3 const&, F f, Shape const& shape, Ts&&... ts) { ++count_bulk_sync; - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - std::vector> results; for (auto const& elem : shape) { - results.push_back(hpx::async(policy, f, elem, ts...)); + results.push_back(hpx::async(hpx::launch::async, f, elem, ts...)); } hpx::when_all(results).get(); } }; -template <> -struct hpx::parallel::execution::is_two_way_executor - : std::true_type -{ -}; +namespace hpx::parallel::execution { + template <> + struct is_two_way_executor : std::true_type + { + }; +} // namespace hpx::parallel::execution struct test_async_executor4 : test_async_executor1 { @@ -237,16 +223,10 @@ struct test_async_executor4 : test_async_executor1 test_async_executor4 const&, F f, Shape const& shape, Ts&&... ts) { ++count_bulk_async; - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - std::vector> results; for (auto const& elem : shape) { - results.push_back(hpx::async(policy, f, elem, ts...)); + results.push_back(hpx::async(hpx::launch::async, f, elem, ts...)); } return results; } @@ -277,11 +257,12 @@ struct test_async_executor5 : test_async_executor1 } }; -template <> -struct hpx::parallel::execution::is_two_way_executor - : std::true_type -{ -}; +namespace hpx::parallel::execution { + template <> + struct is_two_way_executor : std::true_type + { + }; +} // namespace hpx::parallel::execution /////////////////////////////////////////////////////////////////////////////// int hpx_main() @@ -297,7 +278,7 @@ int hpx_main() int main(int argc, char* argv[]) { - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/core/executors/include/hpx/executors/detail/hierarchical_spawning.hpp b/libs/core/executors/include/hpx/executors/detail/hierarchical_spawning.hpp index cde46fef7146..899b37d5d80e 100644 --- a/libs/core/executors/include/hpx/executors/detail/hierarchical_spawning.hpp +++ b/libs/core/executors/include/hpx/executors/detail/hierarchical_spawning.hpp @@ -1,5 +1,5 @@ // Copyright (c) 2019-2020 ETH Zurich -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // Copyright (c) 2019 Agustin Berge // // SPDX-License-Identifier: BSL-1.0 @@ -52,7 +52,7 @@ namespace hpx::parallel::execution::detail { HPX_ASSERT(pool); using result_type = std::vector< - hpx::future>>; + hpx::future>>; result_type results; std::size_t const size = hpx::util::size(shape); @@ -69,10 +69,9 @@ namespace hpx::parallel::execution::detail { std::size_t const part_end = ((t + 1) * size) / num_threads; std::size_t const part_size = part_end - part_begin; - auto hint = hpx::execution::experimental::get_hint(policy); - hint.schedule_hint(static_cast(first_thread + t)); - auto async_policy = - hpx::execution::experimental::with_hint(policy, hint); + auto async_policy = hpx::execution::experimental::with_hint(policy, + threads::thread_schedule_hint{ + static_cast(first_thread + t)}); if (hierarchical_threshold != 0 && part_size > hierarchical_threshold) @@ -162,13 +161,10 @@ namespace hpx::parallel::execution::detail { auto it = std::begin(shape); for (std::size_t t = 0; t != num_threads; ++t) { - auto inner_hint = - hpx::execution::experimental::get_hint(policy); - inner_hint.schedule_hint( - static_cast(first_thread + t)); auto inner_post_policy = - hpx::execution::experimental::with_hint( - policy, inner_hint); + hpx::execution::experimental::with_hint(policy, + threads::thread_schedule_hint{ + static_cast(first_thread + t)}); std::size_t const end = ((t + 1) * size) / num_threads; std::size_t const part_size = end - begin; diff --git a/libs/core/executors/include/hpx/executors/detail/index_queue_spawning.hpp b/libs/core/executors/include/hpx/executors/detail/index_queue_spawning.hpp index 737694e7c2b7..927a1ca7b705 100644 --- a/libs/core/executors/include/hpx/executors/detail/index_queue_spawning.hpp +++ b/libs/core/executors/include/hpx/executors/detail/index_queue_spawning.hpp @@ -104,7 +104,7 @@ namespace hpx::parallel::execution::detail { if (allow_stealing) { // Then steal from the opposite end of the neighboring queues - constexpr auto opposite_end = + static constexpr auto opposite_end = hpx::concurrency::detail::opposite_end_v; for (std::uint32_t offset = 1; offset != state->num_threads; @@ -150,7 +150,7 @@ namespace hpx::parallel::execution::detail { // Finish the work for one worker thread. If this is not the last worker // thread to finish, it will only decrement the counter. If it is the // last thread it will call set_exception if there is an exception. - // Otherwise, it will call set_value on the shared state. + // Otherwise it will call set_value on the shared state. void finish() const { if (--(state->tasks_remaining.data_) == 0) @@ -338,7 +338,8 @@ namespace hpx::parallel::execution::detail { hint.hint == -1) { // apply hint if none was given - hint.schedule_hint(worker_thread + first_thread); + hint.mode = hpx::threads::thread_schedule_hint_mode::thread; + hint.hint = worker_thread + first_thread; hpx::detail::post_policy_dispatch::call( hpx::execution::experimental::with_hint(post_policy, hint), diff --git a/libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp b/libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp index ea6ffc141adb..fb826e25e93f 100644 --- a/libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp +++ b/libs/core/executors/include/hpx/executors/thread_pool_scheduler_bulk.hpp @@ -400,7 +400,8 @@ namespace hpx::execution::experimental::detail { hint.hint == -1) { // apply hint if none was given - hint.schedule_hint(worker_thread + op_state->first_thread); + hint.mode = hpx::threads::thread_schedule_hint_mode::thread; + hint.hint = worker_thread + op_state->first_thread; auto policy = hpx::execution::experimental::with_hint( op_state->scheduler.policy(), hint); diff --git a/libs/core/executors/tests/unit/created_executor.cpp b/libs/core/executors/tests/unit/created_executor.cpp index c7a11a8c073d..910bdf399399 100644 --- a/libs/core/executors/tests/unit/created_executor.cpp +++ b/libs/core/executors/tests/unit/created_executor.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2015 Daniel Bourgeois -// Copyright (c) 2022-2024 Hartmut Kaiser +// Copyright (c) 2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -24,7 +24,7 @@ #include using hpx::util::deferred_call; -using iter = std::vector::iterator; +typedef std::vector::iterator iter; //////////////////////////////////////////////////////////////////////////////// // A parallel executor that returns void for bulk_execute and hpx::future @@ -72,17 +72,7 @@ namespace hpx::parallel::execution { //////////////////////////////////////////////////////////////////////////////// // Tests to void_parallel_executor behavior for the bulk executes -template -decltype(auto) disable_run_as_child(Executor&& exec) -{ - auto hint = hpx::execution::experimental::get_hint(exec); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - - return hpx::experimental::prefer(hpx::execution::experimental::with_hint, - HPX_FORWARD(Executor, exec), hint); -} - -void bulk_test(int, hpx::thread::id const& tid, int passed_through) //-V813 +void bulk_test(int, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST_NEQ(tid, hpx::this_thread::get_id()); HPX_TEST_EQ(passed_through, 42); @@ -102,9 +92,8 @@ void test_void_bulk_sync() executor exec; hpx::parallel::execution::bulk_sync_execute( - disable_run_as_child(exec), hpx::bind(&bulk_test, _1, tid, _2), v, 42); - hpx::parallel::execution::bulk_sync_execute( - disable_run_as_child(exec), &bulk_test, v, tid, 42); + exec, hpx::bind(&bulk_test, _1, tid, _2), v, 42); + hpx::parallel::execution::bulk_sync_execute(exec, &bulk_test, v, tid, 42); } void test_void_bulk_async() @@ -120,12 +109,11 @@ void test_void_bulk_async() using hpx::placeholders::_2; executor exec; - hpx::when_all( - hpx::parallel::execution::bulk_async_execute(disable_run_as_child(exec), - hpx::bind(&bulk_test, _1, tid, _2), v, 42)) + hpx::when_all(hpx::parallel::execution::bulk_async_execute( + exec, hpx::bind(&bulk_test, _1, tid, _2), v, 42)) .get(); hpx::when_all(hpx::parallel::execution::bulk_async_execute( - disable_run_as_child(exec), &bulk_test, v, tid, 42)) + exec, &bulk_test, v, tid, 42)) .get(); } @@ -134,16 +122,16 @@ void test_void_bulk_async() // Create shape argument for parallel_executor std::vector> split( - iter first, iter const& last, int parts) + iter first, iter last, int parts) { - using sz_type = std::iterator_traits::difference_type; - sz_type const count = std::distance(first, last); - sz_type const increment = count / parts; + typedef std::iterator_traits::difference_type sz_type; + sz_type count = std::distance(first, last); + sz_type increment = count / parts; std::vector> results; while (first != last) { - iter const prev = first; + iter prev = first; std::advance(first, (std::min)(increment, std::distance(first, last))); results.push_back(hpx::util::iterator_range(prev, first)); } @@ -151,7 +139,7 @@ std::vector> split( } // parallel sum using hpx's parallel executor -int parallel_sum(iter const& first, iter const& last, int num_parts) +int parallel_sum(iter first, iter last, int num_parts) { hpx::execution::parallel_executor exec; @@ -170,22 +158,22 @@ int parallel_sum(iter const& first, iter const& last, int num_parts) [](int a, hpx::future& b) -> int { return a + b.get(); }); } -// parallel sum using void parallel executor -int void_parallel_sum(iter const& first, iter const& last, int num_parts) +// parallel sum using void parallel executer +int void_parallel_sum(iter first, iter last, int num_parts) { void_parallel_executor exec; std::vector temp(num_parts + 1, 0); std::iota(std::begin(temp), std::end(temp), 0); - std::ptrdiff_t const section_size = std::distance(first, last) / num_parts; + std::ptrdiff_t section_size = std::distance(first, last) / num_parts; std::vector> f = hpx::parallel::execution::bulk_async_execute( exec, [&](const int& i) { - iter const b = first + i * section_size; //-V104 - iter const e = first + + iter b = first + i * section_size; //-V104 + iter e = first + (std::min)(std::distance(first, last), static_cast( (i + 1) * section_size) //-V104 @@ -205,7 +193,7 @@ void sum_test() auto random_num = []() { return std::rand() % 50 - 25; }; std::generate(std::begin(vec), std::end(vec), random_num); - int const sum = std::accumulate(std::begin(vec), std::end(vec), 0); + int sum = std::accumulate(std::begin(vec), std::end(vec), 0); int num_parts = std::rand() % 5 + 3; // Return futures holding results of parallel_sum and void_parallel_sum @@ -247,7 +235,7 @@ int main(int argc, char* argv[]) desc_commandline.add_options()("seed,s", value(), "the random number generator seed to use for this run"); - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/core/executors/tests/unit/parallel_executor.cpp b/libs/core/executors/tests/unit/parallel_executor.cpp index a661539c9403..5912b9ee154f 100644 --- a/libs/core/executors/tests/unit/parallel_executor.cpp +++ b/libs/core/executors/tests/unit/parallel_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -25,7 +25,7 @@ hpx::thread::id test(int passed_through) void test_sync() { - using executor = hpx::execution::parallel_executor; + typedef hpx::execution::parallel_executor executor; executor exec; HPX_TEST(hpx::parallel::execution::sync_execute(exec, &test, 42) == @@ -34,7 +34,7 @@ void test_sync() void test_async() { - using executor = hpx::execution::parallel_executor; + typedef hpx::execution::parallel_executor executor; executor exec; HPX_TEST(hpx::parallel::execution::async_execute(exec, &test, 42).get() != @@ -54,7 +54,7 @@ hpx::thread::id test_f(hpx::future f, int passed_through) void test_then() { - using executor = hpx::execution::parallel_executor; + typedef hpx::execution::parallel_executor executor; hpx::future f = hpx::make_ready_future(); @@ -65,17 +65,7 @@ void test_then() } /////////////////////////////////////////////////////////////////////////////// -template -decltype(auto) disable_run_as_child(Executor&& exec) -{ - auto hint = hpx::execution::experimental::get_hint(exec); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - - return hpx::experimental::prefer(hpx::execution::experimental::with_hint, - HPX_FORWARD(Executor, exec), hint); -} - -void bulk_test(int, hpx::thread::id const& tid, int passed_through) //-V813 +void bulk_test(int, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST_NEQ(tid, hpx::this_thread::get_id()); HPX_TEST_EQ(passed_through, 42); @@ -83,7 +73,7 @@ void bulk_test(int, hpx::thread::id const& tid, int passed_through) //-V813 void test_bulk_sync() { - using executor = hpx::execution::parallel_executor; + typedef hpx::execution::parallel_executor executor; hpx::thread::id tid = hpx::this_thread::get_id(); @@ -95,15 +85,14 @@ void test_bulk_sync() executor exec; hpx::parallel::execution::bulk_sync_execute( - disable_run_as_child(exec), hpx::bind(&bulk_test, _1, tid, _2), v, 42); - hpx::parallel::execution::bulk_sync_execute( - disable_run_as_child(exec), &bulk_test, v, tid, 42); + exec, hpx::bind(&bulk_test, _1, tid, _2), v, 42); + hpx::parallel::execution::bulk_sync_execute(exec, &bulk_test, v, tid, 42); } /////////////////////////////////////////////////////////////////////////////// void test_bulk_async() { - using executor = hpx::execution::parallel_executor; + typedef hpx::execution::parallel_executor executor; hpx::thread::id tid = hpx::this_thread::get_id(); @@ -114,18 +103,16 @@ void test_bulk_async() using hpx::placeholders::_2; executor exec; - hpx::when_all( - hpx::parallel::execution::bulk_async_execute(disable_run_as_child(exec), - hpx::bind(&bulk_test, _1, tid, _2), v, 42)) + hpx::when_all(hpx::parallel::execution::bulk_async_execute( + exec, hpx::bind(&bulk_test, _1, tid, _2), v, 42)) .get(); hpx::when_all(hpx::parallel::execution::bulk_async_execute( - disable_run_as_child(exec), &bulk_test, v, tid, 42)) + exec, &bulk_test, v, tid, 42)) .get(); } /////////////////////////////////////////////////////////////////////////////// -void bulk_test_f(int, hpx::shared_future const& f, - hpx::thread::id const& tid, +void bulk_test_f(int, hpx::shared_future f, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST(f.is_ready()); // make sure, future is ready @@ -138,7 +125,7 @@ void bulk_test_f(int, hpx::shared_future const& f, void test_bulk_then() { - using executor = hpx::execution::parallel_executor; + typedef hpx::execution::parallel_executor executor; hpx::thread::id tid = hpx::this_thread::get_id(); @@ -180,19 +167,19 @@ void test_processing_mask() hpx::execution::parallel_executor exec; { - auto const pool = hpx::threads::detail::get_self_or_default_pool(); - auto const expected_mask = + auto pool = hpx::threads::detail::get_self_or_default_pool(); + auto expected_mask = pool->get_used_processing_units(pool->get_os_thread_count(), false); - auto const mask = + auto mask = hpx::execution::experimental::get_processing_units_mask(exec); HPX_TEST(mask == expected_mask); } { - auto const pool = hpx::threads::detail::get_self_or_default_pool(); - auto const expected_mask = + auto pool = hpx::threads::detail::get_self_or_default_pool(); + auto expected_mask = pool->get_used_processing_units(pool->get_os_thread_count(), true); - auto const mask = hpx::execution::experimental::get_cores_mask(exec); + auto mask = hpx::execution::experimental::get_cores_mask(exec); HPX_TEST(mask == expected_mask); } } @@ -217,7 +204,7 @@ int hpx_main() int main(int argc, char* argv[]) { - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/core/executors/tests/unit/parallel_executor_parameters.cpp b/libs/core/executors/tests/unit/parallel_executor_parameters.cpp index c55a0c70840f..7822d93193a0 100644 --- a/libs/core/executors/tests/unit/parallel_executor_parameters.cpp +++ b/libs/core/executors/tests/unit/parallel_executor_parameters.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -14,16 +14,6 @@ #include #include -template -decltype(auto) disable_run_as_child(Executor&& exec) -{ - auto hint = hpx::execution::experimental::get_hint(exec); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - - return hpx::experimental::prefer(hpx::execution::experimental::with_hint, - HPX_FORWARD(Executor, exec), hint); -} - hpx::threads::thread_stacksize get_stacksize() { return hpx::threads::get_self_stacksize_enum(); @@ -43,8 +33,8 @@ void test_stacksize() HPX_TEST(hpx::execution::experimental::get_stacksize(exec) == hpx::threads::thread_stacksize::default_); - auto newexec = disable_run_as_child( - hpx::execution::experimental::with_stacksize(exec, stacksize)); + auto newexec = + hpx::execution::experimental::with_stacksize(exec, stacksize); HPX_TEST(hpx::execution::experimental::get_stacksize(exec) == hpx::threads::thread_stacksize::default_); @@ -74,8 +64,8 @@ void test_priority() HPX_TEST(hpx::execution::experimental::get_priority(exec) == hpx::threads::thread_priority::default_); - auto newexec = disable_run_as_child( - hpx::execution::experimental::with_priority(exec, priority)); + auto newexec = + hpx::execution::experimental::with_priority(exec, priority); HPX_TEST(hpx::execution::experimental::get_priority(exec) == hpx::threads::thread_priority::default_); @@ -94,22 +84,22 @@ void test_hint() auto orghint = hpx::execution::experimental::get_hint(exec); HPX_TEST(orghint.mode == hpx::threads::thread_schedule_hint_mode::none); - HPX_TEST(orghint.hint == static_cast(-1)); + HPX_TEST(orghint.hint == std::int16_t(-1)); - for (auto const mode : {hpx::threads::thread_schedule_hint_mode::none, + for (auto mode : {hpx::threads::thread_schedule_hint_mode::none, hpx::threads::thread_schedule_hint_mode::thread, hpx::threads::thread_schedule_hint_mode::numa}) { - for (auto const hint : {0, 1}) + for (auto hint : {0, 1}) { hpx::threads::thread_schedule_hint newhint(mode, hint); - auto newexec = disable_run_as_child( - hpx::execution::experimental::with_hint(exec, newhint)); + auto newexec = + hpx::execution::experimental::with_hint(exec, newhint); orghint = hpx::execution::experimental::get_hint(exec); HPX_TEST( orghint.mode == hpx::threads::thread_schedule_hint_mode::none); - HPX_TEST(orghint.hint == static_cast(-1)); + HPX_TEST(orghint.hint == std::int16_t(-1)); newhint = hpx::execution::experimental::get_hint(newexec); HPX_TEST(newhint.mode == mode); @@ -165,15 +155,14 @@ void test_num_cores() using executor = hpx::execution::parallel_executor; executor exec; - auto const num_cores = - hpx::parallel::execution::processing_units_count(exec); + auto num_cores = hpx::parallel::execution::processing_units_count(exec); auto newexec = hpx::parallel::execution::with_processing_units_count(exec, 2); HPX_TEST( num_cores == hpx::parallel::execution::processing_units_count(exec)); - HPX_TEST(static_cast(2) == + HPX_TEST(std::size_t(2) == hpx::parallel::execution::processing_units_count(newexec)); } @@ -193,7 +182,7 @@ int hpx_main() int main(int argc, char* argv[]) { - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/core/executors/tests/unit/parallel_policy_executor.cpp b/libs/core/executors/tests/unit/parallel_policy_executor.cpp index c5c767d97a9e..c3f1ed7c04f2 100644 --- a/libs/core/executors/tests/unit/parallel_policy_executor.cpp +++ b/libs/core/executors/tests/unit/parallel_policy_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2019 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -17,16 +17,6 @@ #include /////////////////////////////////////////////////////////////////////////////// -template -decltype(auto) disable_run_as_child(Executor&& exec) -{ - auto hint = hpx::execution::experimental::get_hint(exec); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - - return hpx::experimental::prefer(hpx::execution::experimental::with_hint, - HPX_FORWARD(Executor, exec), hint); -} - hpx::thread::id test(int passed_through) { HPX_TEST_EQ(passed_through, 42); @@ -36,7 +26,7 @@ hpx::thread::id test(int passed_through) template void test_sync() { - using executor = hpx::execution::parallel_policy_executor; + typedef hpx::execution::parallel_policy_executor executor; executor exec; HPX_TEST(hpx::parallel::execution::sync_execute(exec, &test, 42) == @@ -46,12 +36,12 @@ void test_sync() template void test_async(bool sync) { - using executor = hpx::execution::parallel_policy_executor; + typedef hpx::execution::parallel_policy_executor executor; executor exec; - bool const result = hpx::parallel::execution::async_execute( - disable_run_as_child(exec), &test, 42) - .get() == hpx::this_thread::get_id(); + bool result = + hpx::parallel::execution::async_execute(exec, &test, 42).get() == + hpx::this_thread::get_id(); HPX_TEST_EQ(sync, result); } @@ -70,12 +60,12 @@ hpx::thread::id test_f(hpx::future f, int passed_through) template void test_then(bool sync) { - using executor = hpx::execution::parallel_policy_executor; + typedef hpx::execution::parallel_policy_executor executor; hpx::future f = hpx::make_ready_future(); executor exec; - bool const result = + bool result = hpx::parallel::execution::then_execute(exec, &test_f, f, 42).get() == hpx::this_thread::get_id(); @@ -83,13 +73,13 @@ void test_then(bool sync) } /////////////////////////////////////////////////////////////////////////////// -void bulk_test_s(int, hpx::thread::id const& tid, int passed_through) //-V813 +void bulk_test_s(int, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST_EQ(tid, hpx::this_thread::get_id()); HPX_TEST_EQ(passed_through, 42); } -void bulk_test_a(int, hpx::thread::id const& tid, int passed_through) //-V813 +void bulk_test_a(int, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST_NEQ(tid, hpx::this_thread::get_id()); HPX_TEST_EQ(passed_through, 42); @@ -98,7 +88,7 @@ void bulk_test_a(int, hpx::thread::id const& tid, int passed_through) //-V813 template void test_bulk_sync(bool sync) { - using executor = hpx::execution::parallel_policy_executor; + typedef hpx::execution::parallel_policy_executor executor; hpx::thread::id tid = hpx::this_thread::get_id(); @@ -109,17 +99,17 @@ void test_bulk_sync(bool sync) using hpx::placeholders::_2; executor exec; - hpx::parallel::execution::bulk_sync_execute(disable_run_as_child(exec), + hpx::parallel::execution::bulk_sync_execute(exec, hpx::bind(sync ? &bulk_test_s : &bulk_test_a, _1, tid, _2), v, 42); - hpx::parallel::execution::bulk_sync_execute(disable_run_as_child(exec), - sync ? &bulk_test_s : &bulk_test_a, v, tid, 42); + hpx::parallel::execution::bulk_sync_execute( + exec, sync ? &bulk_test_s : &bulk_test_a, v, tid, 42); } /////////////////////////////////////////////////////////////////////////////// template void test_bulk_async(bool sync) { - using executor = hpx::execution::parallel_policy_executor; + typedef hpx::execution::parallel_policy_executor executor; hpx::thread::id tid = hpx::this_thread::get_id(); @@ -131,18 +121,16 @@ void test_bulk_async(bool sync) executor exec; hpx::when_all( - hpx::parallel::execution::bulk_async_execute(disable_run_as_child(exec), + hpx::parallel::execution::bulk_async_execute(exec, hpx::bind(sync ? &bulk_test_s : &bulk_test_a, _1, tid, _2), v, 42)) .get(); - hpx::when_all( - hpx::parallel::execution::bulk_async_execute(disable_run_as_child(exec), - sync ? &bulk_test_s : &bulk_test_a, v, tid, 42)) + hpx::when_all(hpx::parallel::execution::bulk_async_execute( + exec, sync ? &bulk_test_s : &bulk_test_a, v, tid, 42)) .get(); } /////////////////////////////////////////////////////////////////////////////// -void bulk_test_f_s(int, hpx::shared_future const& f, - hpx::thread::id const& tid, +void bulk_test_f_s(int, hpx::shared_future f, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST(f.is_ready()); // make sure, future is ready @@ -153,8 +141,7 @@ void bulk_test_f_s(int, hpx::shared_future const& f, HPX_TEST_EQ(passed_through, 42); } -void bulk_test_f_a(int, hpx::shared_future const& f, - hpx::thread::id const& tid, +void bulk_test_f_a(int, hpx::shared_future f, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST(f.is_ready()); // make sure, future is ready @@ -168,7 +155,7 @@ void bulk_test_f_a(int, hpx::shared_future const& f, template void test_bulk_then(bool sync) { - using executor = hpx::execution::parallel_policy_executor; + typedef hpx::execution::parallel_policy_executor executor; hpx::thread::id tid = hpx::this_thread::get_id(); @@ -236,7 +223,7 @@ int hpx_main() int main(int argc, char* argv[]) { - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/core/executors/tests/unit/shared_parallel_executor.cpp b/libs/core/executors/tests/unit/shared_parallel_executor.cpp index 457b1d26d215..35d55dee611b 100644 --- a/libs/core/executors/tests/unit/shared_parallel_executor.cpp +++ b/libs/core/executors/tests/unit/shared_parallel_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -26,20 +27,16 @@ struct shared_parallel_executor hpx::parallel::execution::async_execute_t, shared_parallel_executor const&, F&& f, Ts&&... ts) { - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - - return hpx::async(policy, std::forward(f), std::forward(ts)...); + return hpx::async(std::forward(f), std::forward(ts)...); } }; -template <> -struct hpx::parallel::execution::is_two_way_executor - : std::true_type -{ -}; +namespace hpx::parallel::execution { + template <> + struct is_two_way_executor : std::true_type + { + }; +} // namespace hpx::parallel::execution /////////////////////////////////////////////////////////////////////////////// hpx::thread::id test(int passed_through) @@ -63,14 +60,14 @@ void test_async() executor exec; - hpx::shared_future const fut = + hpx::shared_future fut = hpx::parallel::execution::async_execute(exec, &test, 42); HPX_TEST_NEQ(fut.get(), hpx::this_thread::get_id()); } /////////////////////////////////////////////////////////////////////////////// -void bulk_test(int, hpx::thread::id const& tid, int passed_through) //-V813 +void bulk_test(int, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST_NEQ(tid, hpx::this_thread::get_id()); HPX_TEST_EQ(passed_through, 42); @@ -136,7 +133,7 @@ void test_async_void() using executor = shared_parallel_executor; executor exec; - hpx::shared_future const fut = + hpx::shared_future fut = hpx::parallel::execution::async_execute(exec, &void_test, 42); fut.get(); } @@ -157,7 +154,7 @@ int hpx_main() int main(int argc, char* argv[]) { - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/core/executors/tests/unit/standalone_thread_pool_executor.cpp b/libs/core/executors/tests/unit/standalone_thread_pool_executor.cpp index 7250b43d2cdf..29233111906e 100644 --- a/libs/core/executors/tests/unit/standalone_thread_pool_executor.cpp +++ b/libs/core/executors/tests/unit/standalone_thread_pool_executor.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2019 Mikael Simberg -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2017 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -72,17 +72,7 @@ void test_then(Executor& exec) } /////////////////////////////////////////////////////////////////////////////// -template -decltype(auto) disable_run_as_child(Executor&& exec) -{ - auto hint = hpx::execution::experimental::get_hint(exec); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - - return hpx::experimental::prefer(hpx::execution::experimental::with_hint, - HPX_FORWARD(Executor, exec), hint); -} - -void bulk_test(int, hpx::thread::id const& tid, int passed_through) //-V813 +void bulk_test(int, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST_NEQ(tid, hpx::this_thread::get_id()); HPX_TEST_EQ(passed_through, 42); @@ -100,9 +90,8 @@ void test_bulk_sync(Executor& exec) using hpx::placeholders::_2; hpx::parallel::execution::bulk_sync_execute( - disable_run_as_child(exec), hpx::bind(&bulk_test, _1, tid, _2), v, 42); - hpx::parallel::execution::bulk_sync_execute( - disable_run_as_child(exec), &bulk_test, v, tid, 42); + exec, hpx::bind(&bulk_test, _1, tid, _2), v, 42); + hpx::parallel::execution::bulk_sync_execute(exec, &bulk_test, v, tid, 42); } template @@ -116,18 +105,16 @@ void test_bulk_async(Executor& exec) using hpx::placeholders::_1; using hpx::placeholders::_2; - hpx::when_all( - hpx::parallel::execution::bulk_async_execute(disable_run_as_child(exec), - hpx::bind(&bulk_test, _1, tid, _2), v, 42)) + hpx::when_all(hpx::parallel::execution::bulk_async_execute( + exec, hpx::bind(&bulk_test, _1, tid, _2), v, 42)) .get(); hpx::when_all(hpx::parallel::execution::bulk_async_execute( - disable_run_as_child(exec), &bulk_test, v, tid, 42)) + exec, &bulk_test, v, tid, 42)) .get(); } /////////////////////////////////////////////////////////////////////////////// -void bulk_test_f(int, hpx::shared_future const& f, - hpx::thread::id const& tid, +void bulk_test_f(int, hpx::shared_future f, hpx::thread::id tid, int passed_through) //-V813 { HPX_TEST(f.is_ready()); // make sure, future is ready @@ -179,8 +166,8 @@ int main() hpx::threads::policies::local_priority_queue_scheduler<>; // Choose all the parameters for the thread pool and scheduler. - std::size_t const num_threads = (std::min)(static_cast(4), - static_cast(hpx::threads::hardware_concurrency())); + std::size_t const num_threads = (std::min)( + std::size_t(4), std::size_t(hpx::threads::hardware_concurrency())); std::size_t const max_cores = num_threads; hpx::threads::policies::detail::affinity_data ad{}; ad.init(num_threads, max_cores, 0, 1, 0, "core", "balanced", true); diff --git a/libs/core/futures/src/detail/execute_thread.cpp b/libs/core/futures/src/detail/execute_thread.cpp index 53d27a9b5137..196cb37a1099 100644 --- a/libs/core/futures/src/detail/execute_thread.cpp +++ b/libs/core/futures/src/detail/execute_thread.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2024 Hartmut Kaiser +// Copyright (c) 2019-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -91,7 +91,7 @@ namespace hpx::threads::detail { bool reschedule = false; // don't directly run any threads that have started running 'normally' - // and were suspended afterward + // and were suspended afterwards if (thrdptr->runs_as_child()) { LTM_(error).format( @@ -131,8 +131,8 @@ namespace hpx::threads::detail { return false; } - // check again, making sure the state has not changed in the - // meantime + // check again, making sure the state has not changed in the mean + // time if (thrdptr->runs_as_child()) { #if defined(HPX_HAVE_APEX) diff --git a/libs/core/schedulers/include/hpx/schedulers/local_priority_queue_scheduler.hpp b/libs/core/schedulers/include/hpx/schedulers/local_priority_queue_scheduler.hpp index 76733e391d58..f2b42fe1fb84 100644 --- a/libs/core/schedulers/include/hpx/schedulers/local_priority_queue_scheduler.hpp +++ b/libs/core/schedulers/include/hpx/schedulers/local_priority_queue_scheduler.hpp @@ -560,8 +560,8 @@ namespace hpx::threads::policies { num_thread = select_active_pu(num_thread); - data.schedulehint.schedule_hint( - static_cast(num_thread)); + data.schedulehint.mode = thread_schedule_hint_mode::thread; + data.schedulehint.hint = static_cast(num_thread); // now create the thread switch (data.priority) diff --git a/libs/core/schedulers/include/hpx/schedulers/local_workrequesting_scheduler.hpp b/libs/core/schedulers/include/hpx/schedulers/local_workrequesting_scheduler.hpp index 806e8946dd33..a740cffde3a6 100644 --- a/libs/core/schedulers/include/hpx/schedulers/local_workrequesting_scheduler.hpp +++ b/libs/core/schedulers/include/hpx/schedulers/local_workrequesting_scheduler.hpp @@ -692,8 +692,8 @@ namespace hpx::threads::policies { num_thread = select_active_pu(num_thread); - data.schedulehint.schedule_hint( - static_cast(num_thread)); + data.schedulehint.mode = thread_schedule_hint_mode::thread; + data.schedulehint.hint = static_cast(num_thread); // now create the thread switch (data.priority) diff --git a/libs/core/threading/include/hpx/threading/thread.hpp b/libs/core/threading/include/hpx/threading/thread.hpp index 8c1943ed4c8a..d1a60a880e64 100644 --- a/libs/core/threading/include/hpx/threading/thread.hpp +++ b/libs/core/threading/include/hpx/threading/thread.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -43,7 +43,7 @@ namespace hpx { thread_termination_handler_type f); /// The class thread represents a single thread of execution. Threads allow - /// multiple functions to execute concurrently. Threads begin execution + /// multiple functions to execute concurrently. hreads begin execution /// immediately upon construction of the associated thread object (pending /// any OS scheduling delays), starting at the top-level function provided /// as a constructor argument. The return value of the top-level function is @@ -62,6 +62,8 @@ namespace hpx { { using mutex_type = hpx::spinlock; + void terminate(char const* function, char const* reason) const; + public: class id; using native_handle_type = threads::thread_id_type; @@ -73,7 +75,7 @@ namespace hpx { std::enable_if_t, thread>>> explicit thread(F&& f) { - auto const thrd_data = threads::get_self_id_data(); + auto thrd_data = threads::get_self_id_data(); HPX_ASSERT(thrd_data); start_thread(thrd_data->get_scheduler_base()->get_parent_pool(), util::deferred_call(HPX_FORWARD(F, f))); @@ -82,7 +84,7 @@ namespace hpx { template explicit thread(F&& f, Ts&&... vs) { - auto const thrd_data = threads::get_self_id_data(); + auto thrd_data = threads::get_self_id_data(); HPX_ASSERT(thrd_data); start_thread(thrd_data->get_scheduler_base()->get_parent_pool(), util::deferred_call(HPX_FORWARD(F, f), HPX_FORWARD(Ts, vs)...)); @@ -143,15 +145,15 @@ namespace hpx { [[nodiscard]] static unsigned int hardware_concurrency() noexcept; // extensions - void interrupt(bool flag = true) const; + void interrupt(bool flag = true); bool interruption_requested() const; - static void interrupt(id const&, bool flag = true); + static void interrupt(id, bool flag = true); - hpx::future get_future(error_code& ec = throws) const; + hpx::future get_future(error_code& ec = throws); std::size_t get_thread_data() const; - std::size_t set_thread_data(std::size_t) const; + std::size_t set_thread_data(std::size_t); #if defined(HPX_HAVE_LIBCDS) std::size_t get_libcds_data() const; @@ -295,7 +297,7 @@ namespace hpx { /// (and if there are no other threads at the same priority, /// yield has no effect). HPX_CORE_EXPORT void yield() noexcept; - HPX_CORE_EXPORT void yield_to(thread::id const&) noexcept; + HPX_CORE_EXPORT void yield_to(thread::id) noexcept; // extensions HPX_CORE_EXPORT threads::thread_priority get_priority() noexcept; @@ -350,46 +352,45 @@ namespace hpx { class HPX_CORE_EXPORT disable_interruption { - public: - disable_interruption(disable_interruption&&) = delete; - disable_interruption& operator=(disable_interruption&&) = delete; - disable_interruption(disable_interruption const&) = delete; - disable_interruption& operator=( - disable_interruption const&) = delete; + private: + disable_interruption(disable_interruption const&); + disable_interruption& operator=(disable_interruption const&); bool interruption_was_enabled_; friend class restore_interruption; + public: disable_interruption(); ~disable_interruption(); }; class HPX_CORE_EXPORT restore_interruption { - public: - restore_interruption(restore_interruption&&) = delete; - restore_interruption& operator=(restore_interruption&&) = delete; - restore_interruption(restore_interruption const&) = delete; - restore_interruption& operator=( - restore_interruption const&) = delete; + private: + restore_interruption(restore_interruption const&); + restore_interruption& operator=(restore_interruption const&); bool interruption_was_enabled_; - explicit restore_interruption(disable_interruption const& d); + public: + explicit restore_interruption(disable_interruption& d); ~restore_interruption(); }; } // namespace this_thread } // namespace hpx -// specialize std::hash for hpx::thread::id -template <> -struct std::hash<::hpx::thread::id> -{ - std::size_t operator()(::hpx::thread::id const& id) const noexcept +namespace std { + + // specialize std::hash for hpx::thread::id + template <> + struct hash<::hpx::thread::id> { - std::hash<::hpx::threads::thread_id_ref_type> const hasher_; - return hasher_(id.native_handle()); - } -}; // namespace std + std::size_t operator()(::hpx::thread::id const& id) const + { + std::hash<::hpx::threads::thread_id_ref_type> hasher_; + return hasher_(id.native_handle()); + } + }; +} // namespace std #include diff --git a/libs/core/threading/src/thread.cpp b/libs/core/threading/src/thread.cpp index 8df3b30b57cf..7b135e96bb0f 100644 --- a/libs/core/threading/src/thread.cpp +++ b/libs/core/threading/src/thread.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -31,14 +32,14 @@ namespace hpx { - namespace { + namespace detail { - thread_termination_handler_type thread_termination_handler; + static thread_termination_handler_type thread_termination_handler; } void set_thread_termination_handler(thread_termination_handler_type f) { - thread_termination_handler = HPX_MOVE(f); + detail::thread_termination_handler = HPX_MOVE(f); } thread::thread() noexcept @@ -73,7 +74,7 @@ namespace hpx { { if (joinable()) { - if (thread_termination_handler) + if (detail::thread_termination_handler) { try { @@ -82,7 +83,8 @@ namespace hpx { } catch (...) { - thread_termination_handler(std::current_exception()); + detail::thread_termination_handler( + std::current_exception()); } } else @@ -101,20 +103,17 @@ namespace hpx { std::swap(id_, rhs.id_); } - namespace { - - void run_thread_exit_callbacks() + static void run_thread_exit_callbacks() + { + threads::thread_id_type id = threads::get_self_id(); + if (id == threads::invalid_thread_id) { - threads::thread_id_type const id = threads::get_self_id(); - if (id == threads::invalid_thread_id) - { - HPX_THROW_EXCEPTION(hpx::error::null_thread_id, - "run_thread_exit_callbacks", "null thread id encountered"); - } - threads::run_thread_exit_callbacks(id); - threads::free_thread_exit_callbacks(id); + HPX_THROW_EXCEPTION(hpx::error::null_thread_id, + "run_thread_exit_callbacks", "null thread id encountered"); } - } // namespace + threads::run_thread_exit_callbacks(id); + threads::free_thread_exit_callbacks(id); + } threads::thread_result_type thread::thread_function_nullary( hpx::move_only_function const& func) @@ -147,8 +146,9 @@ namespace hpx { // run all callbacks attached to the exit event for this thread run_thread_exit_callbacks(); - return {threads::thread_schedule_state::terminated, - threads::invalid_thread_id}; + return threads::thread_result_type( + threads::thread_schedule_state::terminated, + threads::invalid_thread_id); } thread::id thread::get_id() const noexcept @@ -182,17 +182,15 @@ namespace hpx { { HPX_THROW_EXCEPTION(hpx::error::thread_resource_error, "thread::start_thread", "Could not create thread"); + return; } } - namespace { - - void resume_thread(threads::thread_id_ref_type const& id) - { - threads::set_thread_state( - id.noref(), threads::thread_schedule_state::pending); - } - } // namespace + static void resume_thread(threads::thread_id_ref_type const& id) + { + threads::set_thread_state( + id.noref(), threads::thread_schedule_state::pending); + } void thread::join() { @@ -212,6 +210,7 @@ namespace hpx { l.unlock(); HPX_THROW_EXCEPTION(hpx::error::thread_resource_error, "thread::join", "hpx::thread: trying joining itself"); + return; } this_thread::interruption_point(); @@ -229,7 +228,7 @@ namespace hpx { } // extensions - void thread::interrupt(bool flag) const + void thread::interrupt(bool flag) { threads::interrupt_thread(native_handle(), flag); } @@ -239,7 +238,7 @@ namespace hpx { return threads::get_thread_interruption_requested(native_handle()); } - void thread::interrupt(thread::id const& id, bool flag) + void thread::interrupt(thread::id id, bool flag) { threads::interrupt_thread(id.id_, flag); } @@ -248,7 +247,7 @@ namespace hpx { { return threads::get_thread_data(native_handle()); } - std::size_t thread::set_thread_data(std::size_t data) const + std::size_t thread::set_thread_data(std::size_t data) { return threads::set_thread_data(native_handle(), data); } @@ -298,7 +297,7 @@ namespace hpx { using base_type::mtx_; public: - explicit thread_task_base(threads::thread_id_ref_type const& id) + thread_task_base(threads::thread_id_ref_type const& id) { if (threads::add_thread_exit_callback(id.noref(), hpx::bind_front(&thread_task_base::thread_exit_function, @@ -346,13 +345,13 @@ namespace hpx { }; } // namespace detail - hpx::future thread::get_future(error_code& ec) const + hpx::future thread::get_future(error_code& ec) { if (id_ == threads::invalid_thread_id) { HPX_THROWS_IF(ec, hpx::error::null_thread_id, "thread::get_future", "null thread id encountered"); - return {}; + return hpx::future(); } detail::thread_task_base* p = new detail::thread_task_base(id_); @@ -362,7 +361,7 @@ namespace hpx { HPX_THROWS_IF(ec, hpx::error::thread_resource_error, "thread::get_future", "Could not create future as thread has been terminated."); - return {}; + return hpx::future(); } using traits::future_access; @@ -372,7 +371,7 @@ namespace hpx { /////////////////////////////////////////////////////////////////////////// namespace this_thread { - void yield_to(thread::id const& id) noexcept + void yield_to(thread::id id) noexcept { this_thread::suspend(threads::thread_schedule_state::pending, id.native_handle(), "this_thread::yield_to"); @@ -487,7 +486,8 @@ namespace hpx { disable_interruption::~disable_interruption() { - if (threads::get_self_ptr() != nullptr) + threads::thread_self* p = threads::get_self_ptr(); + if (p) { threads::set_thread_interruption_enabled( threads::get_self_id(), interruption_was_enabled_); @@ -495,8 +495,7 @@ namespace hpx { } /////////////////////////////////////////////////////////////////////// - restore_interruption::restore_interruption( - disable_interruption const& d) + restore_interruption::restore_interruption(disable_interruption& d) : interruption_was_enabled_(d.interruption_was_enabled_) { if (!interruption_was_enabled_) @@ -509,7 +508,8 @@ namespace hpx { restore_interruption::~restore_interruption() { - if (threads::get_self_ptr() != nullptr) + threads::thread_self* p = threads::get_self_ptr(); + if (p) { threads::set_thread_interruption_enabled( threads::get_self_id(), interruption_was_enabled_); diff --git a/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp b/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp index 4f84df68aedd..ff4e8348cb25 100644 --- a/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp +++ b/libs/core/threading_base/include/hpx/threading_base/thread_data.hpp @@ -689,11 +689,8 @@ namespace hpx::threads { if (is_stackless()) { - HPX_ASSERT(dynamic_cast(this) != nullptr); return static_cast(this)->call(); } - - HPX_ASSERT(dynamic_cast(this) != nullptr); return static_cast(this)->call(agent_storage); } @@ -703,11 +700,8 @@ namespace hpx::threads { if (is_stackless()) { - HPX_ASSERT(dynamic_cast(this) != nullptr); return static_cast(this)->call(); } - - HPX_ASSERT(dynamic_cast(this) != nullptr); - return static_cast(this)->call_directly(); + return static_cast(this)->invoke_directly(); } } // namespace hpx::threads diff --git a/libs/core/threading_base/include/hpx/threading_base/thread_data_stackful.hpp b/libs/core/threading_base/include/hpx/threading_base/thread_data_stackful.hpp index d3240aef378c..c9eee85b8752 100644 --- a/libs/core/threading_base/include/hpx/threading_base/thread_data_stackful.hpp +++ b/libs/core/threading_base/include/hpx/threading_base/thread_data_stackful.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // Copyright (c) 2008-2009 Chirag Dekate, Anshul Tandon // @@ -68,7 +68,7 @@ namespace hpx::threads { return coroutine_(set_state_ex(thread_restart_state::signaled)); } - HPX_FORCEINLINE coroutine_type::result_type call_directly() + HPX_FORCEINLINE coroutine_type::result_type invoke_directly() { HPX_ASSERT(get_state().state() == thread_schedule_state::active); HPX_ASSERT(this == coroutine_.get_thread_id().get()); diff --git a/libs/core/threading_base/include/hpx/threading_base/threading_base_fwd.hpp b/libs/core/threading_base/include/hpx/threading_base/threading_base_fwd.hpp index ad05e6bf5dfc..230468b44c42 100644 --- a/libs/core/threading_base/include/hpx/threading_base/threading_base_fwd.hpp +++ b/libs/core/threading_base/include/hpx/threading_base/threading_base_fwd.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -101,15 +101,10 @@ namespace hpx::threads { /// The function \a get_outer_self_id returns the HPX thread id of /// the current outer thread (or zero if the current thread is not a HPX - /// thread). This now always returns the same as \a get_self_id, even for - /// directly executed threads. - HPX_DEPRECATED_V(1, 10, - "hpx::threads::get_outer_self_id is deprecated, use " - "hpx::threads::get_self_id instead") - inline thread_id_type get_outer_self_id() noexcept - { - return get_self_id(); - } + /// thread). This usually returns the same as \a get_self_id, except for + /// directly executed threads, in which case this returns the thread id + /// of the outermost HPX thread. + HPX_CORE_EXPORT thread_id_type get_outer_self_id() noexcept; /// The function \a get_parent_id returns the HPX thread id of the /// current thread's parent (or zero if the current thread is not a diff --git a/libs/core/threading_base/src/set_thread_state_timed.cpp b/libs/core/threading_base/src/set_thread_state_timed.cpp index f28ff76c95d5..9b762a825935 100644 --- a/libs/core/threading_base/src/set_thread_state_timed.cpp +++ b/libs/core/threading_base/src/set_thread_state_timed.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -83,7 +83,7 @@ namespace hpx::threads::detail { // create a new thread in suspended state, which will execute the // requested set_state when timer fires and will re-awaken this thread, // allowing the deadline_timer to go out of scope gracefully - thread_id_ref_type const self_id = get_self_id(); // keep alive + thread_id_ref_type const self_id = get_outer_self_id(); // keep alive std::shared_ptr> triggered( std::make_shared>(false)); diff --git a/libs/core/threading_base/src/thread_data.cpp b/libs/core/threading_base/src/thread_data.cpp index 5049acf2c214..228c8de17b2a 100644 --- a/libs/core/threading_base/src/thread_data.cpp +++ b/libs/core/threading_base/src/thread_data.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2023 Hartmut Kaiser // Copyright (c) 2008-2009 Chirag Dekate, Anshul Tandon // Copyright (c) 2011 Bryce Lelbach // @@ -35,7 +35,7 @@ namespace hpx::threads { void set_get_locality_id(get_locality_id_type* f) { - get_locality_id_f = f; + get_locality_id_f = HPX_MOVE(f); } std::uint32_t get_locality_id(hpx::error_code& ec) @@ -315,6 +315,16 @@ namespace hpx::threads { } thread_id_type get_self_id() noexcept + { + if (thread_self const* self = get_self_ptr(); + HPX_LIKELY(nullptr != self)) + { + return self->get_thread_id(); + } + return threads::invalid_thread_id; + } + + thread_id_type get_outer_self_id() noexcept { if (thread_self const* self = get_self_ptr(); HPX_LIKELY(nullptr != self)) @@ -329,7 +339,7 @@ namespace hpx::threads { if (thread_self const* self = get_self_ptr(); HPX_LIKELY(nullptr != self)) { - return get_thread_id_data(self->get_outer_thread_id()); + return get_thread_id_data(self->get_thread_id()); } return nullptr; } @@ -408,7 +418,7 @@ namespace hpx::threads { if (thread_data const* thrd_data = get_self_id_data(); HPX_LIKELY(nullptr != thrd_data)) { - return hpx::threads::thread_data::get_component_id(); + return thrd_data->get_component_id(); } return 0; #endif diff --git a/libs/core/threading_base/src/thread_helpers.cpp b/libs/core/threading_base/src/thread_helpers.cpp index 7e8a3d814310..810bf734686e 100644 --- a/libs/core/threading_base/src/thread_helpers.cpp +++ b/libs/core/threading_base/src/thread_helpers.cpp @@ -98,9 +98,6 @@ namespace hpx::threads { void interrupt_thread(thread_id_type const& id, bool flag, error_code& ec) { - // Copy id as the original `id` may get reset by the caller - // asynchronously. - auto const keep_alive = id; if (HPX_UNLIKELY(!id)) { HPX_THROWS_IF(ec, hpx::error::null_thread_id, @@ -115,7 +112,7 @@ namespace hpx::threads { // Set thread state to pending. If the thread is currently active we do // not retry. The thread will either exit or hit an interruption_point. - set_thread_state(keep_alive, thread_schedule_state::pending, + set_thread_state(id, thread_schedule_state::pending, thread_restart_state::abort, thread_priority::normal, false, ec); } @@ -631,7 +628,6 @@ namespace hpx::this_thread { HPX_THROW_EXCEPTION(hpx::error::out_of_memory, "has_sufficient_stack_space", "Stack overflow"); } - bool const sufficient_stack_space = static_cast(remaining_stack) >= space_needed; diff --git a/libs/core/threading_base/tests/regressions/thread_stacksize_current.cpp b/libs/core/threading_base/tests/regressions/thread_stacksize_current.cpp index 63045d2d60bb..5c1ede262265 100644 --- a/libs/core/threading_base/tests/regressions/thread_stacksize_current.cpp +++ b/libs/core/threading_base/tests/regressions/thread_stacksize_current.cpp @@ -1,5 +1,4 @@ // Copyright (c) 2020 Mikael Simberg -// Copyright (c) 2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,7 +10,6 @@ // thread_stacksize::minimal and thread_stacksize::maximal when a thread has been // created. -#include #include #include #include @@ -22,23 +20,13 @@ #include #include -template -decltype(auto) disable_run_as_child(Executor&& exec) -{ - auto hint = hpx::execution::experimental::get_hint(exec); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - - return hpx::experimental::prefer(hpx::execution::experimental::with_hint, - HPX_FORWARD(Executor, exec), hint); -} - void test(hpx::threads::thread_stacksize stacksize) { hpx::execution::parallel_executor exec(stacksize); hpx::execution::parallel_executor exec_current( hpx::threads::thread_stacksize::current); - hpx::async(disable_run_as_child(exec), [&exec_current, stacksize]() { + hpx::async(exec, [&exec_current, stacksize]() { // This thread should have the stack size stacksize; it has been // explicitly set in the executor. hpx::threads::thread_stacksize const self_stacksize = @@ -46,7 +34,7 @@ void test(hpx::threads::thread_stacksize stacksize) HPX_TEST_EQ(self_stacksize, stacksize); HPX_TEST_NEQ(self_stacksize, hpx::threads::thread_stacksize::current); - hpx::async(disable_run_as_child(exec_current), [stacksize]() { + hpx::async(exec_current, [stacksize]() { // This thread should also have the stack size stacksize; it has // been inherited size from the parent thread. hpx::threads::thread_stacksize const self_stacksize = diff --git a/libs/core/timed_execution/tests/unit/minimal_timed_async_executor.cpp b/libs/core/timed_execution/tests/unit/minimal_timed_async_executor.cpp index b6bb345a6668..3a12631aad5d 100644 --- a/libs/core/timed_execution/tests/unit/minimal_timed_async_executor.cpp +++ b/libs/core/timed_execution/tests/unit/minimal_timed_async_executor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2022 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -39,7 +39,7 @@ void apply_test(hpx::latch& l, hpx::thread::id& id, int passed_through) /////////////////////////////////////////////////////////////////////////////// template -void test_timed_apply(Executor&& exec) +void test_timed_apply(Executor& exec) { { hpx::latch l(2); @@ -73,7 +73,7 @@ void test_timed_apply(Executor&& exec) } template -void test_timed_sync(Executor&& exec) +void test_timed_sync(Executor& exec) { { hpx::parallel::execution::timed_executor timed_exec( @@ -93,7 +93,7 @@ void test_timed_sync(Executor&& exec) } template -void test_timed_async(Executor&& exec) +void test_timed_async(Executor& exec) { { hpx::parallel::execution::timed_executor timed_exec( @@ -124,11 +124,11 @@ std::atomic count_async_at(0); template void test_timed_executor(std::array expected) { - using execution_category = - typename hpx::traits::executor_execution_category::type; + typedef typename hpx::traits::executor_execution_category::type + execution_category; - HPX_TEST((std::is_same_v) ); + HPX_TEST((std::is_same::value)); count_sync.store(0); count_apply.store(0); @@ -154,20 +154,15 @@ void test_timed_executor(std::array expected) /////////////////////////////////////////////////////////////////////////////// struct test_async_executor1 { - using execution_category = hpx::execution::parallel_execution_tag; + typedef hpx::execution::parallel_execution_tag execution_category; template friend decltype(auto) tag_invoke(hpx::parallel::execution::async_execute_t, test_async_executor1 const&, F&& f, Ts&&... ts) { ++count_async; - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - - return hpx::async(policy, std::forward(f), std::forward(ts)...); + return hpx::async( + hpx::launch::async, std::forward(f), std::forward(ts)...); } }; @@ -180,14 +175,9 @@ struct test_timed_async_executor1 : test_async_executor1 hpx::chrono::steady_time_point const& abs_time, F&& f, Ts&&... ts) { ++count_async_at; - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - hpx::this_thread::sleep_until(abs_time); - return hpx::async(policy, std::forward(f), std::forward(ts)...); + return hpx::async( + hpx::launch::async, std::forward(f), std::forward(ts)...); } }; @@ -210,13 +200,8 @@ struct test_timed_async_executor2 : test_async_executor1 test_timed_async_executor2 const&, F&& f, Ts&&... ts) { ++count_sync; - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - - return hpx::async(policy, std::forward(f), std::forward(ts)...) + return hpx::async( + hpx::launch::async, std::forward(f), std::forward(ts)...) .get(); } }; @@ -231,13 +216,8 @@ struct test_timed_async_executor3 : test_timed_async_executor2 { ++count_sync_at; hpx::this_thread::sleep_until(abs_time); - - auto policy = hpx::launch::async; - auto hint = policy.hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - - return hpx::async(policy, std::forward(f), std::forward(ts)...) + return hpx::async( + hpx::launch::async, std::forward(f), std::forward(ts)...) .get(); } }; @@ -305,7 +285,7 @@ int hpx_main() int main(int argc, char* argv[]) { - // By default, this test should run on all available cores + // By default this test should run on all available cores std::vector const cfg = {"hpx.os_threads=all"}; // Initialize and run HPX diff --git a/libs/full/performance_counters/include/hpx/performance_counters/counter_interface.hpp b/libs/full/performance_counters/include/hpx/performance_counters/counter_interface.hpp index 240a85a189db..8a39be09115a 100644 --- a/libs/full/performance_counters/include/hpx/performance_counters/counter_interface.hpp +++ b/libs/full/performance_counters/include/hpx/performance_counters/counter_interface.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2024 Hartmut Kaiser +// Copyright (c) 2021 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -16,10 +16,10 @@ namespace hpx { namespace performance_counters { /////////////////////////////////////////////////////////////////////////// HPX_EXPORT hpx::future create_performance_counter_async( - id_type const& target_id, counter_info const& info); + id_type target_id, counter_info const& info); - inline id_type create_performance_counter(id_type const& target_id, - counter_info const& info, error_code& ec = throws) + inline id_type create_performance_counter( + id_type target_id, counter_info const& info, error_code& ec = throws) { return create_performance_counter_async(target_id, info).get(ec); } diff --git a/libs/full/performance_counters/include/hpx/performance_counters/detail/counter_interface_functions.hpp b/libs/full/performance_counters/include/hpx/performance_counters/detail/counter_interface_functions.hpp index f552df63374b..89e0d417bbed 100644 --- a/libs/full/performance_counters/include/hpx/performance_counters/detail/counter_interface_functions.hpp +++ b/libs/full/performance_counters/include/hpx/performance_counters/detail/counter_interface_functions.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2024 Hartmut Kaiser +// Copyright (c) 2021 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,9 +11,9 @@ #include #include -namespace hpx::performance_counters::detail { +namespace hpx { namespace performance_counters { namespace detail { /////////////////////////////////////////////////////////////////////////// extern HPX_EXPORT hpx::future (*create_performance_counter_async)( - id_type const& target_id, counter_info const& info); -} // namespace hpx::performance_counters::detail + id_type target_id, counter_info const& info); +}}} // namespace hpx::performance_counters::detail diff --git a/libs/full/performance_counters/src/counter_interface.cpp b/libs/full/performance_counters/src/counter_interface.cpp index dfb2719af186..736170ad1398 100644 --- a/libs/full/performance_counters/src/counter_interface.cpp +++ b/libs/full/performance_counters/src/counter_interface.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021-2024 Hartmut Kaiser +// Copyright (c) 2021 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -11,12 +11,12 @@ #include #include -namespace hpx::performance_counters { +namespace hpx { namespace performance_counters { /////////////////////////////////////////////////////////////////////////// hpx::future create_performance_counter_async( - id_type const& target_id, counter_info const& info) + id_type target_id, counter_info const& info) { return detail::create_performance_counter_async(target_id, info); } -} // namespace hpx::performance_counters +}} // namespace hpx::performance_counters diff --git a/libs/full/performance_counters/src/counters.cpp b/libs/full/performance_counters/src/counters.cpp index f7388592b43d..2fefc351b9ab 100644 --- a/libs/full/performance_counters/src/counters.cpp +++ b/libs/full/performance_counters/src/counters.cpp @@ -1199,7 +1199,7 @@ namespace hpx::performance_counters { if (ec) return {}; - // Take target locality from base counter if this is an + // Take target locality from base counter if if this is an // aggregating counter (the instance name is a base counter). if (p.parentinstance_is_basename_) { diff --git a/libs/full/performance_counters/src/detail/counter_interface_functions.cpp b/libs/full/performance_counters/src/detail/counter_interface_functions.cpp index 447a3537a4f9..cb76bdf1c6d9 100644 --- a/libs/full/performance_counters/src/detail/counter_interface_functions.cpp +++ b/libs/full/performance_counters/src/detail/counter_interface_functions.cpp @@ -1,16 +1,17 @@ -// Copyright (c) 2021-2024 Hartmut Kaiser +// Copyright (c) 2021 Hartmut Kaiser // // 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 #include -namespace hpx::performance_counters::detail { +namespace hpx { namespace performance_counters { namespace detail { hpx::future (*create_performance_counter_async)( - id_type const& target_id, counter_info const& info) = nullptr; -} // namespace hpx::performance_counters::detail + id_type target_id, counter_info const& info) = nullptr; +}}} // namespace hpx::performance_counters::detail diff --git a/libs/full/runtime_distributed/include/hpx/runtime_distributed/stubs/runtime_support.hpp b/libs/full/runtime_distributed/include/hpx/runtime_distributed/stubs/runtime_support.hpp index 68e597659df2..673d7c864812 100644 --- a/libs/full/runtime_distributed/include/hpx/runtime_distributed/stubs/runtime_support.hpp +++ b/libs/full/runtime_distributed/include/hpx/runtime_distributed/stubs/runtime_support.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2021 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -24,7 +25,7 @@ #include #include -namespace hpx::components::stubs { +namespace hpx { namespace components { namespace stubs { /////////////////////////////////////////////////////////////////////////// // The \a runtime_support class is the client side representation of a @@ -46,10 +47,12 @@ namespace hpx::components::stubs { "stubs::runtime_support::create_component_async", "The id passed as the first argument is not representing" " a locality"); + return hpx::make_ready_future(hpx::invalid_id); } - using action_type = - server::create_component_action...>; + typedef server::create_component_action::type...> + action_type; return hpx::async(gid, HPX_FORWARD(Ts, vs)...); } @@ -72,8 +75,9 @@ namespace hpx::components::stubs { bulk_create_component_colocated_async( hpx::id_type const& gid, std::size_t count, Ts&&... vs) { - using action_type = server::bulk_create_component_action...>; + typedef server::bulk_create_component_action::type...> + action_type; return hpx::detail::async_colocated( gid, count, HPX_FORWARD(Ts, vs)...); @@ -104,10 +108,12 @@ namespace hpx::components::stubs { "stubs::runtime_support::bulk_create_component_async", "The id passed as the first argument is not representing" " a locality"); + return hpx::make_ready_future(std::vector()); } - using action_type = server::bulk_create_component_action...>; + typedef server::bulk_create_component_action::type...> + action_type; return hpx::async(gid, count, HPX_FORWARD(Ts, vs)...); } @@ -130,8 +136,9 @@ namespace hpx::components::stubs { static hpx::future create_component_colocated_async( hpx::id_type const& gid, Ts&&... vs) { - using action_type = - server::create_component_action...>; + typedef server::create_component_action::type...> + action_type; return hpx::detail::async_colocated( gid, HPX_FORWARD(Ts, vs)...); } @@ -160,9 +167,11 @@ namespace hpx::components::stubs { "stubs::runtime_support::copy_create_component_async", "The id passed as the first argument is not representing" " a locality"); + return hpx::make_ready_future(hpx::invalid_id); } - using action_type = server::copy_create_component_action; + typedef typename server::copy_create_component_action + action_type; return hpx::async(gid, p, local_op); } @@ -189,10 +198,11 @@ namespace hpx::components::stubs { "stubs::runtime_support::migrate_component_async", "The id passed as the first argument is not representing" " a locality"); + return hpx::make_ready_future(hpx::invalid_id); } - using action_type = - server::migrate_component_here_action; + typedef typename server::migrate_component_here_action + action_type; return hpx::async(target_locality, p, to_migrate); } @@ -201,8 +211,8 @@ namespace hpx::components::stubs { DistPolicy const& policy, std::shared_ptr const& p, hpx::id_type const& to_migrate) { - using action_type = - server::migrate_component_here_action; + typedef typename server::migrate_component_here_action + action_type; return hpx::async(policy, p, to_migrate); } @@ -259,10 +269,9 @@ namespace hpx::components::stubs { /////////////////////////////////////////////////////////////////////// static hpx::future create_performance_counter_async( - hpx::id_type const& targetgid, + hpx::id_type targetgid, performance_counters::counter_info const& info); - static hpx::id_type create_performance_counter( - hpx::id_type const& targetgid, + static hpx::id_type create_performance_counter(hpx::id_type targetgid, performance_counters::counter_info const& info, error_code& ec = throws); @@ -278,4 +287,4 @@ namespace hpx::components::stubs { hpx::id_type const& target, naming::gid_type const& gid, parcelset::endpoints_type const& endpoints); }; -} // namespace hpx::components::stubs +}}} // namespace hpx::components::stubs diff --git a/libs/full/runtime_distributed/src/runtime_support.cpp b/libs/full/runtime_distributed/src/runtime_support.cpp index c18522630b3c..124ced88a2ca 100644 --- a/libs/full/runtime_distributed/src/runtime_support.cpp +++ b/libs/full/runtime_distributed/src/runtime_support.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2021 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -17,7 +17,7 @@ HPX_PLUGIN_EXPORT_LIST(HPX_PLUGIN_COMPONENT_PREFIX, factory) HPX_REGISTER_REGISTRY_MODULE() -namespace hpx::components::server { +namespace hpx { namespace components { namespace server { void runtime_support::add_pre_startup_function(startup_function_type f) { @@ -54,9 +54,9 @@ namespace hpx::components::server { shutdown_functions_.push_back(HPX_MOVE(f)); } } -} // namespace hpx::components::server +}}} // namespace hpx::components::server -namespace hpx::agas::detail::impl { +namespace hpx { namespace agas { namespace detail { namespace impl { /// \brief Invoke an asynchronous garbage collection step on the given target /// locality. @@ -90,9 +90,9 @@ namespace hpx::agas::detail::impl { ec = make_error_code(e.get_error(), e.what()); } } -} // namespace hpx::agas::detail::impl +}}}} // namespace hpx::agas::detail::impl -namespace hpx::agas { +namespace hpx { namespace agas { // initialize AGAS interface function pointers in components_base module struct HPX_EXPORT runtime_components_init_interface_functions @@ -111,9 +111,9 @@ namespace hpx::agas { runtime_components_init_; return runtime_components_init_; } -} // namespace hpx::agas +}} // namespace hpx::agas -namespace hpx::components { +namespace hpx { namespace components { // some compilers try to invoke this function, even if it's actually not // needed @@ -140,4 +140,4 @@ namespace hpx::components { static counter_interface_functions counter_init_; return counter_init_; } -} // namespace hpx::components +}} // namespace hpx::components diff --git a/libs/full/runtime_distributed/src/server/runtime_support_server.cpp b/libs/full/runtime_distributed/src/server/runtime_support_server.cpp index 8ad6f24c9d1c..03526483d60f 100644 --- a/libs/full/runtime_distributed/src/server/runtime_support_server.cpp +++ b/libs/full/runtime_distributed/src/server/runtime_support_server.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -308,11 +307,8 @@ namespace hpx { namespace components { namespace server { } // We need the lock here to ensure the mutual exclusion of - // hpx::latch::count_down and hpx::latch::~latch - std::unique_lock l(dijkstra_mtx_); - [[maybe_unused]] hpx::util::ignore_while_checking< - std::unique_lock> - il(&l); + // hpx::latch::count_down and and hpx::latch::~latch + std::lock_guard l(dijkstra_mtx_); dijkstra_cond_->count_down(1); return; } @@ -401,11 +397,8 @@ namespace hpx { namespace components { namespace server { } while (dijkstra_color_); // We need the lock here to ensure the mutual exclusion of - // hpx::latch::count_down and hpx::latch::~latch - std::unique_lock l(dijkstra_mtx_); - [[maybe_unused]] hpx::util::ignore_while_checking< - std::unique_lock> - il(&l); + // hpx::latch::count_down and and hpx::latch::~latch + std::lock_guard l(dijkstra_mtx_); dijkstra_cond_.reset(); } @@ -868,7 +861,7 @@ namespace hpx { namespace components { namespace server { // working around non-copy-ability of packaged_task struct indirect_packaged_task { - using packaged_task_type = hpx::packaged_task; + typedef hpx::packaged_task packaged_task_type; indirect_packaged_task() : pt(std::make_shared([]() {})) @@ -901,8 +894,8 @@ namespace hpx { namespace components { namespace server { std::vector locality_ids = find_remote_localities(); - using action_type = - server::runtime_support::remove_from_connection_cache_action; + typedef server::runtime_support::remove_from_connection_cache_action + action_type; std::vector> callbacks; callbacks.reserve(locality_ids.size()); @@ -935,8 +928,8 @@ namespace hpx { namespace components { namespace server { if (rtd == nullptr) return; - using action_type = - server::runtime_support::remove_from_connection_cache_action; + typedef server::runtime_support::remove_from_connection_cache_action + action_type; action_type act; indirect_packaged_task ipt; @@ -960,7 +953,7 @@ namespace hpx { namespace components { namespace server { char const* message_handler_type, char const* action, error_code& ec) { // locate the factory for the requested plugin type - using plugin_map_scoped_lock = std::unique_lock; + typedef std::unique_lock plugin_map_scoped_lock; plugin_map_scoped_lock l(p_mtx_); plugin_map_type::const_iterator it = @@ -1022,7 +1015,7 @@ namespace hpx { namespace components { namespace server { std::size_t interval, error_code& ec) { // locate the factory for the requested plugin type - using plugin_map_scoped_lock = std::unique_lock; + typedef std::unique_lock plugin_map_scoped_lock; plugin_map_scoped_lock l(p_mtx_); plugin_map_type::const_iterator it = @@ -1083,7 +1076,7 @@ namespace hpx { namespace components { namespace server { serialization::binary_filter* next_filter, error_code& ec) { // locate the factory for the requested plugin type - using plugin_map_scoped_lock = std::unique_lock; + typedef std::unique_lock plugin_map_scoped_lock; plugin_map_scoped_lock l(p_mtx_); plugin_map_type::const_iterator it = plugins_.find(binary_filter_type); @@ -1231,7 +1224,7 @@ namespace hpx { namespace components { namespace server { } util::section::section_map const& s = (*sec).get_sections(); - using iterator = util::section::section_map::const_iterator; + typedef util::section::section_map::const_iterator iterator; iterator end = s.end(); for (iterator i = s.begin(); i != end; ++i) { @@ -1732,7 +1725,7 @@ namespace hpx { namespace components { namespace server { } util::section::section_map const& s = (*sec).get_sections(); - using iterator = util::section::section_map::const_iterator; + typedef util::section::section_map::const_iterator iterator; iterator end = s.end(); for (iterator i = s.begin(); i != end; ++i) { diff --git a/libs/full/runtime_distributed/src/stubs/runtime_support_stubs.cpp b/libs/full/runtime_distributed/src/stubs/runtime_support_stubs.cpp index e7dd24987bb4..bd752703169e 100644 --- a/libs/full/runtime_distributed/src/stubs/runtime_support_stubs.cpp +++ b/libs/full/runtime_distributed/src/stubs/runtime_support_stubs.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2024 Hartmut Kaiser +// Copyright (c) 2007-2016 Hartmut Kaiser // Copyright (c) 2011 Bryce Lelbach // // SPDX-License-Identifier: BSL-1.0 @@ -19,32 +19,24 @@ #include #include #include +#include #include #include #include +#include -namespace hpx::components::stubs { - - template - auto disable_run_as_child(Policy&& p) - { - auto policy = p; - auto hint = policy.get_hint(); - hint.runs_as_child_mode(hpx::threads::thread_execution_hint::none); - policy.set_hint(hint); - return policy; - } +namespace hpx { namespace components { namespace stubs { hpx::future runtime_support::load_components_async( - [[maybe_unused]] hpx::id_type const& gid) + hpx::id_type const& gid) { #if !defined(HPX_COMPUTE_DEVICE_CODE) - using action_type = server::runtime_support::load_components_action; - return hpx::async( - disable_run_as_child(hpx::launch::async), gid); + typedef server::runtime_support::load_components_action action_type; + return hpx::async(gid); #else HPX_ASSERT(false); + HPX_UNUSED(gid); return hpx::make_ready_future(0); #endif } @@ -55,17 +47,16 @@ namespace hpx::components::stubs { } hpx::future runtime_support::call_startup_functions_async( - [[maybe_unused]] hpx::id_type const& gid, - [[maybe_unused]] bool pre_startup) + hpx::id_type const& gid, bool pre_startup) { #if !defined(HPX_COMPUTE_DEVICE_CODE) - using action_type = - server::runtime_support::call_startup_functions_action; - - return hpx::async( - disable_run_as_child(hpx::launch::async), gid, pre_startup); + typedef server::runtime_support::call_startup_functions_action + action_type; + return hpx::async(gid, pre_startup); #else HPX_ASSERT(false); + HPX_UNUSED(gid); + HPX_UNUSED(pre_startup); return ::hpx::make_ready_future(); #endif } @@ -78,14 +69,13 @@ namespace hpx::components::stubs { /// \brief Shutdown the given runtime system hpx::future runtime_support::shutdown_async( - [[maybe_unused]] hpx::id_type const& targetgid, - [[maybe_unused]] double timeout) + hpx::id_type const& targetgid, double timeout) { #if !defined(HPX_COMPUTE_DEVICE_CODE) // Create a promise directly and execute the required action. // This action has implemented special response handling as the // back-parcel is sent explicitly (and synchronously). - using action_type = server::runtime_support::shutdown_action; + typedef server::runtime_support::shutdown_action action_type; hpx::distributed::promise value; auto f = value.get_future(); @@ -98,6 +88,8 @@ namespace hpx::components::stubs { return f; #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); + HPX_UNUSED(timeout); return ::hpx::make_ready_future(); #endif } @@ -112,18 +104,19 @@ namespace hpx::components::stubs { /// \brief Shutdown the runtime systems of all localities void runtime_support::shutdown_all( - [[maybe_unused]] hpx::id_type const& targetgid, - [[maybe_unused]] double timeout) + hpx::id_type const& targetgid, double timeout) { #if !defined(HPX_COMPUTE_DEVICE_CODE) hpx::post( targetgid, timeout); #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); + HPX_UNUSED(timeout); #endif } - void runtime_support::shutdown_all([[maybe_unused]] double timeout) + void runtime_support::shutdown_all(double timeout) { #if !defined(HPX_COMPUTE_DEVICE_CODE) hpx::post( @@ -133,6 +126,7 @@ namespace hpx::components::stubs { timeout); #else HPX_ASSERT(false); + HPX_UNUSED(timeout); #endif } @@ -140,13 +134,13 @@ namespace hpx::components::stubs { /// \brief Retrieve configuration information /// \brief Terminate the given runtime system hpx::future runtime_support::terminate_async( - [[maybe_unused]] hpx::id_type const& targetgid) + hpx::id_type const& targetgid) { #if !defined(HPX_COMPUTE_DEVICE_CODE) // Create a future directly and execute the required action. // This action has implemented special response handling as the // back-parcel is sent explicitly (and synchronously). - using action_type = server::runtime_support::terminate_action; + typedef server::runtime_support::terminate_action action_type; hpx::distributed::promise value; auto f = value.get_future(); @@ -155,6 +149,7 @@ namespace hpx::components::stubs { return f; #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); return ::hpx::make_ready_future(); #endif } @@ -167,13 +162,13 @@ namespace hpx::components::stubs { } /// \brief Terminate the runtime systems of all localities - void runtime_support::terminate_all( - [[maybe_unused]] hpx::id_type const& targetgid) + void runtime_support::terminate_all(hpx::id_type const& targetgid) { #if !defined(HPX_COMPUTE_DEVICE_CODE) hpx::post(targetgid); #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); #endif } @@ -190,46 +185,44 @@ namespace hpx::components::stubs { /////////////////////////////////////////////////////////////////////// void runtime_support::garbage_collect_non_blocking( - [[maybe_unused]] hpx::id_type const& targetgid) + hpx::id_type const& targetgid) { #if !defined(HPX_COMPUTE_DEVICE_CODE) - using action_type = server::runtime_support::garbage_collect_action; + typedef server::runtime_support::garbage_collect_action action_type; hpx::post(targetgid); #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); #endif } hpx::future runtime_support::garbage_collect_async( - [[maybe_unused]] hpx::id_type const& targetgid) + hpx::id_type const& targetgid) { #if !defined(HPX_COMPUTE_DEVICE_CODE) - using action_type = server::runtime_support::garbage_collect_action; - return hpx::async( - disable_run_as_child(hpx::launch::async), targetgid); + typedef server::runtime_support::garbage_collect_action action_type; + return hpx::async(targetgid); #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); return ::hpx::make_ready_future(); #endif } - void runtime_support::garbage_collect( - [[maybe_unused]] hpx::id_type const& targetgid) + void runtime_support::garbage_collect(hpx::id_type const& targetgid) { #if !defined(HPX_COMPUTE_DEVICE_CODE) - using action_type = server::runtime_support::garbage_collect_action; - hpx::async( - disable_run_as_child(hpx::launch::async), targetgid) - .get(); + typedef server::runtime_support::garbage_collect_action action_type; + hpx::async(targetgid).get(); #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); #endif } /////////////////////////////////////////////////////////////////////// hpx::future runtime_support::create_performance_counter_async( - [[maybe_unused]] hpx::id_type const& targetgid, - [[maybe_unused]] performance_counters::counter_info const& info) + hpx::id_type targetgid, performance_counters::counter_info const& info) { #if !defined(HPX_COMPUTE_DEVICE_CODE) if (!naming::is_locality(targetgid)) @@ -238,21 +231,23 @@ namespace hpx::components::stubs { "stubs::runtime_support::create_performance_counter_async", "The id passed as the first argument is not representing" " a locality"); + return make_ready_future(hpx::invalid_id); } - using action_type = - server::runtime_support::create_performance_counter_action; - return hpx::async( - disable_run_as_child(hpx::launch::async), targetgid, info); + typedef server::runtime_support::create_performance_counter_action + action_type; + return hpx::async(targetgid, info); #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); + HPX_UNUSED(info); return ::hpx::make_ready_future(hpx::invalid_id); #endif } hpx::id_type runtime_support::create_performance_counter( - hpx::id_type const& targetgid, - performance_counters::counter_info const& info, error_code& ec) + hpx::id_type targetgid, performance_counters::counter_info const& info, + error_code& ec) { return create_performance_counter_async(targetgid, info).get(ec); } @@ -260,17 +255,17 @@ namespace hpx::components::stubs { /////////////////////////////////////////////////////////////////////// /// \brief Retrieve configuration information hpx::future runtime_support::get_config_async( - [[maybe_unused]] hpx::id_type const& targetgid) + hpx::id_type const& targetgid) { #if !defined(HPX_COMPUTE_DEVICE_CODE) // Create a future, execute the required action, // we simply return the initialized future, the caller needs // to call get() on the return value to obtain the result - using action_type = server::runtime_support::get_config_action; - return hpx::async( - disable_run_as_child(hpx::launch::async), targetgid); + typedef server::runtime_support::get_config_action action_type; + return hpx::async(targetgid); #else HPX_ASSERT(false); + HPX_UNUSED(targetgid); return ::hpx::make_ready_future(util::section{}); #endif } @@ -285,16 +280,18 @@ namespace hpx::components::stubs { /////////////////////////////////////////////////////////////////////// void runtime_support::remove_from_connection_cache_async( - [[maybe_unused]] hpx::id_type const& target, - [[maybe_unused]] naming::gid_type const& gid, - [[maybe_unused]] parcelset::endpoints_type const& endpoints) + hpx::id_type const& target, naming::gid_type const& gid, + parcelset::endpoints_type const& endpoints) { #if !defined(HPX_COMPUTE_DEVICE_CODE) - using action_type = - server::runtime_support::remove_from_connection_cache_action; + typedef server::runtime_support::remove_from_connection_cache_action + action_type; hpx::post(target, gid, endpoints); #else HPX_ASSERT(false); + HPX_UNUSED(target); + HPX_UNUSED(gid); + HPX_UNUSED(endpoints); #endif } -} // namespace hpx::components::stubs +}}} // namespace hpx::components::stubs diff --git a/tests/regressions/threads/main_thread_exit_callbacks.cpp b/tests/regressions/threads/main_thread_exit_callbacks.cpp index 629fa256a9bd..4a6451236cd0 100644 --- a/tests/regressions/threads/main_thread_exit_callbacks.cpp +++ b/tests/regressions/threads/main_thread_exit_callbacks.cpp @@ -1,5 +1,4 @@ // Copyright (c) 2023 Panos Syskakis -// Copyright (c) 2024 Hartmut Kaiser // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -19,7 +18,7 @@ int hpx_main() { hpx::threads::thread_id_type id = hpx::threads::get_self_id(); hpx::threads::add_thread_exit_callback(id, [id]() { - hpx::threads::thread_id_type const id1 = hpx::threads::get_self_id(); + hpx::threads::thread_id_type id1 = hpx::threads::get_self_id(); HPX_TEST_EQ(id1, id); callback_called = true;