Skip to content

Commit

Permalink
Allowing for LCOs to be simple components
Browse files Browse the repository at this point in the history
- flyby: refactored all HPX_REGISTER_BASE_LCO* macros
- flyby: pass through component type to all thread execution functions
  • Loading branch information
hkaiser committed Jul 11, 2017
1 parent c3d8bdf commit ae34321
Show file tree
Hide file tree
Showing 29 changed files with 576 additions and 263 deletions.
7 changes: 5 additions & 2 deletions examples/quickstart/data_actions.cpp
Expand Up @@ -48,7 +48,8 @@ struct data_get_action

// Return the referenced data
static data_type invoke(
hpx::naming::address::address_type /*lva*/)
hpx::naming::address::address_type /*lva*/,
naming::address::component_type /*comptype*/)
{
return *Data;
}
Expand All @@ -75,7 +76,9 @@ struct data_set_action

// Return the referenced data
static void invoke(
hpx::naming::address::address_type /*lva*/, data_type const& data)
hpx::naming::address::address_type /*lva*/,
naming::address::component_type /*comptype*/,
data_type const& data)
{
*Data = data;
}
Expand Down
288 changes: 219 additions & 69 deletions hpx/lcos/base_lco_with_value.hpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hpx/lcos/detail/async_implementations.hpp
Expand Up @@ -120,7 +120,7 @@ namespace hpx { namespace detail
typename Action::component_type
>::call(addr));

return Action::execute_function(addr.address_,
return Action::execute_function(addr.address_, addr.type_,
std::forward<Ts>(vs)...);
}
};
Expand Down Expand Up @@ -162,7 +162,7 @@ namespace hpx { namespace detail
>::call(addr));

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

// invoke callback
cb(boost::system::error_code(), parcelset::parcel());
Expand Down
2 changes: 1 addition & 1 deletion hpx/lcos/detail/promise_lco.hpp
Expand Up @@ -203,7 +203,7 @@ namespace traits {
if (value == components::component_invalid)
{
value = derived_component_type(++detail::unique_type,
components::component_base_lco_with_value);
components::component_base_lco_with_value_managed);
}
return value;
}
Expand Down
39 changes: 25 additions & 14 deletions hpx/lcos/packaged_action.hpp
Expand Up @@ -383,8 +383,7 @@ namespace lcos {
traits::component_type_is_compatible<component_type>::call(
addr));

if (traits::component_supports_migration<
component_type>::call())
if (traits::component_supports_migration<component_type>::call())
{
r = traits::action_was_object_migrated<Action>::call(
id, addr.address_);
Expand All @@ -393,15 +392,18 @@ namespace lcos {
// local, direct execution
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
addr.address_, addr.type_,
std::forward<Ts>(vs)...));
return;
}
}
else
{
// local, direct execution
this->shared_state_->set_data(action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, addr.type_,
std::forward<Ts>(vs)...));
return;
}
}
Expand Down Expand Up @@ -434,15 +436,18 @@ namespace lcos {
// local, direct execution
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
addr.address_, addr.type_,
std::forward<Ts>(vs)...));
return;
}
}
else
{
// local, direct execution
this->shared_state_->set_data(action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, addr.type_,
std::forward<Ts>(vs)...));
return;
}
}
Expand Down Expand Up @@ -476,7 +481,8 @@ namespace lcos {
// local, direct execution
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
addr.address_, addr.type_,
std::forward<Ts>(vs)...));

// invoke callback
cb(boost::system::error_code(), parcelset::parcel());
Expand All @@ -486,8 +492,10 @@ namespace lcos {
else
{
// local, direct execution
this->shared_state_->set_data(action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, addr.type_,
std::forward<Ts>(vs)...));

// invoke callback
cb(boost::system::error_code(), parcelset::parcel());
Expand Down Expand Up @@ -523,7 +531,8 @@ namespace lcos {
// local, direct execution
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
addr.address_, addr.type_,
std::forward<Ts>(vs)...));

// invoke callback
cb(boost::system::error_code(), parcelset::parcel());
Expand All @@ -533,8 +542,10 @@ namespace lcos {
else
{
// local, direct execution
this->shared_state_->set_data(action_type::execute_function(
addr.address_, std::forward<Ts>(vs)...));
this->shared_state_->set_data(
action_type::execute_function(
addr.address_, addr.type_,
std::forward<Ts>(vs)...));

// invoke callback
cb(boost::system::error_code(), parcelset::parcel());
Expand Down
2 changes: 1 addition & 1 deletion hpx/lcos/server/latch.hpp
Expand Up @@ -134,7 +134,7 @@ HPX_REGISTER_ACTION_DECLARATION(
hpx::lcos::server::latch::wait_action,
hpx_lcos_server_latch_wait_action)

HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION2(
HPX_REGISTER_BASE_LCO_WITH_VALUE_DECLARATION(
bool, std::ptrdiff_t, bool_std_ptrdiff);

#endif
Expand Down
8 changes: 5 additions & 3 deletions hpx/lcos_fwd.hpp
Expand Up @@ -8,6 +8,7 @@
#define HPX_LCOS_FWD_HPP

#include <hpx/config.hpp>
#include <hpx/traits/is_component.hpp>
#include <hpx/traits/promise_local_result.hpp>
#include <hpx/traits/promise_remote_result.hpp>

Expand All @@ -26,11 +27,12 @@ namespace hpx
class HPX_EXPORT base_lco;

template <typename Result, typename RemoteResult =
typename traits::promise_remote_result<Result>::type>
typename traits::promise_remote_result<Result>::type,
typename ComponentType = traits::detail::managed_component_tag>
class base_lco_with_value;

template <>
class base_lco_with_value<void, void>;
template <typename ComponentType>
class base_lco_with_value<void, void, ComponentType>;

template <typename Result, typename RemoteResult =
typename traits::promise_remote_result<Result>::type>
Expand Down
8 changes: 5 additions & 3 deletions hpx/runtime/actions/base_action.hpp
Expand Up @@ -74,7 +74,8 @@ namespace hpx { namespace actions
/// for a \a thread.
virtual threads::thread_function_type
get_thread_function(naming::id_type&& target,
naming::address_type lva) = 0;
naming::address_type lva,
naming::address::component_type comptype) = 0;

/// return the id of the locality of the parent thread
virtual std::uint32_t get_parent_locality_id() const = 0;
Expand All @@ -96,7 +97,7 @@ namespace hpx { namespace actions

/// Perform thread initialization
virtual void schedule_thread(naming::gid_type const& target,
naming::address_type lva,
naming::address_type lva, naming::component_type comptype,
std::size_t num_thread) = 0;

/// Return whether the given object was migrated
Expand All @@ -119,7 +120,8 @@ namespace hpx { namespace actions

virtual void load_schedule(serialization::input_archive& ar,
naming::gid_type&& target, naming::address_type lva,
std::size_t num_thread, bool& deferred_schedule) = 0;
naming::component_type comptype, std::size_t num_thread,
bool& deferred_schedule) = 0;

/// The function \a get_serialization_id returns the id which has been
/// associated with this action (mainly used for serialization purposes).
Expand Down

0 comments on commit ae34321

Please sign in to comment.