Skip to content

Commit

Permalink
Merge branch 'master' into fix_serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed May 18, 2017
2 parents adc04ac + 2546c6b commit b31a628
Show file tree
Hide file tree
Showing 20 changed files with 452 additions and 138 deletions.
14 changes: 11 additions & 3 deletions CMakeLists.txt
Expand Up @@ -9,11 +9,11 @@
# 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)

# We require at least CMake V2.8.12
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
# We require at least CMake V3.0.2
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)

# explicitly set certain policies
cmake_policy(VERSION 2.8.12)
cmake_policy(VERSION 3.0.2)
macro(hpx_set_cmake_policy policy value)
if(POLICY ${policy})
cmake_policy(SET ${policy} ${value})
Expand Down Expand Up @@ -880,6 +880,14 @@ if(HPX_WITH_TRANSFORM_REDUCE_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY)
endif()

# HPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY: introduced in V1.1.0
hpx_option(HPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY BOOL
"Enable old overloads for inclkusive_scan (default: ON)"
ON ADVANCED)
if(HPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY)
hpx_add_config_define(HPX_HAVE_INCLUSIVE_SCAN_COMPATIBILITY)
endif()

################################################################################
# Set basic search paths for HPX
################################################################################
Expand Down
1 change: 1 addition & 0 deletions cmake/HPX_Documentation.cmake
Expand Up @@ -110,6 +110,7 @@ macro(hpx_quickbook_to_boostbook name)
add_custom_command(OUTPUT ${name}.xml
COMMAND "${BOOSTQUICKBOOK_EXECUTABLE}"
"--output-file=${name}.xml"
"--include-path=${CMAKE_CURRENT_BINARY_DIR}/generated"
"${git_commit_option}"
"${doxygen_option}"
"-D__hpx_source_dir__=${doc_source_dir}"
Expand Down
13 changes: 8 additions & 5 deletions docs/CMakeLists.txt
Expand Up @@ -282,9 +282,11 @@ foreach(_cat ${HPX_OPTION_CATEGORIES})
set(HPX_CMAKE_OPTIONS "${HPX_CMAKE_OPTIONS}] [/ ${_cat} Options]\n\n")
endforeach()

set(QUICKBOOK_CMAKE_VARIABLES_DEST
"${CMAKE_CURRENT_BINARY_DIR}/generated/build_system/cmake_variables.qbk")
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/templates/cmake_variables.qbk.in"
"${PROJECT_SOURCE_DIR}/docs/manual/build_system/cmake_variables.qbk"
${QUICKBOOK_CMAKE_VARIABLES_DEST}
@ONLY
)

Expand All @@ -309,10 +311,11 @@ foreach(_toolchain ${_toolchain_files})
set(HPX_CMAKE_TOOLCHAINS "${HPX_CMAKE_TOOLCHAINS}\n")
endforeach()


set(QUICKBOOK_CMAKE_TOOLCHAINS_DEST
"${CMAKE_CURRENT_BINARY_DIR}/generated/build_system/cmake_toolchains.qbk")
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/templates/cmake_toolchains.qbk.in"
"${PROJECT_SOURCE_DIR}/docs/manual/build_system/cmake_toolchains.qbk"
${QUICKBOOK_CMAKE_TOOLCHAINS_DEST}
@ONLY
)

Expand All @@ -321,8 +324,8 @@ hpx_quickbook_to_html(hpx
INDEX hpx.idx
DEPENDENCIES
${all_documentation_dependencies}
"${PROJECT_SOURCE_DIR}/docs/manual/build_system/cmake_variables.qbk"
"${PROJECT_SOURCE_DIR}/docs/manual/build_system/cmake_toolchains.qbk"
${QUICKBOOK_CMAKE_VARIABLES_DEST}
${QUICKBOOK_CMAKE_TOOLCHAINS_DEST}
CATALOG "${CMAKE_CURRENT_BINARY_DIR}/boostbook_catalog.xml"
XSLTPROC_ARGS chunk.section.depth=4
chunk.first.sections=1
Expand Down
4 changes: 2 additions & 2 deletions docs/manual/build_system/prerequisites.qbk
Expand Up @@ -60,7 +60,7 @@ favorite compiler with __hpx__ visit __stellar_hpx_buildbot__.
[[__clang__ ][3.4 or newer ][3.3 ]]

[[[*Build System]]]
[[__cmake__ ][3.1 ][2.8.10 ]]
[[__cmake__ ][3.1 ][3.0.2 ]]

[[[*Required Libraries]]]
[[__boost_libraries__ ][1.57.0 or newer ][1.51.0 ]
Expand Down Expand Up @@ -89,7 +89,7 @@ favorite compiler with __hpx__ visit __stellar_hpx_buildbot__.
[[__visual_cxx__ (x64) ][2013 ][2013 ]]

[[[*Build System]]]
[[__cmake__ ][3.1 ][2.8.10 ]]
[[__cmake__ ][3.1 ][3.0.2 ]]

[[[*Required Libraries]]]
[[__boost__ ][1.57.0 or newer ][1.51.0 ]
Expand Down
10 changes: 10 additions & 0 deletions docs/whats_new.qbk
Expand Up @@ -21,6 +21,16 @@ particular order):
available and to fall back to the corresponding Boost facilities otherwise.
The cmake configuration option `-DHPX_WITH_THREAD_COMPATIBILITY=On` can be
used to force using the Boost equivalents.
* The parameter sequence for the `hpx::parallel::transform_inclusive_scan` overload
taking one iterator range has changed (again) to match the changes this algorithm
has undergone while being moved to C++17. The old overloads can be still enabled
at configure time by specifying `-DHPX_WITH_TRANSFORM_REDUCE_COMPATIBILITY=On`
to __cmake__.
* The parameter sequence for the `hpx::parallel::inclusive_scan` overload
taking one iterator range has changed to match the changes this algorithm
has undergone while being moved to C++17. The old overloads can be still enabled
at configure time by specifying `-DHPX_WITH_INCLUSIVE_SCAN_COMPATIBILITY=On`
to __cmake__.

[heading Breaking Changes]

Expand Down
171 changes: 159 additions & 12 deletions hpx/parallel/algorithms/inclusive_scan.hpp
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2016 Hartmut Kaiser
// Copyright (c) 2014-2017 Hartmut Kaiser
// Copyright (c) 2016 Minh-Khanh Do
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand Down Expand Up @@ -271,12 +271,49 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
/// \a op is not mathematically associative, the behavior of
/// \a inclusive_scan may be non-deterministic.
///
template <typename ExPolicy, typename InIter, typename OutIter, typename Op,
typename T,
HPX_CONCEPT_REQUIRES_(
is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<InIter>::value &&
hpx::traits::is_iterator<OutIter>::value &&
hpx::traits::is_callable<
Op(typename std::iterator_traits<InIter>::value_type,
typename std::iterator_traits<InIter>::value_type)
>::value)>
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
inclusive_scan(ExPolicy&& policy, InIter first, InIter last, OutIter dest,
Op && op, T init)
{
static_assert(
(hpx::traits::is_input_iterator<InIter>::value),
"Requires at least input iterator.");
static_assert(
(hpx::traits::is_output_iterator<OutIter>::value ||
hpx::traits::is_forward_iterator<OutIter>::value),
"Requires at least output iterator.");

typedef hpx::traits::is_segmented_iterator<InIter> is_segmented;

return detail::inclusive_scan_(
std::forward<ExPolicy>(policy), first, last, dest,
init, std::forward<Op>(op),
is_segmented());
}

#if defined(HPX_HAVE_INCLUSIVE_SCAN_COMPATIBILITY)
/// \cond NOINTERNAL
template <typename ExPolicy, typename InIter, typename OutIter, typename T,
typename Op>
inline typename std::enable_if<
execution::is_execution_policy<ExPolicy>::value,
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
>::type
typename Op,
HPX_CONCEPT_REQUIRES_(
is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<InIter>::value &&
hpx::traits::is_iterator<OutIter>::value &&
hpx::traits::is_callable<
Op(typename std::iterator_traits<InIter>::value_type,
typename std::iterator_traits<InIter>::value_type)
>::value)>
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
inclusive_scan(ExPolicy&& policy, InIter first, InIter last, OutIter dest,
T init, Op && op)
{
Expand All @@ -295,14 +332,15 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
init, std::forward<Op>(op),
is_segmented());
}
/// \endcond

///////////////////////////////////////////////////////////////////////////
/// Assigns through each iterator \a i in [result, result + (last - first))
/// the value of
/// GENERALIZED_NONCOMMUTATIVE_SUM(+, init, *first, ..., *(first + (i - result))).
///
/// \note Complexity: O(\a last - \a first) applications of the
/// predicate \a op.
/// predicate \a +.
///
/// \tparam ExPolicy The type of the execution policy to use (deduced).
/// It describes the manner in which the execution
Expand Down Expand Up @@ -355,11 +393,16 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
/// The difference between \a exclusive_scan and \a inclusive_scan is that
/// \a inclusive_scan includes the ith input element in the ith sum.
///
template <typename ExPolicy, typename InIter, typename OutIter, typename T>
inline typename std::enable_if<
execution::is_execution_policy<ExPolicy>::value,
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
>::type
template <typename ExPolicy, typename InIter, typename OutIter, typename T,
HPX_CONCEPT_REQUIRES_(
is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<InIter>::value &&
hpx::traits::is_iterator<OutIter>::value &&
!hpx::traits::is_callable<
T(typename std::iterator_traits<InIter>::value_type,
typename std::iterator_traits<InIter>::value_type)
>::value)>
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
inclusive_scan(ExPolicy&& policy, InIter first, InIter last, OutIter dest,
T init)
{
Expand All @@ -378,6 +421,110 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
init, std::plus<T>(),
is_segmented());
}
#endif

///////////////////////////////////////////////////////////////////////////
/// Assigns through each iterator \a i in [result, result + (last - first))
/// the value of
/// GENERALIZED_NONCOMMUTATIVE_SUM(op, *first, ..., *(first + (i - result))).
///
/// \note Complexity: O(\a last - \a first) applications of the
/// predicate \a op.
///
/// \tparam ExPolicy The type of the execution policy to use (deduced).
/// It describes the manner in which the execution
/// of the algorithm may be parallelized and the manner
/// in which it executes the assignments.
/// \tparam InIter The type of the source iterators used (deduced).
/// This iterator type must meet the requirements of an
/// input iterator.
/// \tparam OutIter The type of the iterator representing the
/// destination range (deduced).
/// This iterator type must meet the requirements of an
/// output iterator.
/// \tparam Op The type of the binary function object used for
/// the reduction operation.
///
/// \param policy The execution policy to use for the scheduling of
/// the iterations.
/// \param first Refers to the beginning of the sequence of elements
/// the algorithm will be applied to.
/// \param last Refers to the end of the sequence of elements the
/// algorithm will be applied to.
/// \param dest Refers to the beginning of the destination range.
/// \param op Specifies the function (or function object) which
/// will be invoked for each of the values of the input
/// sequence. This is a
/// binary predicate. The signature of this predicate
/// should be equivalent to:
/// \code
/// Ret fun(const Type1 &a, const Type1 &b);
/// \endcode \n
/// The signature does not need to have const&, but
/// the function must not modify the objects passed to
/// it.
/// The types \a Type1 and \a Ret must be
/// such that an object of a type as given by the input
/// sequence can be implicitly converted to any
/// of those types.
///
/// The reduce operations in the parallel \a inclusive_scan algorithm invoked
/// with an execution policy object of type \a sequenced_policy
/// execute in sequential order in the calling thread.
///
/// The reduce operations in the parallel \a inclusive_scan algorithm invoked
/// with an execution policy object of type \a parallel_policy
/// or \a parallel_task_policy are permitted to execute in an unordered
/// fashion in unspecified threads, and indeterminately sequenced
/// within each thread.
///
/// \returns The \a copy_n algorithm returns a \a hpx::future<OutIter> if
/// the execution policy is of type
/// \a sequenced_task_policy or
/// \a parallel_task_policy and
/// returns \a OutIter otherwise.
/// The \a inclusive_scan algorithm returns the output iterator
/// to the element in the destination range, one past the last
/// element copied.
///
/// \note GENERALIZED_NONCOMMUTATIVE_SUM(+, a1, ..., aN) is defined as:
/// * a1 when N is 1
/// * GENERALIZED_NONCOMMUTATIVE_SUM(op, a1, ..., aK)
/// + GENERALIZED_NONCOMMUTATIVE_SUM(+, aM, ..., aN)
/// where 1 < K+1 = M <= N.
///
/// The difference between \a exclusive_scan and \a inclusive_scan is that
/// \a inclusive_scan includes the ith input element in the ith sum.
///
template <typename ExPolicy, typename InIter, typename OutIter, typename Op,
HPX_CONCEPT_REQUIRES_(
is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<InIter>::value &&
hpx::traits::is_iterator<OutIter>::value &&
hpx::traits::is_callable<
Op(typename std::iterator_traits<InIter>::value_type,
typename std::iterator_traits<InIter>::value_type)
>::value)>
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
inclusive_scan(ExPolicy&& policy, InIter first, InIter last, OutIter dest,
Op && op)
{
static_assert(
(hpx::traits::is_input_iterator<InIter>::value),
"Requires at least input iterator.");
static_assert(
(hpx::traits::is_output_iterator<OutIter>::value ||
hpx::traits::is_forward_iterator<OutIter>::value),
"Requires at least output iterator.");

typedef typename std::iterator_traits<InIter>::value_type value_type;
typedef hpx::traits::is_segmented_iterator<InIter> is_segmented;

return detail::inclusive_scan_(
std::forward<ExPolicy>(policy), first, last, dest,
value_type(), std::forward<Op>(op),
is_segmented());
}

///////////////////////////////////////////////////////////////////////////
/// Assigns through each iterator \a i in [result, result + (last - first))
Expand Down
45 changes: 43 additions & 2 deletions hpx/parallel/algorithms/transform_inclusive_scan.hpp
Expand Up @@ -278,7 +278,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
/// \a transform_inclusive_scan may be non-deterministic.
///
template <typename ExPolicy, typename InIter, typename OutIter,
typename T, typename Op, typename Conv,
typename Op, typename Conv, typename T,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<InIter>::value &&
Expand All @@ -296,7 +296,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)
>::value)>
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
transform_inclusive_scan(ExPolicy && policy, InIter first, InIter last,
OutIter dest, T init, Op && op, Conv && conv)
OutIter dest, Op && op, Conv && conv, T init)
{
static_assert(
(hpx::traits::is_input_iterator<InIter>::value),
Expand All @@ -320,6 +320,47 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1)

#if defined(HPX_HAVE_TRANSFORM_REDUCE_COMPATIBILITY)
/// \cond NOINTERNAL
template <typename ExPolicy, typename InIter, typename OutIter,
typename T, typename Op, typename Conv,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<InIter>::value &&
hpx::traits::is_iterator<OutIter>::value &&
hpx::traits::is_callable<
Conv(typename std::iterator_traits<InIter>::value_type)
>::value &&
hpx::traits::is_callable<
Op(typename hpx::util::result_of<
Conv(typename std::iterator_traits<InIter>::value_type)
>::type,
typename hpx::util::result_of<
Conv(typename std::iterator_traits<InIter>::value_type)
>::type)
>::value)>
typename util::detail::algorithm_result<ExPolicy, OutIter>::type
transform_inclusive_scan(ExPolicy && policy, InIter first, InIter last,
OutIter dest, T init, Op && op, Conv && conv)
{
static_assert(
(hpx::traits::is_input_iterator<InIter>::value),
"Requires at least input iterator.");
static_assert(
(hpx::traits::is_output_iterator<OutIter>::value ||
hpx::traits::is_input_iterator<OutIter>::value),
"Requires at least output iterator.");

typedef std::integral_constant<bool,
is_sequential_execution_policy<ExPolicy>::value ||
!hpx::traits::is_forward_iterator<InIter>::value ||
!hpx::traits::is_forward_iterator<OutIter>::value
> is_seq;

return detail::transform_inclusive_scan<OutIter>().call(
std::forward<ExPolicy>(policy), is_seq(),
first, last, dest, std::forward<Conv>(conv), std::move(init),
std::forward<Op>(op));
}

template <typename ExPolicy, typename InIter, typename OutIter,
typename T, typename Op, typename Conv,
HPX_CONCEPT_REQUIRES_(
Expand Down

0 comments on commit b31a628

Please sign in to comment.