Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2117: location: add new assertions to detect duplicate insertions #2118

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/vt/topos/location/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,22 @@ struct EntityLocationCoord : LocationCoord {
*/
LocInstType getInst() const;

/**
* \brief Whether dynamic membership is allowed
*
* \return whether it is allowed
*/
bool hasDynamicMembership() const { return dynamic_membership_; }

/**
* \brief Set whether dynamic membership is allowed
*
* \param[in] in_dynamic_membership whether it is allowed
*/
void setDynamicMembership(bool in_dynamic_membership) {
dynamic_membership_ = in_dynamic_membership;
}

private:
LocInstType this_inst = no_loc_inst;

Expand All @@ -461,6 +477,10 @@ struct EntityLocationCoord : LocationCoord {

// List of nodes that inquire about an entity that require an update
LocAsksType loc_asks_;

/// Whether the managed entities have dynamic membership (deletions/insertions
/// after construction)
bool dynamic_membership_ = false;
};

}} // end namespace vt::location
Expand Down
14 changes: 14 additions & 0 deletions src/vt/topos/location/location.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ void EntityLocationCoord<EntityID>::registerEntity(

local_registered_.insert(id);

if (not migrated and not hasDynamicMembership()) {
vtAssert(
not recs_.exists(id),
"Duplicate insertion of the same entity is not allowed"
);
}

recs_.insert(id, home, LocRecType{id, eLocState::Local, this_node});

if (msg_action != nullptr) {
Expand Down Expand Up @@ -788,6 +795,13 @@ void EntityLocationCoord<EntityID>::updatePendingRequest(

pending_actions_.erase(pending_iter);
} else {
if (not hasDynamicMembership()) {
vtAssert(
not recs_.exists(id),
"Duplicate insertion of the same entity is not allowed"
);
}

recs_.insert(id, home_node, LocRecType{id, eLocState::Remote, node});

// trigger any pending actions upon registration
Expand Down
3 changes: 2 additions & 1 deletion src/vt/vrt/collection/collection_builder.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ void CollectionManager::makeCollectionImpl(param::ConstructParams<ColT>& po) {

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda ugly that a method named getFoo has a side effect of creating said Foo

auto lm = theLocMan()->getCollectionLM<IndexType>(proxy);
lm->setDynamicMembership(has_dynamic_membership);

// Insert action on cleanup for this collection
addCleanupFn<ColT>(proxy);
Expand Down