Skip to content

Commit

Permalink
Merge pull request #4943 from msimberg/api-cleanup
Browse files Browse the repository at this point in the history
Move public hpx::parallel::execution functionality to hpx::execution
  • Loading branch information
msimberg authored Sep 9, 2020
2 parents 2c85c15 + d565350 commit 19ad131
Show file tree
Hide file tree
Showing 421 changed files with 4,911 additions and 5,508 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ int hpx_main(hpx::program_options::variables_map& vm)

// initialize data
// segmented version of algorithm used
using namespace hpx::parallel;
generate(execution::par, v.begin(), v.end(), random_fill());
hpx::generate(hpx::execution::par, v.begin(), v.end(), random_fill());

return hpx::finalize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ void test(T minval, T maxval)
hpx::partitioned_vector<T> os(sz);
os.register_as("test_vector");
hpx::fill(
hpx::parallel::execution::par, std::begin(os), std::end(os), 42);
hpx::execution::par, std::begin(os), std::end(os), 42);

oarchive << os;

hpx::serialization::input_archive iarchive(buffer);

hpx::partitioned_vector<T> is(os.size());
hpx::fill(
hpx::parallel::execution::par, std::begin(is), std::end(is), 0);
hpx::execution::par, std::begin(is), std::end(is), 0);

iarchive >> is;

Expand Down
32 changes: 16 additions & 16 deletions docs/sphinx/api/public_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,30 +272,30 @@ for more information about execution policies and executor parameters.

.. note::

These names are also available in the ``hpx::execution`` namespace, but not
in the top-level ``hpx`` namespace.
These names are only available in the ``hpx::execution`` namespace, not in
the top-level ``hpx`` namespace.

Constants
---------

- :cpp:var:`hpx::parallel::execution::seq`
- :cpp:var:`hpx::parallel::execution::par`
- :cpp:var:`hpx::parallel::execution::par_unseq`
- :cpp:var:`hpx::parallel::execution::task`
- :cpp:var:`hpx::execution::seq`
- :cpp:var:`hpx::execution::par`
- :cpp:var:`hpx::execution::par_unseq`
- :cpp:var:`hpx::execution::task`

Classes
-------

- :cpp:class:`hpx::parallel::execution::sequenced_policy`
- :cpp:class:`hpx::parallel::execution::parallel_policy`
- :cpp:class:`hpx::parallel::execution::parallel_unsequenced_policy`
- :cpp:class:`hpx::parallel::execution::sequenced_task_policy`
- :cpp:class:`hpx::parallel::execution::parallel_task_policy`
- :cpp:class:`hpx::parallel::execution::auto_chunk_size`
- :cpp:class:`hpx::parallel::execution::dynamic_chunk_size`
- :cpp:class:`hpx::parallel::execution::guided_chunk_size`
- :cpp:class:`hpx::parallel::execution::persistent_auto_chunk_size`
- :cpp:class:`hpx::parallel::execution::static_chunk_size`
- :cpp:class:`hpx::execution::sequenced_policy`
- :cpp:class:`hpx::execution::parallel_policy`
- :cpp:class:`hpx::execution::parallel_unsequenced_policy`
- :cpp:class:`hpx::execution::sequenced_task_policy`
- :cpp:class:`hpx::execution::parallel_task_policy`
- :cpp:class:`hpx::execution::auto_chunk_size`
- :cpp:class:`hpx::execution::dynamic_chunk_size`
- :cpp:class:`hpx::execution::guided_chunk_size`
- :cpp:class:`hpx::execution::persistent_auto_chunk_size`
- :cpp:class:`hpx::execution::static_chunk_size`

Header ``hpx/functional.hpp``
=============================
Expand Down
67 changes: 33 additions & 34 deletions docs/sphinx/manual/writing_single_node_hpx_applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ C++ Extensions for Parallelism), |cpp11_n4088|_ (Task Blocks), and
Using parallel algorithms
-------------------------

.. |sequenced_execution_policy| replace:: :cpp:class:`hpx::parallel::execution::sequenced_policy`
.. |sequenced_task_execution_policy| replace:: :cpp:class:`hpx::parallel::execution::sequenced_task_policy`
.. |parallel_execution_policy| replace:: :cpp:class:`hpx::parallel::execution::parallel_policy`
.. |parallel_unsequenced_execution_policy| replace:: :cpp:class:`hpx::parallel::execution::parallel_unsequenced_policy`
.. |parallel_task_execution_policy| replace:: :cpp:class:`hpx::parallel::execution::parallel_task_policy`
.. |sequenced_execution_policy| replace:: :cpp:class:`hpx::execution::sequenced_policy`
.. |sequenced_task_execution_policy| replace:: :cpp:class:`hpx::execution::sequenced_task_policy`
.. |parallel_execution_policy| replace:: :cpp:class:`hpx::execution::parallel_policy`
.. |parallel_unsequenced_execution_policy| replace:: :cpp:class:`hpx::execution::parallel_unsequenced_policy`
.. |parallel_task_execution_policy| replace:: :cpp:class:`hpx::execution::parallel_task_policy`
.. |execution_policy| replace:: :cpp:class:`hpx::parallel::v1::execution_policy`
.. |exception_list| replace:: :cpp:class:`hpx::exception_list`
.. |par_for_each| replace:: :cpp:class:`hpx::parallel::v1::for_each`
Expand Down Expand Up @@ -799,15 +799,14 @@ number of tasks to schedule is given by ``num_tasks``. The lambda function
exposes a means of test-probing the execution of a single iteration for
performance measurement purposes. The execution parameter type might dynamically
determine the execution time of one or more tasks in order to calculate the
chunk size; see :cpp:class:`hpx::parallel::execution::auto_chunk_size` for an
example of this executor parameter type.
chunk size; see :cpp:class:`hpx::execution::auto_chunk_size` for an example of
this executor parameter type.

Other functions in the interface exist to discover whether an executor parameter
type should be invoked once (i.e., it returns a static chunk size; see
:cpp:class:`hpx::parallel::execution::static_chunk_size`) or whether it should
be invoked for each scheduled chunk of work (i.e., it returns a variable chunk
size; for an example, see
:cpp:class:`hpx::parallel::execution::guided_chunk_size`).
:cpp:class:`hpx::execution::static_chunk_size`) or whether it should be invoked
for each scheduled chunk of work (i.e., it returns a variable chunk size; for an
example, see :cpp:class:`hpx::execution::guided_chunk_size`).

Although this interface appears to require executor parameter type authors to
implement all different basic operations, none are required. In
Expand All @@ -816,27 +815,27 @@ parameter types will naturally specialize all operations for maximum efficiency.

|hpx| implements the following executor parameter types:

* :cpp:class:`hpx::parallel::execution::auto_chunk_size`: Loop iterations are
divided into pieces and then assigned to threads. The number of loop
iterations combined is determined based on measurements of how long the
execution of 1% of the overall number of iterations takes. This executor
parameter type makes sure that as many loop iterations are combined as
necessary to run for the amount of time specified.
* :cpp:class:`hpx::parallel::execution::static_chunk_size`: Loop iterations are
divided into pieces of a given size and then assigned to threads. If the size
is not specified, the iterations are, if possible, evenly divided contiguously
among the threads. This executor parameters type is equivalent to OpenMP's
STATIC scheduling directive.
* :cpp:class:`hpx::parallel::execution::dynamic_chunk_size`: Loop iterations are
divided into pieces of a given size and then dynamically scheduled among the
cores; when a core finishes one chunk, it is dynamically assigned another. If
the size is not specified, the default chunk size is 1. This executor
parameter type is equivalent to OpenMP's DYNAMIC scheduling directive.
* :cpp:class:`hpx::parallel::execution::guided_chunk_size`: Iterations are
dynamically assigned to cores in blocks as cores request them until no blocks
remain to be assigned. This is similar to ``dynamic_chunk_size`` except that the block
size decreases each time a number of loop iterations is given to a thread. The
size of the initial block is proportional to ``number_of_iterations /
* :cpp:class:`hpx::execution::auto_chunk_size`: Loop iterations are divided into
pieces and then assigned to threads. The number of loop iterations combined is
determined based on measurements of how long the execution of 1% of the
overall number of iterations takes. This executor parameter type makes sure
that as many loop iterations are combined as necessary to run for the amount
of time specified.
* :cpp:class:`hpx::execution::static_chunk_size`: Loop iterations are divided
into pieces of a given size and then assigned to threads. If the size is not
specified, the iterations are, if possible, evenly divided contiguously among
the threads. This executor parameters type is equivalent to OpenMP's STATIC
scheduling directive.
* :cpp:class:`hpx::execution::dynamic_chunk_size`: Loop iterations are divided
into pieces of a given size and then dynamically scheduled among the cores;
when a core finishes one chunk, it is dynamically assigned another. If the
size is not specified, the default chunk size is 1. This executor parameter
type is equivalent to OpenMP's DYNAMIC scheduling directive.
* :cpp:class:`hpx::execution::guided_chunk_size`: Iterations are dynamically
assigned to cores in blocks as cores request them until no blocks remain to be
assigned. This is similar to ``dynamic_chunk_size`` except that the block size
decreases each time a number of loop iterations is given to a thread. The size
of the initial block is proportional to ``number_of_iterations /
number_of_cores``. Subsequent blocks are proportional to
``number_of_iterations_remaining / number_of_cores``. The optional chunk size
parameter defines the minimum block size. The default minimal chunk size is 1.
Expand Down Expand Up @@ -961,11 +960,11 @@ created ``task_block``. In the following example the use of an explicit
This also causes the :cpp:class:`hpx::parallel::v2::task_block` object to be a
template in our implementation. The template argument is the type of the
execution policy used to create the task block. The template argument defaults
to :cpp:class:`hpx::parallel::execution::parallel_policy`.
to :cpp:class:`hpx::execution::parallel_policy`.

|hpx| still supports calling :cpp:func:`hpx::parallel::v2::define_task_block`
without an explicit execution policy. In this case the task block will run using
the :cpp:class:`hpx::parallel::execution::parallel_policy`.
the :cpp:class:`hpx::execution::parallel_policy`.

|hpx| also adds the ability to access the execution policy that was used to
create a given ``task_block``.
Expand Down
2 changes: 1 addition & 1 deletion examples/1d_stencil/1d_stencil_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct stepper
// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::execution::par;
using hpx::execution::par;
hpx::ranges::for_each(par, range, [&U, nx](std::size_t i) {
U[0][i] = hpx::make_ready_future(partition_data(nx, double(i)));
});
Expand Down
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_4_repart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct stepper
// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::execution::par;
using hpx::execution::par;
hpx::ranges::for_each(par, range, [&U, nx](std::size_t i) {
U[0][i] = hpx::make_ready_future(partition_data(nx, double(i)));
});
Expand All @@ -276,7 +276,7 @@ struct stepper
// Initialize from existing data
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::execution::par;
using hpx::execution::par;
hpx::ranges::for_each(par, range, [&U, nx, data](std::size_t i) {
U[0][i] = hpx::make_ready_future(
partition_data(nx, data.get() + (i * nx)));
Expand Down
2 changes: 1 addition & 1 deletion examples/1d_stencil/1d_stencil_4_throttle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ struct stepper
// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::execution::par;
using hpx::execution::par;
hpx::ranges::for_each(par, range, [&U, nx](std::size_t i) {
U[0][i] = hpx::make_ready_future(partition_data(nx, double(i)));
});
Expand Down
2 changes: 1 addition & 1 deletion examples/1d_stencil/1d_stencil_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int hpx_main(boost::program_options::variables_map& vm)
auto range = boost::irange(static_cast<std::size_t>(0), nlp);

executor_type executor(numa_domains);
auto policy = hpx::parallel::execution::par.on(executor);
auto policy = hpx::execution::par.on(executor);

hpx::util::high_resolution_timer t;
for (std::size_t t = 0; t < steps; ++t)
Expand Down
4 changes: 2 additions & 2 deletions examples/quickstart/component_with_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
// Define a base component which exposes the required interface
struct hello_world_server
: hpx::components::executor_component<
hpx::parallel::execution::parallel_executor,
hpx::execution::parallel_executor,
hpx::components::component_base<hello_world_server> >
{
typedef hpx::parallel::execution::parallel_executor executor_type;
typedef hpx::execution::parallel_executor executor_type;
typedef hpx::components::executor_component<
executor_type, hpx::components::component_base<hello_world_server>
> base_type;
Expand Down
4 changes: 2 additions & 2 deletions examples/quickstart/partitioned_vector_spmd_foreach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ int hpx_main(hpx::program_options::variables_map& vm)

// fill the vector with random numbers
partitioned_vector_view<int> view(v);
hpx::generate(hpx::parallel::execution::par, view.begin(), view.end(),
hpx::generate(hpx::execution::par, view.begin(), view.end(),
[&]() { return dist(gen); });

// square all numbers in the array
hpx::ranges::for_each(
hpx::parallel::execution::par, view, [](int& val) { val *= val; });
hpx::execution::par, view, [](int& val) { val *= val; });

// do the same using a plain loop
std::size_t maxnum = view.size();
Expand Down
6 changes: 3 additions & 3 deletions examples/quickstart/potpourri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ int main(int, char**)
std::vector<int> v(1000000);

// We fill the vector synchronously and sequentially.
hpx::generate(hpx::parallel::execution::seq, std::begin(v), std::end(v),
hpx::generate(hpx::execution::seq, std::begin(v), std::end(v),
&rand_wrapper);

// We can launch the sort in parallel and asynchronously.
hpx::future<void> done_sorting = hpx::parallel::sort(
hpx::parallel::execution::par( // In parallel.
hpx::parallel::execution::task), // Asynchronously.
hpx::execution::par( // In parallel.
hpx::execution::task), // Asynchronously.
std::begin(v), std::end(v));

// We launch the final task when the vector has been sorted and result is
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/safe_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ inline bool satisfies_criteria(int d)

int hpx_main(int argc, char* argv[])
{
using hpx::parallel::execution::par;
using hpx::execution::par;
using hpx::ranges::for_each;

// initialize data
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/sort_by_key_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int hpx_main()
print_sequence(keys, values);

hpx::parallel::sort_by_key(
hpx::parallel::execution::par,
hpx::execution::par,
keys.begin(),
keys.end(),
values.begin());
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/vector_counting_dotproduct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int hpx_main()

double result =
hpx::transform_reduce(
hpx::parallel::execution::par,
hpx::execution::par,
hpx::util::counting_iterator<size_t>(0),
hpx::util::counting_iterator<size_t>(10007),
0.0,
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/vector_zip_dotproduct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int hpx_main()

double result =
hpx::transform_reduce(
hpx::parallel::execution::par,
hpx::execution::par,
make_zip_iterator(std::begin(xvalues), std::begin(yvalues)),
make_zip_iterator(std::end(xvalues), std::end(yvalues)),
0.0,
Expand Down
2 changes: 1 addition & 1 deletion examples/transpose/transpose_await.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int hpx_main(hpx::program_options::variables_map& vm)
std::cout << "Untiled\n";
std::cout << "Number of iterations = " << iterations << "\n";
}
using hpx::parallel::execution::par;
using hpx::execution::par;
using hpx::ranges::for_each;

// Fill the original matrix, set transpose to known garbage value.
Expand Down
2 changes: 1 addition & 1 deletion examples/transpose/transpose_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ int hpx_main(hpx::program_options::variables_map& vm)
std::cout << "Untiled\n";
std::cout << "Number of iterations = " << iterations << "\n";
}
using hpx::parallel::execution::par;
using hpx::execution::par;
using hpx::ranges::for_each;

// Fill the original matrix, set transpose to known garbage value.
Expand Down
2 changes: 1 addition & 1 deletion examples/transpose/transpose_block_numa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ int hpx_main(hpx::program_options::variables_map& vm)
std::cout << "Number of iterations = " << iterations << "\n";
}

using hpx::parallel::execution::par;
using hpx::execution::par;
using hpx::ranges::for_each;

// Fill the original matrix, set transpose to known garbage value.
Expand Down
2 changes: 1 addition & 1 deletion examples/transpose/transpose_smp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int hpx_main(hpx::program_options::variables_map& vm)
std::cout << "Untiled\n";
std::cout << "Number of iterations = " << iterations << "\n";

using hpx::parallel::execution::par;
using hpx::execution::par;
using hpx::ranges::for_each;

const std::uint64_t start = 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/transpose/transpose_smp_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ int hpx_main(hpx::program_options::variables_map& vm)
std::cout << "Untiled\n";
std::cout << "Number of iterations = " << iterations << "\n";

using hpx::parallel::execution::par;
using hpx::parallel::execution::task;
using hpx::execution::par;
using hpx::execution::task;
using hpx::ranges::for_each;

const std::uint64_t start = 0;
Expand Down
25 changes: 23 additions & 2 deletions libs/core/execution_base/include/hpx/execution_base/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <type_traits>
#include <utility>

namespace hpx { namespace parallel { namespace execution {
namespace hpx { namespace execution {
///////////////////////////////////////////////////////////////////////////
/// Function invocations executed by a group of sequential execution agents
/// execute in sequential order.
Expand Down Expand Up @@ -49,8 +49,29 @@ namespace hpx { namespace parallel { namespace execution {
{
constexpr task_policy_tag() {}
};
/// \endcond
}} // namespace hpx::execution

namespace hpx { namespace parallel { namespace execution {
using parallel_execution_tag HPX_DEPRECATED_V(1, 6,
"hpx::parallel::execution::parallel_execution_tag is deprecated. Use "
"hpx::execution::parallel_execution_tag instead.") =
hpx::execution::parallel_execution_tag;
using sequenced_execution_tag HPX_DEPRECATED_V(1, 6,
"hpx::parallel::execution::sequenced_execution_tag is deprecated. Use "
"hpx::execution::sequenced_execution_tag instead.") =
hpx::execution::sequenced_execution_tag;
using task_policy_tag HPX_DEPRECATED_V(1, 6,
"hpx::parallel::execution::task_policy_tag is deprecated. Use "
"hpx::execution::task_policy_tag instead.") =
hpx::execution::task_policy_tag;
using unsequenced_execution_tag HPX_DEPRECATED_V(1, 6,
"hpx::parallel::execution::unsequenced_execution_tag is deprecated. "
"Use hpx::execution::unsequenced_execution_tag instead.") =
hpx::execution::unsequenced_execution_tag;
}}} // namespace hpx::parallel::execution
/// \endcond

namespace hpx { namespace parallel { namespace execution {
///////////////////////////////////////////////////////////////////////////
// Define infrastructure for customization points
namespace detail {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

void test(hpx::threads::thread_stacksize stacksize)
{
hpx::parallel::execution::parallel_executor exec(stacksize);
hpx::parallel::execution::parallel_executor exec_current(
hpx::execution::parallel_executor exec(stacksize);
hpx::execution::parallel_executor exec_current(
hpx::threads::thread_stacksize_current);

hpx::async(exec, [&exec_current, stacksize]() {
Expand Down
Loading

0 comments on commit 19ad131

Please sign in to comment.