From ad648473ffd4bb3030c735e2961ea727c6136efa Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Tue, 24 Oct 2023 13:36:11 +0200 Subject: [PATCH 01/12] Refactor runtime init/start/stop/etc. functions to never return useless ints --- examples/quickstart/hello_world.cpp | 4 +- .../pika/init_runtime/init_runtime.hpp | 160 +++++--- libs/pika/init_runtime/src/init_runtime.cpp | 370 ++++++++++-------- .../runtime/include/pika/runtime/runtime.hpp | 6 +- libs/pika/runtime/src/runtime.cpp | 20 +- 5 files changed, 315 insertions(+), 245 deletions(-) diff --git a/examples/quickstart/hello_world.cpp b/examples/quickstart/hello_world.cpp index d54ca44e8..5f376a81d 100644 --- a/examples/quickstart/hello_world.cpp +++ b/examples/quickstart/hello_world.cpp @@ -10,13 +10,15 @@ #include +#include #include int pika_main() { // Say hello to the world! std::cout << "Hello World!\n" << std::flush; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp b/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp index d292bc927..610cbdd00 100644 --- a/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp +++ b/libs/pika/init_runtime/include/pika/init_runtime/init_runtime.hpp @@ -49,27 +49,6 @@ extern char** environ; namespace pika { namespace detail { - PIKA_EXPORT int init_helper( - pika::program_options::variables_map&, util::detail::function const&); - - struct dump_config - { - dump_config(pika::runtime const& rt) - : rt_(std::cref(rt)) - { - } - - void operator()() const - { - std::cout << "Configuration after runtime start:\n"; - std::cout << "----------------------------------\n"; - rt_.get().get_config().dump(0, std::cout); - std::cout << "----------------------------------\n"; - } - - std::reference_wrapper rt_; - }; - // Default params to initialize the init_params struct PIKA_MAYBE_UNUSED static int dummy_argc = 1; PIKA_MAYBE_UNUSED static char app_name[] = PIKA_APPLICATION_STRING; @@ -97,34 +76,6 @@ namespace pika { pika::detail::rp_callback_type rp_callback; }; - namespace detail { - PIKA_EXPORT int run_or_start( - util::detail::function const& f, - int argc, const char* const* argv, init_params const& params, bool blocking); - - inline int init_start_impl( - util::detail::function f, int argc, - const char* const* argv, init_params const& params, bool blocking) - { - if (argc == 0 || argv == nullptr) - { - argc = dummy_argc; - argv = dummy_argv; - } - -#if defined(__FreeBSD__) - freebsd_environ = environ; -#endif - // set a handler for std::abort - std::signal(SIGABRT, pika::detail::on_abort); - std::atexit(pika::detail::on_exit); -#if defined(PIKA_HAVE_CXX11_STD_QUICK_EXIT) - std::at_quick_exit(pika::detail::on_exit); -#endif - return run_or_start(f, argc, argv, params, blocking); - } - } // namespace detail - PIKA_EXPORT int init(std::function f, int argc, const char* const* argv, init_params const& params = init_params()); PIKA_EXPORT int init(std::function f, int argc, const char* const* argv, @@ -133,19 +84,110 @@ namespace pika { init_params const& params = init_params()); PIKA_EXPORT int init(std::nullptr_t, int argc, const char* const* argv, init_params const& params = init_params()); - PIKA_EXPORT bool start(std::function f, int argc, + + /// Start the runtime. + /// + /// @param f entry point of the first task on the pika runtime. f will be passed all non-pika + /// command line arguments. + /// @param argc number of arguments in argv + /// @param argv array of arguments. The first element is ignored. + /// + /// @pre `(argc == 0 && argv == nullptr) || (argc >= 1 && argv != nullptr)` + /// @pre the runtime is stopped + /// @post the runtime is running + PIKA_EXPORT void start(std::function f, int argc, const char* const* argv, init_params const& params = init_params()); - PIKA_EXPORT bool start(std::function f, int argc, const char* const* argv, + + /// Start the runtime. + /// + /// @param f entry point of the first task on the pika runtime. f will be passed all non-pika + /// command line arguments. + /// @param argc number of arguments in argv + /// @param argv array of arguments. The first element is ignored. + /// + /// @pre `(argc == 0 && argv == nullptr) || (argc >= 1 && argv != nullptr)` + /// @pre the runtime is stopped + /// @post the runtime is running + PIKA_EXPORT void start(std::function f, int argc, const char* const* argv, init_params const& params = init_params()); - PIKA_EXPORT bool start(std::function f, int argc, const char* const* argv, + + /// Start the runtime. + /// + /// @param f entry point of the first task on the pika runtime + /// @param argc number of arguments in argv + /// @param argv array of arguments. The first element is ignored. + /// + /// @pre `(argc == 0 && argv == nullptr) || (argc >= 1 && argv != nullptr)` + /// @pre the runtime is not running + PIKA_EXPORT void start(std::function f, int argc, const char* const* argv, init_params const& params = init_params()); - PIKA_EXPORT bool start(std::nullptr_t, int argc, const char* const* argv, + + PIKA_EXPORT void start(std::nullptr_t, int argc, const char* const* argv, init_params const& params = init_params()); - PIKA_EXPORT bool start( + + /// Start the runtime. + /// + /// No task is created on the runtime. + /// + /// @param argc number of arguments in argv + /// @param argv array of arguments. The first element is ignored. + /// + /// @pre `(argc == 0 && argv == nullptr) || (argc >= 1 && argv != nullptr)` + /// @pre the runtime is inactive + /// @post the runtime is running + PIKA_EXPORT void start( int argc, const char* const* argv, init_params const& params = init_params()); - PIKA_EXPORT int finalize(error_code& ec = throws); - PIKA_EXPORT int stop(error_code& ec = throws); - PIKA_EXPORT int wait(error_code& ec = throws); - PIKA_EXPORT int suspend(error_code& ec = throws); - PIKA_EXPORT int resume(error_code& ec = throws); + + /// Stop the runtime. + /// + /// Waits until @ref pika::finalize has been called and there is no more activity on the + /// runtime. See @ref pika::wait. The runtime can be started again after calling @ref + /// pika::stop. Must be called from outside the runtime. + /// + /// @return the return value of the callable passed to @p pika::start, if any. If none was + /// passed, returns 0. + /// + /// @pre the runtime is active + /// @pre the calling thread is not a pika task + /// @post the runtime is inactive + PIKA_EXPORT int stop(); + + /// Signal the runtime that it may be stopped. + /// + /// Until @ref pika::finalize has been called, @ref pika::stop will not return. This function + /// exists to distinguish between the runtime being idle but still expecting work to be + /// scheduled on it and the runtime being idle and ready to be shutdown. Unlike @pika::stop, + /// @ref pika::finalize can be called from within or outside the runtime. + /// + /// @pre the runtime is active + PIKA_EXPORT void finalize(); + + /// Wait for the runtime to be idle. + /// + /// Waits until the runtime is idle. This includes tasks scheduled on the thread pools as well + /// as non-tasks such as CUDA kernels submitted through pika facilities. Can be called from + /// within the runtime, in which case the calling task is ignored when determining idleness. + /// + /// @pre the runtime is active + /// @post all work submitted before the call to wait is completed + PIKA_EXPORT void wait(); + + /// Suspend the runtime. + /// + /// Waits until the runtime is idle and suspends worker threads on all thread pools. Work can be + /// scheduled on the runtime even when it is suspended, but no progress will be made. + /// + /// @pre the calling thread is not a pika task + /// @pre runtime is running or suspended + /// @post runtime is suspended + PIKA_EXPORT void suspend(); + + /// Resume the runtime. + /// + /// Resumes the runtime by waking all worker threads on all thread pools. + /// + /// @pre the calling thread is not a pika task + /// @pre runtime is suspended or running + /// @post runtime is running + PIKA_EXPORT void resume(); } // namespace pika diff --git a/libs/pika/init_runtime/src/init_runtime.cpp b/libs/pika/init_runtime/src/init_runtime.cpp index 45cad82b0..71771b6b1 100644 --- a/libs/pika/init_runtime/src/init_runtime.cpp +++ b/libs/pika/init_runtime/src/init_runtime.cpp @@ -107,174 +107,7 @@ namespace pika { // Invoke custom startup functions return f(static_cast(argcount), argv.data()); } - } // namespace detail - - // Print stack trace and exit. - int init(std::function f, int argc, - const char* const* argv, init_params const& params) - { - return detail::init_start_impl(PIKA_MOVE(f), argc, argv, params, true); - } - - int init(std::function f, int argc, const char* const* argv, - init_params const& params) - { - util::detail::function main_f = - pika::util::detail::bind_back(pika::detail::init_helper, f); - return detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, true); - } - - int init(std::function f, int argc, const char* const* argv, init_params const& params) - { - util::detail::function main_f = - pika::util::detail::bind(f); - return detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, true); - } - - int init(std::nullptr_t, int argc, const char* const* argv, init_params const& params) - { - util::detail::function main_f; - return detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, true); - } - - bool start(std::function f, int argc, - const char* const* argv, init_params const& params) - { - return 0 == detail::init_start_impl(PIKA_MOVE(f), argc, argv, params, false); - } - - bool start(std::function f, int argc, const char* const* argv, - init_params const& params) - { - util::detail::function main_f = - pika::util::detail::bind_back(pika::detail::init_helper, f); - return 0 == detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false); - } - - bool start(std::function f, int argc, const char* const* argv, init_params const& params) - { - util::detail::function main_f = - pika::util::detail::bind(f); - return 0 == detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false); - } - - bool start(std::nullptr_t, int argc, const char* const* argv, init_params const& params) - { - util::detail::function main_f; - return 0 == detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false); - } - bool start(int argc, const char* const* argv, init_params const& params) - { - util::detail::function main_f; - return 0 == detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false); - } - - int finalize(error_code& ec) - { - if (!is_running()) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::finalize", - "the runtime system is not active (did you already call finalize?)"); - return -1; - } - - if (&ec != &throws) ec = make_success_code(); - - runtime* rt = get_runtime_ptr(); - if (nullptr == rt) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::finalize", - "the runtime system is not active (did you already call pika::stop?)"); - return -1; - } - - rt->finalize(); - - return 0; - } - - int stop(error_code& ec) - { - if (threads::detail::get_self_ptr()) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::stop", - "this function cannot be called from a pika thread"); - return -1; - } - - std::unique_ptr rt(get_runtime_ptr()); // take ownership! - if (nullptr == rt.get()) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::stop", - "the runtime system is not active (did you already call pika::stop?)"); - return -1; - } - - int result = rt->wait(); - - rt->stop(); - rt->rethrow_exception(); - - return result; - } - - int wait(error_code& ec) - { - runtime* rt = get_runtime_ptr(); - if (nullptr == rt) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::wait", - "the runtime system is not active (did you already call pika::stop?)"); - return -1; - } - - rt->get_thread_manager().wait(); - - return 0; - } - - int suspend(error_code& ec) - { - if (threads::detail::get_self_ptr()) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::suspend", - "this function cannot be called from a pika thread"); - return -1; - } - - runtime* rt = get_runtime_ptr(); - if (nullptr == rt) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::suspend", - "the runtime system is not active (did you already call pika::stop?)"); - return -1; - } - - return rt->suspend(); - } - - int resume(error_code& ec) - { - if (threads::detail::get_self_ptr()) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::resume", - "this function cannot be called from a pika thread"); - return -1; - } - - runtime* rt = get_runtime_ptr(); - if (nullptr == rt) - { - PIKA_THROWS_IF(ec, pika::error::invalid_status, "pika::resume", - "the runtime system is not active (did you already call pika::stop?)"); - return -1; - } - - return rt->resume(); - } - - namespace detail { void activate_global_options(detail::command_line_handling& cmdline) { #if defined(__linux) || defined(linux) || defined(__linux__) || defined(__FreeBSD__) @@ -308,6 +141,24 @@ namespace pika { #endif } + struct dump_config + { + dump_config(pika::runtime const& rt) + : rt_(std::cref(rt)) + { + } + + void operator()() const + { + std::cout << "Configuration after runtime start:\n"; + std::cout << "----------------------------------\n"; + rt_.get().get_config().dump(0, std::cout); + std::cout << "----------------------------------\n"; + } + + std::reference_wrapper rt_; + }; + /////////////////////////////////////////////////////////////////////// void add_startup_functions(pika::runtime& rt, pika::program_options::variables_map& vm, startup_function_type startup, shutdown_function_type shutdown) @@ -529,5 +380,190 @@ namespace pika { } return result; } + + int init_start_impl(util::detail::function f, + int argc, const char* const* argv, init_params const& params, bool blocking) + { + if (argc == 0 || argv == nullptr) + { + argc = dummy_argc; + argv = dummy_argv; + } + +#if defined(__FreeBSD__) + freebsd_environ = environ; +#endif + // set a handler for std::abort + std::signal(SIGABRT, pika::detail::on_abort); + std::atexit(pika::detail::on_exit); +#if defined(PIKA_HAVE_CXX11_STD_QUICK_EXIT) + std::at_quick_exit(pika::detail::on_exit); +#endif + return run_or_start(f, argc, argv, params, blocking); + } } // namespace detail + + int init(std::function f, int argc, + const char* const* argv, init_params const& params) + { + return detail::init_start_impl(PIKA_MOVE(f), argc, argv, params, true); + } + + int init(std::function f, int argc, const char* const* argv, + init_params const& params) + { + util::detail::function main_f = + pika::util::detail::bind_back(pika::detail::init_helper, f); + return detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, true); + } + + int init(std::function f, int argc, const char* const* argv, init_params const& params) + { + util::detail::function main_f = + pika::util::detail::bind(f); + return detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, true); + } + + int init(std::nullptr_t, int argc, const char* const* argv, init_params const& params) + { + util::detail::function main_f; + return detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, true); + } + + void start(std::function f, int argc, + const char* const* argv, init_params const& params) + { + if (detail::init_start_impl(PIKA_MOVE(f), argc, argv, params, false) != 0) + { + PIKA_UNREACHABLE; + } + } + + void start(std::function f, int argc, const char* const* argv, + init_params const& params) + { + util::detail::function main_f = + pika::util::detail::bind_back(pika::detail::init_helper, f); + if (detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false) != 0) + { + PIKA_UNREACHABLE; + } + } + + void start(std::function f, int argc, const char* const* argv, init_params const& params) + { + util::detail::function main_f = + pika::util::detail::bind(f); + if (detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false) != 0) + { + PIKA_UNREACHABLE; + } + } + + void start(std::nullptr_t, int argc, const char* const* argv, init_params const& params) + { + util::detail::function main_f; + if (detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false) != 0) + { + PIKA_UNREACHABLE; + } + } + + void start(int argc, const char* const* argv, init_params const& params) + { + util::detail::function main_f; + if (detail::init_start_impl(PIKA_MOVE(main_f), argc, argv, params, false) != 0) + { + PIKA_UNREACHABLE; + } + } + + void finalize() + { + if (!is_running()) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::finalize", + "the runtime system is not active (did you already call finalize?)"); + } + + runtime* rt = get_runtime_ptr(); + if (nullptr == rt) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::finalize", + "the runtime system is not active (did you already call pika::stop?)"); + } + + rt->finalize(); + } + + int stop() + { + if (threads::detail::get_self_ptr()) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::stop", + "this function cannot be called from a pika thread"); + } + + std::unique_ptr rt(get_runtime_ptr()); // take ownership! + if (nullptr == rt.get()) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::stop", + "the runtime system is not active (did you already call pika::stop?)"); + } + + int result = rt->wait(); + + rt->stop(); + rt->rethrow_exception(); + + return result; + } + + void wait() + { + runtime* rt = get_runtime_ptr(); + if (nullptr == rt) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::wait", + "the runtime system is not active (did you already call pika::stop?)"); + } + + rt->get_thread_manager().wait(); + } + + void suspend() + { + if (threads::detail::get_self_ptr()) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::suspend", + "this function cannot be called from a pika thread"); + } + + runtime* rt = get_runtime_ptr(); + if (nullptr == rt) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::suspend", + "the runtime system is not active (did you already call pika::stop?)"); + } + + rt->suspend(); + } + + void resume() + { + if (threads::detail::get_self_ptr()) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::resume", + "this function cannot be called from a pika thread"); + } + + runtime* rt = get_runtime_ptr(); + if (nullptr == rt) + { + PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika::resume", + "the runtime system is not active (did you already call pika::stop?)"); + } + + rt->resume(); + } } // namespace pika diff --git a/libs/pika/runtime/include/pika/runtime/runtime.hpp b/libs/pika/runtime/include/pika/runtime/runtime.hpp index 2966fa3a0..dc15a8444 100644 --- a/libs/pika/runtime/include/pika/runtime/runtime.hpp +++ b/libs/pika/runtime/include/pika/runtime/runtime.hpp @@ -199,12 +199,12 @@ namespace pika { virtual void stop(bool blocking = true); /// \brief Suspend the runtime system - virtual int suspend(); + virtual void suspend(); /// \brief Resume the runtime system - virtual int resume(); + virtual void resume(); - virtual int finalize(); + virtual void finalize(); /// \brief Allow access to the thread manager instance used by the pika /// runtime. diff --git a/libs/pika/runtime/src/runtime.cpp b/libs/pika/runtime/src/runtime.cpp index 87c0c56a8..d6d0297d6 100644 --- a/libs/pika/runtime/src/runtime.cpp +++ b/libs/pika/runtime/src/runtime.cpp @@ -1318,51 +1318,41 @@ namespace pika { cond.notify_all(); // we're done now } - int runtime::suspend() + void runtime::suspend() { LRT_(info).format("runtime: about to suspend runtime"); - if (state_.load() == runtime_state::sleeping) { return 0; } + if (state_.load() == runtime_state::sleeping) { return; } if (state_.load() != runtime_state::running) { PIKA_THROW_EXCEPTION(pika::error::invalid_status, "runtime::suspend", "Can only suspend runtime from running state"); - return -1; } thread_manager_->suspend(); set_state(runtime_state::sleeping); - - return 0; } - int runtime::resume() + void runtime::resume() { LRT_(info).format("runtime: about to resume runtime"); - if (state_.load() == runtime_state::running) { return 0; } + if (state_.load() == runtime_state::running) { return; } if (state_.load() != runtime_state::sleeping) { PIKA_THROW_EXCEPTION(pika::error::invalid_status, "runtime::resume", "Can only resume runtime from suspended state"); - return -1; } thread_manager_->resume(); set_state(runtime_state::running); - - return 0; } - int runtime::finalize() - { - notify_finalize(); - return 0; - } + void runtime::finalize() { notify_finalize(); } pika::threads::detail::thread_manager& runtime::get_thread_manager() { From 8d5b7d68db6f8fb1d5a277b734b6ceba13441d65 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 25 Oct 2023 15:38:43 +0200 Subject: [PATCH 02/12] Add documentation for pika::start/stop/finalize/wait/resume/suspend --- docs/api.rst | 35 +++++++++++++++++-- examples/CMakeLists.txt | 2 +- examples/documentation/CMakeLists.txt | 32 +++++++++++++++++ .../documentation/init_hpp_documentation.cpp | 26 ++++++++++++++ 4 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 examples/documentation/CMakeLists.txt create mode 100644 examples/documentation/init_hpp_documentation.cpp diff --git a/docs/api.rst b/docs/api.rst index 975f78ca0..67c9f64ea 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -18,6 +18,13 @@ even in patch versions. The API reference is a work in progress. The following headers are part of the public API. Any other headers are internal implementation details. +.. contents:: + :local: + :depth: 1 + :backlinks: none + +These headers are part of the public API, but are currently undocumented. + - ``pika/async_rw_mutex.hpp`` - ``pika/barrier.hpp`` - ``pika/condition_variable.hpp`` @@ -31,6 +38,28 @@ headers are internal implementation details. - ``pika/shared_mutex.hpp`` - ``pika/thread.hpp`` -All functionality in a namespace containing ``detail`` and all macros prefixed -with ``PIKA_DETAIL`` are implementation details and may change without warning -at any time. +All functionality in a namespace containing ``detail`` and all macros prefixed with ``PIKA_DETAIL`` +are implementation details and may change without warning at any time. All functionality in a +namespace containing ``experimental`` may change without warning at any time. However, the intention +is to stabilize those APIs over time. + +.. _header_pika_init: + +``pika/init.hpp`` +================= + +The ``pika/init.hpp`` header provides functionality to manage the pika runtime. + +.. literalinclude:: ../examples/documentation/init_hpp_documentation.cpp + :language: c++ + :start-at: #include + +.. doxygenfunction:: start(int argc, const char *const *argv, init_params const ¶ms) +.. doxygenfunction:: stop() +.. doxygenfunction:: finalize() +.. doxygenfunction:: wait() +.. doxygenfunction:: resume() +.. doxygenfunction:: suspend() + +.. doxygenstruct:: pika::init_params + :members: diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b00a88f8e..47fb712c7 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,7 +6,7 @@ # 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) -set(subdirs 1d_stencil balancing future_reduce jacobi_smp quickstart) +set(subdirs 1d_stencil balancing documentation future_reduce jacobi_smp quickstart) foreach(subdir ${subdirs}) if(PIKA_WITH_TESTS AND PIKA_WITH_TESTS_EXAMPLES) diff --git a/examples/documentation/CMakeLists.txt b/examples/documentation/CMakeLists.txt new file mode 100644 index 000000000..c9015b941 --- /dev/null +++ b/examples/documentation/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (c) 2023 ETH Zurich +# +# 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) + +set(example_programs + init_hpp_documentation +) + +foreach(example_program ${example_programs}) + set(sources ${example_program}.cpp) + + source_group("Source Files" FILES ${sources}) + + pika_add_executable( + ${example_program} INTERNAL_FLAGS + SOURCES ${sources} ${${example_program}_FLAGS} + FOLDER "Examples/Documentation" + ) + + target_link_libraries( + ${example_program} PRIVATE ${${example_program}_LIBRARIES} + ) + pika_add_example_target_dependencies("documentation" ${example_program}) + + if(PIKA_WITH_TESTS AND PIKA_WITH_TESTS_EXAMPLES) + pika_add_example_test( + "documentation" ${example_program} ${${example_program}_PARAMETERS} + ) + endif() +endforeach() diff --git a/examples/documentation/init_hpp_documentation.cpp b/examples/documentation/init_hpp_documentation.cpp new file mode 100644 index 000000000..52e91b2b4 --- /dev/null +++ b/examples/documentation/init_hpp_documentation.cpp @@ -0,0 +1,26 @@ +// Copyright (c) 2023 ETH Zurich +// +// 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 + +int main(int argc, char* argv[]) +{ + pika::start(argc, argv); + + // The pika runtime is now active and we can schedule work on the default thread pool + pika::this_thread::experimental::sync_wait( + pika::execution::experimental::schedule( + pika::execution::experimental::thread_pool_scheduler{}) | + pika::execution::experimental::then([]() { fmt::print("Hello from the pika runtime\n"); })); + + pika::finalize(); + pika::stop(); + + return 0; +} From 09baba47be477179fc7f2e8be1fadcdb3058fb16 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 25 Oct 2023 15:43:01 +0200 Subject: [PATCH 03/12] Enable breathe extension for documentation --- .github/workflows/docs.yml | 11 ++++++++--- docs/Doxyfile | 18 ++++++++++++++++++ docs/conf.py | 16 ++++++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 docs/Doxyfile diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d92ae66ea..f9275f194 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -36,10 +36,15 @@ jobs: --allow-downgrades \ --allow-remove-essential \ --allow-change-held-packages \ - python3 python3-pip - pip install sphinx sphinx-material + doxygen python3 python3-pip + pip install breathe sphinx sphinx-material - name: Build documentation - run: sphinx-build -W -n -a -b html docs build/docs + run: | + export PIKA_DOCS_DOXYGEN_OUTPUT_DIRECTORY=$PWD/build/docs/doxygen + export PIKA_DOCS_DOXYGEN_INPUT_ROOT=$PWD + mkdir -p $PIKA_DOCS_DOXYGEN_OUTPUT_DIRECTORY + doxygen docs/Doxyfile + sphinx-build -W -a -b html docs $PWD/build/docs - name: Upload HTML output as artifact uses: actions/upload-pages-artifact@v2 with: diff --git a/docs/Doxyfile b/docs/Doxyfile new file mode 100644 index 000000000..697c0ab3c --- /dev/null +++ b/docs/Doxyfile @@ -0,0 +1,18 @@ +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = "pika" +GENERATE_XML = YES +GENERATE_LATEX = NO +GENERATE_MAN = NO +GENERATE_RTF = NO +GENERATE_HTML = NO +QUIET = NO +OUTPUT_DIRECTORY = "$(PIKA_DOCS_DOXYGEN_OUTPUT_DIRECTORY)" +INPUT = "$(PIKA_DOCS_DOXYGEN_INPUT_ROOT)/libs/pika/init_runtime" +FILE_PATTERNS = *.cpp *.hpp *.cu +RECURSIVE = YES +EXCLUDE_PATTERNS = */test */detail +EXCLUDE_SYMBOLS = "*detail*" +ENABLE_PREPPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +PREDEFINED = PIKA_EXPORT= diff --git a/docs/conf.py b/docs/conf.py index 61c4ac4bb..4197c72aa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -5,6 +5,7 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) from datetime import datetime +import os # Project settings project = "pika" @@ -14,13 +15,23 @@ release = version # General sphinx settings -extensions = [] +extensions = ["breathe"] exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] source_suffix = [".rst"] language = "English" primary_domain = "cpp" highlight_language = "cpp" +breathe_projects = {"pika": os.getenv("PIKA_DOCS_DOXYGEN_OUTPUT_DIRECTORY") + "/xml"} +breathe_default_project = "pika" +breathe_domain_by_extension = { + "hpp": "cpp", + "cpp": "cpp", + "cu": "cpp", +} +breathe_default_members = ("members",) +breathe_show_include = False + # HTML settings html_title = "pika" html_theme = "sphinx_material" @@ -38,7 +49,8 @@ "repo_url": "https://github.com/pika-org/pika", "repo_name": "pika", "html_minify": False, - "html_prettify": True, + # Disabled because of https://github.com/bashtage/sphinx-material/issues/123 + "html_prettify": False, "logo_icon": "", "css_minify": True, "repo_type": "github", From d079fb652be7bd8fcc4de47da166c3928c503118 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 25 Oct 2023 15:43:15 +0200 Subject: [PATCH 04/12] Add breathe and doxygen to shell.nix --- shell.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell.nix b/shell.nix index a9efa5a37..4b36d9945 100644 --- a/shell.nix +++ b/shell.nix @@ -17,6 +17,8 @@ pkgs.mkShell.override { stdenv = pkgs.gcc11Stdenv; } { mpich ninja pkg-config + doxygen + python311Packages.breathe python311Packages.sphinx python311Packages.sphinx-material ]; From 41d1d14c35202b73479a793fe89a99ae7937757b Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 25 Oct 2023 15:50:09 +0200 Subject: [PATCH 05/12] Always show permalink for function etc. documentation --- docs/_static/pika.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/_static/pika.css b/docs/_static/pika.css index a9f58c900..02495cbef 100644 --- a/docs/_static/pika.css +++ b/docs/_static/pika.css @@ -30,3 +30,7 @@ .md-header-nav__topic { font-weight: bold; } + +.md-typeset .headerlink { + opacity: 1; +} From a94fe6d5b5b0f2eaaa1ab1a0eb6f12ace905199b Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 25 Oct 2023 15:51:14 +0200 Subject: [PATCH 06/12] Move hello_world_documentation example to documentation subdirectory --- docs/index.rst | 2 +- examples/CMakeLists.txt | 4 +++- examples/documentation/CMakeLists.txt | 4 +--- .../hello_world_documentation.cpp | 0 examples/quickstart/CMakeLists.txt | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) rename examples/{quickstart => documentation}/hello_world_documentation.cpp (100%) diff --git a/docs/index.rst b/docs/index.rst index 270479e86..e906e9726 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,7 +23,7 @@ scheduler target the pika runtime. The stdexec repository contains `an excellent list of resources for learning more about std::execution `_ itself. -.. literalinclude:: ../examples/quickstart/hello_world_documentation.cpp +.. literalinclude:: ../examples/documentation/hello_world_documentation.cpp :language: c++ :start-at: #include diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 47fb712c7..ca374a705 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,7 +6,9 @@ # 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) -set(subdirs 1d_stencil balancing documentation future_reduce jacobi_smp quickstart) +set(subdirs 1d_stencil balancing documentation future_reduce jacobi_smp + quickstart +) foreach(subdir ${subdirs}) if(PIKA_WITH_TESTS AND PIKA_WITH_TESTS_EXAMPLES) diff --git a/examples/documentation/CMakeLists.txt b/examples/documentation/CMakeLists.txt index c9015b941..34b10ebde 100644 --- a/examples/documentation/CMakeLists.txt +++ b/examples/documentation/CMakeLists.txt @@ -4,9 +4,7 @@ # 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) -set(example_programs - init_hpp_documentation -) +set(example_programs hello_world_documentation init_hpp_documentation) foreach(example_program ${example_programs}) set(sources ${example_program}.cpp) diff --git a/examples/quickstart/hello_world_documentation.cpp b/examples/documentation/hello_world_documentation.cpp similarity index 100% rename from examples/quickstart/hello_world_documentation.cpp rename to examples/documentation/hello_world_documentation.cpp diff --git a/examples/quickstart/CMakeLists.txt b/examples/quickstart/CMakeLists.txt index 02a2116de..270edbc59 100644 --- a/examples/quickstart/CMakeLists.txt +++ b/examples/quickstart/CMakeLists.txt @@ -11,7 +11,6 @@ set(example_programs event_synchronization fibonacci hello_world - hello_world_documentation latch_example # suffix added to avoid conflict with unit tests pipeline1 # shared_mutex # Disabled due to unavailable timed suspension timed_wake # From e1d40dcd90a23f041606dab8ad29314fc8e0101a Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 1 Nov 2023 09:39:34 +0100 Subject: [PATCH 07/12] Use [[maybe_unused]] instead of (void) to ignore runtime pointer in initialization --- libs/pika/init_runtime/src/init_runtime.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/pika/init_runtime/src/init_runtime.cpp b/libs/pika/init_runtime/src/init_runtime.cpp index 71771b6b1..00e4151f5 100644 --- a/libs/pika/init_runtime/src/init_runtime.cpp +++ b/libs/pika/init_runtime/src/init_runtime.cpp @@ -233,8 +233,7 @@ namespace pika { start(*rt, cfg.pika_main_f_, cfg.vm_, PIKA_MOVE(startup), PIKA_MOVE(shutdown)); // pointer to runtime is stored in TLS - pika::runtime* p = rt.release(); - (void) p; + [[maybe_unused]] pika::runtime* p = rt.release(); return 0; } From 91c785da31a33f728366973165b8c34cdf49c9b4 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 1 Nov 2023 15:25:22 +0100 Subject: [PATCH 08/12] Consistently throw exceptions instead of returning negative ints when starting runtime --- .../command_line_handling.hpp | 11 +- .../parse_command_line.hpp | 4 +- .../src/command_line_handling.cpp | 39 +- .../src/parse_command_line.cpp | 496 ++++++++---------- libs/pika/init_runtime/src/init_runtime.cpp | 127 ++--- libs/pika/runtime/src/runtime.cpp | 8 +- 6 files changed, 307 insertions(+), 378 deletions(-) diff --git a/libs/pika/command_line_handling/include/pika/command_line_handling/command_line_handling.hpp b/libs/pika/command_line_handling/include/pika/command_line_handling/command_line_handling.hpp index bb11c1445..3d3aff9f0 100644 --- a/libs/pika/command_line_handling/include/pika/command_line_handling/command_line_handling.hpp +++ b/libs/pika/command_line_handling/include/pika/command_line_handling/command_line_handling.hpp @@ -20,6 +20,12 @@ #include namespace pika::detail { + enum class command_line_handling_result + { + success, // All went well, continue starting the runtime + exit, // All went well, but should exit (e.g. --pika:help was given) + }; + struct command_line_handling { command_line_handling(pika::util::runtime_configuration rtcfg, @@ -41,7 +47,8 @@ namespace pika::detail { { } - int call(pika::program_options::options_description const& desc_cmdline, int argc, + command_line_handling_result call( + pika::program_options::options_description const& desc_cmdline, int argc, const char* const* argv); pika::program_options::variables_map vm_; @@ -71,7 +78,7 @@ namespace pika::detail { void check_pu_offset() const; void check_pu_step() const; - bool handle_arguments(detail::manage_config& cfgmap, + void handle_arguments(detail::manage_config& cfgmap, pika::program_options::variables_map& vm, std::vector& ini_config); void enable_logging_settings( diff --git a/libs/pika/command_line_handling/include/pika/command_line_handling/parse_command_line.hpp b/libs/pika/command_line_handling/include/pika/command_line_handling/parse_command_line.hpp index 177e80965..99246dcb4 100644 --- a/libs/pika/command_line_handling/include/pika/command_line_handling/parse_command_line.hpp +++ b/libs/pika/command_line_handling/include/pika/command_line_handling/parse_command_line.hpp @@ -38,14 +38,14 @@ namespace pika::detail { commandline_error_mode const m, commandline_error_mode const b) noexcept; std::string enquote(std::string const& arg); - bool parse_commandline(pika::detail::section const& rtcfg, + void parse_commandline(pika::detail::section const& rtcfg, pika::program_options::options_description const& app_options, std::string const& cmdline, pika::program_options::variables_map& vm, commandline_error_mode error_mode = commandline_error_mode::return_on_error, pika::program_options::options_description* visible = nullptr, std::vector* unregistered_options = nullptr); - bool parse_commandline(pika::detail::section const& rtcfg, + void parse_commandline(pika::detail::section const& rtcfg, pika::program_options::options_description const& app_options, std::string const& arg0, std::vector const& args, pika::program_options::variables_map& vm, commandline_error_mode error_mode = commandline_error_mode::return_on_error, diff --git a/libs/pika/command_line_handling/src/command_line_handling.cpp b/libs/pika/command_line_handling/src/command_line_handling.cpp index d9e07e110..7dd68547d 100644 --- a/libs/pika/command_line_handling/src/command_line_handling.cpp +++ b/libs/pika/command_line_handling/src/command_line_handling.cpp @@ -407,7 +407,7 @@ namespace pika::detail { } /////////////////////////////////////////////////////////////////////////// - bool command_line_handling::handle_arguments(detail::manage_config& cfgmap, + void command_line_handling::handle_arguments(detail::manage_config& cfgmap, pika::program_options::variables_map& vm, std::vector& ini_config) { bool debug_clp = vm.count("pika:debug-clp"); @@ -553,8 +553,6 @@ namespace pika::detail { for (std::string const& s : ini_config) { std::cerr << s << std::endl; } std::cerr << "-----------------------------------\n"; } - - return true; } /////////////////////////////////////////////////////////////////////////// @@ -754,8 +752,9 @@ namespace pika::detail { } /////////////////////////////////////////////////////////////////////////// - int command_line_handling::call(pika::program_options::options_description const& desc_cmdline, - int argc, const char* const* argv) + command_line_handling_result command_line_handling::call( + pika::program_options::options_description const& desc_cmdline, int argc, + const char* const* argv) { // set the flag signaling that command line parsing has been done cmd_line_parsed_ = true; @@ -791,14 +790,11 @@ namespace pika::detail { // creating a separate instance just for the preliminary // command line handling. pika::program_options::variables_map prevm; - if (!parse_commandline(rtcfg_, desc_cmdline, argv[0], args, prevm, error_mode)) - { - return -1; - } + parse_commandline(rtcfg_, desc_cmdline, argv[0], args, prevm, error_mode); // handle all --pika:foo options std::vector ini_config; // discard - if (!handle_arguments(cfgmap, prevm, ini_config)) { return -2; } + handle_arguments(cfgmap, prevm, ini_config); // re-initialize runtime configuration object if (prevm.count("pika:config")) @@ -836,18 +832,15 @@ namespace pika::detail { pika::program_options::options_description help; std::vector unregistered_options; - if (!parse_commandline(rtcfg_, desc_cmdline, argv[0], args, vm_, - error_mode | commandline_error_mode::report_missing_config_file, &help, - &unregistered_options)) - { - return -1; - } + parse_commandline(rtcfg_, desc_cmdline, argv[0], args, vm_, + error_mode | commandline_error_mode::report_missing_config_file, &help, + &unregistered_options); // break into debugger, if requested handle_attach_debugger(); // handle all --pika:foo and --pika:*:foo options - if (!handle_arguments(cfgmap, vm_, ini_config_)) { return -2; } + handle_arguments(cfgmap, vm_, ini_config_); // store unregistered command line and arguments store_command_line(argc, argv); @@ -857,10 +850,7 @@ namespace pika::detail { rtcfg_.reconfigure(ini_config_); // help can be printed only after the runtime mode has been set - if (handle_help_options(help)) - { - return 1; // exit application gracefully - } + if (handle_help_options(help)) { return command_line_handling_result::exit; } // print version/copyright information if (vm_.count("pika:version")) @@ -871,7 +861,7 @@ namespace pika::detail { version_printed_ = true; } - return 1; + return command_line_handling_result::exit; } // print configuration information (static and dynamic) @@ -883,7 +873,7 @@ namespace pika::detail { info_printed_ = true; } - return 1; + return command_line_handling_result::exit; } // Print a warning about process masks resulting in only one worker @@ -916,7 +906,6 @@ namespace pika::detail { } } - // all is good - return 0; + return command_line_handling_result::success; } } // namespace pika::detail diff --git a/libs/pika/command_line_handling/src/parse_command_line.cpp b/libs/pika/command_line_handling/src/parse_command_line.cpp index d71a1c75d..9a42f96e2 100644 --- a/libs/pika/command_line_handling/src/parse_command_line.cpp +++ b/libs/pika/command_line_handling/src/parse_command_line.cpp @@ -242,7 +242,7 @@ namespace pika::detail { /////////////////////////////////////////////////////////////////////////// // parse the command line - bool parse_commandline(pika::detail::section const& rtcfg, + void parse_commandline(pika::detail::section const& rtcfg, pika::program_options::options_description const& app_options, std::string const& arg0, std::vector const& args, pika::program_options::variables_map& vm, commandline_error_mode error_mode, pika::program_options::options_description* visible, @@ -257,258 +257,236 @@ namespace pika::detail { using pika::program_options::value; using namespace pika::program_options::command_line_style; - try - { - // clang-format off - options_description cmdline_options( - "pika options (allowed on command line only)"); - cmdline_options.add_options() - ("pika:help", "print out program usage (this message)") - ("pika:version", "print out pika version and copyright information") - ("pika:info", "print out pika configuration information") - ("pika:options-file", value >()->composing(), - "specify a file containing command line options " - "(alternatively: @filepath)") - ; - - options_description pika_options( - "pika options (additionally allowed in an options file)"); - options_description hidden_options("Hidden options"); - // clang-format on - - // general options definitions - // clang-format off - pika_options.add_options() - ("pika:pu-offset", value(), - "the first processing unit this instance of pika should be " - "run on (default: 0), valid for " - "--pika:queuing=local, --pika:queuing=abp-priority, " - "--pika:queuing=static, --pika:queuing=static-priority, " - "and --pika:queuing=local-priority only") - ("pika:pu-step", value(), - "the step between used processing unit numbers for this " - "instance of pika (default: 1), valid for " - "--pika:queuing=local, --pika:queuing=abp-priority, " - "--pika:queuing=static, --pika:queuing=static-priority " - "and --pika:queuing=local-priority only") - ("pika:affinity", value(), - "the affinity domain the OS threads will be confined to, " - "possible values: pu, core, numa, machine (default: pu), valid for " - "--pika:queuing=local, --pika:queuing=abp-priority, " - "--pika:queuing=static, --pika:queuing=static-priority " - " and --pika:queuing=local-priority only") - ("pika:bind", value >()->composing(), - "the detailed affinity description for the OS threads, see " - "the documentation for a detailed description of possible " - "values. Do not use with --pika:pu-step, --pika:pu-offset, or " - "--pika:affinity options. Implies --pika:numa-sensitive=1" - "(--pika:bind=none disables defining thread affinities).") - ("pika:process-mask", value(), - "a process mask in hexadecimal form to restrict cores available for " - "the pika runtime. If a mask has been set externally on the executable, " - "this option overrides that mask. Has no effect if " - "--pika:ignore-process-mask is used. This option does not set the " - "process mask for the main thread. The mask only affects threads spawned " - "by the pika runtime.") - ("pika:ignore-process-mask", "ignore the process mask to restrict " - "available hardware resources, use all available processing units") - ("pika:print-bind", - "print to the console the bit masks calculated from the " - "arguments specified to all --pika:bind options.") - ("pika:threads", value(), - "the number of operating system threads to spawn for the pika " - "runtime (default: cores, using 'all' will spawn one thread for " - "each processing unit") - ("pika:cores", value(), - "the number of cores to utilize for the pika " - "runtime (default: 'all', i.e. the number of cores is based on " - "the number of total cores in the system)") - ("pika:queuing", value(), - "the queue scheduling policy to use, options are " - "'local', 'local-priority-fifo','local-priority-lifo', " - "'abp-priority-fifo', 'abp-priority-lifo', 'static', and " - "'static-priority' (default: 'local-priority'; " - "all option values can be abbreviated)") - ("pika:high-priority-threads", value(), - "the number of operating system threads maintaining a high " - "priority queue (default: number of OS threads), valid for " - "--pika:queuing=local-priority,--pika:queuing=static-priority, " - " and --pika:queuing=abp-priority only)") - ("pika:numa-sensitive", value()->implicit_value(0), - "makes the local-priority scheduler NUMA sensitive (" - "allowed values: 0 - no NUMA sensitivity, 1 - allow only for " - "boundary cores to steal across NUMA domains, 2 - " - "no cross boundary stealing is allowed (default value: 0)") - ; - - options_description config_options("pika configuration options"); - config_options.add_options() - ("pika:app-config", value(), - "load the specified application configuration (ini) file") - ("pika:config", value()->default_value(""), - "load the specified pika configuration (ini) file") - ("pika:ini", value >()->composing(), - "add a configuration definition to the default runtime " - "configuration") - ("pika:exit", "exit after configuring the runtime") - ; - - options_description debugging_options("pika debugging options"); - debugging_options.add_options() - ("pika:dump-config-initial", "print the initial runtime configuration") - ("pika:dump-config", "print the final runtime configuration") - // enable debug output from command line handling - ("pika:debug-clp", "debug command line processing") - ("pika:debug-pika-log", value()->implicit_value("cout"), - "enable all messages on the pika log channel and send all " - "pika logs to the target destination") - ("pika:debug-timing-log", value()->implicit_value("cout"), - "enable all messages on the timing log channel and send all " - "timing logs to the target destination") - ("pika:debug-app-log", value()->implicit_value("cout"), - "enable all messages on the application log channel and send all " - "application logs to the target destination") + // clang-format off + options_description cmdline_options( + "pika options (allowed on command line only)"); + cmdline_options.add_options() + ("pika:help", "print out program usage (this message)") + ("pika:version", "print out pika version and copyright information") + ("pika:info", "print out pika configuration information") + ("pika:options-file", value >()->composing(), + "specify a file containing command line options " + "(alternatively: @filepath)") + ; + + options_description pika_options( + "pika options (additionally allowed in an options file)"); + options_description hidden_options("Hidden options"); + + // general options definitions + pika_options.add_options() + ("pika:pu-offset", value(), + "the first processing unit this instance of pika should be " + "run on (default: 0), valid for " + "--pika:queuing=local, --pika:queuing=abp-priority, " + "--pika:queuing=static, --pika:queuing=static-priority, " + "and --pika:queuing=local-priority only") + ("pika:pu-step", value(), + "the step between used processing unit numbers for this " + "instance of pika (default: 1), valid for " + "--pika:queuing=local, --pika:queuing=abp-priority, " + "--pika:queuing=static, --pika:queuing=static-priority " + "and --pika:queuing=local-priority only") + ("pika:affinity", value(), + "the affinity domain the OS threads will be confined to, " + "possible values: pu, core, numa, machine (default: pu), valid for " + "--pika:queuing=local, --pika:queuing=abp-priority, " + "--pika:queuing=static, --pika:queuing=static-priority " + " and --pika:queuing=local-priority only") + ("pika:bind", value >()->composing(), + "the detailed affinity description for the OS threads, see " + "the documentation for a detailed description of possible " + "values. Do not use with --pika:pu-step, --pika:pu-offset, or " + "--pika:affinity options. Implies --pika:numa-sensitive=1" + "(--pika:bind=none disables defining thread affinities).") + ("pika:process-mask", value(), + "a process mask in hexadecimal form to restrict cores available for " + "the pika runtime. If a mask has been set externally on the executable, " + "this option overrides that mask. Has no effect if " + "--pika:ignore-process-mask is used. This option does not set the " + "process mask for the main thread. The mask only affects threads spawned " + "by the pika runtime.") + ("pika:ignore-process-mask", "ignore the process mask to restrict " + "available hardware resources, use all available processing units") + ("pika:print-bind", + "print to the console the bit masks calculated from the " + "arguments specified to all --pika:bind options.") + ("pika:threads", value(), + "the number of operating system threads to spawn for the pika " + "runtime (default: cores, using 'all' will spawn one thread for " + "each processing unit") + ("pika:cores", value(), + "the number of cores to utilize for the pika " + "runtime (default: 'all', i.e. the number of cores is based on " + "the number of total cores in the system)") + ("pika:queuing", value(), + "the queue scheduling policy to use, options are " + "'local', 'local-priority-fifo','local-priority-lifo', " + "'abp-priority-fifo', 'abp-priority-lifo', 'static', and " + "'static-priority' (default: 'local-priority'; " + "all option values can be abbreviated)") + ("pika:high-priority-threads", value(), + "the number of operating system threads maintaining a high " + "priority queue (default: number of OS threads), valid for " + "--pika:queuing=local-priority,--pika:queuing=static-priority, " + " and --pika:queuing=abp-priority only)") + ("pika:numa-sensitive", value()->implicit_value(0), + "makes the local-priority scheduler NUMA sensitive (" + "allowed values: 0 - no NUMA sensitivity, 1 - allow only for " + "boundary cores to steal across NUMA domains, 2 - " + "no cross boundary stealing is allowed (default value: 0)") + ; + + options_description config_options("pika configuration options"); + config_options.add_options() + ("pika:app-config", value(), + "load the specified application configuration (ini) file") + ("pika:config", value()->default_value(""), + "load the specified pika configuration (ini) file") + ("pika:ini", value >()->composing(), + "add a configuration definition to the default runtime " + "configuration") + ("pika:exit", "exit after configuring the runtime") + ; + + options_description debugging_options("pika debugging options"); + debugging_options.add_options() + ("pika:dump-config-initial", "print the initial runtime configuration") + ("pika:dump-config", "print the final runtime configuration") + // enable debug output from command line handling + ("pika:debug-clp", "debug command line processing") + ("pika:debug-pika-log", value()->implicit_value("cout"), + "enable all messages on the pika log channel and send all " + "pika logs to the target destination") + ("pika:debug-timing-log", value()->implicit_value("cout"), + "enable all messages on the timing log channel and send all " + "timing logs to the target destination") + ("pika:debug-app-log", value()->implicit_value("cout"), + "enable all messages on the application log channel and send all " + "application logs to the target destination") #if defined(_POSIX_VERSION) || defined(PIKA_WINDOWS) - ("pika:attach-debugger", - value()->implicit_value("startup"), - "wait for a debugger to be attached, possible values: " - "off, startup, exception or test-failure (default: startup)") + ("pika:attach-debugger", + value()->implicit_value("startup"), + "wait for a debugger to be attached, possible values: " + "off, startup, exception or test-failure (default: startup)") #endif + ; + + hidden_options.add_options() + ("pika:ignore", "this option will be silently ignored") + ; + + // construct the overall options description and parse the + // command line + options_description desc_cmdline; + options_description positional_options; + desc_cmdline + .add(app_options).add(cmdline_options) + .add(pika_options) + .add(config_options).add(debugging_options) + .add(hidden_options) + ; + + options_description desc_cfgfile; + desc_cfgfile + .add(app_options).add(pika_options) + .add(config_options) + .add(debugging_options).add(hidden_options) + ; + + if (rtcfg.get_entry("pika.commandline.allow_unknown", "0") == "0") + { + // move all positional options into the pika:positional option + // group + positional_options_description pd; + pd.add("pika:positional", -1); + + positional_options.add_options() + ("pika:positional", value >(), + "positional options") ; - - hidden_options.add_options() - ("pika:ignore", "this option will be silently ignored") - ; - // clang-format off - - // construct the overall options description and parse the - // command line - options_description desc_cmdline; - options_description positional_options; - desc_cmdline - .add(app_options).add(cmdline_options) - .add(pika_options) - .add(config_options).add(debugging_options) - .add(hidden_options) - ; - - options_description desc_cfgfile; - desc_cfgfile - .add(app_options).add(pika_options) - .add(config_options) - .add(debugging_options).add(hidden_options) - ; - - if (rtcfg.get_entry("pika.commandline.allow_unknown", "0") == "0") - { - // move all positional options into the pika:positional option - // group - positional_options_description pd; - pd.add("pika:positional", -1); - - positional_options.add_options() - ("pika:positional", value >(), - "positional options") - ; - desc_cmdline.add(positional_options); - desc_cfgfile.add(positional_options); - - // parse command line, allow for unregistered options this point - parsed_options opts(detail::get_commandline_parser( - command_line_parser(args) - .options(desc_cmdline) - .positional(pd) - .style(unix_style) - .extra_parser(detail::option_parser(rtcfg, - contains_error_mode(error_mode, - commandline_error_mode::ignore_aliases))), - error_mode & ~commandline_error_mode::ignore_aliases) - .run()); - - // collect unregistered options, if needed - if (unregistered_options) { - using pika::program_options::collect_unrecognized; - using pika::program_options::exclude_positional; - *unregistered_options = - collect_unrecognized(opts.options, exclude_positional); - } - - store(opts, vm); - } - else - { - // parse command line, allow for unregistered options this point - parsed_options opts(detail::get_commandline_parser( - command_line_parser(args) - .options(desc_cmdline) - .style(unix_style) - .extra_parser(detail::option_parser(rtcfg, - contains_error_mode(error_mode, - commandline_error_mode::ignore_aliases))), - error_mode & ~commandline_error_mode::ignore_aliases) - .run()); - - // collect unregistered options, if needed - if (unregistered_options) { - using pika::program_options::collect_unrecognized; - using pika::program_options::include_positional; - *unregistered_options = - collect_unrecognized(opts.options, include_positional); - } - - store(opts, vm); + desc_cmdline.add(positional_options); + desc_cfgfile.add(positional_options); + + // parse command line, allow for unregistered options this point + parsed_options opts(detail::get_commandline_parser( + command_line_parser(args) + .options(desc_cmdline) + .positional(pd) + .style(unix_style) + .extra_parser(detail::option_parser(rtcfg, + contains_error_mode(error_mode, + commandline_error_mode::ignore_aliases))), + error_mode & ~commandline_error_mode::ignore_aliases) + .run()); + + // collect unregistered options, if needed + if (unregistered_options) { + using pika::program_options::collect_unrecognized; + using pika::program_options::exclude_positional; + *unregistered_options = + collect_unrecognized(opts.options, exclude_positional); } - if (vm.count("pika:help")) - { - // collect help information - if (visible) { - (*visible) - .add(app_options).add(cmdline_options) - .add(pika_options) - .add(debugging_options).add(config_options) - ; - } - return true; + store(opts, vm); + } + else + { + // parse command line, allow for unregistered options this point + parsed_options opts(detail::get_commandline_parser( + command_line_parser(args) + .options(desc_cmdline) + .style(unix_style) + .extra_parser(detail::option_parser(rtcfg, + contains_error_mode(error_mode, + commandline_error_mode::ignore_aliases))), + error_mode & ~commandline_error_mode::ignore_aliases) + .run()); + + // collect unregistered options, if needed + if (unregistered_options) { + using pika::program_options::collect_unrecognized; + using pika::program_options::include_positional; + *unregistered_options = + collect_unrecognized(opts.options, include_positional); } - notify(vm); - - detail::handle_generic_config_options( - arg0, vm, desc_cfgfile, rtcfg, error_mode); - detail::handle_config_options( - vm, desc_cfgfile, rtcfg, error_mode); + store(opts, vm); } - catch (std::exception const& e) { - if (contains_error_mode(error_mode, commandline_error_mode::rethrow_on_error)) - throw; - std::cerr << "pika::init: exception caught: " - << e.what() << std::endl; - return false; + if (vm.count("pika:help")) + { + // collect help information + if (visible) { + (*visible) + .add(app_options).add(cmdline_options) + .add(pika_options) + .add(debugging_options).add(config_options) + ; + } + return; } - return true; + + // clang-format on + notify(vm); + + detail::handle_generic_config_options(arg0, vm, desc_cfgfile, rtcfg, error_mode); + detail::handle_config_options(vm, desc_cfgfile, rtcfg, error_mode); } /////////////////////////////////////////////////////////////////////////// - namespace detail - { + namespace detail { std::string extract_arg0(std::string const& cmdline) { std::string::size_type p = cmdline.find_first_of(" \t"); - if (p != std::string::npos) - { - return cmdline.substr(0, p); - } + if (p != std::string::npos) { return cmdline.substr(0, p); } return cmdline; } - } + } // namespace detail - bool parse_commandline( - pika::detail::section const& rtcfg, - pika::program_options::options_description const& app_options, - std::string const& cmdline, pika::program_options::variables_map& vm, - commandline_error_mode error_mode, + void parse_commandline(pika::detail::section const& rtcfg, + pika::program_options::options_description const& app_options, std::string const& cmdline, + pika::program_options::variables_map& vm, commandline_error_mode error_mode, pika::program_options::options_description* visible, std::vector* unregistered_options) { @@ -518,8 +496,7 @@ namespace pika::detail { #else std::vector args = split_unix(cmdline); #endif - return parse_commandline(rtcfg, app_options, - detail::extract_arg0(cmdline), args, vm, error_mode, + parse_commandline(rtcfg, app_options, detail::extract_arg0(cmdline), args, vm, error_mode, visible, unregistered_options); } @@ -528,56 +505,47 @@ namespace pika::detail { { char quote = (s.find_first_of('"') != std::string::npos) ? '\'' : '"'; - if (s.find_first_of("\t ") != std::string::npos) - return quote + s + quote; + if (s.find_first_of("\t ") != std::string::npos) return quote + s + quote; return s; } - void add_as_option(std::string& command_line, std::string const& k, - std::string const& v) + void add_as_option(std::string& command_line, std::string const& k, std::string const& v) { command_line += "--" + k; - if (!v.empty()) - command_line += "=" + v; + if (!v.empty()) command_line += "=" + v; } - std::string - reconstruct_command_line(pika::program_options::variables_map const &vm) + std::string reconstruct_command_line(pika::program_options::variables_map const& vm) { std::string command_line; for (auto const& v : vm) { std::any const& value = v.second.value(); - if (std::any_cast(&value)) { - add_as_option(command_line, v.first, - embed_in_quotes(v.second.as())); - if (!command_line.empty()) - command_line += " "; + if (std::any_cast(&value)) + { + add_as_option(command_line, v.first, embed_in_quotes(v.second.as())); + if (!command_line.empty()) command_line += " "; } - else if (std::any_cast(&value)) { - add_as_option(command_line, v.first, - std::to_string(v.second.as())); - if (!command_line.empty()) - command_line += " "; + else if (std::any_cast(&value)) + { + add_as_option(command_line, v.first, std::to_string(v.second.as())); + if (!command_line.empty()) command_line += " "; } - else if (std::any_cast(&value)) { - add_as_option(command_line, v.first, - std::to_string(v.second.as())); - if (!command_line.empty()) - command_line += " "; + else if (std::any_cast(&value)) + { + add_as_option(command_line, v.first, std::to_string(v.second.as())); + if (!command_line.empty()) command_line += " "; } - else if (std::any_cast>( - &value)) + else if (std::any_cast>(&value)) { auto const& vec = v.second.as>(); for (std::string const& e : vec) { add_as_option(command_line, v.first, embed_in_quotes(e)); - if (!command_line.empty()) - command_line += " "; + if (!command_line.empty()) command_line += " "; } } } return command_line; } -} +} // namespace pika::detail diff --git a/libs/pika/init_runtime/src/init_runtime.cpp b/libs/pika/init_runtime/src/init_runtime.cpp index 00e4151f5..7346084e0 100644 --- a/libs/pika/init_runtime/src/init_runtime.cpp +++ b/libs/pika/init_runtime/src/init_runtime.cpp @@ -280,104 +280,69 @@ namespace pika { #endif } - // make sure the runtime system is not active yet - int ensure_no_runtime_is_up() - { - // make sure the runtime system is not active yet - if (get_runtime_ptr() != nullptr) - { - std::cerr - << "pika::init: can't initialize runtime system more than once! Exiting...\n"; - return -1; - } - return 0; - } - /////////////////////////////////////////////////////////////////////// int run_or_start( util::detail::function const& f, int argc, const char* const* argv, init_params const& params, bool blocking) { - int result = 0; - try + if (get_runtime_ptr() != nullptr) { - if ((result = ensure_no_runtime_is_up()) != 0) { return result; } + PIKA_THROW_EXCEPTION( + pika::error::invalid_status, "pika::start/init", "runtime already initialized"); + } - pika::detail::command_line_handling cmdline{ - pika::util::runtime_configuration(argv[0]), params.cfg, f}; + pika::detail::command_line_handling cmdline{ + pika::util::runtime_configuration(argv[0]), params.cfg, f}; - // scope exception handling to resource partitioner initialization - // any exception thrown during run_or_start below are handled - // separately - try - { - result = cmdline.call(params.desc_cmdline, argc, argv); - - pika::detail::affinity_data affinity_data{}; - affinity_data.init(pika::detail::get_entry_as( - cmdline.rtcfg_, "pika.os_threads", 0), - pika::detail::get_entry_as(cmdline.rtcfg_, "pika.cores", 0), - pika::detail::get_entry_as( - cmdline.rtcfg_, "pika.pu_offset", 0), - pika::detail::get_entry_as(cmdline.rtcfg_, "pika.pu_step", 0), - 0, cmdline.rtcfg_.get_entry("pika.affinity", ""), - cmdline.rtcfg_.get_entry("pika.bind", ""), - !pika::detail::get_entry_as( - cmdline.rtcfg_, "pika.ignore_process_mask", false)); - - pika::resource::partitioner rp = pika::resource::detail::make_partitioner( - params.rp_mode, cmdline.rtcfg_, affinity_data); - - activate_global_options(cmdline); - - init_environment(cmdline); - - // check whether pika should be exited at this point - // (parse_result is returning a result > 0, if the program options - // contain --pika:help or --pika:version, on error result is < 0) - if (result != 0) - { - if (result > 0) result = 0; - return result; - } + auto cmdline_result = cmdline.call(params.desc_cmdline, argc, argv); - // If thread_pools initialization in user main - if (params.rp_callback) { params.rp_callback(rp, cmdline.vm_); } + pika::detail::affinity_data affinity_data{}; + affinity_data.init( + pika::detail::get_entry_as(cmdline.rtcfg_, "pika.os_threads", 0), + pika::detail::get_entry_as(cmdline.rtcfg_, "pika.cores", 0), + pika::detail::get_entry_as(cmdline.rtcfg_, "pika.pu_offset", 0), + pika::detail::get_entry_as(cmdline.rtcfg_, "pika.pu_step", 0), 0, + cmdline.rtcfg_.get_entry("pika.affinity", ""), + cmdline.rtcfg_.get_entry("pika.bind", ""), + !pika::detail::get_entry_as( + cmdline.rtcfg_, "pika.ignore_process_mask", false)); - // Setup all internal parameters of the resource_partitioner - rp.configure_pools(); - } - catch (pika::exception const& e) - { - std::cerr << "pika::init: pika::exception caught: " << pika::get_error_what(e) - << "\n"; - return -1; - } + pika::resource::partitioner rp = pika::resource::detail::make_partitioner( + params.rp_mode, cmdline.rtcfg_, affinity_data); + + activate_global_options(cmdline); + + init_environment(cmdline); + + switch (cmdline_result) + { + case command_line_handling_result::success: break; + case command_line_handling_result::exit: return 0; + } + + // If thread_pools initialization in user main + if (params.rp_callback) { params.rp_callback(rp, cmdline.vm_); } + + // Setup all internal parameters of the resource_partitioner + rp.configure_pools(); #if defined(PIKA_HAVE_HIP) - LPROGRESS_ << "run_local: initialize HIP"; - whip::check_error(hipInit(0)); + LPROGRESS_ << "run_local: initialize HIP"; + whip::check_error(hipInit(0)); #endif - // Initialize and start the pika runtime. - LPROGRESS_ << "run_local: create runtime"; + // Initialize and start the pika runtime. + LPROGRESS_ << "run_local: create runtime"; - // Build and configure this runtime instance. - std::unique_ptr rt; + // Build and configure this runtime instance. + std::unique_ptr rt; - // Command line handling should have updated this by now. - LPROGRESS_ << "creating local runtime"; - rt.reset(new pika::runtime(cmdline.rtcfg_, true)); + // Command line handling should have updated this by now. + LPROGRESS_ << "creating local runtime"; + rt.reset(new pika::runtime(cmdline.rtcfg_, true)); - result = run_or_start(blocking, PIKA_MOVE(rt), cmdline, PIKA_MOVE(params.startup), - PIKA_MOVE(params.shutdown)); - } - catch (pika::detail::command_line_error const& e) - { - std::cerr << "pika::init: std::exception caught: " << e.what() << "\n"; - return -1; - } - return result; + return run_or_start(blocking, PIKA_MOVE(rt), cmdline, PIKA_MOVE(params.startup), + PIKA_MOVE(params.shutdown)); } int init_start_impl(util::detail::function f, diff --git a/libs/pika/runtime/src/runtime.cpp b/libs/pika/runtime/src/runtime.cpp index d6d0297d6..b5c604bf1 100644 --- a/libs/pika/runtime/src/runtime.cpp +++ b/libs/pika/runtime/src/runtime.cpp @@ -691,7 +691,7 @@ namespace pika { namespace detail { /////////////////////////////////////////////////////////////////////////// // retrieve the command line arguments - bool retrieve_commandline_arguments( + void retrieve_commandline_arguments( pika::program_options::options_description const& app_options, pika::program_options::variables_map& vm) { @@ -706,20 +706,20 @@ namespace pika { pika::detail::section& cfg = pika::get_runtime().get_config(); if (cfg.has_entry("pika.cmd_line")) cmdline = cfg.get_entry("pika.cmd_line"); - return parse_commandline( + parse_commandline( cfg, app_options, cmdline, vm, commandline_error_mode::allow_unregistered); } /////////////////////////////////////////////////////////////////////////// // retrieve the command line arguments - bool retrieve_commandline_arguments( + void retrieve_commandline_arguments( std::string const& appname, pika::program_options::variables_map& vm) { using pika::program_options::options_description; options_description desc_commandline("Usage: " + appname + " [options]"); - return retrieve_commandline_arguments(desc_commandline, vm); + retrieve_commandline_arguments(desc_commandline, vm); } } // namespace detail From c07708d8049c75f6f217ab2c999c1e781248413e Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 1 Nov 2023 15:52:54 +0100 Subject: [PATCH 09/12] Don't use return value of pika::finalize for returning from pika_main pika::finalize now returns void. Explicitly return EXIT_SUCCESS instead. --- .inshpect.toml | 1 + examples/1d_stencil/1d_stencil_1.cpp | 4 +++- examples/1d_stencil/1d_stencil_2.cpp | 4 +++- examples/1d_stencil/1d_stencil_3.cpp | 4 +++- examples/future_reduce/rnd_future_reduce.cpp | 4 +++- examples/hello_world_standalone/hello_world.cpp | 4 +++- examples/jacobi_smp/jacobi.cpp | 4 +++- examples/quickstart/command_line_handling.cpp | 4 +++- examples/quickstart/customize_async.cpp | 4 +++- examples/quickstart/enumerate_threads.cpp | 4 +++- examples/quickstart/event_synchronization.cpp | 4 +++- examples/quickstart/latch_example.cpp | 4 +++- examples/quickstart/pipeline1.cpp | 4 +++- examples/quickstart/shared_mutex.cpp | 4 +++- examples/quickstart/use_main_thread.cpp | 7 ++++++- .../tests/performance/cuda_scheduler_throughput.cpp | 4 +++- libs/pika/async_cuda/tests/performance/synchronize.cu | 4 +++- libs/pika/async_cuda/tests/unit/cublas_matmul.cpp | 4 +++- libs/pika/async_cuda/tests/unit/cuda_bulk.cu | 4 +++- libs/pika/async_cuda/tests/unit/cuda_sender.cu | 4 +++- libs/pika/async_cuda/tests/unit/then_with_stream.cu | 4 +++- libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp | 4 +++- libs/pika/async_mpi/tests/unit/mpi_async_storage.cpp | 4 +++- .../tests/unit/mpi_ring_async_sender_receiver.cpp | 5 ++++- .../tests/regressions/ignore_aliases.cpp | 4 +++- .../command_line_handling/tests/unit/get_env_var_as.cpp | 4 +++- .../pika/concurrency/tests/unit/contiguous_index_queue.cpp | 5 ++++- .../coroutine_function_destructor_yield_4800.cpp | 4 +++- .../execution/tests/regressions/lambda_arguments_2403.cpp | 4 +++- .../tests/regressions/lambda_return_type_2402.cpp | 4 +++- .../tests/regressions/split_continuation_clear.cpp | 4 +++- libs/pika/execution/tests/unit/algorithm_sync_wait.cpp | 4 +++- libs/pika/executors/tests/unit/thread_pool_scheduler.cpp | 4 +++- libs/pika/init_runtime/tests/unit/config_entry.cpp | 5 ++++- libs/pika/init_runtime/tests/unit/const_args_init.cpp | 7 ++++++- .../init_runtime/tests/unit/shutdown_suspended_thread.cpp | 4 +++- .../tests/performance/stencil3_iterators.cpp | 4 +++- .../pika/iterator_support/tests/unit/counting_iterator.cpp | 3 ++- .../pika/iterator_support/tests/unit/stencil3_iterator.cpp | 4 +++- .../iterator_support/tests/unit/transform_iterator.cpp | 4 +++- .../tests/regressions/command_line_arguments_706.cpp | 3 ++- .../regressions/command_line_required_arguments_2990.cpp | 4 +++- .../tests/regressions/commandline_options_1437.cpp | 3 ++- .../examples/oversubscribing_resource_partitioner.cpp | 3 ++- .../examples/simple_resource_partitioner.cpp | 3 ++- .../examples/simplest_resource_partitioner_1.cpp | 6 +++++- .../examples/simplest_resource_partitioner_2.cpp | 7 ++++++- .../tests/regressions/help_exit_4317_1.cpp | 4 +++- .../tests/regressions/help_exit_4317_2.cpp | 4 +++- .../tests/unit/cross_pool_injection.cpp | 4 +++- .../tests/unit/named_pool_executor.cpp | 4 +++- .../tests/unit/resource_partitioner_info.cpp | 4 +++- .../tests/unit/scheduler_priority_check.cpp | 4 +++- .../tests/unit/shutdown_suspended_pus.cpp | 4 +++- .../resource_partitioner/tests/unit/suspend_disabled.cpp | 4 +++- libs/pika/resource_partitioner/tests/unit/suspend_pool.cpp | 4 +++- .../resource_partitioner/tests/unit/suspend_thread.cpp | 4 +++- .../tests/unit/suspend_thread_external.cpp | 4 +++- .../tests/unit/suspend_thread_timed.cpp | 4 +++- libs/pika/resource_partitioner/tests/unit/used_pus.cpp | 4 +++- libs/pika/runtime/tests/unit/thread_mapper.cpp | 4 +++- libs/pika/schedulers/tests/unit/schedule_last.cpp | 4 +++- .../tests/performance/channel_mpmc_throughput.cpp | 4 +++- .../tests/performance/channel_mpsc_throughput.cpp | 4 +++- .../tests/performance/channel_spsc_throughput.cpp | 4 +++- .../tests/regressions/ignore_while_locked_1485.cpp | 4 +++- .../tests/regressions/shared_mutex_1702.cpp | 4 +++- libs/pika/synchronization/tests/unit/async_rw_mutex.cpp | 4 +++- libs/pika/synchronization/tests/unit/barrier.cpp | 4 +++- .../tests/unit/shared_mutex/shared_mutex1.cpp | 4 +++- .../tests/unit/shared_mutex/shared_mutex2.cpp | 4 +++- libs/pika/synchronization/tests/unit/sliding_semaphore.cpp | 4 +++- libs/pika/threading/tests/unit/condition_variable2.cpp | 4 +++- libs/pika/threading/tests/unit/condition_variable3.cpp | 4 +++- libs/pika/threading/tests/unit/condition_variable4.cpp | 4 +++- libs/pika/threading/tests/unit/condition_variable_race.cpp | 3 ++- libs/pika/threading/tests/unit/error_callback.cpp | 4 +++- libs/pika/threading/tests/unit/jthread1.cpp | 4 +++- libs/pika/threading/tests/unit/jthread2.cpp | 4 +++- libs/pika/threading/tests/unit/stack_check.cpp | 4 +++- libs/pika/threading/tests/unit/stop_token_cb1.cpp | 4 +++- libs/pika/threading/tests/unit/stop_token_race.cpp | 3 ++- libs/pika/threading/tests/unit/thread_yield.cpp | 4 +++- .../threading_base/tests/regressions/thread_local_data.cpp | 5 ++++- .../tests/regressions/thread_stacksize_current.cpp | 4 +++- .../tests/unit/resume_suspended_same_thread.cpp | 4 +++- 86 files changed, 264 insertions(+), 85 deletions(-) diff --git a/.inshpect.toml b/.inshpect.toml index 2ac792436..24633950d 100644 --- a/.inshpect.toml +++ b/.inshpect.toml @@ -202,6 +202,7 @@ patterns = [ [includes] enable = true patterns = [ + { pattern = '\bEXIT_(SUCCESS|FAILURE)\b', include = 'cstdlib' }, { pattern = '\bstd::make_shared\b', include = 'memory' }, { pattern = '\bstd::map\b', include = 'map' }, { pattern = '\bstd::set\b', include = 'set' }, diff --git a/examples/1d_stencil/1d_stencil_1.cpp b/examples/1d_stencil/1d_stencil_1.cpp index d3183f899..c2de5a6fa 100644 --- a/examples/1d_stencil/1d_stencil_1.cpp +++ b/examples/1d_stencil/1d_stencil_1.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -104,7 +105,8 @@ int pika_main(pika::program_options::variables_map& vm) std::uint64_t const os_thread_count = pika::get_os_thread_count(); print_time_results(os_thread_count, elapsed, nx, nt, header); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/examples/1d_stencil/1d_stencil_2.cpp b/examples/1d_stencil/1d_stencil_2.cpp index 4aa1c5b8b..5f0f35152 100644 --- a/examples/1d_stencil/1d_stencil_2.cpp +++ b/examples/1d_stencil/1d_stencil_2.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -138,7 +139,8 @@ int pika_main(pika::program_options::variables_map& vm) std::uint64_t const os_thread_count = pika::get_os_thread_count(); print_time_results(os_thread_count, elapsed, nx, nt, header); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/examples/1d_stencil/1d_stencil_3.cpp b/examples/1d_stencil/1d_stencil_3.cpp index 08d258734..d217afd7a 100644 --- a/examples/1d_stencil/1d_stencil_3.cpp +++ b/examples/1d_stencil/1d_stencil_3.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -167,7 +168,8 @@ int pika_main(pika::program_options::variables_map& vm) std::uint64_t const os_thread_count = pika::get_os_thread_count(); print_time_results(os_thread_count, elapsed, nx, np, nt, header); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/examples/future_reduce/rnd_future_reduce.cpp b/examples/future_reduce/rnd_future_reduce.cpp index c74f5f7fc..8172edb0d 100644 --- a/examples/future_reduce/rnd_future_reduce.cpp +++ b/examples/future_reduce/rnd_future_reduce.cpp @@ -9,6 +9,7 @@ #include #include // +#include #include #include #include @@ -106,7 +107,8 @@ int pika_main() << "\n " << htimer.elapsed() << " seconds \n" << std::flush; // Initiate shutdown of the runtime system. - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } //---------------------------------------------------------------------------- diff --git a/examples/hello_world_standalone/hello_world.cpp b/examples/hello_world_standalone/hello_world.cpp index c0f3019c9..483930bf2 100644 --- a/examples/hello_world_standalone/hello_world.cpp +++ b/examples/hello_world_standalone/hello_world.cpp @@ -7,13 +7,15 @@ #include #include +#include #include int pika_main() { std::cout << "Hello from pika-thread with id " << pika::this_thread::get_id() << std::endl; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/examples/jacobi_smp/jacobi.cpp b/examples/jacobi_smp/jacobi.cpp index b969c1fc8..a7623d63b 100644 --- a/examples/jacobi_smp/jacobi.cpp +++ b/examples/jacobi_smp/jacobi.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -61,7 +62,8 @@ int pika_main(variables_map& vm) #if defined(JACOBI_SMP_NO_pika) return 0; #else - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; #endif } diff --git a/examples/quickstart/command_line_handling.cpp b/examples/quickstart/command_line_handling.cpp index 14e043690..1d26dce0c 100644 --- a/examples/quickstart/command_line_handling.cpp +++ b/examples/quickstart/command_line_handling.cpp @@ -9,6 +9,7 @@ #include +#include #include #include @@ -27,7 +28,8 @@ int pika_main(pika::program_options::variables_map& vm) } else { pika::cout << "no positional command line options\n"; } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/examples/quickstart/customize_async.cpp b/examples/quickstart/customize_async.cpp index 88c7e8733..7e9fb97a0 100644 --- a/examples/quickstart/customize_async.cpp +++ b/examples/quickstart/customize_async.cpp @@ -13,6 +13,7 @@ #include #include +#include #include namespace ex = pika::execution::experimental; @@ -75,7 +76,8 @@ int pika_main() tt::sync_wait(ex::schedule(fancy_scheduler) | ex::then(run_with_large_stack)); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/examples/quickstart/enumerate_threads.cpp b/examples/quickstart/enumerate_threads.cpp index 0f690852f..b26b521ce 100644 --- a/examples/quickstart/enumerate_threads.cpp +++ b/examples/quickstart/enumerate_threads.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -56,7 +57,8 @@ int pika_main() tt::sync_wait(ex::when_all_vector(std::move(results))); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/examples/quickstart/event_synchronization.cpp b/examples/quickstart/event_synchronization.cpp index 1ef18c77a..7562b36db 100644 --- a/examples/quickstart/event_synchronization.cpp +++ b/examples/quickstart/event_synchronization.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -67,7 +68,8 @@ int pika_main() l.arrive_and_wait(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/examples/quickstart/latch_example.cpp b/examples/quickstart/latch_example.cpp index 5964ae4a0..ad039620e 100644 --- a/examples/quickstart/latch_example.cpp +++ b/examples/quickstart/latch_example.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -43,7 +44,8 @@ int pika_main(pika::program_options::variables_map& vm) tt::sync_wait(ex::when_all_vector(std::move(results))); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/examples/quickstart/pipeline1.cpp b/examples/quickstart/pipeline1.cpp index 7b02581d4..f0579a1d1 100644 --- a/examples/quickstart/pipeline1.cpp +++ b/examples/quickstart/pipeline1.cpp @@ -10,6 +10,7 @@ #include +#include #include #include #include @@ -57,7 +58,8 @@ int pika_main() pipeline::process(input); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/examples/quickstart/shared_mutex.cpp b/examples/quickstart/shared_mutex.cpp index 7bc5c164b..134f5f481 100644 --- a/examples/quickstart/shared_mutex.cpp +++ b/examples/quickstart/shared_mutex.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -88,7 +89,8 @@ int pika_main() ready = true; for (auto& t : threads) t.join(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/examples/quickstart/use_main_thread.cpp b/examples/quickstart/use_main_thread.cpp index 319ce7c1f..a0491622f 100644 --- a/examples/quickstart/use_main_thread.cpp +++ b/examples/quickstart/use_main_thread.cpp @@ -9,11 +9,16 @@ #include +#include #include // Our main pika thread does nothing except for signalling to the runtime to // finalize. -int pika_main() { return pika::finalize(); } +int pika_main() +{ + pika::finalize(); + return EXIT_SUCCESS; +} int main(int argc, char* argv[]) { diff --git a/libs/pika/async_cuda/tests/performance/cuda_scheduler_throughput.cpp b/libs/pika/async_cuda/tests/performance/cuda_scheduler_throughput.cpp index 01c24bbfc..9fe70b6f9 100644 --- a/libs/pika/async_cuda/tests/performance/cuda_scheduler_throughput.cpp +++ b/libs/pika/async_cuda/tests/performance/cuda_scheduler_throughput.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -153,7 +154,8 @@ int pika_main(pika::program_options::variables_map& vm) matrixMultiply(matrix_size, device, iterations); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } // ------------------------------------------------------------------------- diff --git a/libs/pika/async_cuda/tests/performance/synchronize.cu b/libs/pika/async_cuda/tests/performance/synchronize.cu index 943ae891d..10903d2c8 100644 --- a/libs/pika/async_cuda/tests/performance/synchronize.cu +++ b/libs/pika/async_cuda/tests/performance/synchronize.cu @@ -12,6 +12,7 @@ #include #include +#include #include __global__ void dummy() {} @@ -210,7 +211,8 @@ int pika_main(pika::program_options::variables_map& vm) << '\n'; } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/async_cuda/tests/unit/cublas_matmul.cpp b/libs/pika/async_cuda/tests/unit/cublas_matmul.cpp index 4318176c5..7698721df 100644 --- a/libs/pika/async_cuda/tests/unit/cublas_matmul.cpp +++ b/libs/pika/async_cuda/tests/unit/cublas_matmul.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -318,7 +319,8 @@ int pika_main(pika::program_options::variables_map& vm) pika::cuda::experimental::cuda_scheduler cuda_sched3(std::move(cuda_sched)); matrixMultiply(cuda_sched3, matrix_size, device, 1); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } // ------------------------------------------------------------------------- diff --git a/libs/pika/async_cuda/tests/unit/cuda_bulk.cu b/libs/pika/async_cuda/tests/unit/cuda_bulk.cu index e8fcdf3bf..40a71c488 100644 --- a/libs/pika/async_cuda/tests/unit/cuda_bulk.cu +++ b/libs/pika/async_cuda/tests/unit/cuda_bulk.cu @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -101,7 +102,8 @@ int pika_main() } #endif - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/libs/pika/async_cuda/tests/unit/cuda_sender.cu b/libs/pika/async_cuda/tests/unit/cuda_sender.cu index 82be1a248..b569c98e6 100644 --- a/libs/pika/async_cuda/tests/unit/cuda_sender.cu +++ b/libs/pika/async_cuda/tests/unit/cuda_sender.cu @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -174,7 +175,8 @@ int pika_main(pika::program_options::variables_map& vm) // test a full kernel example test_saxpy(cuda_sched); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } // ------------------------------------------------------------------------- diff --git a/libs/pika/async_cuda/tests/unit/then_with_stream.cu b/libs/pika/async_cuda/tests/unit/then_with_stream.cu index 9fbc70d33..9c2235e1b 100644 --- a/libs/pika/async_cuda/tests/unit/then_with_stream.cu +++ b/libs/pika/async_cuda/tests/unit/then_with_stream.cu @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -582,7 +583,8 @@ int pika_main() PIKA_TEST(exception_thrown); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp b/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp index 200feb9ed..843e220a0 100644 --- a/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp +++ b/libs/pika/async_mpi/tests/unit/algorithm_transform_mpi.cpp @@ -13,6 +13,7 @@ #include "algorithm_test_utils.hpp" #include +#include #include #include #include @@ -235,7 +236,8 @@ int pika_main() test_adl_isolation(mpi::transform_mpi(my_namespace::my_sender{}, [](MPI_Request) {})); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/async_mpi/tests/unit/mpi_async_storage.cpp b/libs/pika/async_mpi/tests/unit/mpi_async_storage.cpp index 8cef4940a..1f23f7c8a 100644 --- a/libs/pika/async_mpi/tests/unit/mpi_async_storage.cpp +++ b/libs/pika/async_mpi/tests/unit/mpi_async_storage.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -445,7 +446,8 @@ int pika_main(pika::program_options::variables_map& vm) local_send_storage.shrink_to_fit(); nws_deb<2>.debug("Calling finalize ", rank); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } //---------------------------------------------------------------------------- diff --git a/libs/pika/async_mpi/tests/unit/mpi_ring_async_sender_receiver.cpp b/libs/pika/async_mpi/tests/unit/mpi_ring_async_sender_receiver.cpp index 2bab6e9cc..c48d9c2a9 100644 --- a/libs/pika/async_mpi/tests/unit/mpi_ring_async_sender_receiver.cpp +++ b/libs/pika/async_mpi/tests/unit/mpi_ring_async_sender_receiver.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -450,7 +451,9 @@ int pika_main(pika::program_options::variables_map& vm) } // let the user polling go out of scope } - return pika::finalize(); + + pika::finalize(); + return EXIT_SUCCESS; } //---------------------------------------------------------------------------- diff --git a/libs/pika/command_line_handling/tests/regressions/ignore_aliases.cpp b/libs/pika/command_line_handling/tests/regressions/ignore_aliases.cpp index 098ab80f4..746e8d3af 100644 --- a/libs/pika/command_line_handling/tests/regressions/ignore_aliases.cpp +++ b/libs/pika/command_line_handling/tests/regressions/ignore_aliases.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -17,7 +18,8 @@ int pika_main(int argc, char* argv[]) PIKA_TEST_EQ(argc, 2); PIKA_TEST_EQ(std::string(argv[1]), std::string("-wobble=1")); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) diff --git a/libs/pika/command_line_handling/tests/unit/get_env_var_as.cpp b/libs/pika/command_line_handling/tests/unit/get_env_var_as.cpp index be27f352a..d7b075d5d 100644 --- a/libs/pika/command_line_handling/tests/unit/get_env_var_as.cpp +++ b/libs/pika/command_line_handling/tests/unit/get_env_var_as.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -37,7 +38,8 @@ int pika_main() std::string s = pika::detail::get_env_var_as("string", "wrong"); PIKA_TEST_EQ(s, std::string("hello-world")); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) diff --git a/libs/pika/concurrency/tests/unit/contiguous_index_queue.cpp b/libs/pika/concurrency/tests/unit/contiguous_index_queue.cpp index 335e51068..9e2dadda9 100644 --- a/libs/pika/concurrency/tests/unit/contiguous_index_queue.cpp +++ b/libs/pika/concurrency/tests/unit/contiguous_index_queue.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -198,7 +199,9 @@ int pika_main(pika::program_options::variables_map& vm) test_concurrent(pop_mode::left); test_concurrent(pop_mode::right); test_concurrent(pop_mode::random); - return pika::finalize(); + + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/coroutines/tests/regressions/coroutine_function_destructor_yield_4800.cpp b/libs/pika/coroutines/tests/regressions/coroutine_function_destructor_yield_4800.cpp index 15bfdcef7..5cf96e8e7 100644 --- a/libs/pika/coroutines/tests/regressions/coroutine_function_destructor_yield_4800.cpp +++ b/libs/pika/coroutines/tests/regressions/coroutine_function_destructor_yield_4800.cpp @@ -12,6 +12,7 @@ #include #include +#include #include namespace ex = pika::execution::experimental; @@ -62,7 +63,8 @@ int pika_main() ex::execute(ex::thread_pool_scheduler{}, [y = yielder{}] {}); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/execution/tests/regressions/lambda_arguments_2403.cpp b/libs/pika/execution/tests/regressions/lambda_arguments_2403.cpp index 1c0bb38d6..7c2ab336e 100644 --- a/libs/pika/execution/tests/regressions/lambda_arguments_2403.cpp +++ b/libs/pika/execution/tests/regressions/lambda_arguments_2403.cpp @@ -11,6 +11,7 @@ #include #include +#include #include int pika_main() @@ -25,7 +26,8 @@ int pika_main() PIKA_TEST_EQ(std::count(large.begin(), large.end(), 10.0), std::ptrdiff_t(large.size())); - return pika::finalize(); // Handles pika shutdown + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/execution/tests/regressions/lambda_return_type_2402.cpp b/libs/pika/execution/tests/regressions/lambda_return_type_2402.cpp index b499d1b68..e28d9637d 100644 --- a/libs/pika/execution/tests/regressions/lambda_return_type_2402.cpp +++ b/libs/pika/execution/tests/regressions/lambda_return_type_2402.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -32,7 +33,8 @@ int pika_main() PIKA_TEST(all_of(mass_density == 0.0)); }); - return pika::finalize(); // Handles pika shutdown + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/execution/tests/regressions/split_continuation_clear.cpp b/libs/pika/execution/tests/regressions/split_continuation_clear.cpp index d6258d378..e59119b3c 100644 --- a/libs/pika/execution/tests/regressions/split_continuation_clear.cpp +++ b/libs/pika/execution/tests/regressions/split_continuation_clear.cpp @@ -16,6 +16,7 @@ #include #include +#include namespace ex = pika::execution::experimental; @@ -29,7 +30,8 @@ int pika_main() for (std::size_t j = 0; j < 10; ++j) { ex::start_detached(s); } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/execution/tests/unit/algorithm_sync_wait.cpp b/libs/pika/execution/tests/unit/algorithm_sync_wait.cpp index e0a7a7506..8a6207f9a 100644 --- a/libs/pika/execution/tests/unit/algorithm_sync_wait.cpp +++ b/libs/pika/execution/tests/unit/algorithm_sync_wait.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -113,7 +114,8 @@ int pika_main() PIKA_TEST(exception_thrown); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/executors/tests/unit/thread_pool_scheduler.cpp b/libs/pika/executors/tests/unit/thread_pool_scheduler.cpp index b2da7dd7e..43b669a92 100644 --- a/libs/pika/executors/tests/unit/thread_pool_scheduler.cpp +++ b/libs/pika/executors/tests/unit/thread_pool_scheduler.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1507,7 +1508,8 @@ int pika_main() test_completion_scheduler(); test_scheduler_queries(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/init_runtime/tests/unit/config_entry.cpp b/libs/pika/init_runtime/tests/unit/config_entry.cpp index 90277a987..9e9fdda54 100644 --- a/libs/pika/init_runtime/tests/unit/config_entry.cpp +++ b/libs/pika/init_runtime/tests/unit/config_entry.cpp @@ -10,6 +10,7 @@ #include #include +#include #include void test_get_entry() @@ -58,7 +59,9 @@ int pika_main() { test_get_entry(); test_set_entry(); - return pika::finalize(); + + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/init_runtime/tests/unit/const_args_init.cpp b/libs/pika/init_runtime/tests/unit/const_args_init.cpp index d6c2b6146..2f508b511 100644 --- a/libs/pika/init_runtime/tests/unit/const_args_init.cpp +++ b/libs/pika/init_runtime/tests/unit/const_args_init.cpp @@ -7,9 +7,14 @@ #include #include +#include #include -int pika_main() { return pika::finalize(); } +int pika_main() +{ + pika::finalize(); + return EXIT_SUCCESS; +} int main() { diff --git a/libs/pika/init_runtime/tests/unit/shutdown_suspended_thread.cpp b/libs/pika/init_runtime/tests/unit/shutdown_suspended_thread.cpp index c8ebdc99c..41cb76175 100644 --- a/libs/pika/init_runtime/tests/unit/shutdown_suspended_thread.cpp +++ b/libs/pika/init_runtime/tests/unit/shutdown_suspended_thread.cpp @@ -14,12 +14,14 @@ #include #include +#include int pika_main() { pika::apply([] { pika::this_thread::sleep_for(std::chrono::milliseconds(500)); }); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/iterator_support/tests/performance/stencil3_iterators.cpp b/libs/pika/iterator_support/tests/performance/stencil3_iterators.cpp index 0cf01a512..3733a9e0f 100644 --- a/libs/pika/iterator_support/tests/performance/stencil3_iterators.cpp +++ b/libs/pika/iterator_support/tests/performance/stencil3_iterators.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -495,7 +496,8 @@ int pika_main(pika::program_options::variables_map& vm) } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/pika/iterator_support/tests/unit/counting_iterator.cpp b/libs/pika/iterator_support/tests/unit/counting_iterator.cpp index 5e9a95d82..3b86d69f4 100644 --- a/libs/pika/iterator_support/tests/unit/counting_iterator.cpp +++ b/libs/pika/iterator_support/tests/unit/counting_iterator.cpp @@ -316,7 +316,8 @@ int pika_main(pika::program_options::variables_map& vm) test(pika::util::make_counting_iterator(array), pika::util::make_counting_iterator(array + 2000 - 1)); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/iterator_support/tests/unit/stencil3_iterator.cpp b/libs/pika/iterator_support/tests/unit/stencil3_iterator.cpp index 253be5902..1598d7a87 100644 --- a/libs/pika/iterator_support/tests/unit/stencil3_iterator.cpp +++ b/libs/pika/iterator_support/tests/unit/stencil3_iterator.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -186,7 +187,8 @@ int pika_main() test_stencil3_iterator(); test_stencil3_iterator_custom(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/iterator_support/tests/unit/transform_iterator.cpp b/libs/pika/iterator_support/tests/unit/transform_iterator.cpp index 9eb16aa25..b811a95e5 100644 --- a/libs/pika/iterator_support/tests/unit/transform_iterator.cpp +++ b/libs/pika/iterator_support/tests/unit/transform_iterator.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -137,7 +138,8 @@ int pika_main() test_left_element_full(); test_right_element_full(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp b/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp index 9b46a7ff7..28882ee33 100644 --- a/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp +++ b/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp @@ -20,7 +20,8 @@ int pika_main(int argc, char** argv_init) PIKA_TEST_EQ(0, std::strcmp(argv[0], argv_init[0])); for (int i = 1; i < argc; ++i) { PIKA_TEST_EQ(0, std::strcmp(argv[i + 1], argv_init[i])); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main() diff --git a/libs/pika/program_options/tests/regressions/command_line_required_arguments_2990.cpp b/libs/pika/program_options/tests/regressions/command_line_required_arguments_2990.cpp index ab4542a02..9e9baee85 100644 --- a/libs/pika/program_options/tests/regressions/command_line_required_arguments_2990.cpp +++ b/libs/pika/program_options/tests/regressions/command_line_required_arguments_2990.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -20,7 +21,8 @@ int pika_main(variables_map& vm) std::cout << "Value of reqopt2: " << vm["reqopt2"].as() << std::endl; std::cout << "Value of reqopt3: " << vm["reqopt3"].as() << std::endl; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp b/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp index 2f5a8ca1b..d7b7bb1fd 100644 --- a/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp +++ b/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp @@ -17,7 +17,8 @@ int my_pika_main(int argc, char**) PIKA_TEST_EQ(argc, 1); invoked_main = true; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp b/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp index a50b225bf..fa412b3d2 100644 --- a/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp +++ b/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp @@ -192,7 +192,8 @@ int pika_main(/*pika::program_options::variables_map& vm*/) senders.clear(); thread_set.clear(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } // ------------------------------------------------------------------------- diff --git a/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp b/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp index e2101fce9..a0d69c9c1 100644 --- a/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp +++ b/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp @@ -177,7 +177,8 @@ int pika_main(pika::program_options::variables_map&) senders.clear(); thread_set.clear(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } // ------------------------------------------------------------------------- diff --git a/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp b/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp index 104a19c4d..1b219014a 100644 --- a/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp +++ b/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp @@ -10,7 +10,11 @@ //[body #include -int pika_main() { return pika::finalize(); } +int pika_main() +{ + pika::finalize(); + return EXIT_SUCCESS; +} int main(int argc, char** argv) { diff --git a/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_2.cpp b/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_2.cpp index 4aa7165c8..0dc37a3e5 100644 --- a/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_2.cpp +++ b/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_2.cpp @@ -12,9 +12,14 @@ #include #include +#include #include -int pika_main() { return pika::finalize(); } +int pika_main() +{ + pika::finalize(); + return EXIT_SUCCESS; +} void init_resource_partitioner_handler( pika::resource::partitioner& rp, pika::program_options::variables_map const& /*vm*/) diff --git a/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_1.cpp b/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_1.cpp index 40dfc09d1..a020ee234 100644 --- a/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_1.cpp +++ b/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_1.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -16,7 +17,8 @@ std::atomic main_executed(false); int pika_main() { main_executed = true; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_2.cpp b/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_2.cpp index 7b5a1ed54..48fb79438 100644 --- a/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_2.cpp +++ b/libs/pika/resource_partitioner/tests/regressions/help_exit_4317_2.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -16,7 +17,8 @@ std::atomic main_executed(false); int pika_main() { main_executed = true; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/resource_partitioner/tests/unit/cross_pool_injection.cpp b/libs/pika/resource_partitioner/tests/unit/cross_pool_injection.cpp index 5848f82c1..f32ae212e 100644 --- a/libs/pika/resource_partitioner/tests/unit/cross_pool_injection.cpp +++ b/libs/pika/resource_partitioner/tests/unit/cross_pool_injection.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -194,7 +195,8 @@ int pika_main() pika::this_thread::yield(); } while (counter > 0); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } void init_resource_partitioner_handler(pika::resource::partitioner& rp, diff --git a/libs/pika/resource_partitioner/tests/unit/named_pool_executor.cpp b/libs/pika/resource_partitioner/tests/unit/named_pool_executor.cpp index b2ce22580..19e36f619 100644 --- a/libs/pika/resource_partitioner/tests/unit/named_pool_executor.cpp +++ b/libs/pika/resource_partitioner/tests/unit/named_pool_executor.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -108,7 +109,8 @@ int pika_main() // just wait until everything is done tt::sync_wait(ex::when_all_vector(std::move(lotsa_senders))); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } void init_resource_partitioner_handler( diff --git a/libs/pika/resource_partitioner/tests/unit/resource_partitioner_info.cpp b/libs/pika/resource_partitioner/tests/unit/resource_partitioner_info.cpp index 265989f18..666822f4f 100644 --- a/libs/pika/resource_partitioner/tests/unit/resource_partitioner_info.cpp +++ b/libs/pika/resource_partitioner/tests/unit/resource_partitioner_info.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,8 @@ int pika_main() PIKA_TEST_EQ(std::size_t(0), pool.get_thread_offset()); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/resource_partitioner/tests/unit/scheduler_priority_check.cpp b/libs/pika/resource_partitioner/tests/unit/scheduler_priority_check.cpp index a0ae35928..3c24c395e 100644 --- a/libs/pika/resource_partitioner/tests/unit/scheduler_priority_check.cpp +++ b/libs/pika/resource_partitioner/tests/unit/scheduler_priority_check.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -156,7 +157,8 @@ int pika_main(variables_map& vm) << "Launch : " << launch_count << "\n" << "Launch HP : " << hp_launch_count << std::endl; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/resource_partitioner/tests/unit/shutdown_suspended_pus.cpp b/libs/pika/resource_partitioner/tests/unit/shutdown_suspended_pus.cpp index 28f6f9cfc..61391e3cd 100644 --- a/libs/pika/resource_partitioner/tests/unit/shutdown_suspended_pus.cpp +++ b/libs/pika/resource_partitioner/tests/unit/shutdown_suspended_pus.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,8 @@ int pika_main() } // Start shutdown - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } void test_scheduler(int argc, char* argv[], pika::resource::scheduling_policy scheduler) diff --git a/libs/pika/resource_partitioner/tests/unit/suspend_disabled.cpp b/libs/pika/resource_partitioner/tests/unit/suspend_disabled.cpp index 52d119a4b..cbb3c4822 100644 --- a/libs/pika/resource_partitioner/tests/unit/suspend_disabled.cpp +++ b/libs/pika/resource_partitioner/tests/unit/suspend_disabled.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -38,7 +39,8 @@ int pika_main() PIKA_TEST(exception_thrown); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/resource_partitioner/tests/unit/suspend_pool.cpp b/libs/pika/resource_partitioner/tests/unit/suspend_pool.cpp index d11eac754..eb218a1f4 100644 --- a/libs/pika/resource_partitioner/tests/unit/suspend_pool.cpp +++ b/libs/pika/resource_partitioner/tests/unit/suspend_pool.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -110,7 +111,8 @@ int pika_main() } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } void test_scheduler(int argc, char* argv[], pika::resource::scheduling_policy scheduler) diff --git a/libs/pika/resource_partitioner/tests/unit/suspend_thread.cpp b/libs/pika/resource_partitioner/tests/unit/suspend_thread.cpp index 1402c31b8..d32f25b4a 100644 --- a/libs/pika/resource_partitioner/tests/unit/suspend_thread.cpp +++ b/libs/pika/resource_partitioner/tests/unit/suspend_thread.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -189,7 +190,8 @@ int pika_main() } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } void test_scheduler(int argc, char* argv[], pika::resource::scheduling_policy scheduler) diff --git a/libs/pika/resource_partitioner/tests/unit/suspend_thread_external.cpp b/libs/pika/resource_partitioner/tests/unit/suspend_thread_external.cpp index a5ee79973..bcde3af65 100644 --- a/libs/pika/resource_partitioner/tests/unit/suspend_thread_external.cpp +++ b/libs/pika/resource_partitioner/tests/unit/suspend_thread_external.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -156,7 +157,8 @@ int pika_main() } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } void test_scheduler(int argc, char* argv[], pika::resource::scheduling_policy scheduler) diff --git a/libs/pika/resource_partitioner/tests/unit/suspend_thread_timed.cpp b/libs/pika/resource_partitioner/tests/unit/suspend_thread_timed.cpp index 40c912626..572213477 100644 --- a/libs/pika/resource_partitioner/tests/unit/suspend_thread_timed.cpp +++ b/libs/pika/resource_partitioner/tests/unit/suspend_thread_timed.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -96,7 +97,8 @@ int pika_main(int argc, char* argv[]) } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } void test_scheduler(int argc, char* argv[], pika::resource::scheduling_policy scheduler) diff --git a/libs/pika/resource_partitioner/tests/unit/used_pus.cpp b/libs/pika/resource_partitioner/tests/unit/used_pus.cpp index cdca20183..32f0e3abb 100644 --- a/libs/pika/resource_partitioner/tests/unit/used_pus.cpp +++ b/libs/pika/resource_partitioner/tests/unit/used_pus.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -30,7 +31,8 @@ int pika_main() PIKA_TEST(pika::threads::detail::bit_or(used_pu_mask, thread_mask)); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/runtime/tests/unit/thread_mapper.cpp b/libs/pika/runtime/tests/unit/thread_mapper.cpp index 2fa178246..5d2ce256f 100644 --- a/libs/pika/runtime/tests/unit/thread_mapper.cpp +++ b/libs/pika/runtime/tests/unit/thread_mapper.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,8 @@ int pika_main() }); t.join(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/schedulers/tests/unit/schedule_last.cpp b/libs/pika/schedulers/tests/unit/schedule_last.cpp index 73fbb3a22..d71e2cc07 100644 --- a/libs/pika/schedulers/tests/unit/schedule_last.cpp +++ b/libs/pika/schedulers/tests/unit/schedule_last.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,8 @@ int pika_main() PIKA_TEST(run); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } template diff --git a/libs/pika/synchronization/tests/performance/channel_mpmc_throughput.cpp b/libs/pika/synchronization/tests/performance/channel_mpmc_throughput.cpp index 98fb7d14e..22c41ef0c 100644 --- a/libs/pika/synchronization/tests/performance/channel_mpmc_throughput.cpp +++ b/libs/pika/synchronization/tests/performance/channel_mpmc_throughput.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -104,7 +105,8 @@ int pika_main() std::cout << "Consumer throughput: " << (NUM_TESTS / consumer_time) << " [op/s] (" << (consumer_time / NUM_TESTS) << " [s/op])\n"; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/libs/pika/synchronization/tests/performance/channel_mpsc_throughput.cpp b/libs/pika/synchronization/tests/performance/channel_mpsc_throughput.cpp index 05a1ea607..41b9e2368 100644 --- a/libs/pika/synchronization/tests/performance/channel_mpsc_throughput.cpp +++ b/libs/pika/synchronization/tests/performance/channel_mpsc_throughput.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -104,7 +105,8 @@ int pika_main() std::cout << "Consumer throughput: " << (NUM_TESTS / consumer_time) << " [op/s] (" << (consumer_time / NUM_TESTS) << " [s/op])\n"; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/libs/pika/synchronization/tests/performance/channel_spsc_throughput.cpp b/libs/pika/synchronization/tests/performance/channel_spsc_throughput.cpp index 181223b90..dfc77fb16 100644 --- a/libs/pika/synchronization/tests/performance/channel_spsc_throughput.cpp +++ b/libs/pika/synchronization/tests/performance/channel_spsc_throughput.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -104,7 +105,8 @@ int pika_main() std::cout << "Consumer throughput: " << (NUM_TESTS / consumer_time) << " [op/s] (" << (consumer_time / NUM_TESTS) << " [s/op])\n"; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/libs/pika/synchronization/tests/regressions/ignore_while_locked_1485.cpp b/libs/pika/synchronization/tests/regressions/ignore_while_locked_1485.cpp index 7ff3b00c5..e6671a6a8 100644 --- a/libs/pika/synchronization/tests/regressions/ignore_while_locked_1485.cpp +++ b/libs/pika/synchronization/tests/regressions/ignore_while_locked_1485.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -92,7 +93,8 @@ void test_condition_with_mutex() int pika_main() { test_condition_with_mutex(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/synchronization/tests/regressions/shared_mutex_1702.cpp b/libs/pika/synchronization/tests/regressions/shared_mutex_1702.cpp index b4c37ced5..301f64335 100644 --- a/libs/pika/synchronization/tests/regressions/shared_mutex_1702.cpp +++ b/libs/pika/synchronization/tests/regressions/shared_mutex_1702.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -31,7 +32,8 @@ int pika_main() [[maybe_unused]] int i = data; } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/synchronization/tests/unit/async_rw_mutex.cpp b/libs/pika/synchronization/tests/unit/async_rw_mutex.cpp index 71232afd1..5476fe9c3 100644 --- a/libs/pika/synchronization/tests/unit/async_rw_mutex.cpp +++ b/libs/pika/synchronization/tests/unit/async_rw_mutex.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -317,7 +318,8 @@ int pika_main(pika::program_options::variables_map& vm) test_multiple_when_all(async_rw_mutex{0}); test_multiple_when_all(async_rw_mutex{mytype{}}); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/synchronization/tests/unit/barrier.cpp b/libs/pika/synchronization/tests/unit/barrier.cpp index 998994745..6426f49ba 100644 --- a/libs/pika/synchronization/tests/unit/barrier.cpp +++ b/libs/pika/synchronization/tests/unit/barrier.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -212,7 +213,8 @@ int pika_main() test_barrier_empty_oncomplete_split(); test_barrier_oncomplete_split(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) { return pika::init(pika_main, argc, argv); } diff --git a/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex1.cpp b/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex1.cpp index 019dd32bc..0e0efae29 100644 --- a/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex1.cpp +++ b/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex1.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -313,7 +314,8 @@ int pika_main() test_unlocking_writer_unblocks_all_readers(); test_unlocking_last_reader_only_unblocks_one_writer(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex2.cpp b/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex2.cpp index 85ccd2a35..adeea143a 100644 --- a/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex2.cpp +++ b/libs/pika/synchronization/tests/unit/shared_mutex/shared_mutex2.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -277,7 +278,8 @@ int pika_main() test_if_other_thread_has_shared_lock_try_lock_shared_returns_true(); test_if_other_thread_has_shared_lock_try_lock_upgrade_returns_true(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/synchronization/tests/unit/sliding_semaphore.cpp b/libs/pika/synchronization/tests/unit/sliding_semaphore.cpp index 53eab774f..9c6f91b3a 100644 --- a/libs/pika/synchronization/tests/unit/sliding_semaphore.cpp +++ b/libs/pika/synchronization/tests/unit/sliding_semaphore.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -71,7 +72,8 @@ int pika_main() // tt::sync_wait(ex::when_all_vector(std::move(senders))); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/condition_variable2.cpp b/libs/pika/threading/tests/unit/condition_variable2.cpp index 61e57f552..187f28193 100644 --- a/libs/pika/threading/tests/unit/condition_variable2.cpp +++ b/libs/pika/threading/tests/unit/condition_variable2.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -600,7 +601,8 @@ int pika_main() PIKA_TEST(false); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/condition_variable3.cpp b/libs/pika/threading/tests/unit/condition_variable3.cpp index 0a6eefbfa..7993aaa7e 100644 --- a/libs/pika/threading/tests/unit/condition_variable3.cpp +++ b/libs/pika/threading/tests/unit/condition_variable3.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -57,7 +58,8 @@ int pika_main() PIKA_TEST(false); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/condition_variable4.cpp b/libs/pika/threading/tests/unit/condition_variable4.cpp index 16d45c7ed..43d7a332f 100644 --- a/libs/pika/threading/tests/unit/condition_variable4.cpp +++ b/libs/pika/threading/tests/unit/condition_variable4.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -142,7 +143,8 @@ int pika_main() PIKA_TEST(false); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/condition_variable_race.cpp b/libs/pika/threading/tests/unit/condition_variable_race.cpp index bd9fb8ffb..d2238a253 100644 --- a/libs/pika/threading/tests/unit/condition_variable_race.cpp +++ b/libs/pika/threading/tests/unit/condition_variable_race.cpp @@ -214,7 +214,8 @@ int pika_main() PIKA_TEST(false); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/error_callback.cpp b/libs/pika/threading/tests/unit/error_callback.cpp index a31963d64..01706784b 100644 --- a/libs/pika/threading/tests/unit/error_callback.cpp +++ b/libs/pika/threading/tests/unit/error_callback.cpp @@ -10,6 +10,7 @@ #include #include +#include #include std::atomic count_error_handler(0); @@ -25,7 +26,8 @@ bool on_thread_error(std::size_t, std::exception_ptr const&) int pika_main() { PIKA_THROW_EXCEPTION(pika::error::invalid_status, "test", "test"); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/jthread1.cpp b/libs/pika/threading/tests/unit/jthread1.cpp index 09cddc537..5d23d89a0 100644 --- a/libs/pika/threading/tests/unit/jthread1.cpp +++ b/libs/pika/threading/tests/unit/jthread1.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -442,7 +443,8 @@ int pika_main() test_temporarily_disable_token(); test_jthread_api(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/jthread2.cpp b/libs/pika/threading/tests/unit/jthread2.cpp index 3e589d75e..eca23048b 100644 --- a/libs/pika/threading/tests/unit/jthread2.cpp +++ b/libs/pika/threading/tests/unit/jthread2.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -297,7 +298,8 @@ int pika_main() test_jthread_move(); // testEnabledIfForCopyConstructor_CompileTimeOnly(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/stack_check.cpp b/libs/pika/threading/tests/unit/stack_check.cpp index d3f6d2e82..52c006429 100644 --- a/libs/pika/threading/tests/unit/stack_check.cpp +++ b/libs/pika/threading/tests/unit/stack_check.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -83,7 +84,8 @@ int pika_main() current_stack = stack_now; my_stack_info.pop(); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/stop_token_cb1.cpp b/libs/pika/threading/tests/unit/stop_token_cb1.cpp index f379098c4..dfcf9f0bc 100644 --- a/libs/pika/threading/tests/unit/stop_token_cb1.cpp +++ b/libs/pika/threading/tests/unit/stop_token_cb1.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -431,7 +432,8 @@ int pika_main() test_callback_deregistration_blocks_until_callback_finishes(); test_cancellation_single_thread_performance(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/stop_token_race.cpp b/libs/pika/threading/tests/unit/stop_token_race.cpp index 28978272d..89ea4bdc2 100644 --- a/libs/pika/threading/tests/unit/stop_token_race.cpp +++ b/libs/pika/threading/tests/unit/stop_token_race.cpp @@ -185,7 +185,8 @@ int pika_main() test_callback_concurrent_unregister(); test_callback_concurrent_unregister_other_thread(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading/tests/unit/thread_yield.cpp b/libs/pika/threading/tests/unit/thread_yield.cpp index 96bd357db..51392d19f 100644 --- a/libs/pika/threading/tests/unit/thread_yield.cpp +++ b/libs/pika/threading/tests/unit/thread_yield.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,8 @@ int pika_main() tt::sync_wait(ex::when_all_vector(std::move(finished))); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/pika/threading_base/tests/regressions/thread_local_data.cpp b/libs/pika/threading_base/tests/regressions/thread_local_data.cpp index 2d8773c6e..939f8695c 100644 --- a/libs/pika/threading_base/tests/regressions/thread_local_data.cpp +++ b/libs/pika/threading_base/tests/regressions/thread_local_data.cpp @@ -11,6 +11,7 @@ #include #include +#include namespace ex = pika::execution::experimental; namespace tt = pika::this_thread::experimental; @@ -44,7 +45,9 @@ int pika_main() { tt::sync_wait(ex::schedule(ex::thread_pool_scheduler{}) | ex::then(test)); PIKA_TEST(data_deallocated); - return pika::finalize(); + + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/libs/pika/threading_base/tests/regressions/thread_stacksize_current.cpp b/libs/pika/threading_base/tests/regressions/thread_stacksize_current.cpp index 0c8f9cff8..b7b9df260 100644 --- a/libs/pika/threading_base/tests/regressions/thread_stacksize_current.cpp +++ b/libs/pika/threading_base/tests/regressions/thread_stacksize_current.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -58,7 +59,8 @@ int pika_main() test(stacksize); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/libs/pika/threading_base/tests/unit/resume_suspended_same_thread.cpp b/libs/pika/threading_base/tests/unit/resume_suspended_same_thread.cpp index d9ce170cb..85c0b9093 100644 --- a/libs/pika/threading_base/tests/unit/resume_suspended_same_thread.cpp +++ b/libs/pika/threading_base/tests/unit/resume_suspended_same_thread.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -49,7 +50,8 @@ int pika_main() }); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) From 800698089112d08d438141176fb75225c44f391c Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 1 Nov 2023 15:58:30 +0100 Subject: [PATCH 10/12] Make dump_config constructor explicit --- libs/pika/init_runtime/src/init_runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pika/init_runtime/src/init_runtime.cpp b/libs/pika/init_runtime/src/init_runtime.cpp index 7346084e0..bcd099b04 100644 --- a/libs/pika/init_runtime/src/init_runtime.cpp +++ b/libs/pika/init_runtime/src/init_runtime.cpp @@ -143,7 +143,7 @@ namespace pika { struct dump_config { - dump_config(pika::runtime const& rt) + explicit dump_config(pika::runtime const& rt) : rt_(std::cref(rt)) { } From 84dd01db73ea24368e55b11e7449b668ca2041c5 Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 1 Nov 2023 16:00:49 +0100 Subject: [PATCH 11/12] Explicitly ignore return values of setting signal and exit handlers --- libs/pika/init_runtime/src/init_runtime.cpp | 6 +++--- .../tests/regressions/command_line_arguments_706.cpp | 2 ++ .../tests/regressions/commandline_options_1437.cpp | 2 ++ .../examples/oversubscribing_resource_partitioner.cpp | 1 + .../examples/simple_resource_partitioner.cpp | 1 + .../examples/simplest_resource_partitioner_1.cpp | 2 ++ libs/pika/synchronization/tests/unit/event.cpp | 4 +++- libs/pika/synchronization/tests/unit/latch.cpp | 5 +++-- tests/performance/local/async_overheads.cpp | 4 +++- tests/performance/local/coroutines_call_overhead.cpp | 4 +++- tests/performance/local/future_overhead.cpp | 4 +++- tests/performance/local/future_overhead_report.cpp | 4 +++- tests/performance/local/htts_v2/htts2_pika.cpp | 4 +++- tests/performance/local/start_stop.cpp | 7 ++++++- tests/performance/local/timed_task_spawn.cpp | 4 +++- tests/regressions/multiple_init.cpp | 5 ++++- tests/regressions/multiple_init_2918.cpp | 4 +++- tests/regressions/stack_size_config_4543.cpp | 4 +++- tests/regressions/threads/block_os_threads_1036.cpp | 4 +++- tests/regressions/threads/stackless_self_4155.cpp | 5 ++++- tests/regressions/threads/thread_data_1111.cpp | 4 +++- tests/regressions/threads/thread_suspend_duration.cpp | 4 +++- tests/regressions/threads/thread_suspend_pending.cpp | 4 +++- tests/regressions/threads/threads_all_1422.cpp | 4 +++- tests/regressions/unhandled_exception_582.cpp | 5 ++++- tests/regressions/util/set_config_entry_deadlock.cpp | 4 +++- 26 files changed, 77 insertions(+), 24 deletions(-) diff --git a/libs/pika/init_runtime/src/init_runtime.cpp b/libs/pika/init_runtime/src/init_runtime.cpp index bcd099b04..e1fee5612 100644 --- a/libs/pika/init_runtime/src/init_runtime.cpp +++ b/libs/pika/init_runtime/src/init_runtime.cpp @@ -358,10 +358,10 @@ namespace pika { freebsd_environ = environ; #endif // set a handler for std::abort - std::signal(SIGABRT, pika::detail::on_abort); - std::atexit(pika::detail::on_exit); + [[maybe_unused]] auto signal_handler = std::signal(SIGABRT, pika::detail::on_abort); + [[maybe_unused]] auto exit_result = std::atexit(pika::detail::on_exit); #if defined(PIKA_HAVE_CXX11_STD_QUICK_EXIT) - std::at_quick_exit(pika::detail::on_exit); + [[maybe_unused]] auto quick_exit_result = std::at_quick_exit(pika::detail::on_exit); #endif return run_or_start(f, argc, argv, params, blocking); } diff --git a/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp b/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp index 28882ee33..701b61d4a 100644 --- a/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp +++ b/libs/pika/program_options/tests/regressions/command_line_arguments_706.cpp @@ -10,6 +10,8 @@ #include #include +#include + char const* argv[] = {"command_line_argument_test", // We need only one thread, this argument should be gone in pika_main "--pika:threads=1", "nx=1", "ny=1=5"}; diff --git a/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp b/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp index d7b7bb1fd..79cb108bd 100644 --- a/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp +++ b/libs/pika/program_options/tests/regressions/commandline_options_1437.cpp @@ -9,6 +9,8 @@ #include #include +#include + bool invoked_main = false; int my_pika_main(int argc, char**) diff --git a/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp b/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp index fa412b3d2..158984cfe 100644 --- a/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp +++ b/libs/pika/resource_partitioner/examples/oversubscribing_resource_partitioner.cpp @@ -16,6 +16,7 @@ # include # include # include +# include # include # include # include diff --git a/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp b/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp index a0d69c9c1..02162968d 100644 --- a/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp +++ b/libs/pika/resource_partitioner/examples/simple_resource_partitioner.cpp @@ -18,6 +18,7 @@ # include # include # include +# include # include # include # include diff --git a/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp b/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp index 1b219014a..f48bf3f78 100644 --- a/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp +++ b/libs/pika/resource_partitioner/examples/simplest_resource_partitioner_1.cpp @@ -10,6 +10,8 @@ //[body #include +#include + int pika_main() { pika::finalize(); diff --git a/libs/pika/synchronization/tests/unit/event.cpp b/libs/pika/synchronization/tests/unit/event.cpp index 49ad97a79..5db679234 100644 --- a/libs/pika/synchronization/tests/unit/event.cpp +++ b/libs/pika/synchronization/tests/unit/event.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -84,7 +85,8 @@ int pika_main(variables_map& vm) } // Initiate shutdown of the runtime system. - return finalize(); + finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/pika/synchronization/tests/unit/latch.cpp b/libs/pika/synchronization/tests/unit/latch.cpp index 86f7669da..4517043ac 100644 --- a/libs/pika/synchronization/tests/unit/latch.cpp +++ b/libs/pika/synchronization/tests/unit/latch.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -109,8 +110,8 @@ int pika_main() PIKA_TEST_EQ(num_threads.load(), NUM_THREADS); } - PIKA_TEST_EQ(pika::finalize(), 0); - return 0; + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/tests/performance/local/async_overheads.cpp b/tests/performance/local/async_overheads.cpp index a817a201e..d6c49a5fd 100644 --- a/tests/performance/local/async_overheads.cpp +++ b/tests/performance/local/async_overheads.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -119,7 +120,8 @@ int pika_main(pika::program_options::variables_map& vm) pika::util::print_cdash_timing( "AsyncSpeedup", sequential_time_per_task / hierarchical_time_per_task); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/tests/performance/local/coroutines_call_overhead.cpp b/tests/performance/local/coroutines_call_overhead.cpp index 092dea097..a6bc7a0aa 100644 --- a/tests/performance/local/coroutines_call_overhead.cpp +++ b/tests/performance/local/coroutines_call_overhead.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -163,7 +164,8 @@ int pika_main(variables_map& vm) print_results(total_elapsed); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/performance/local/future_overhead.cpp b/tests/performance/local/future_overhead.cpp index 50d67df69..6f365de81 100644 --- a/tests/performance/local/future_overhead.cpp +++ b/tests/performance/local/future_overhead.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -385,7 +386,8 @@ int pika_main(variables_map& vm) } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/performance/local/future_overhead_report.cpp b/tests/performance/local/future_overhead_report.cpp index 695480f7a..a5cf3e983 100644 --- a/tests/performance/local/future_overhead_report.cpp +++ b/tests/performance/local/future_overhead_report.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -140,7 +141,8 @@ int pika_main(variables_map& vm) if (test_all) { measure_function_create_thread_hierarchical_placement(count, repetitions); } } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/performance/local/htts_v2/htts2_pika.cpp b/tests/performance/local/htts_v2/htts2_pika.cpp index 0874a3577..d1dda2d7d 100644 --- a/tests/performance/local/htts_v2/htts2_pika.cpp +++ b/tests/performance/local/htts_v2/htts2_pika.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -63,7 +64,8 @@ struct pika_driver : htts2::driver results_type results = kernel(); print_results(results); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } pika::threads::detail::thread_result_type payload_thread_function( diff --git a/tests/performance/local/start_stop.cpp b/tests/performance/local/start_stop.cpp index 207086535..cd89ca9f6 100644 --- a/tests/performance/local/start_stop.cpp +++ b/tests/performance/local/start_stop.cpp @@ -16,11 +16,16 @@ #include #include +#include #include namespace ex = pika::execution::experimental; -int pika_main() { return pika::finalize(); } +int pika_main() +{ + pika::finalize(); + return EXIT_SUCCESS; +} int main(int argc, char** argv) { diff --git a/tests/performance/local/timed_task_spawn.cpp b/tests/performance/local/timed_task_spawn.cpp index bc9786652..18feedb2a 100644 --- a/tests/performance/local/timed_task_spawn.cpp +++ b/tests/performance/local/timed_task_spawn.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -458,7 +459,8 @@ int pika_main(variables_map& vm) // Force termination of all suspended tasks. pika::get_runtime().get_thread_manager().abort_all_suspended_threads(); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/regressions/multiple_init.cpp b/tests/regressions/multiple_init.cpp index 95ba0432a..f69da38da 100644 --- a/tests/regressions/multiple_init.cpp +++ b/tests/regressions/multiple_init.cpp @@ -9,12 +9,15 @@ #include #include +#include + int invoked_init = 0; int pika_main() { ++invoked_init; - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/tests/regressions/multiple_init_2918.cpp b/tests/regressions/multiple_init_2918.cpp index 45456e92c..fd0dc328a 100644 --- a/tests/regressions/multiple_init_2918.cpp +++ b/tests/regressions/multiple_init_2918.cpp @@ -8,6 +8,7 @@ #include #include +#include #include std::string expected; @@ -15,7 +16,8 @@ std::string expected; int pika_init_test(std::string s, int, char**) { PIKA_TEST_EQ(s, expected); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) diff --git a/tests/regressions/stack_size_config_4543.cpp b/tests/regressions/stack_size_config_4543.cpp index 6df40b127..2ed34dc7a 100644 --- a/tests/regressions/stack_size_config_4543.cpp +++ b/tests/regressions/stack_size_config_4543.cpp @@ -9,6 +9,7 @@ #include #include +#include // This test ensures that thread creation uses the correct stack sizes. We // slightly change all the stack sizes in the configuration to catch problems @@ -21,7 +22,8 @@ int pika_main() pika::thread t([]() {}); t.join(); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/tests/regressions/threads/block_os_threads_1036.cpp b/tests/regressions/threads/block_os_threads_1036.cpp index 696938bee..fb6f60429 100644 --- a/tests/regressions/threads/block_os_threads_1036.cpp +++ b/tests/regressions/threads/block_os_threads_1036.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -107,7 +108,8 @@ int pika_main() exit_barrier.arrive_and_wait(); } - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/regressions/threads/stackless_self_4155.cpp b/tests/regressions/threads/stackless_self_4155.cpp index c97f2988f..b482f2358 100644 --- a/tests/regressions/threads/stackless_self_4155.cpp +++ b/tests/regressions/threads/stackless_self_4155.cpp @@ -8,6 +8,8 @@ #include #include +#include + void stackless_thread() { PIKA_TEST_NEQ(pika::threads::detail::get_self_id(), pika::threads::detail::invalid_thread_id); @@ -20,7 +22,8 @@ int pika_main() pika::execution::thread_priority::default_, pika::execution::thread_schedule_hint(), pika::execution::thread_stacksize::nostack); pika::threads::detail::register_work(data); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/tests/regressions/threads/thread_data_1111.cpp b/tests/regressions/threads/thread_data_1111.cpp index 32baf7fa7..95553f189 100644 --- a/tests/regressions/threads/thread_data_1111.cpp +++ b/tests/regressions/threads/thread_data_1111.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -39,7 +40,8 @@ int pika_main() PIKA_TEST_EQ(get_thread_num(), 42); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/tests/regressions/threads/thread_suspend_duration.cpp b/tests/regressions/threads/thread_suspend_duration.cpp index 2c341500d..b7e5afd8c 100644 --- a/tests/regressions/threads/thread_suspend_duration.cpp +++ b/tests/regressions/threads/thread_suspend_duration.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -72,7 +73,8 @@ int pika_main(variables_map& vm) } // Initiate shutdown of the runtime system. - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/regressions/threads/thread_suspend_pending.cpp b/tests/regressions/threads/thread_suspend_pending.cpp index fc8aa7a69..add229f82 100644 --- a/tests/regressions/threads/thread_suspend_pending.cpp +++ b/tests/regressions/threads/thread_suspend_pending.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -66,7 +67,8 @@ int pika_main(variables_map& vm) } // Initiate shutdown of the runtime system. - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } /////////////////////////////////////////////////////////////////////////////// diff --git a/tests/regressions/threads/threads_all_1422.cpp b/tests/regressions/threads/threads_all_1422.cpp index 0eea940e8..69fc26c86 100644 --- a/tests/regressions/threads/threads_all_1422.cpp +++ b/tests/regressions/threads/threads_all_1422.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -28,7 +29,8 @@ int pika_main() PIKA_TEST_EQ(num_cores, os_threads); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/tests/regressions/unhandled_exception_582.cpp b/tests/regressions/unhandled_exception_582.cpp index df2bb0a39..a071c0897 100644 --- a/tests/regressions/unhandled_exception_582.cpp +++ b/tests/regressions/unhandled_exception_582.cpp @@ -10,10 +10,13 @@ #include #include +#include + int pika_main() { PIKA_THROW_EXCEPTION(pika::error::invalid_status, "pika_main", "testing"); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char** argv) diff --git a/tests/regressions/util/set_config_entry_deadlock.cpp b/tests/regressions/util/set_config_entry_deadlock.cpp index c7ca8bbf8..b27a1b16d 100644 --- a/tests/regressions/util/set_config_entry_deadlock.cpp +++ b/tests/regressions/util/set_config_entry_deadlock.cpp @@ -12,6 +12,7 @@ # include # include +# include # include std::atomic invoked_callback(false); @@ -46,7 +47,8 @@ int pika_main() PIKA_TEST(!val.empty()); PIKA_TEST_EQ(val, std::string("test1")); - return pika::finalize(); + pika::finalize(); + return EXIT_SUCCESS; } int main(int argc, char* argv[]) From 9f532a0ff951142d80f9c094b98ac1146673ea3e Mon Sep 17 00:00:00 2001 From: Mikael Simberg Date: Wed, 1 Nov 2023 16:04:36 +0100 Subject: [PATCH 12/12] Don't test for pika::start return value since it no longer returns anything --- libs/pika/init_runtime/tests/unit/const_args_init.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/pika/init_runtime/tests/unit/const_args_init.cpp b/libs/pika/init_runtime/tests/unit/const_args_init.cpp index 2f508b511..3a20d3005 100644 --- a/libs/pika/init_runtime/tests/unit/const_args_init.cpp +++ b/libs/pika/init_runtime/tests/unit/const_args_init.cpp @@ -26,7 +26,7 @@ int main() PIKA_TEST_EQ(pika::init(pika_main, argc, argv), 0); - PIKA_TEST(pika::start(pika_main, argc, argv)); + pika::start(pika_main, argc, argv); PIKA_TEST_EQ(pika::stop(), 0); } @@ -35,7 +35,7 @@ int main() PIKA_TEST_EQ(pika::init(pika_main, argc, argv), 0); - PIKA_TEST(pika::start(pika_main, argc, argv)); + pika::start(pika_main, argc, argv); PIKA_TEST_EQ(pika::stop(), 0); } @@ -44,7 +44,7 @@ int main() PIKA_TEST_EQ(pika::init(pika_main, argc, argv), 0); - PIKA_TEST(pika::start(pika_main, argc, argv)); + pika::start(pika_main, argc, argv); PIKA_TEST_EQ(pika::stop(), 0); } @@ -53,7 +53,7 @@ int main() PIKA_TEST_EQ(pika::init(pika_main, argc, argv), 0); - PIKA_TEST(pika::start(pika_main, argc, argv)); + pika::start(pika_main, argc, argv); PIKA_TEST_EQ(pika::stop(), 0); }