Skip to content

Commit

Permalink
#1554: location: remove ColT From location manager template
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Oct 19, 2021
1 parent 83f885f commit 56df696
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 41 deletions.
18 changes: 9 additions & 9 deletions src/vt/topos/location/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ struct LocationManager : runtime::component::Component<LocationManager> {
using VrtLocProxyType = EntityLocationCoord<VirtualProxyType>;
using DataRepType = EntityLocationCoord<DataRepIDType>;

template <typename ColT, typename IndexT>
using CollectionProxyType = ::vt::vrt::VirtualElmProxyType<ColT, IndexT>;
template <typename ColT, typename IndexT>
using VrtColl = EntityLocationCoord<CollectionProxyType<ColT, IndexT>>;
template <typename ColT, typename IndexT>
using CollectionLocType = PtrType<VrtColl<ColT, IndexT>>;
template <typename IndexT>
using IndexedElmType = EntityLocationCoord<IndexT>;

template <typename IndexT>
using CollectionLocType = PtrType<IndexT>;

using LocErasureType = LocationCoord;
using LocDeleterType = std::function<void(LocErasureType*)>;
using CollectionLocErasedType = std::unique_ptr<
Expand Down Expand Up @@ -127,15 +127,15 @@ struct LocationManager : runtime::component::Component<LocationManager> {
*
* \return pointer to the coordinator, typed on the collection/index
*/
template <typename ColT, typename IndexT>
VrtColl<ColT, IndexT>* getCollectionLM(VirtualProxyType const& proxy);
template <typename IndexT>
IndexedElmType<IndexT>* getCollectionLM(VirtualProxyType const& proxy);

/**
* \internal \brief Insert a new location coordinator for a collection
*
* \param[in] proxy the collection proxy bits
*/
template <typename ColT, typename IndexT>
template <typename IndexT>
void insertCollectionLM(VirtualProxyType const& proxy);

public:
Expand Down
12 changes: 6 additions & 6 deletions src/vt/topos/location/manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@

namespace vt { namespace location {

template <typename ColT, typename IndexT>
template <typename IndexT>
void LocationManager::insertCollectionLM(VirtualProxyType const& proxy) {
using LocType = VrtColl<ColT, IndexT>;
using LocType = IndexedElmType<IndexT>;
auto loc_man_typed = new LocType(
collection_lm_tag_t{}, static_cast<LocInstType>(proxy)
);
Expand All @@ -76,10 +76,10 @@ void LocationManager::insertCollectionLM(VirtualProxyType const& proxy) {
);
}

template <typename ColT, typename IndexT>
LocationManager::VrtColl<ColT, IndexT>*
template <typename IndexT>
LocationManager::IndexedElmType<IndexT>*
LocationManager::getCollectionLM(VirtualProxyType const& proxy) {
using LocType = VrtColl<ColT, IndexT>;
using LocType = IndexedElmType<IndexT>;

auto loc_iter = collectionLoc.find(proxy);
auto const& found = loc_iter != collectionLoc.end();
Expand All @@ -91,7 +91,7 @@ LocationManager::getCollectionLM(VirtualProxyType const& proxy) {
);

if (!found) {
LocationManager::insertCollectionLM<ColT, IndexT>(proxy);
LocationManager::insertCollectionLM<IndexT>(proxy);
loc_iter = collectionLoc.find(proxy);
} else if (!found) {
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/collection_builder.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void CollectionManager::makeCollectionImpl(param::ConstructParams<ColT>& po) {

// Invoke getCollectionLM() to create a new location manager instance for
// this collection
theLocMan()->getCollectionLM<ColT, IndexType>(proxy);
theLocMan()->getCollectionLM<IndexType>(proxy);

// Insert action on cleanup for this collection
addCleanupFn<ColT>(proxy);
Expand Down
32 changes: 13 additions & 19 deletions src/vt/vrt/collection/manager.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1178,12 +1178,12 @@ messaging::PendingSend CollectionManager::sendMsgUntypedHandler(
theMsg()->pushEpoch(cur_epoch);
auto home_node = theCollection()->getMappedNode<ColT>(col_proxy, idx);
// route the message to the destination using the location manager
auto lm = theLocMan()->getCollectionLM<ColT, IdxT>(col_proxy);
auto lm = theLocMan()->getCollectionLM<IdxT>(col_proxy);
vtAssert(lm != nullptr, "LM must exist");
theMsg()->markAsCollectionMessage(msg);
lm->template routeMsgSerializeHandler<
MsgT, collectionMsgTypedHandler<ColT,IdxT,MsgT>
>(toProxy, home_node, msg);
>(idx, home_node, msg);
theMsg()->popEpoch(cur_epoch);
}
};
Expand Down Expand Up @@ -1233,16 +1233,16 @@ bool CollectionManager::insertCollectionElement(
});

if (is_migrated_in) {
theLocMan()->getCollectionLM<ColT, IndexT>(proxy)->entityImmigrated(
VrtElmProxy<ColT, IndexT>{proxy,idx}, home_node, migrated_from,
theLocMan()->getCollectionLM<IndexT>(proxy)->entityImmigrated(
idx, home_node, migrated_from,
CollectionManager::collectionMsgHandler<ColT, IndexT>
);
elm_holder->applyListeners(
listener::ElementEventEnum::ElementMigratedIn, idx
);
} else {
theLocMan()->getCollectionLM<ColT, IndexT>(proxy)->registerEntity(
VrtElmProxy<ColT, IndexT>{proxy,idx}, home_node,
theLocMan()->getCollectionLM<IndexT>(proxy)->registerEntity(
idx, home_node,
CollectionManager::collectionMsgHandler<ColT, IndexT>
);
elm_holder->applyListeners(
Expand Down Expand Up @@ -1366,7 +1366,7 @@ void CollectionManager::insertMetaCollection(
* This is to ensure that the collection LM instance gets created so that
* messages can be forwarded properly
*/
theLocMan()->getCollectionLM<ColT,IndexType>(proxy);
theLocMan()->getCollectionLM<IndexType>(proxy);

/**
* Type-erase some lambdas for doing the collective broadcast that collects up
Expand Down Expand Up @@ -1459,9 +1459,8 @@ template <typename ColT, typename MsgT>
using IndexType = typename ColT::IndexType;
auto proxy = msg->proxy_;
auto idx = msg->idx_;
auto lm = theLocMan()->getCollectionLM<ColT, IndexType>(proxy.getProxy());
VrtElmProxy<ColT, IndexType> elm{proxy.getProxy(),idx};
auto elm_lives_somewhere = lm->isCached(elm);
auto lm = theLocMan()->getCollectionLM<IndexType>(proxy.getProxy());
auto elm_lives_somewhere = lm->isCached(idx);

vt_debug_print(
verbose, vrt_coll,
Expand All @@ -1474,7 +1473,7 @@ template <typename ColT, typename MsgT>
} else {
auto const insert_node = msg->construct_node_;
// reserve the slot to stop any race with other insertions
lm->registerEntityRemote(elm, msg->home_node_, insert_node);
lm->registerEntityRemote(idx, msg->home_node_, insert_node);

// send a message back that the insertion shall proceed
auto send_msg = makeMessage<InsertMsg<ColT, MsgT>>(
Expand Down Expand Up @@ -1696,11 +1695,8 @@ void CollectionManager::insert(
// element exists here and is live--return
proceed_with_insertion = false;
} else {
auto lm = theLocMan()->getCollectionLM<ColT, IndexType>(
untyped_proxy
);
VrtElmProxy<ColT, IndexType> elm{untyped_proxy,idx};
auto elm_lives_somewhere = lm->isCached(elm);
auto lm = theLocMan()->getCollectionLM<IndexType>(untyped_proxy);
auto elm_lives_somewhere = lm->isCached(idx);
if (elm_lives_somewhere) {
// element exists somewhere in the system and since we are the home
// we check the cache to determine if it has been inserted
Expand Down Expand Up @@ -1893,9 +1889,7 @@ MigrateStatus CollectionManager::migrateOut(
MigrateMsgType, MigrateHandlers::migrateInHandler<ColT, IndexT>
>(dest, msg);

theLocMan()->getCollectionLM<ColT, IndexT>(col_proxy)->entityEmigrated(
proxy, dest
);
theLocMan()->getCollectionLM<IndexT>(col_proxy)->entityEmigrated(idx, dest);

/*
* Invoke the virtual epilog migrate out function
Expand Down
10 changes: 4 additions & 6 deletions src/vt/vrt/collection/messages/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,17 @@

namespace vt { namespace vrt { namespace collection {

template <typename MessageT, typename ColT>
using RoutedMessageType = LocationRoutedMsg<
::vt::vrt::VirtualElmProxyType<ColT, typename ColT::IndexType>, MessageT
>;
template <typename MessageT, typename IndexT>
using RoutedMessageType = LocationRoutedMsg<IndexT, MessageT>;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
static struct ColMsgWrapTagType { } ColMsgWrapTag { };
#pragma GCC diagnostic pop

template <typename ColT, typename BaseMsgT = ::vt::Message>
struct CollectionMessage : RoutedMessageType<BaseMsgT, ColT> {
using MessageParentType = RoutedMessageType<BaseMsgT, ColT>;
struct CollectionMessage : RoutedMessageType<BaseMsgT, typename ColT::IndexType> {
using MessageParentType = RoutedMessageType<BaseMsgT, typename ColT::IndexType>;
vt_msg_serialize_if_needed_by_parent();

/*
Expand Down

0 comments on commit 56df696

Please sign in to comment.