-
Notifications
You must be signed in to change notification settings - Fork 0
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
#142: phase: allow starting at non-zero phase #143
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be more efficient to have a single function find both the number of phases n_phases
and the minimum phase min_phase
and store both as member variables of info
. This would reduce the amount of times we have to loop through all ranks and phases.
if (auto phase_work = phase_history.find(phase); | ||
phase_work != phase_history.end()) { | ||
|
||
// Get all objects at specified phase | ||
auto& object_work_at_phase = phase_work->second.getObjectWork(); | ||
// Get all objects at specified phase | ||
auto& object_work_at_phase = phase_work->second.getObjectWork(); | ||
|
||
for (auto const& [elm_id, obj_work] : object_work_at_phase) { | ||
// fmt::print(" Object Id: {}\n", elm_id); | ||
objects_at_phase.insert(std::make_pair(elm_id, obj_work)); | ||
for (auto const& [elm_id, obj_work] : object_work_at_phase) { | ||
// fmt::print(" Object Id: {}\n", elm_id); | ||
objects_at_phase.insert(std::make_pair(elm_id, obj_work)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add an else
block with a warning or error message in case the phase is not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a warning or error either of these places. You could try to normalize your edges and find that for the phase you are checking there is no phase work.
} | ||
if (communications_to_add.empty()) { | ||
return; | ||
if (phaseWork.find(phase) != phaseWork.end()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, more error handling may be helpful
* | ||
* \return the minimim phase in the data | ||
*/ | ||
PhaseType getMinPhase() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we iterate through all ranks twice--first to get the number of phases (getNumPhases()
) and then again here to get the minimum phase (getMinPhase()
).
We could get both of these values (the number and the min) from a single for
loop, e.g. by calling rank_info.getNumPhases()
in this function and storing it as a member of info
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getNumPhases
actually just extracts the count of phases from rank 0 (it doesn't look at values to determine if there are holes or where it starts). It then loops through the other ranks as an error check to determine if they also have the same number of phases.
The count of phases is just the size of the unordered_map, which tells us nothing about the min. We must actually examine the values because they are unordered in the map.
Getting the number of phases should be a constant time operation of just looking at the size of the |
I have made min phase cached so it doesn't compute each time, which should improve performance. |
Fixes #142