Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt execution policy name changes from C++17 #2436

Merged
merged 8 commits into from Dec 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 9 additions & 1 deletion CMakeLists.txt
Expand Up @@ -773,7 +773,7 @@ if(HPX_WITH_ASYNC_FUNCTION_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_ASYNC_FUNCTION_COMPATIBILITY)
endif()

# BADBAD: This enables an overload of swap is necessary to work around the
# BADBAD: This enables an overload of swap which is necessary to work around the
# problems caused by zip_iterator not being a real random access iterator.
# Dereferencing zip_iterator does not yield a true reference but
# only a temporary tuple holding true references.
Expand All @@ -796,6 +796,14 @@ if(HPX_WITH_BOOST_CHRONO_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_BOOST_CHRONO_COMPATIBILITY)
endif()

# HPX_WITH_EXECUTION_POLICY_COMPATIBILITY: introduced in V1.0.0
hpx_option(HPX_WITH_EXECUTION_POLICY_COMPATIBILITY BOOL
"Enable old execution policy names in API (default: ON)"
ON ADVANCED)
if(HPX_WITH_EXECUTION_POLICY_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_EXECUTION_POLICY_COMPATIBILITY)
endif()

################################################################################
# Set basic search paths for HPX
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion docs/CMakeLists.txt
Expand Up @@ -74,7 +74,6 @@ set(doxygen_dependencies
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/generate.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/includes.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/inclusive_scan.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/inner_product.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/is_partitioned.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/is_sorted.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/lexicographical_compare.hpp"
Expand All @@ -99,6 +98,7 @@ set(doxygen_dependencies
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/transform_exclusive_scan.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/transform_inclusive_scan.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/transform_reduce.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/transform_reduce_binary.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/uninitialized_copy.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/uninitialized_fill.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/copy.hpp"
Expand Down
2 changes: 2 additions & 0 deletions docs/manual/build_system/cmake_variables.qbk
Expand Up @@ -43,6 +43,7 @@ The options are split into these categories:
* [link build_system.cmake_variables.HPX_WITH_DATAPAR_BOOST_SIMD HPX_WITH_DATAPAR_BOOST_SIMD]
* [link build_system.cmake_variables.HPX_WITH_DATAPAR_LIBFLATARRAY HPX_WITH_DATAPAR_LIBFLATARRAY]
* [link build_system.cmake_variables.HPX_WITH_DATAPAR_VC HPX_WITH_DATAPAR_VC]
* [link build_system.cmake_variables.HPX_WITH_EXECUTION_POLICY_COMPATIBILITY HPX_WITH_EXECUTION_POLICY_COMPATIBILITY]
* [link build_system.cmake_variables.HPX_WITH_FORTRAN HPX_WITH_FORTRAN]
* [link build_system.cmake_variables.HPX_WITH_FULL_RPATH HPX_WITH_FULL_RPATH]
* [link build_system.cmake_variables.HPX_WITH_GCC_VERSION_CHECK HPX_WITH_GCC_VERSION_CHECK]
Expand Down Expand Up @@ -78,6 +79,7 @@ The options are split into these categories:
[[[#build_system.cmake_variables.HPX_WITH_DATAPAR_BOOST_SIMD] `HPX_WITH_DATAPAR_BOOST_SIMD:BOOL`][Enable data parallel algorithm support using the external Boost.SIMD library (default: OFF)]]
[[[#build_system.cmake_variables.HPX_WITH_DATAPAR_LIBFLATARRAY] `HPX_WITH_DATAPAR_LIBFLATARRAY:BOOL`][Enable data parallel algorithm support using the external LibFlatArray (default: OFF)]]
[[[#build_system.cmake_variables.HPX_WITH_DATAPAR_VC] `HPX_WITH_DATAPAR_VC:BOOL`][Enable data parallel algorithm support using the external Vc library (default: OFF)]]
[[[#build_system.cmake_variables.HPX_WITH_EXECUTION_POLICY_COMPATIBILITY] `HPX_WITH_EXECUTION_POLICY_COMPATIBILITY:BOOL`][Enable old execution policy names in API (default: ON)]]
[[[#build_system.cmake_variables.HPX_WITH_FORTRAN] `HPX_WITH_FORTRAN:BOOL`][Enable or disable the compilation of Fortran examples using HPX]]
[[[#build_system.cmake_variables.HPX_WITH_FULL_RPATH] `HPX_WITH_FULL_RPATH:BOOL`][Build and link HPX libraries and executables with full RPATHs (default: ON)]]
[[[#build_system.cmake_variables.HPX_WITH_GCC_VERSION_CHECK] `HPX_WITH_GCC_VERSION_CHECK:BOOL`][Don't ignore version reported by gcc (default: ON)]]
Expand Down
24 changes: 11 additions & 13 deletions docs/manual/parallel_algorithms.qbk
Expand Up @@ -21,11 +21,11 @@ Extensions for Parallelism), __cpp11_n4088__ (Task Blocks), and __cpp11_n4406__

[section:parallel_algorithms Using Parallel Algorithms]

[def __sequential_execution_policy__ [classref hpx::parallel::v1::sequential_execution_policy `sequential_execution_policy`]]
[def __sequential_task_execution_policy__ [classref hpx::parallel::v1::sequential_task_execution_policy `sequential_task_execution_policy`]]
[def __parallel_execution_policy__ [classref hpx::parallel::v1::parallel_execution_policy `parallel_execution_policy`]]
[def __parallel_vector_execution_policy__ [classref hpx::parallel::v1::parallel_vector_execution_policy `parallel_vector_execution_policy`]]
[def __parallel_task_execution_policy__ [classref hpx::parallel::v1::parallel_task_execution_policy `parallel_task_execution_policy`]]
[def __sequential_execution_policy__ [classref hpx::parallel::execution::sequenced_policy `sequenced_policy`]]
[def __sequential_task_execution_policy__ [classref hpx::parallel::execution::sequenced_task_policy `sequenced_task_policy`]]
[def __parallel_execution_policy__ [classref hpx::parallel::execution::parallel_policy `parallel_policy`]]
[def __parallel_vector_execution_policy__ [classref hpx::parallel::execution::parallel_unsequenced_policy `parallel_unsequenced_policy`]]
[def __parallel_task_execution_policy__ [classref hpx::parallel::execution::parallel_task_policy `parallel_task_policy`]]
[def __execution_policy__ [classref hpx::parallel::v1::execution_policy `execution_policy`]]

[def __exception_list__ [classref hpx::exception_list `exception_list`]]
Expand Down Expand Up @@ -308,9 +308,6 @@ __hpx__ provides implementations of the following parallel algorithms:
[[ [algoref adjacent_difference] ]
[Calculates the difference between each element in an input range and the preceding element.]
[`<hpx/include/parallel_adjacent_difference.hpp>`]]
[[ [algoref inner_product] ]
[Accumulates the inner products of two input ranges.]
[`<hpx/include/parallel_inner_product.hpp>`]]
[[ [algoref reduce] ]
[Sums up a range of elements.]
[`<hpx/include/parallel_reduce.hpp>`]]
Expand All @@ -320,7 +317,8 @@ __hpx__ provides implementations of the following parallel algorithms:
sequence {2,3,4,5,6,7,8,9,10} would be reduced to keys={1,2,3,1}, values={9,5,30,10}]
[`<hpx/include/parallel_reduce.hpp>`]]
[[ [algoref transform_reduce] ]
[Sums up a range of elements after applying a function.]
[Sums up a range of elements after applying a function. Also, accumulates
the inner products of two input ranges.]
[`<hpx/include/parallel_transform_reduce.hpp>`]]
[[ [algoref transform_inclusive_scan] ]
[Does an inclusive parallel scan over a range of elements after applying
Expand Down Expand Up @@ -648,7 +646,7 @@ created `task_block`. In the following example the use of an explicit
int left = 0, right = 0;

define_task_block(
par, // parallel_execution_policy
execution::par, // execution::parallel_policy
[&](task_block<>& tb) {
if (n->left)
tb.run([&] { left = traverse(n->left, compute); });
Expand All @@ -663,12 +661,12 @@ This also causes the [classref hpx::parallel::v2::task_block `hpx::parallel::tas
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
[classref hpx::parallel::v1::parallel_execution_policy `hpx::parallel::parallel_execution_policy`].
[classref hpx::parallel::execution::parallel_policy `hpx::parallel::execution::parallel_policy`].

__hpx__ still supports calling
[funcref hpx::parallel::v2::define_task_block `hpx::parallel::define_task_block`]
without an explicit execution policy. In this case the task block will run using
the [classref hpx::parallel::v1::parallel_execution_policy `hpx::parallel::parallel_execution_policy`].
the [classref hpx::parallel::execution::parallel_policy `hpx::parallel::execution::parallel_policy`].

__hpx__ also adds the ability to access the execution policy which was used to
create a given `task_block`.
Expand All @@ -687,7 +685,7 @@ function enables this use case:
int left = 0, right = 0;

define_task_block(
par, // parallel_execution_policy
execution::par, // execution::parallel_policy
[&](auto& tb) {
if (n->left)
{
Expand Down
13 changes: 12 additions & 1 deletion docs/whats_new.qbk
Expand Up @@ -43,6 +43,11 @@ particular order):
component instances as their parameter (instead of a global id).
* Added the helper utility `hpx::performance_countyers::performance_counter_set`
helping to encapsulate a set of performance counters to be managed concurrently.
* All execution policies and related classes have been renamed to be consistent
with the naming changes applied for C++17. All policies now live in the
namespace `hpx::parallel::execution`. The ols names can be still enabled
at configure time by specifying `-DHPX_WITH_EXECUTION_POLICY_COMPATIBILITY=On`
to __cmake__.

[heading Breaking Changes]

Expand All @@ -52,6 +57,12 @@ particular order):
it have been replaced with `std::chrono`. This facility can be still enabled
at configure time by specifying `-DHPX_WITH_BOOST_CHRONO_COMPATIBILITY=On`
to __cmake__.
* The parameter sequence for the `hpx::parallel::transform_reduce` overload
taking one iterator range has changed to match the changes this algorithm has
undergone while being moved to C++17.
* The algorithm `hpx::parallel::inner_product` has been renamed to
`hpx::parallel::transform_reduce` to match the changes this algorithm has
undergone while being moved to C++17.

[heading Bug Fixes (Closed Tickets)]

Expand Down Expand Up @@ -125,7 +136,7 @@ Here is a list of the important tickets we closed for this release.
* [pr 2299] - Replace boost::[c]ref with std::[c]ref, add inspect checks
* [pr 2297] - Fixing compilation with no hw_loc
* [pr 2296] - Hpx compute
* [pr 2295] - Making sure for_loop(par, 0, N, ...) is actually executed in
* [pr 2295] - Making sure for_loop(execution::par, 0, N, ...) is actually executed in
parallel
* [pr 2294] - Throwing exceptions if the runtime is not up and running
* [pr 2293] - Removing unused parcel port code
Expand Down
2 changes: 1 addition & 1 deletion examples/1d_stencil/1d_stencil_4.cpp
Expand Up @@ -145,7 +145,7 @@ struct stepper
// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::par;
using hpx::parallel::execution::par;
hpx::parallel::for_each(par, boost::begin(range), boost::end(range),
[&U, nx](std::size_t i)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_4_parallel.cpp
Expand Up @@ -102,7 +102,7 @@ struct stepper
next[0] = heat(left[size-1], middle[0], middle[1]);

using namespace hpx::parallel;
for_each(par, iterator(1), iterator(size-1),
for_each(execution::par, iterator(1), iterator(size-1),
[&next, &middle](std::size_t i)
{
next[i] = heat(middle[i-1], middle[i], middle[i+1]);
Expand All @@ -120,7 +120,7 @@ struct stepper
using hpx::util::unwrapped;
using hpx::dataflow;
using hpx::parallel::for_each;
using hpx::parallel::par;
using hpx::parallel::execution::par;

// U[t][i] is the state of position i at time t.
std::vector<space> U(2);
Expand Down
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_4_repart.cpp
Expand Up @@ -230,7 +230,7 @@ struct stepper
// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::par;
using hpx::parallel::execution::par;
hpx::parallel::for_each(
par, boost::begin(range), boost::end(range),
[&U, nx](std::size_t i)
Expand All @@ -244,7 +244,7 @@ struct stepper
// Initialize from existing data
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::par;
using hpx::parallel::execution::par;
hpx::parallel::for_each(
par, boost::begin(range), boost::end(range),
[&U, nx, data](std::size_t i)
Expand Down
5 changes: 3 additions & 2 deletions examples/1d_stencil/1d_stencil_4_throttle.cpp
Expand Up @@ -214,8 +214,9 @@ struct stepper
// Initial conditions: f(0, i) = i
std::size_t b = 0;
auto range = boost::irange(b, np);
using hpx::parallel::par;
hpx::parallel::for_each(par, boost::begin(range), boost::end(range),
using hpx::parallel::execution::par;
hpx::parallel::for_each(par,
boost::begin(range), boost::end(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/quickstart/partitioned_vector_spmd_foreach.cpp
Expand Up @@ -161,7 +161,7 @@ int hpx_main(boost::program_options::variables_map& vm)
// fill the vector with random numbers
partitioned_vector_view<int> view(v);
hpx::parallel::generate(
hpx::parallel::par,
hpx::parallel::execution::par,
view.begin(), view.end(),
[&]()
{
Expand All @@ -170,7 +170,7 @@ int hpx_main(boost::program_options::variables_map& vm)

// square all numbers in the array
hpx::parallel::for_each(
hpx::parallel::par,
hpx::parallel::execution::par,
view.begin(), view.end(),
[](int& val)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/safe_object.cpp
Expand Up @@ -82,7 +82,7 @@ inline bool satisfies_criteria(int d)
int hpx_main(int argc, char* argv[])
{
using hpx::parallel::for_each;
using hpx::parallel::par;
using hpx::parallel::execution::par;

// initialize data
std::vector<int> data = random_fill(1000);
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/sort_by_key_demo.cpp
Expand Up @@ -46,7 +46,7 @@ int hpx_main()
print_sequence(keys, values);

hpx::parallel::sort_by_key(
hpx::parallel::par,
hpx::parallel::execution::par,
keys.begin(),
keys.end(),
values.begin());
Expand Down
5 changes: 3 additions & 2 deletions examples/quickstart/vector_counting_dotproduct.cpp
Expand Up @@ -12,6 +12,7 @@
#include <boost/iterator/counting_iterator.hpp>
#include <boost/range/functions.hpp>

#include <algorithm>
#include <string>
#include <vector>

Expand All @@ -26,14 +27,14 @@ int hpx_main()

double result =
hpx::parallel::transform_reduce(
hpx::parallel::par,
hpx::parallel::execution::par,
boost::counting_iterator<size_t>(0),
boost::counting_iterator<size_t>(10007),
0.0,
[&xvalues, &yvalues](size_t i)
{
return xvalues[i] * yvalues[i];
},
0.0,
std::plus<double>()
);
// print the result
Expand Down
4 changes: 2 additions & 2 deletions examples/quickstart/vector_zip_dotproduct.cpp
Expand Up @@ -29,14 +29,14 @@ int hpx_main()

double result =
hpx::parallel::transform_reduce(
hpx::parallel::par,
hpx::parallel::execution::par,
make_zip_iterator(boost::begin(xvalues), boost::begin(yvalues)),
make_zip_iterator(boost::end(xvalues), boost::end(yvalues)),
0.0,
[](tuple<double, double> r)
{
return get<0>(r) * get<1>(r);
},
0.0,
std::plus<double>()
);
// print the result
Expand Down
9 changes: 4 additions & 5 deletions examples/transpose/transpose_await.cpp
Expand Up @@ -280,7 +280,7 @@ int hpx_main(boost::program_options::variables_map& vm)
<< "Number of iterations = " << iterations << "\n";
}
using hpx::parallel::for_each;
using hpx::parallel::par;
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
Expand Down Expand Up @@ -316,7 +316,7 @@ int hpx_main(boost::program_options::variables_map& vm)
auto range = boost::irange(blocks_start, blocks_end);

const std::uint64_t block_size = block_order * block_order;
for_each(par, boost::begin(range), boost::end(range),
for_each(execution::par, boost::begin(range), boost::end(range),
[&](std::uint64_t b)
{
transpose_phase(A, B, block_order, b,
Expand Down Expand Up @@ -436,12 +436,12 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
std::uint64_t blocks_end)
{
using hpx::parallel::transform_reduce;
using hpx::parallel::par;
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
double errsq =
transform_reduce(par, boost::begin(range), boost::end(range),
transform_reduce(par, boost::begin(range), boost::end(range), 0.0,
[&](std::uint64_t b) -> double
{
sub_block trans_block =
Expand All @@ -459,7 +459,6 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
}
return errsq;
},
0.0,
[](double lhs, double rhs) { return lhs + rhs; }
);

Expand Down
7 changes: 3 additions & 4 deletions examples/transpose/transpose_block.cpp
Expand Up @@ -245,7 +245,7 @@ int hpx_main(boost::program_options::variables_map& vm)
<< "Number of iterations = " << iterations << "\n";
}
using hpx::parallel::for_each;
using hpx::parallel::par;
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
Expand Down Expand Up @@ -448,12 +448,12 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
std::uint64_t blocks_end)
{
using hpx::parallel::transform_reduce;
using hpx::parallel::par;
using hpx::parallel::execution::par;

// Fill the original matrix, set transpose to known garbage value.
auto range = boost::irange(blocks_start, blocks_end);
double errsq =
transform_reduce(par, boost::begin(range), boost::end(range),
transform_reduce(par, boost::begin(range), boost::end(range), 0.0,
[&](std::uint64_t b) -> double
{
sub_block trans_block =
Expand All @@ -471,7 +471,6 @@ double test_results(std::uint64_t order, std::uint64_t block_order,
}
return errsq;
},
0.0,
[](double lhs, double rhs) { return lhs + rhs; }
);

Expand Down