Skip to content

Commit

Permalink
Merge branch 'master' into inspect_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Sep 6, 2017
2 parents d3f4c98 + 3542836 commit f036fe6
Show file tree
Hide file tree
Showing 70 changed files with 2,630 additions and 524 deletions.
2 changes: 1 addition & 1 deletion cmake/HPX_PerformCxxFeatureTests.cmake
Expand Up @@ -81,7 +81,7 @@ macro(hpx_perform_cxx_feature_tests)

# Check the availability of certain C++11 library features
hpx_check_for_cxx11_std_array(
DEFINITIONS HPX_HAVE_CXX11_STD_ARRAY)
REQUIRED "HPX needs support for C++11 std::array")

hpx_check_for_cxx11_std_atomic(
REQUIRED "HPX needs support for C++11 std::atomic")
Expand Down
2 changes: 2 additions & 0 deletions docs/CMakeLists.txt
Expand Up @@ -79,6 +79,7 @@ set(doxygen_dependencies
"${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"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/merge.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/minmax.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/mismatch.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/algorithms/move.hpp"
Expand Down Expand Up @@ -112,6 +113,7 @@ set(doxygen_dependencies
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/for_each.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/generate.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/is_heap.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/merge.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/minmax.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/partition.hpp"
"${PROJECT_SOURCE_DIR}/hpx/parallel/container_algorithms/remove_copy.hpp"
Expand Down
5 changes: 5 additions & 0 deletions docs/manual/parallel_algorithms.qbk
Expand Up @@ -339,6 +339,11 @@ __hpx__ provides implementations of the following parallel algorithms:

[table Set operations on sorted sequences (In Header: `<hpx/include/parallel_algorithm.hpp>`)
[[Name] [Description] [In Header] [Algorithm page at cppreference.com]]
[[ [algoref merge] ]
[Merges two sorted ranges.]
[`<hpx/include/parallel_merge.hpp>`]
[[cpprefalgodocs merge]]
]
[[ [algoref includes] ]
[Returns true if one set is a subset of another.]
[`<hpx/include/parallel_set_operations.hpp>`]
Expand Down
6 changes: 4 additions & 2 deletions examples/resource_partitioner/simple_resource_partitioner.cpp
Expand Up @@ -141,8 +141,10 @@ int hpx_main(boost::program_options::variables_map& vm)
}
}
// the last futures we made are stored in here
future_4.get();
future_5.get();
if (future_4.valid())
future_4.get();
if (future_5.valid())
future_5.get();
});

future_3.get();
Expand Down
13 changes: 13 additions & 0 deletions hpx/include/parallel_merge.hpp
@@ -0,0 +1,13 @@
// Copyright (c) 2017 Taeguk Kwon
//
// 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)

#if !defined(HPX_PARALLEL_MERGE_AUG_08_2017_0808AM)
#define HPX_PARALLEL_MERGE_AUG_08_2017_0808AM

#include <hpx/parallel/algorithms/merge.hpp>
#include <hpx/parallel/container_algorithms/merge.hpp>

#endif

90 changes: 59 additions & 31 deletions hpx/lcos/base_lco_with_value.hpp
Expand Up @@ -7,6 +7,7 @@
#define HPX_LCOS_BASE_LCO_WITH_VALUE_HPP

#include <hpx/config.hpp>
#include <hpx/throw_exception.hpp>
#include <hpx/lcos/base_lco.hpp>
#include <hpx/plugins/parcel/coalescing_message_handler_registration.hpp>
#include <hpx/runtime/actions/basic_action.hpp>
Expand Down Expand Up @@ -76,6 +77,21 @@ namespace hpx { namespace lcos
virtual ~base_lco_with_value() noexcept {}

virtual void set_event()
{
set_event_nonvirt(std::is_default_constructible<RemoteResult>());
}

void set_event_nonvirt(std::false_type)
{
// this shouldn't ever be called
HPX_THROW_EXCEPTION(invalid_status,
"base_lco_with_value::set_event_nonvirt",
"attempt to use a non-default-constructible return type with "
"an action in a context where default-construction would be "
"required");
}

void set_event_nonvirt(std::true_type)
{
set_value(RemoteResult());
}
Expand Down Expand Up @@ -240,32 +256,36 @@ namespace hpx { namespace traits

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION_1(Value) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION_4( \
Value, Value, Value, ::hpx::traits::detail::managed_component_tag) \
Value, Value, Value, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION_2(Value, Name) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION_4( \
Value, Value, Name, ::hpx::traits::detail::managed_component_tag) \
Value, Value, Name, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION_3( \
Value, RemoteValue, Name) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION_4( \
Value, RemoteValue, Name, ::hpx::traits::detail::managed_component_tag)\
Value, RemoteValue, Name, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION_4( \
Value, RemoteValue, Name, Tag) \
typedef ::hpx::lcos::base_lco_with_value< Value, RemoteValue, Tag> \
HPX_PP_CAT(base_lco_with_value_, Name); \
typedef ::hpx::lcos::base_lco_with_value<Value, RemoteValue, \
::hpx::traits::detail::Tag> \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag); \
HPX_REGISTER_ACTION_DECLARATION( \
HPX_PP_CAT(base_lco_with_value_, Name)::set_value_action, \
HPX_PP_CAT(set_value_action_, Name)) \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::set_value_action, \
HPX_PP_CAT(HPX_PP_CAT(set_value_action_, Name), Tag)) \
HPX_REGISTER_ACTION_DECLARATION( \
HPX_PP_CAT(base_lco_with_value_, Name)::get_value_action, \
HPX_PP_CAT(get_value_action_, Name)) \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::get_value_action, \
HPX_PP_CAT(HPX_PP_CAT(get_value_action_, Name), Tag)) \
HPX_ACTION_USES_MESSAGE_COALESCING_NOTHROW_DECLARATION( \
HPX_PP_CAT(base_lco_with_value_, Name)::set_value_action, \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::set_value_action, \
"lco_set_value_action", std::size_t(-1), std::size_t(-1)) \
/**/

Expand All @@ -282,30 +302,34 @@ namespace hpx { namespace traits

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_1(Value) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_4( \
Value, Value, Value, ::hpx::traits::detail::managed_component_tag) \
Value, Value, Value, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_2(Value, Name) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_4( \
Value, Value, Name, ::hpx::traits::detail::managed_component_tag) \
Value, Value, Name, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_3(Value, RemoteValue, Name) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_4( \
Value, RemoteValue, Name, ::hpx::traits::detail::managed_component_tag)\
Value, RemoteValue, Name, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_4(Value, RemoteValue, Name, Tag) \
typedef ::hpx::lcos::base_lco_with_value< Value, RemoteValue, Tag> \
HPX_PP_CAT(base_lco_with_value_, Name); \
typedef ::hpx::lcos::base_lco_with_value<Value, RemoteValue, \
::hpx::traits::detail::Tag> \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag); \
HPX_REGISTER_ACTION( \
HPX_PP_CAT(base_lco_with_value_, Name)::set_value_action, \
HPX_PP_CAT(set_value_action_, Name)) \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::set_value_action, \
HPX_PP_CAT(HPX_PP_CAT(set_value_action_, Name), Tag)) \
HPX_REGISTER_ACTION( \
HPX_PP_CAT(base_lco_with_value_, Name)::get_value_action, \
HPX_PP_CAT(get_value_action_, Name)) \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag):: \
get_value_action, \
HPX_PP_CAT(HPX_PP_CAT(get_value_action_, Name), Tag)) \
HPX_ACTION_USES_MESSAGE_COALESCING_NOTHROW_DEFINITION( \
HPX_PP_CAT(base_lco_with_value_, Name)::set_value_action, \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::set_value_action, \
"lco_set_value_action", std::size_t(-1), std::size_t(-1)) \
/**/

Expand All @@ -325,33 +349,37 @@ namespace hpx { namespace traits
Value, RemoteValue, Name, ActionIdGet, ActionIdSet) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_ID_6( \
Value, RemoteValue, Name, ActionIdGet, ActionIdSet, \
::hpx::traits::detail::managed_component_tag) \
managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_ID_4( \
Value, Name, ActionIdGet, ActionIdSet) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_ID_6(Value, Value, Name, \
ActionIdGet, ActionIdSet, ::hpx::traits::detail::managed_component_tag)\
ActionIdGet, ActionIdSet, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_ID_5( \
Value, RemoteValue, Name, ActionIdGet, ActionIdSet) \
HPX_REGISTER_BASE_LCO_WITH_VALUE_ID_6(Value, RemoteValue, Name, \
ActionIdGet, ActionIdSet, ::hpx::traits::detail::managed_component_tag)\
ActionIdGet, ActionIdSet, managed_component_tag) \
/**/

#define HPX_REGISTER_BASE_LCO_WITH_VALUE_ID_6( \
Value, RemoteValue, Name, ActionIdGet, ActionIdSet, Tag) \
typedef ::hpx::lcos::base_lco_with_value< Value, RemoteValue, Tag> \
HPX_PP_CAT(base_lco_with_value_, Name); \
Value, RemoteValue, Name, ActionIdGet, ActionIdSet, Tag) \
typedef ::hpx::lcos::base_lco_with_value<Value, RemoteValue, \
::hpx::traits::detail::Tag> \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag); \
HPX_REGISTER_ACTION_ID( \
HPX_PP_CAT(base_lco_with_value_, Name)::set_value_action, \
HPX_PP_CAT(set_value_action_, Name), ActionIdSet) \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::set_value_action, \
HPX_PP_CAT(HPX_PP_CAT(set_value_action_, Name), Tag), ActionIdSet) \
HPX_REGISTER_ACTION_ID( \
HPX_PP_CAT(base_lco_with_value_, Name)::get_value_action, \
HPX_PP_CAT(get_value_action_, Name), ActionIdGet) \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::get_value_action, \
HPX_PP_CAT(HPX_PP_CAT(get_value_action_, Name), Tag), ActionIdGet) \
HPX_ACTION_USES_MESSAGE_COALESCING_NOTHROW_DEFINITION( \
HPX_PP_CAT(base_lco_with_value_, Name)::set_value_action, \
HPX_PP_CAT(HPX_PP_CAT(base_lco_with_value_, Name), Tag) \
::set_value_action, \
"lco_set_value_action", std::size_t(-1), std::size_t(-1)) \
/**/

Expand Down
56 changes: 8 additions & 48 deletions hpx/lcos/detail/async_implementations.hpp
Expand Up @@ -109,23 +109,6 @@ namespace hpx { namespace detail
}
};

template <typename Action, typename Result>
struct sync_local_invoke<Action, lcos::future<Result> >
{
template <typename ...Ts>
HPX_FORCEINLINE static lcos::future<Result>
call(naming::id_type const&, naming::address && addr, Ts &&... vs)
{
HPX_ASSERT(!!addr);
HPX_ASSERT(traits::component_type_is_compatible<
typename Action::component_type
>::call(addr));

return Action::execute_function(addr.address_, addr.type_,
std::forward<Ts>(vs)...);
}
};

///////////////////////////////////////////////////////////////////////////
template <typename Action, typename Result>
struct sync_local_invoke_cb
Expand All @@ -149,33 +132,10 @@ namespace hpx { namespace detail
}
};

template <typename Action, typename Result>
struct sync_local_invoke_cb<Action, lcos::future<Result> >
{
template <typename Callback, typename ...Ts>
HPX_FORCEINLINE static lcos::future<Result>
call(naming::id_type const&, naming::address && addr, Callback && cb,
Ts &&... vs)
{
HPX_ASSERT(!!addr);
HPX_ASSERT(traits::component_type_is_compatible<
typename Action::component_type
>::call(addr));

lcos::future<Result> f = Action::execute_function(
addr.address_, addr.type_, std::forward<Ts>(vs)...);

// invoke callback
cb(boost::system::error_code(), parcelset::parcel());

return f;
}
};

///////////////////////////////////////////////////////////////////////////
template <typename Action, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_impl(launch policy, hpx::id_type const& id, Ts&&... vs)
{
Expand Down Expand Up @@ -238,7 +198,7 @@ namespace hpx { namespace detail

template <typename Action, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_impl(hpx::detail::sync_policy, hpx::id_type const& id, Ts&&... vs)
{
Expand Down Expand Up @@ -282,7 +242,7 @@ namespace hpx { namespace detail

template <typename Action, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_impl(hpx::detail::async_policy, hpx::id_type const& id, Ts&&... vs)
{
Expand All @@ -305,7 +265,7 @@ namespace hpx { namespace detail

template <typename Action, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_impl(hpx::detail::deferred_policy, hpx::id_type const& id, Ts&&... vs)
{
Expand Down Expand Up @@ -333,7 +293,7 @@ namespace hpx { namespace detail
///
template <typename Action, typename Callback, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_cb_impl(launch policy, hpx::id_type const& id, Callback&& cb, Ts&&... vs)
{
Expand Down Expand Up @@ -401,7 +361,7 @@ namespace hpx { namespace detail

template <typename Action, typename Callback, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_cb_impl(hpx::detail::sync_policy, hpx::id_type const& id, Callback&& cb,
Ts&&... vs)
Expand Down Expand Up @@ -451,7 +411,7 @@ namespace hpx { namespace detail

template <typename Action, typename Callback, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_cb_impl(hpx::detail::async_policy, hpx::id_type const& id, Callback&& cb,
Ts&&... vs)
Expand All @@ -476,7 +436,7 @@ namespace hpx { namespace detail

template <typename Action, typename Callback, typename ...Ts>
hpx::future<
typename hpx::traits::extract_action<Action>::local_result_type
typename hpx::traits::extract_action<Action>::type::local_result_type
>
async_cb_impl(hpx::detail::deferred_policy, hpx::id_type const& id,
Callback&& cb, Ts&&... vs)
Expand Down

0 comments on commit f036fe6

Please sign in to comment.