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

#142: phase: allow starting at non-zero phase #143

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lifflander
Copy link
Contributor

Fixes #142

@lifflander lifflander linked an issue Feb 26, 2025 that may be closed by this pull request
Copy link
Contributor

@cwschilly cwschilly left a 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.

Comment on lines +651 to 661
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));
}
}
Copy link
Contributor

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

Copy link
Contributor Author

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()) {
Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@lifflander
Copy link
Contributor Author

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.

Getting the number of phases should be a constant time operation of just looking at the size of the phase_info for rank 0. The min_phase does cost more, but I agree that it should just happen once.

@lifflander
Copy link
Contributor Author

I have made min phase cached so it doesn't compute each time, which should improve performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when phases don't start at zero
2 participants