Skip to content

Commit

Permalink
voloctree: split mapped octant list build loop to make it more readable
Browse files Browse the repository at this point in the history
The split separates the loop in a first loop to find the first overlapping
rank of the reference mesh and the first overlapping octant of the mapped
mesh. A second loop fill the octant lists starting from data retrieved in
the previous one. This version of the algorithm should be safe, avoiding
evaluation of morton number of non-existing octants and giving empty lists
if no overlap occurs.
  • Loading branch information
marcocisternino committed Jan 29, 2024
1 parent b59ef91 commit c279845
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions src/voloctree/voloctree_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,41 +1232,52 @@ bool VolOctreeMapper::_recoverPartition()
std::map<int, std::vector<Octant>> list_octant;
std::map<int, std::vector<long>> list_id;
std::map<int, std::vector<long>> list_globalId;
uint32_t idx = 0;
for (int reference_rank : toreference_rank[m_rank]) {

// Initialize idx position in mapped tree to the first mapped
// octant inside the overlapping region
std::vector<int>::iterator overlap_ref_rank_end_it = toreference_rank[m_rank].end();
std::vector<int>::iterator first_overlap_rank_it = overlap_ref_rank_end_it;
uint32_t first_overlap_map_idx = 0;
for (std::vector<int>::iterator ref_rank_it = toreference_rank[m_rank].begin(); ref_rank_it != overlap_ref_rank_end_it; ++ref_rank_it) {
first_overlap_map_idx = 0;

This comment has been minimized.

Copy link
@andrea-iob

andrea-iob Jan 30, 2024

Member

Was the previous algorithm resetting first_overlap_map_idx (idx) for every rank?

This comment has been minimized.

Copy link
@marcocisternino

marcocisternino Jan 30, 2024

Author Member

I removed the loop and I fixed the second loop. Now on my test case it works up to 38 processes and it fails at 39.

int reference_rank = *ref_rank_it;
uint64_t reference_first_morton = partitionFDReference[reference_rank];
uint64_t reference_last_morton = partitionLDReference[reference_rank];
// Initialize idx position in mapped tree to the first mapped
// octant inside the overlapping region
uint64_t morton = mappedPatch->getTree().getLastDescMorton(idx);
uint64_t morton = mappedPatch->getTree().getLastDescMorton(first_overlap_map_idx);
while (morton < reference_first_morton) {
idx++;
if (idx == mappedPatch->getTree().getNumOctants()) {
first_overlap_map_idx++;
if (first_overlap_map_idx == mappedPatch->getTree().getNumOctants()) {
break;
}
morton = mappedPatch->getTree().getLastDescMorton(idx);
morton = mappedPatch->getTree().getLastDescMorton(first_overlap_map_idx);
}
if (idx == mappedPatch->getTree().getNumOctants()) {
continue;
}
// Fill partitioning info structure with mapped octants in the
// overlapping region
morton = mappedPatch->getTree().getMorton(idx);
while (morton < reference_last_morton) {
Octant oct = *mappedPatch->getTree().getOctant(idx);
list_octant[reference_rank].push_back(oct);
VolOctree::OctantInfo octantIfo(idx, true);
long id = mappedPatch->getOctantId(octantIfo);
list_id[reference_rank].push_back(id);
long globalId = mappedPatch->getTree().getGlobalIdx(idx);
list_globalId[reference_rank].push_back(globalId);
m_partitionIR.list_sent_octantIR.emplace_back(oct, id, globalId, reference_rank);
idx++;
if (idx == mappedPatch->getTree().getNumOctants()) {
--idx;
break;
first_overlap_rank_it = ref_rank_it;
}

// Fill partitioning info structure with mapped octants in the
// overlapping region
if (first_overlap_map_idx < mappedPatch->getTree().getNumOctants() ) {
uint32_t idx = first_overlap_map_idx;
bool exitLoop = false;
for (std::vector<int>::iterator ref_rank_it = first_overlap_rank_it; ref_rank_it != overlap_ref_rank_end_it && !exitLoop; ++ref_rank_it) {
int reference_rank = *ref_rank_it;
uint64_t reference_last_morton = partitionLDReference[reference_rank];
uint64_t morton = mappedPatch->getTree().getMorton(idx);
while (morton < reference_last_morton) {
Octant oct = *mappedPatch->getTree().getOctant(idx);
list_octant[reference_rank].push_back(oct);
VolOctree::OctantInfo octantIfo(idx, true);
long id = mappedPatch->getOctantId(octantIfo);
list_id[reference_rank].push_back(id);
long globalId = mappedPatch->getTree().getGlobalIdx(idx);
list_globalId[reference_rank].push_back(globalId);
m_partitionIR.list_sent_octantIR.emplace_back(oct, id, globalId, reference_rank);
idx++;
if (idx == mappedPatch->getTree().getNumOctants()) {
exitLoop = true;
break;
}
morton = mappedPatch->getTree().getMorton(idx);
}
morton = mappedPatch->getTree().getMorton(idx);
}
}

Expand Down

0 comments on commit c279845

Please sign in to comment.