Skip to content

Commit

Permalink
#1490: vrt_coll: finish generalizing code
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Aug 2, 2021
1 parent a6cb570 commit f144f34
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/vt/vrt/collection/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1871,9 +1871,12 @@ struct CollectionManager
typename ColT::IndexType range, std::string const& file_base
);

private:
template <typename ColT, typename IdxT = typename ColT::IndexType>
struct RestoreMigrateMsg : vt::Message {
template <
typename ColT,
typename MsgT = vt::Message,
typename IdxT = typename ColT::IndexType
>
struct RestoreMigrateMsg : MsgT {
RestoreMigrateMsg() = default;
RestoreMigrateMsg(NodeType in_to_node, IdxT in_idx, CollectionProxyWrapType<ColT> in_proxy)
: to_node_(in_to_node),
Expand All @@ -1887,17 +1890,18 @@ struct CollectionManager
};

template <typename ColT, typename IdxT = typename ColT::IndexType>
struct RestoreMigrateColMsg : RestoreMigrateMsg<ColT, IdxT>, CollectionMessage<ColT> {
struct RestoreMigrateColMsg
: RestoreMigrateMsg<ColT, CollectionMessage<ColT>, IdxT>
{
RestoreMigrateColMsg() = default;
RestoreMigrateColMsg(NodeType in_to_node, IdxT in_idx, CollectionProxyWrapType<ColT> in_proxy)
: RestoreMigrateMsg<ColT>(in_to_node, in_idx, in_proxy)
: RestoreMigrateMsg<ColT, CollectionMessage<ColT>, IdxT>(in_to_node, in_idx, in_proxy)
{ }
};

template <typename ColT>
static void restoreHandler(RestoreMigrateMsg<ColT>* msg);

public:
/**
* \brief Restore the collection (collective) from file on top of an existing
* collection. Migrates collection elements to the rank saved from the
Expand Down
15 changes: 10 additions & 5 deletions src/vt/vrt/collection/manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3162,7 +3162,9 @@ void CollectionManager::checkpointToFile(

namespace detail {
template <typename ColT>
inline void restoreOffHomeElement(CollectionManager::RestoreMigrateColMsg<ColT>* msg, ColT*) {
inline void restoreOffHomeElement(
CollectionManager::RestoreMigrateColMsg<ColT>* msg, ColT*
) {
auto idx = msg->idx_;
auto node = msg->to_node_;
auto proxy = msg->proxy_;
Expand Down Expand Up @@ -3219,10 +3221,13 @@ void CollectionManager::restoreFromFileInPlace(
vtAssertExpr(mapped_node != uninitialized_destination);
auto this_node = theContext()->getNode();

auto msg = makeMessage<RestoreMigrateMsg<ColT>>(this_node, idx, proxy);
theMsg()->sendMsg<
RestoreMigrateMsg<ColT>, restoreHandler<ColT>
>(mapped_node, msg);
using MsgType = RestoreMigrateMsg<ColT>;
auto msg = makeMessage<MsgType>(this_node, idx, proxy);
if (mapped_node != this_node) {
theMsg()->sendMsg<MsgType, restoreHandler<ColT>>(mapped_node, msg);
} else {
restoreHandler<ColT>(msg.get());
}
}
}
});
Expand Down

0 comments on commit f144f34

Please sign in to comment.