diff --git a/libs/core/algorithms/tests/unit/algorithms/CMakeLists.txt b/libs/core/algorithms/tests/unit/algorithms/CMakeLists.txt index 080f7c7da9c..5e82d391923 100644 --- a/libs/core/algorithms/tests/unit/algorithms/CMakeLists.txt +++ b/libs/core/algorithms/tests/unit/algorithms/CMakeLists.txt @@ -32,7 +32,6 @@ set(tests copyif_forward copyif_exception copyif_bad_alloc - # copyif_sender copyn copyn_sender count @@ -84,14 +83,10 @@ set(tests for_loop_induction for_loop_induction_async for_loop_n - # for_loop_n_sender for_loop_n_strided - # for_loop_n_strided_sender for_loop_reduction for_loop_reduction_async - # for_loop_sender for_loop_strided - # for_loop_strided_sender generate generate_sender generaten @@ -105,7 +100,6 @@ set(tests inclusive_scan inclusive_scan_exception inplace_merge - # inplace_merge_sender is_partitioned is_partitioned_sender is_sorted @@ -115,11 +109,9 @@ set(tests lexicographical_compare lexicographical_compare_sender make_heap - # make_heap_sender max_element max_element_sender merge - # merge_sender min_element min_element_sender minmax_element @@ -131,16 +123,12 @@ set(tests move move_sender nth_element - # nth_element_sender none_of none_of_sender parallel_sort partial_sort - # partial_sort_sender partial_sort_copy - # partial_sort_copy_sender partition - # partition_sender partition_copy reduce_ reduce_sender @@ -173,29 +161,18 @@ set(tests search search_sender searchn - # searchn_sender set_difference - # set_difference_sender set_intersection - # set_intersection_sender set_symmetric_difference - # set_symmetric_difference_sender set_union - # set_union_sender shift_left - # shift_left_sender shift_right - # shift_right_sender sort - # sort_sender sort_by_key - # sort_by_key_sender sort_exceptions stable_partition - # stable_partition_sender stable_sort stable_sort_exceptions - # stable_sort_sender starts_with starts_with_sender swapranges diff --git a/libs/core/algorithms/tests/unit/algorithms/copyif_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/copyif_sender.cpp deleted file mode 100644 index 8091ce67be3..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/copyif_sender.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2014 Grant Mercer -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -//////////////////////////////////////////////////////////////////////////// -unsigned int seed = std::random_device{}(); -std::mt19937 gen(seed); -std::uniform_int_distribution<> dis(0, (std::numeric_limits::max)()); - -template -void test_copy_if_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(10007); - std::vector d(c.size()); - auto middle = std::begin(c) + c.size() / 2; - std::iota(std::begin(c), middle, dis(gen)); - std::fill(middle, std::end(c), -1); - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), - std::begin(d), [](int i) { return !(i < 0); }) | - hpx::copy_if(ex_policy.on(exec))); - - std::size_t count = 0; - HPX_TEST(std::equal( - std::begin(c), middle, std::begin(d), [&count](int v1, int v2) -> bool { - HPX_TEST_EQ(v1, v2); - ++count; - return v1 == v2; - })); - - HPX_TEST(std::equal(middle, std::end(c), std::begin(d) + d.size() / 2, - [&count](int v1, int v2) -> bool { - HPX_TEST_NEQ(v1, v2); - ++count; - return v1 != v2; - })); - - HPX_TEST_EQ(count, d.size()); -} - -template -void copy_if_sender_test() -{ - using namespace hpx::execution; - test_copy_if_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_copy_if_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_copy_if_sender(hpx::launch::async, par(task), IteratorTag()); - test_copy_if_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - copy_if_sender_test(); - copy_if_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/for_loop_n_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/for_loop_n_sender.cpp deleted file mode 100644 index 3a114884df3..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/for_loop_n_sender.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -/////////////////////////////////////////////////////////////////////////////// -int seed = std::random_device{}(); -std::mt19937 gen(seed); - -template -void test_for_loop_n_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(10007); - std::iota(std::begin(c), std::end(c), gen()); - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c)), c.size(), [](iterator it) { - *it = 42; - }) | hpx::experimental::for_loop_n(ex_policy.on(exec))); - - // verify values - std::size_t count = 0; - std::for_each(std::begin(c), std::end(c), [&count](std::size_t v) -> void { - HPX_TEST_EQ(v, std::size_t(42)); - ++count; - }); - HPX_TEST_EQ(count, c.size()); -} - -template -void for_loop_n_sender_test() -{ - using namespace hpx::execution; - test_for_loop_n_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_for_loop_n_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_for_loop_n_sender(hpx::launch::async, par(task), IteratorTag()); - test_for_loop_n_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - for_loop_n_sender_test(); - for_loop_n_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/for_loop_n_strided_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/for_loop_n_strided_sender.cpp deleted file mode 100644 index f056272352f..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/for_loop_n_strided_sender.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -/////////////////////////////////////////////////////////////////////////////// -int seed = std::random_device{}(); -std::mt19937 gen(seed); -std::uniform_int_distribution<> dis(1, 10006); - -template -void test_for_loop_n_strided_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(10007); - std::iota(std::begin(c), std::end(c), gen()); - - std::for_each(std::begin(c), std::end(c), [](std::size_t& v) -> void { - if (v == 42) - v = 43; - }); - - int stride = dis(gen); //-V103 - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c)), c.size(), stride, - [](iterator it) { *it = 42; }) | - hpx::experimental::for_loop_n_strided(ex_policy.on(exec))); - - // verify values - std::size_t count = 0; - for (std::size_t i = 0; i != c.size(); ++i) - { - if (i % stride == 0) //-V104 - { - HPX_TEST_EQ(c[i], std::size_t(42)); - } - else - { - HPX_TEST_NEQ(c[i], std::size_t(42)); - } - ++count; - } - HPX_TEST_EQ(count, c.size()); -} - -template -void for_loop_n_strided_sender_test() -{ - using namespace hpx::execution; - test_for_loop_n_strided_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_for_loop_n_strided_sender( - hpx::launch::sync, unseq(task), IteratorTag()); - - test_for_loop_n_strided_sender( - hpx::launch::async, par(task), IteratorTag()); - test_for_loop_n_strided_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - for_loop_n_strided_sender_test(); - for_loop_n_strided_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/for_loop_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/for_loop_sender.cpp deleted file mode 100644 index 86d0abb0c76..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/for_loop_sender.cpp +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (c) 2016-2022 Hartmut Kaiser -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -/////////////////////////////////////////////////////////////////////////////// -unsigned int seed = std::random_device{}(); -std::mt19937 gen(seed); - -template -void test_for_loop_sender_direct(Policy l, ExPolicy&& policy, IteratorTag) -{ - static_assert(hpx::is_execution_policy_v, - "hpx::is_execution_policy_v"); - - typedef std::vector::iterator base_iterator; - typedef test::test_iterator iterator; - - std::vector c(10007); - std::iota(std::begin(c), std::end(c), gen()); - - namespace ex = hpx::execution::experimental; - - using scheduler_t = ex::thread_pool_policy_scheduler; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(l)); - hpx::experimental::for_loop(policy.on(exec), iterator(std::begin(c)), - iterator(std::end(c)), [](iterator it) { *it = 42; }); - - // verify values - std::size_t count = 0; - std::for_each(std::begin(c), std::end(c), [&count](std::size_t v) -> void { - HPX_TEST_EQ(v, std::size_t(42)); - ++count; - }); - HPX_TEST_EQ(count, c.size()); -} - -template -void test_for_loop_sender_direct_async(Policy l, ExPolicy&& policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - typedef std::vector::iterator base_iterator; - typedef test::test_iterator iterator; - - std::vector c(10007); - std::iota(std::begin(c), std::end(c), gen()); - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - - using scheduler_t = ex::thread_pool_policy_scheduler; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(l)); -#ifdef HPX_HAVE_STDEXEC - tt::sync_wait( - hpx::experimental::for_loop(policy.on(exec), iterator(std::begin(c)), - iterator(std::end(c)), [](iterator it) { *it = 42; })); -#else - hpx::experimental::for_loop(policy.on(exec), iterator(std::begin(c)), - iterator(std::end(c)), [](iterator it) { *it = 42; }) | - tt::sync_wait(); -#endif - - // verify values - std::size_t count = 0; - std::for_each(std::begin(c), std::end(c), [&count](std::size_t v) -> void { - HPX_TEST_EQ(v, std::size_t(42)); - ++count; - }); - HPX_TEST_EQ(count, c.size()); -} - -template -void test_for_loop() -{ - using namespace hpx::execution; - - test_for_loop_sender_direct(hpx::launch::sync, seq, IteratorTag()); - test_for_loop_sender_direct(hpx::launch::sync, unseq, IteratorTag()); - test_for_loop_sender_direct(hpx::launch::async, par, IteratorTag()); - test_for_loop_sender_direct(hpx::launch::async, par_unseq, IteratorTag()); - - test_for_loop_sender_direct_async( - hpx::launch::sync, seq(task), IteratorTag()); - test_for_loop_sender_direct_async( - hpx::launch::sync, unseq(task), IteratorTag()); - test_for_loop_sender_direct_async( - hpx::launch::async, par(task), IteratorTag()); - test_for_loop_sender_direct_async( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -void for_loop_test() -{ - test_for_loop(); - test_for_loop(); -} - -template -void test_for_loop_sender(Policy l, ExPolicy&& policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - typedef std::vector::iterator base_iterator; - typedef test::test_iterator iterator; - - std::vector c(10007); - std::iota(std::begin(c), std::end(c), gen()); - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - - auto f = [](iterator it) { *it = 42; }; - - using scheduler_t = ex::thread_pool_policy_scheduler; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(l)); -#ifdef HPX_HAVE_STDEXEC - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), f) | - hpx::experimental::for_loop(policy.on(exec))); -#else - ex::just(iterator(std::begin(c)), iterator(std::end(c)), f) | - hpx::experimental::for_loop(policy.on(exec)) | tt::sync_wait(); -#endif - - // verify values - std::size_t count = 0; - std::for_each(std::begin(c), std::end(c), [&count](std::size_t v) -> void { - HPX_TEST_EQ(v, std::size_t(42)); - ++count; - }); - HPX_TEST_EQ(count, c.size()); -} - -template -void test_for_loop_sender() -{ - using namespace hpx::execution; - - test_for_loop_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_for_loop_sender(hpx::launch::sync, unseq(task), IteratorTag()); - test_for_loop_sender(hpx::launch::async, par(task), IteratorTag()); - test_for_loop_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -void for_loop_test_sender() -{ - test_for_loop_sender(); - test_for_loop_sender(); -} - -/////////////////////////////////////////////////////////////////////////////// -int hpx_main(hpx::program_options::variables_map& vm) -{ - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - gen.seed(seed); - - for_loop_test(); - for_loop_test_sender(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/for_loop_strided_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/for_loop_strided_sender.cpp deleted file mode 100644 index e42c31bda50..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/for_loop_strided_sender.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -/////////////////////////////////////////////////////////////////////////////// -int seed = std::random_device{}(); -std::mt19937 gen(seed); -std::uniform_int_distribution<> dis(1, 10006); - -template -void test_for_loop_strided_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(10007); - std::iota(std::begin(c), std::end(c), gen()); - - std::for_each(std::begin(c), std::end(c), [](std::size_t& v) -> void { - if (v == 42) - v = 43; - }); - - int stride = dis(gen); //-V103 - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), - stride, [](iterator it) { *it = 42; }) | - hpx::experimental::for_loop_strided(ex_policy.on(exec))); - - // verify values - std::size_t count = 0; - for (std::size_t i = 0; i != c.size(); ++i) - { - if (i % stride == 0) //-V104 - { - HPX_TEST_EQ(c[i], std::size_t(42)); - } - else - { - HPX_TEST_NEQ(c[i], std::size_t(42)); - } - ++count; - } - HPX_TEST_EQ(count, c.size()); -} - -template -void for_loop_strided_sender_test() -{ - using namespace hpx::execution; - test_for_loop_strided_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_for_loop_strided_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_for_loop_strided_sender(hpx::launch::async, par(task), IteratorTag()); - test_for_loop_strided_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - for_loop_strided_sender_test(); - for_loop_strided_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/inplace_merge_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/inplace_merge_sender.cpp deleted file mode 100644 index b9995348ca1..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/inplace_merge_sender.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include -#include - -#include "inplace_merge_tests.hpp" - -template -void inplace_merge_sender_test() -{ - using namespace hpx::execution; - test_inplace_merge_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_inplace_merge_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_inplace_merge_sender(hpx::launch::async, par(task), IteratorTag()); - test_inplace_merge_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - inplace_merge_sender_test(); - inplace_merge_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/inplace_merge_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/inplace_merge_tests.hpp index 3255d5e6132..57cc26e00cc 100644 --- a/libs/core/algorithms/tests/unit/algorithms/inplace_merge_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/inplace_merge_tests.hpp @@ -475,53 +475,6 @@ void test_inplace_merge_bad_alloc_async(ExPolicy&& policy, IteratorTag) HPX_TEST(returned_from_algorithm); } -template -void test_inplace_merge_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - int rand_base = _gen(); - std::less comp{}; - - std::size_t const left_size = 300007, right_size = 123456; - std::vector res(left_size + right_size), sol; - - base_iterator res_first = std::begin(res); - base_iterator res_middle = res_first + left_size; - base_iterator res_last = std::end(res); - - std::generate(res_first, res_middle, random_fill(rand_base, 6)); - std::generate(res_middle, res_last, random_fill(rand_base, 8)); - std::sort(res_first, res_middle, comp); - std::sort(res_middle, res_last, comp); - - sol = res; - base_iterator sol_first = std::begin(sol); - base_iterator sol_middle = sol_first + left_size; - base_iterator sol_last = std::end(sol); - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(res_first), iterator(res_middle), - iterator(res_last), comp) | - hpx::inplace_merge(ex_policy.on(exec))); - - std::inplace_merge(sol_first, sol_middle, sol_last, comp); - - bool equality = test::equal(res_first, res_last, sol_first, sol_last); - - HPX_TEST(equality); -} - /////////////////////////////////////////////////////////////////////////////// template void test_inplace_merge_etc(IteratorTag, DataType, int rand_base) diff --git a/libs/core/algorithms/tests/unit/algorithms/make_heap_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/make_heap_sender.cpp deleted file mode 100644 index ee09b43561a..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/make_heap_sender.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -/////////////////////////////////////////////////////////////////////////// -int seed = std::random_device{}(); -std::mt19937 gen(seed); - -template -void test_make_heap_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(10007); - std::iota(std::begin(c), std::end(c), 0); - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | - hpx::make_heap(ex_policy.on(exec))); - - HPX_TEST_EQ(std::is_heap(std::begin(c), std::end(c)), true); -} - -template -void make_heap_sender_test() -{ - using namespace hpx::execution; - test_make_heap_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_make_heap_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_make_heap_sender(hpx::launch::async, par(task), IteratorTag()); - test_make_heap_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - make_heap_sender_test(); - make_heap_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/merge_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/merge_sender.cpp deleted file mode 100644 index 8bc14f0192e..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/merge_sender.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include -#include - -#include "merge_tests.hpp" - -template -void merge_sender_test() -{ - using namespace hpx::execution; - test_merge_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_merge_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_merge_sender(hpx::launch::async, par(task), IteratorTag()); - test_merge_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - merge_sender_test(); - merge_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/merge_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/merge_tests.hpp index 567949a508a..d768a9f1444 100644 --- a/libs/core/algorithms/tests/unit/algorithms/merge_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/merge_tests.hpp @@ -452,50 +452,6 @@ void test_merge_bad_alloc_async(ExPolicy&& policy, IteratorTag) HPX_TEST(returned_from_algorithm); } -template -void test_merge_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - int rand_base = _gen(); - std::less comp{}; - - std::size_t const size1 = 300007, size2 = 123456; - std::vector src1(size1), src2(size2), dest_res(size1 + size2), - dest_sol(size1 + size2); - - std::generate(std::begin(src1), std::end(src1), random_fill(rand_base, 6)); - std::generate(std::begin(src2), std::end(src2), random_fill(rand_base, 8)); - std::sort(std::begin(src1), std::end(src1), comp); - std::sort(std::begin(src2), std::end(src2), comp); - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - auto snd_result = tt::sync_wait( - ex::just(iterator(std::begin(src1)), iterator(std::end(src1)), - iterator(std::begin(src2)), iterator(std::end(src2)), - iterator(std::begin(dest_res)), comp) | - hpx::merge(ex_policy.on(exec))); - - auto result = hpx::get<0>(*snd_result); - - auto solution = std::merge(std::begin(src1), std::end(src1), - std::begin(src2), std::end(src2), std::begin(dest_sol), comp); - - bool equality = test::equal( - std::begin(dest_res), result.base(), std::begin(dest_sol), solution); - - HPX_TEST(equality); -} - /////////////////////////////////////////////////////////////////////////////// template void test_merge_etc(IteratorTag, DataType, int rand_base) diff --git a/libs/core/algorithms/tests/unit/algorithms/nth_element_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/nth_element_sender.cpp deleted file mode 100644 index 58ec162d187..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/nth_element_sender.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -//////////////////////////////////////////////////////////////////////////// -int seed = std::random_device{}(); -std::mt19937 gen(seed); - -constexpr std::size_t SIZE{10007}; - -template -void test_nth_element_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(SIZE); - std::generate( - std::begin(c), std::end(c), []() { return std::rand() % SIZE; }); - std::vector d = c; - - auto rand_index = std::rand() % SIZE; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait( - ex::just(iterator(std::begin(c)), iterator(std::begin(c) + rand_index), - iterator(std::end(c))) | - hpx::nth_element(ex_policy.on(exec))); - - std::nth_element(std::begin(d), std::begin(d) + rand_index, std::end(d)); - - HPX_TEST(*(std::begin(c) + rand_index) == *(std::begin(d) + rand_index)); - - for (int k = 0; k < rand_index; k++) - { - HPX_TEST(c[k] <= c[rand_index]); - } - - for (int k = rand_index + 1; k < SIZE; k++) - { - HPX_TEST(c[k] >= c[rand_index]); - } -} - -template -void nth_element_sender_test() -{ - using namespace hpx::execution; - test_nth_element_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_nth_element_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_nth_element_sender(hpx::launch::async, par(task), IteratorTag()); - test_nth_element_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - nth_element_sender_test(); - nth_element_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/partial_sort_copy_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/partial_sort_copy_sender.cpp deleted file mode 100644 index b5ecce0130c..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/partial_sort_copy_sender.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -#if defined(HPX_DEBUG) -constexpr std::uint64_t NELEM{111}; -#else -constexpr std::uint64_t NELEM{1007}; -#endif - -//////////////////////////////////////////////////////////////////////////// -unsigned int seed = std::random_device{}(); -std::mt19937 gen(seed); - -template -void test_partial_sort_copy_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - using compare_t = std::less; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector l{9, 7, 6, 8, 5, 4, 1, 2, 3}; - std::uint64_t v1[20], v2[20]; - - //------------------------------------------------------------------------ - // Output size is smaller than input size - //------------------------------------------------------------------------ - for (int i = 0; i < 20; ++i) - v1[i] = v2[i] = 999; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(l)), iterator(std::end(l)), - &v1[0], &v1[4]) | - hpx::partial_sort_copy(ex_policy.on(exec))); - - std::partial_sort_copy(l.begin(), l.end(), &v2[0], &v2[4]); - - for (int i = 0; i < 4; ++i) - { - HPX_TEST(v1[i] == v2[i]); - }; - for (int i = 4; i < 20; ++i) - { - HPX_TEST(v1[i] == v2[i]); - }; - - //------------------------------------------------------------------------ - // Output size is equal than input size - //------------------------------------------------------------------------ - for (int i = 0; i < 20; ++i) - v1[i] = v2[i] = 999; - - tt::sync_wait(ex::just(iterator(std::begin(l)), iterator(std::end(l)), - &v1[0], &v1[9]) | - hpx::partial_sort_copy(ex_policy.on(exec))); - - std::partial_sort_copy(l.begin(), l.end(), &v2[0], &v2[9]); - - for (int i = 0; i < 9; ++i) - { - HPX_TEST(v1[i] == v2[i]); - }; - for (int i = 9; i < 20; ++i) - { - HPX_TEST(v1[i] == v2[i]); - }; - - //------------------------------------------------------------------------ - // Output size is greater than input size - //------------------------------------------------------------------------ - for (int i = 0; i < 20; ++i) - v1[i] = v2[i] = 999; - - tt::sync_wait(ex::just(iterator(std::begin(l)), iterator(std::end(l)), - &v1[0], &v1[20]) | - hpx::partial_sort_copy(ex_policy.on(exec))); - - std::partial_sort_copy(l.begin(), l.end(), &v2[0], &v2[20]); - - for (int i = 0; i < 9; ++i) - { - HPX_TEST(v1[i] == v2[i]); - }; - for (int i = 9; i < 20; ++i) - { - HPX_TEST(v1[i] == v2[i]); - }; -} - -template -void partial_sort_copy_sender_test() -{ - using namespace hpx::execution; - test_partial_sort_copy_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_partial_sort_copy_sender( - hpx::launch::sync, unseq(task), IteratorTag()); - - test_partial_sort_copy_sender(hpx::launch::async, par(task), IteratorTag()); - test_partial_sort_copy_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - partial_sort_copy_sender_test(); - partial_sort_copy_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/partial_sort_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/partial_sort_sender.cpp deleted file mode 100644 index b0af8605706..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/partial_sort_sender.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -//////////////////////////////////////////////////////////////////////////// -unsigned int seed = std::random_device{}(); -std::mt19937 gen(seed); -constexpr std::uint64_t SIZE{1007}; - -template -void test_partial_sort_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using compare_t = std::less; - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector A, B; - A.reserve(SIZE); - B.reserve(SIZE); - - for (std::uint64_t i = 0; i < SIZE; ++i) - { - A.emplace_back(i); - } - std::shuffle(A.begin(), A.end(), gen); - - for (std::uint64_t i = 1; i < SIZE; ++i) - { - B = A; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait( - ex::just(iterator(std::begin(B)), iterator(std::begin(B) + i), - iterator(std::end(B)), compare_t{}) | - hpx::partial_sort(ex_policy.on(exec))); - - for (std::uint64_t j = 0; j < i; ++j) - { - HPX_TEST(B[j] == j); - } - } -} - -template -void partial_sort_sender_test() -{ - using namespace hpx::execution; - test_partial_sort_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_partial_sort_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_partial_sort_sender(hpx::launch::async, par(task), IteratorTag()); - test_partial_sort_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - partial_sort_sender_test(); - partial_sort_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/partition_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/partition_sender.cpp deleted file mode 100644 index 15c24007fd0..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/partition_sender.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include -#include - -#include "partition_tests.hpp" - -template -void partition_sender_test() -{ - using namespace hpx::execution; - test_partition_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_partition_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_partition_sender(hpx::launch::async, par(task), IteratorTag()); - test_partition_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - partition_sender_test(); - partition_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/partition_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/partition_tests.hpp index d6a319ab59f..8f77bf292ca 100644 --- a/libs/core/algorithms/tests/unit/algorithms/partition_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/partition_tests.hpp @@ -515,53 +515,3 @@ void test_partition_bad_alloc() test_partition_bad_alloc_async(seq(task), IteratorTag()); test_partition_bad_alloc_async(par(task), IteratorTag()); } - -//////////////////////////////////////////////////////////////////////////////// -template -void test_partition_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - const std::size_t size = 30007; - const int rand_base = _gen(); - - random_fill gen_functor{rand_base, size / 10}; - auto pred = [rand_base](const int n) -> bool { return n < rand_base; }; - - std::vector c(size), c_org; - std::generate(std::begin(c), std::end(c), gen_functor); - c_org = c; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - auto snd_result = tt::sync_wait( - ex::just(iterator(std::begin(c)), iterator(std::end(c)), pred) | - hpx::partition(ex_policy.on(exec))); - - auto result = hpx::get<0>(*snd_result); - - bool is_partitioned = std::is_partitioned(std::begin(c), std::end(c), pred); - - HPX_TEST(is_partitioned); - - auto solution = std::partition_point(std::begin(c), std::end(c), pred); - - HPX_TEST(result.base() == solution); - - std::sort(std::begin(c), std::end(c)); - std::sort(std::begin(c_org), std::end(c_org)); - - bool unchanged = test::equal( - std::begin(c), std::end(c), std::begin(c_org), std::end(c_org)); - - HPX_TEST(unchanged); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/searchn_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/searchn_sender.cpp deleted file mode 100644 index 5eb806ecf68..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/searchn_sender.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -template -void test_search_n_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(10007); - // fill vector with random values above 2 - std::fill(std::begin(c), std::end(c), (std::rand() % 100) + 3); - // create subsequence in middle of vector - c[c.size() / 2] = 1; - c[c.size() / 2 + 1] = 2; - - std::size_t h[] = {1, 2}; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - auto snd_result = tt::sync_wait(ex::just(iterator(std::begin(c)), c.size(), - std::begin(h), std::end(h)) | - hpx::search_n(ex_policy.on(exec))); - - iterator index = hpx::get<0>(*snd_result); - - base_iterator test_index = std::begin(c) + c.size() / 2; - - HPX_TEST(index == iterator(test_index)); -} - -template -void search_n_sender_test() -{ - using namespace hpx::execution; - test_search_n_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_search_n_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_search_n_sender(hpx::launch::async, par(task), IteratorTag()); - test_search_n_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - search_n_sender_test(); - search_n_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/set_difference_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/set_difference_sender.cpp deleted file mode 100644 index beb49811e2b..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/set_difference_sender.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -template -void test_set_difference_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c1 = test::random_fill(10007); - std::vector c2 = test::random_fill(c1.size()); - - std::sort(std::begin(c1), std::end(c1)); - std::sort(std::begin(c2), std::end(c2)); - - std::vector c3(2 * c1.size()), c4(2 * c1.size()); //-V656 - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c1)), iterator(std::end(c1)), - std::begin(c2), std::end(c2), std::begin(c3)) | - hpx::set_difference(ex_policy.on(exec))); - - std::set_difference(std::begin(c1), std::end(c1), std::begin(c2), - std::end(c2), std::begin(c4)); - - // verify values - HPX_TEST(std::equal(std::begin(c3), std::end(c3), std::begin(c4))); -} - -template -void set_difference_sender_test() -{ - using namespace hpx::execution; - test_set_difference_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_set_difference_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_set_difference_sender(hpx::launch::async, par(task), IteratorTag()); - test_set_difference_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - set_difference_sender_test(); - set_difference_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/set_intersection_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/set_intersection_sender.cpp deleted file mode 100644 index 29fdfbab554..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/set_intersection_sender.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -template -void test_set_intersection_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c1 = test::random_fill(10007); - std::vector c2 = test::random_fill(c1.size()); - - std::sort(std::begin(c1), std::end(c1)); - std::sort(std::begin(c2), std::end(c2)); - - std::vector c3(2 * c1.size()), c4(2 * c1.size()); //-V656 - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c1)), iterator(std::end(c1)), - std::begin(c2), std::end(c2), std::begin(c3)) | - hpx::set_intersection(ex_policy.on(exec))); - - std::set_intersection(std::begin(c1), std::end(c1), std::begin(c2), - std::end(c2), std::begin(c4)); - - // verify values - HPX_TEST(std::equal(std::begin(c3), std::end(c3), std::begin(c4))); -} - -template -void set_intersection_sender_test() -{ - using namespace hpx::execution; - test_set_intersection_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_set_intersection_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_set_intersection_sender(hpx::launch::async, par(task), IteratorTag()); - test_set_intersection_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - set_intersection_sender_test(); - set_intersection_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/set_symmetric_difference_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/set_symmetric_difference_sender.cpp deleted file mode 100644 index 556e925186b..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/set_symmetric_difference_sender.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -template -void test_set_symmetric_difference_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c1 = test::random_fill(10007); - std::vector c2 = test::random_fill(c1.size()); - - auto comp = [](std::size_t l, std::size_t r) { return l > r; }; - - std::sort(std::begin(c1), std::end(c1), comp); - std::sort(std::begin(c2), std::end(c2), comp); - - std::vector c3(2 * c1.size()), c4(2 * c1.size()); //-V656 - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(iterator(std::begin(c1)), iterator(std::end(c1)), - std::begin(c2), std::end(c2), std::begin(c3), comp) | - hpx::set_symmetric_difference(ex_policy.on(exec))); - - std::set_symmetric_difference(std::begin(c1), std::end(c1), std::begin(c2), - std::end(c2), std::begin(c4), comp); - - // verify values - HPX_TEST(std::equal(std::begin(c3), std::end(c3), std::begin(c4))); -} - -template -void set_symmetric_difference_sender_test() -{ - using namespace hpx::execution; - test_set_symmetric_difference_sender( - hpx::launch::sync, seq(task), IteratorTag()); - test_set_symmetric_difference_sender( - hpx::launch::sync, unseq(task), IteratorTag()); - - test_set_symmetric_difference_sender( - hpx::launch::async, par(task), IteratorTag()); - test_set_symmetric_difference_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - set_symmetric_difference_sender_test(); - set_symmetric_difference_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/shift_left_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/shift_left_sender.cpp deleted file mode 100644 index 61a0c055a2d..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/shift_left_sender.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -constexpr std::size_t ARR_SIZE{100007}; - -template -void test_shift_left_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(ARR_SIZE); - std::iota(std::begin(c), std::end(c), std::rand()); - std::vector d = c; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - // shift by zero should have no effect - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), 0) | - hpx::shift_left(ex_policy.on(exec))); - HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d))); - - // shift by a negative number should have no effect - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), -4) | - hpx::shift_left(ex_policy.on(exec))); - HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d))); - - std::size_t n = (std::rand() % ARR_SIZE) + 1; - - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), n) | - hpx::shift_left(ex_policy.on(exec))); - - std::move(std::begin(d) + n, std::end(d), std::begin(d)); - - // verify values - HPX_TEST(std::equal( - std::begin(c), std::begin(c) + (ARR_SIZE - n), std::begin(d))); - - // ensure shift by more than n does not crash - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), - (ARR_SIZE + 1)) | - hpx::shift_left(ex_policy.on(exec))); -} - -template -void shift_left_sender_test() -{ - using namespace hpx::execution; - test_shift_left_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_shift_left_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_shift_left_sender(hpx::launch::async, par(task), IteratorTag()); - test_shift_left_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - shift_left_sender_test(); - shift_left_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/shift_right_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/shift_right_sender.cpp deleted file mode 100644 index 2ee4456853e..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/shift_right_sender.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_utils.hpp" - -constexpr std::size_t ARR_SIZE{100007}; - -template -void test_shift_right_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(ARR_SIZE); - std::iota(std::begin(c), std::end(c), std::rand()); - std::vector d = c; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - // shift by zero should have no effect - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), 0) | - hpx::shift_right(ex_policy.on(exec))); - HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d))); - - // shift by a negative number should have no effect - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), -4) | - hpx::shift_right(ex_policy.on(exec))); - HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d))); - - std::size_t n = (std::rand() % ARR_SIZE) + 1; - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), n) | - hpx::shift_right(ex_policy.on(exec))); - - std::move_backward(std::begin(d), std::end(d) - n, std::end(d)); - - // verify values - HPX_TEST(std::equal(std::begin(c) + n, std::end(c), std::begin(d) + n)); - - // ensure shift by more than n does not crash - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), - (ARR_SIZE + 1)) | - hpx::shift_right(ex_policy.on(exec))); -} - -template -void shift_right_sender_test() -{ - using namespace hpx::execution; - test_shift_right_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_shift_right_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_shift_right_sender(hpx::launch::async, par(task), IteratorTag()); - test_shift_right_sender(hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - shift_right_sender_test(); - shift_right_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/sort_by_key_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/sort_by_key_sender.cpp deleted file mode 100644 index 9f5793b27f9..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/sort_by_key_sender.cpp +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -// -#if defined(HPX_DEBUG) -#define HPX_SORT_BY_KEY_TEST_SIZE (1 << 8) -#else -#define HPX_SORT_BY_KEY_TEST_SIZE (1 << 18) -#endif -// -#include "sort_tests.hpp" -// -#define EXTRA_DEBUG -// -namespace debug { - template - void output(const std::string& name, const std::vector& v) - { -#ifdef EXTRA_DEBUG7 - std::cout << name.c_str() << "\t : {" << v.size() << "} : "; - std::copy(std::begin(v), std::end(v), - std::ostream_iterator(std::cout, ", ")); - std::cout << "\n"; -#else - HPX_UNUSED(name); - HPX_UNUSED(v); -#endif - } - - template - void output(const std::string& name, Iter begin, Iter end) - { -#ifdef EXTRA_DEBUG - std::cout << name.c_str() << "\t : {" << std::distance(begin, end) - << "} : "; - std::copy(begin, end, - std::ostream_iterator< - typename std::iterator_traits::value_type>( - std::cout, ", ")); - std::cout << "\n"; -#else - HPX_UNUSED(name); - HPX_UNUSED(begin); - HPX_UNUSED(end); -#endif - } - -#if defined(EXTRA_DEBUG) -#define debug_msg(a) std::cout << a -#else -#define debug_msg(a) -#endif -} // namespace debug - -#undef msg -#define msg(a, b, d) \ - std::cout << std::setw(60) << a << std::setw(12) << b << std::setw(8) \ - << #d << "\t"; - -//////////////////////////////////////////////////////////////////////////////// - -template -void test_sort_by_key_sender(LnPolicy ln_policy, ExPolicy&& ex_policy) -{ - using Tkey = std::size_t; - using Tval = std::size_t; - - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - msg(typeid(ExPolicy).name(), typeid(Tval).name(), sync); - std::cout << "\n"; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - // vector of values, and keys - std::vector values, o_values; - std::vector keys, o_keys; - // - values.assign(HPX_SORT_BY_KEY_TEST_SIZE, 0); - keys.assign(HPX_SORT_BY_KEY_TEST_SIZE, 0); - - // generate a sequence as the values - std::iota(values.begin(), values.end(), 0); - // generate a sequence as the keys - std::iota(keys.begin(), keys.end(), 0); - - // shuffle the keys up, - std::random_device rd; - std::mt19937 g(rd()); - std::shuffle(keys.begin(), keys.end(), g); - - // make copies of initial states - o_keys = keys; - o_values = values; - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - tt::sync_wait(ex::just(keys.begin(), keys.end(), values.begin()) | - hpx::experimental::sort_by_key(ex_policy.on(exec))); - - // after sorting by key, the values should be equal to the original keys - bool is_equal = std::equal(keys.begin(), keys.end(), o_values.begin()); - if (is_equal) - { - //std::cout << "Test Passed\n"; - } - else - { - debug::output("keys ", o_keys); - debug::output("values ", o_values); - debug::output("key range", keys); - debug::output("val range", values); - throw std::string("Problem"); - } - HPX_TEST(is_equal); -} - -void sort_by_key_sender_test() -{ - using namespace hpx::execution; - test_sort_by_key_sender(hpx::launch::sync, seq(task)); - test_sort_by_key_sender(hpx::launch::sync, unseq(task)); - - test_sort_by_key_sender(hpx::launch::async, par(task)); - test_sort_by_key_sender(hpx::launch::async, par_unseq(task)); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - sort_by_key_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/sort_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/sort_sender.cpp deleted file mode 100644 index d27ff38c536..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/sort_sender.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include -#include - -#include "sort_tests.hpp" - -void sort_sender_test() -{ - using namespace hpx::execution; - test_sort_sender(hpx::launch::sync, seq(task)); - test_sort_sender(hpx::launch::sync, unseq(task)); - - test_sort_sender(hpx::launch::async, par(task)); - test_sort_sender(hpx::launch::async, par_unseq(task)); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - sort_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/sort_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/sort_tests.hpp index 6cbc28d9709..862bd6fbe4d 100644 --- a/libs/core/algorithms/tests/unit/algorithms/sort_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/sort_tests.hpp @@ -704,37 +704,3 @@ void test_sort1_async_str(ExPolicy&& policy, Compare comp = Compare()) bool is_sorted = (verify_(c, comp, elapsed, true) != 0); HPX_TEST(is_sorted); } - -//////////////////////////////////////////////////////////////////////////////// - -template -void test_sort_sender(LnPolicy ln_policy, ExPolicy&& ex_policy) -{ - using T = std::size_t; - using Compare = std::less; - - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - msg(typeid(ExPolicy).name(), typeid(T).name(), typeid(Compare).name(), sync, - random); - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - Compare comp{}; - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - // Fill vector with random values - std::vector c(HPX_SORT_TEST_SIZE); - rnd_fill(c, (std::numeric_limits::min)(), - (std::numeric_limits::max)(), T(std::rand())); - - std::uint64_t t = hpx::chrono::high_resolution_clock::now(); - tt::sync_wait( - ex::just(c.begin(), c.end(), comp) | hpx::sort(ex_policy.on(exec))); - std::uint64_t elapsed = hpx::chrono::high_resolution_clock::now() - t; - - bool is_sorted = (verify_(c, comp, elapsed, true) != 0); - HPX_TEST(is_sorted); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/stable_partition_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/stable_partition_sender.cpp deleted file mode 100644 index b8ad81b8ce7..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/stable_partition_sender.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include -#include - -#include "stable_partition_tests.hpp" - -template -void stable_partition_sender_test() -{ - using namespace hpx::execution; - test_stable_partition_sender(hpx::launch::sync, seq(task), IteratorTag()); - test_stable_partition_sender(hpx::launch::sync, unseq(task), IteratorTag()); - - test_stable_partition_sender(hpx::launch::async, par(task), IteratorTag()); - test_stable_partition_sender( - hpx::launch::async, par_unseq(task), IteratorTag()); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - stable_partition_sender_test(); - stable_partition_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/stable_partition_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/stable_partition_tests.hpp index 6f18f8e7ee6..ea1c5a42810 100644 --- a/libs/core/algorithms/tests/unit/algorithms/stable_partition_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/stable_partition_tests.hpp @@ -313,50 +313,3 @@ void test_stable_partition_bad_alloc_async(ExPolicy p, IteratorTag) HPX_TEST(caught_bad_alloc); HPX_TEST(returned_from_algorithm); } - -template -void test_stable_partition_sender( - LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) -{ - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - - using base_iterator = std::vector::iterator; - using iterator = test::test_iterator; - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - std::vector c(10007); - std::vector d(c.size()); - std::iota(std::begin(c), std::end(c), std::rand()); - std::copy(std::begin(c), std::end(c), std::begin(d)); - - int partition_at = std::rand(); - - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - auto snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), - less_than(partition_at)) | - hpx::stable_partition(ex_policy.on(exec))); - - auto result = hpx::get<0>(*snd_result); - - auto partition_pt = std::find_if( - std::begin(c), std::end(c), great_equal_than(partition_at)); - HPX_TEST(result.base() == partition_pt); - - // verify values - std::stable_partition(std::begin(d), std::end(d), less_than(partition_at)); - - std::size_t count = 0; - HPX_TEST(std::equal(std::begin(c), std::end(c), std::begin(d), - [&count](std::size_t v1, std::size_t v2) -> bool { - HPX_TEST_EQ(v1, v2); - ++count; - return v1 == v2; - })); - HPX_TEST_EQ(count, d.size()); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/stable_sort_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/stable_sort_sender.cpp deleted file mode 100644 index 4abf23df898..00000000000 --- a/libs/core/algorithms/tests/unit/algorithms/stable_sort_sender.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2024 Tobias Wukovitsch -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include - -#include -#include -#include -#include - -#include "stable_sort_tests.hpp" - -void stable_sort_sender_test() -{ - using namespace hpx::execution; - test_stable_sort_sender(hpx::launch::sync, seq(task)); - test_stable_sort_sender(hpx::launch::sync, unseq(task)); - - test_stable_sort_sender(hpx::launch::async, par(task)); - test_stable_sort_sender(hpx::launch::async, par_unseq(task)); -} - -int hpx_main(hpx::program_options::variables_map& vm) -{ - unsigned int seed = (unsigned int) std::time(nullptr); - if (vm.count("seed")) - seed = vm["seed"].as(); - - std::cout << "using seed: " << seed << std::endl; - std::srand(seed); - - stable_sort_sender_test(); - - return hpx::local::finalize(); -} - -int main(int argc, char* argv[]) -{ - // add command line option which controls the random number generator seed - using namespace hpx::program_options; - options_description desc_commandline( - "Usage: " HPX_APPLICATION_STRING " [options]"); - - desc_commandline.add_options()("seed,s", value(), - "the random number generator seed to use for this run"); - - // By default this test should run on all available cores - std::vector const cfg = {"hpx.os_threads=all"}; - - // Initialize and run HPX - hpx::local::init_params init_args; - init_args.desc_cmdline = desc_commandline; - init_args.cfg = cfg; - - HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv, init_args), 0, - "HPX main exited with non-zero status"); - - return hpx::util::report_errors(); -} diff --git a/libs/core/algorithms/tests/unit/algorithms/stable_sort_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/stable_sort_tests.hpp index e86458a0f77..64597d2eebd 100644 --- a/libs/core/algorithms/tests/unit/algorithms/stable_sort_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/stable_sort_tests.hpp @@ -709,37 +709,3 @@ void test_stable_sort1_async_str(ExPolicy&& policy, Compare comp = Compare()) bool is_sorted = (verify_(c, comp, elapsed, true) != 0); HPX_TEST(is_sorted); } - -//////////////////////////////////////////////////////////////////////////////// - -template -void test_stable_sort_sender(LnPolicy ln_policy, ExPolicy&& ex_policy) -{ - using T = std::size_t; - using Compare = std::less; - - static_assert(hpx::is_async_execution_policy_v, - "hpx::is_async_execution_policy_v"); - msg(typeid(ExPolicy).name(), typeid(T).name(), typeid(Compare).name(), sync, - random); - - namespace ex = hpx::execution::experimental; - namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; - - Compare comp{}; - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - - // Fill vector with random values - std::vector c(HPX_SORT_TEST_SIZE); - rnd_fill(c, (std::numeric_limits::min)(), - (std::numeric_limits::max)(), T(std::rand())); - - std::uint64_t t = hpx::chrono::high_resolution_clock::now(); - tt::sync_wait(ex::just(c.begin(), c.end(), comp) | - hpx::stable_sort(ex_policy.on(exec))); - std::uint64_t elapsed = hpx::chrono::high_resolution_clock::now() - t; - - bool is_sorted = (verify_(c, comp, elapsed, true) != 0); - HPX_TEST(is_sorted); -}