Skip to content

Commit

Permalink
Revert "Trying to split off swarm tags from field tags"
Browse files Browse the repository at this point in the history
This reverts commit 09a62fa.
  • Loading branch information
brryan committed May 16, 2024
1 parent 5e7aff3 commit 33d92a4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/bvals/bvals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void BoundarySwarm::SetupPersistentMPI() {
NeighborBlock &nb = pmb->neighbors[n];
// Neighbor on different MPI process
if (nb.rank != Globals::my_rank) {
send_tag[nb.bufid] = pmb->pmy_mesh->tag_map.GetSwarmTag(pmb.get(), nb);
recv_tag[nb.bufid] = pmb->pmy_mesh->tag_map.GetSwarmTag(pmb.get(), nb);
send_tag[nb.bufid] = pmb->pmy_mesh->tag_map.GetTag(pmb.get(), nb);
recv_tag[nb.bufid] = pmb->pmy_mesh->tag_map.GetTag(pmb.get(), nb);
if (bd_var_.req_send[nb.bufid] != MPI_REQUEST_NULL) {
MPI_Request_free(&bd_var_.req_send[nb.bufid]);
}
Expand Down
22 changes: 1 addition & 21 deletions src/bvals/comms/tag_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ void TagMap::AddMeshDataToMap(std::shared_ptr<MeshData<Real>> &md) {
auto &pair_map = map_[other_rank];
// Add channel key with an invalid tag
pair_map[MakeChannelPair(pmb, nb)] = -1;
if (swarm_map_.count(other_rank) < 1) swarm_map_[other_rank] = rank_pair_map_t();
auto &swarm_pair_map = swarm_map_[other_rank];
// Add channel key with an invalid tag
swarm_pair_map[MakeChannelPair(pmb, nb)] = -1;
}
}
}
Expand All @@ -92,22 +88,15 @@ void TagMap::ResolveMap() {
PARTHENON_FAIL("MPI error, cannot query largest supported MPI tag value.");
}
#endif
auto it = map_.begin();
auto swarm_it = swarm_map_.begin();
while (it != map_.end() && swarm_it != swarm_map_.end()) {
for (auto it = map_.begin(); it != map_.end(); ++it) {
auto &pair_map = it->second;
int idx = 0;
std::for_each(pair_map.begin(), pair_map.end(),
[&idx](auto &pair) { pair.second = idx++; });
auto &swarm_pair_map = swarm_it->second;
std::for_each(swarm_pair_map.begin(), swarm_pair_map.end(),
[&idx](auto &swarm_pair) { swarm_pair.second = idx++; });
#ifdef MPI_PARALLEL
if (idx > (*reinterpret_cast<int *>(max_tag)) && it->first != Globals::my_rank)
PARTHENON_FAIL("Number of tags exceeds the maximum allowed by this MPI version.");
#endif
++it;
++swarm_it;
}
}

Expand All @@ -120,13 +109,4 @@ int TagMap::GetTag(const MeshBlock *pmb, const NeighborBlock &nb) {
return pair_map[cpair];
}

int TagMap::GetSwarmTag(const MeshBlock *pmb, const NeighborBlock &nb) {
const int other_rank = nb.rank;
auto &swarm_pair_map = swarm_map_[other_rank];
auto cpair = MakeChannelPair(pmb, nb);
PARTHENON_REQUIRE(swarm_pair_map.count(cpair) == 1,
"Trying to get tag for key that hasn't been entered.\n");
return swarm_pair_map[cpair];
}

} // namespace parthenon
2 changes: 0 additions & 2 deletions src/bvals/comms/tag_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class TagMap {
using tag_map_t = std::unordered_map<int, rank_pair_map_t>;

tag_map_t map_;
tag_map_t swarm_map_;

// Given the two blocks (one described by the MeshBlock and the other described by the
// firsts NeighborBlock information) return an ordered pair of BlockGeometricElementIds
Expand All @@ -109,7 +108,6 @@ class TagMap {
// After the map has been resolved, get the tag for a particular MeshBlock NeighborBlock
// pair
int GetTag(const MeshBlock *pmb, const NeighborBlock &nb);
int GetSwarmTag(const MeshBlock *pmb, const NeighborBlock &nb);
};
} // namespace parthenon

Expand Down

0 comments on commit 33d92a4

Please sign in to comment.