Skip to content

Commit

Permalink
Moving most of APIs from hpx::parallel::execution to hpx::execution::…
Browse files Browse the repository at this point in the history
…experimental
  • Loading branch information
hkaiser committed Nov 8, 2024
1 parent 342d373 commit 65458c6
Show file tree
Hide file tree
Showing 76 changed files with 1,546 additions and 1,468 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ With ``executor_parameter_traits``, clients access all types of executor
parameters uniformly, e.g.::

std::size_t chunk_size =
hpx::execution::get_chunk_size(my_parameter, my_executor,
hpx::execution::experimental::get_chunk_size(my_parameter, my_executor,
num_cores, num_tasks);

This call synchronously retrieves the size of a single chunk of loop iterations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2023 Hartmut Kaiser
// Copyright (c) 2007-2024 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand Down Expand Up @@ -114,9 +114,10 @@ namespace hpx::parallel::detail {

using buffer_type = typename set_operations_buffer<Iter3>::type;

std::size_t cores = execution::processing_units_count(
policy.parameters(), policy.executor(), hpx::chrono::null_duration,
(std::min)(len1, len2));
std::size_t cores =
hpx::execution::experimental::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, (std::min)(len1, len2));

std::size_t const step = (len1 + cores - 1) / cores;

Expand Down
17 changes: 10 additions & 7 deletions libs/core/algorithms/include/hpx/parallel/algorithms/make_heap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,22 +369,25 @@ namespace hpx::parallel {
};

std::size_t const cores =
execution::processing_units_count(policy.parameters(),
policy.executor(), hpx::chrono::null_duration, n);
hpx::execution::experimental::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, n);

// Take a standard chunk size (amount of work / cores), and only
// take a quarter of that. If our chunk size is too large a LOT
// of the work will be done sequentially due to the level
// barrier of heap parallelism. 1/4 of the standard chunk size
// is an estimate to lower the average number of levels done
// sequentially
std::size_t chunk_size = execution::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, n);
std::size_t chunk_size =
hpx::execution::experimental::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, n);
chunk_size /= 4;

std::size_t max_chunks = execution::maximal_number_of_chunks(
policy.parameters(), policy.executor(), cores, n);
std::size_t max_chunks =
hpx::execution::experimental::maximal_number_of_chunks(
policy.parameters(), policy.executor(), cores, n);

util::detail::adjust_chunk_size_and_max_chunks(
cores, n, chunk_size, max_chunks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,15 @@ namespace hpx::parallel {
{
// figure out the chunk size to use
std::size_t const cores =
execution::processing_units_count(policy.parameters(),
policy.executor(), hpx::chrono::null_duration, nelem);
hpx::execution::experimental::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, nelem);

// number of elements to sort
std::size_t chunk_size = execution::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, nelem);
std::size_t chunk_size =
hpx::execution::experimental::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, nelem);

hpx::future<Iter> left = execution::async_execute(
policy.executor(), sort_thread_helper(), policy, first,
Expand Down
29 changes: 15 additions & 14 deletions libs/core/algorithms/include/hpx/parallel/algorithms/partition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,19 +670,19 @@ namespace hpx::parallel {
}
else
{
std::size_t const cores =
execution::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, size);
std::size_t const cores = hpx::execution::experimental::
processing_units_count(policy.parameters(),
policy.executor(), hpx::chrono::null_duration,
size);

std::size_t chunk_size = execution::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, size);
std::size_t chunk_size =
hpx::execution::experimental::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, size);

std::size_t max_chunks =
execution::maximal_number_of_chunks(
policy.parameters(), policy.executor(), cores,
size);
std::size_t max_chunks = hpx::execution::experimental::
maximal_number_of_chunks(policy.parameters(),
policy.executor(), cores, size);

util::detail::adjust_chunk_size_and_max_chunks(
cores, size, chunk_size, max_chunks);
Expand Down Expand Up @@ -1341,9 +1341,10 @@ namespace hpx::parallel {
if (first == last)
return first;

std::size_t const cores = execution::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, std::distance(first, last));
std::size_t const cores =
hpx::execution::experimental::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, std::distance(first, last));

// TODO: Find better block size.
constexpr std::size_t block_size =
Expand Down
20 changes: 11 additions & 9 deletions libs/core/algorithms/include/hpx/parallel/algorithms/rotate.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2023 Hartmut Kaiser
// Copyright (c) 2007-2024 Hartmut Kaiser
// Copyright (c) 2021-2022 Chuanqiu He
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -225,9 +225,9 @@ namespace hpx::parallel {

// get number of cores currently used
std::size_t const cores =
parallel::execution::processing_units_count(policy.parameters(),
policy.executor(), hpx::chrono::null_duration,
size_left + size_right);
hpx::execution::experimental::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, size_left + size_right);

// get currently used first core
std::size_t first_core =
Expand Down Expand Up @@ -257,11 +257,13 @@ namespace hpx::parallel {
auto p = policy(hpx::execution::task);

auto left_policy =
execution::with_processing_units_count(p, cores_left);
auto right_policy = execution::with_processing_units_count(
hpx::execution::experimental::with_first_core(
p, cores == 1 ? first_core : first_core + cores_left),
cores_right);
hpx::execution::experimental::with_processing_units_count(
p, cores_left);
auto right_policy =
hpx::execution::experimental::with_processing_units_count(
hpx::execution::experimental::with_first_core(
p, cores == 1 ? first_core : first_core + cores_left),
cores_right);

detail::reverse<FwdIter> r;

Expand Down
21 changes: 12 additions & 9 deletions libs/core/algorithms/include/hpx/parallel/algorithms/sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,18 @@ namespace hpx::parallel {

// figure out the chunk size to use
std::size_t const cores =
execution::processing_units_count(policy.parameters(),
policy.executor(), hpx::chrono::null_duration, count);

std::size_t max_chunks = execution::maximal_number_of_chunks(
policy.parameters(), policy.executor(), cores, count);

std::size_t chunk_size = execution::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, count);
hpx::execution::experimental::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, count);

std::size_t max_chunks =
hpx::execution::experimental::maximal_number_of_chunks(
policy.parameters(), policy.executor(), cores, count);

std::size_t chunk_size =
hpx::execution::experimental::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, count);

util::detail::adjust_chunk_size_and_max_chunks(
cores, count, max_chunks, chunk_size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,18 @@ namespace hpx::parallel {

// figure out the chunk size to use
std::size_t cores =
execution::processing_units_count(policy.parameters(),
policy.executor(), hpx::chrono::null_duration, count);

std::size_t max_chunks = execution::maximal_number_of_chunks(
policy.parameters(), policy.executor(), cores, count);

std::size_t chunk_size = execution::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, count);
hpx::execution::experimental::processing_units_count(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, count);

std::size_t max_chunks =
hpx::execution::experimental::maximal_number_of_chunks(
policy.parameters(), policy.executor(), cores, count);

std::size_t chunk_size =
hpx::execution::experimental::get_chunk_size(
policy.parameters(), policy.executor(),
hpx::chrono::null_duration, cores, count);

util::detail::adjust_chunk_size_and_max_chunks(
cores, count, max_chunks, chunk_size);
Expand Down
Loading

0 comments on commit 65458c6

Please sign in to comment.