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

Enable Utilities::MPI::NoncontiguousPartitioner to handle padding #9639

Merged
merged 1 commit into from Mar 18, 2020

Conversation

peterrum
Copy link
Member

@peterrum peterrum commented Mar 8, 2020

This PR enables Utilities::MPI::NoncontiguousPartitioner to handle padding in the source and destination vectors. The user can indicate that the purpose of a vector entry is only for padding by inserting numbers::invalid_dof_index into std::vector<types::global_dof_index> &indices_has and/or std::vector<types::global_dof_index> &indices_want.

I still need to write an appropriate test.

FYI @nfehn @kronbichler

return it == indices_has.end() ? 0 : (*it + 1);
[&indices_has_clean]() {
const auto it =
max_element(indices_has_clean.begin(), indices_has_clean.end());
Copy link
Member

Choose a reason for hiding this comment

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

You'll want to use the following -- the current form may not work with some compilers.

Suggested change
max_element(indices_has_clean.begin(), indices_has_clean.end());
std::max_element(indices_has_clean.begin(), indices_has_clean.end());

const auto it =
max_element(indices_want.begin(), indices_want.end());
return it == indices_want.end() ? 0 : (*it + 1);
max_element(indices_want_clean.begin(), indices_want_clean.end());
Copy link
Member

Choose a reason for hiding this comment

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

same here

@peterrum peterrum changed the title Enable Utilities::MPI::NoncontiguousPartitioner to handle padding [WIP] Enable Utilities::MPI::NoncontiguousPartitioner to handle padding Mar 16, 2020
@peterrum
Copy link
Member Author

I have integrate @bangerth's suggestions, made a bug fix, and added a test. I think this PR is ready to be reviewed.

Copy link
Member

@kronbichler kronbichler left a comment

Choose a reason for hiding this comment

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

Looks good except for an unnecessary lambda (pre-existing, but it got worse with longer variable names).

Comment on lines 203 to 213
const types::global_dof_index n_dofs = Utilities::MPI::max(
std::max(
[&indices_has]() {
const auto it = max_element(indices_has.begin(), indices_has.end());
return it == indices_has.end() ? 0 : (*it + 1);
[&indices_has_clean]() {
const auto it = std::max_element(indices_has_clean.begin(),
indices_has_clean.end());
return it == indices_has_clean.end() ? 0 : (*it + 1);
}(),
[&indices_want]() {
const auto it =
max_element(indices_want.begin(), indices_want.end());
return it == indices_want.end() ? 0 : (*it + 1);
[&indices_want_clean]() {
const auto it = std::max_element(indices_want_clean.begin(),
indices_want_clean.end());
return it == indices_want_clean.end() ? 0 : (*it + 1);
Copy link
Member

Choose a reason for hiding this comment

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

This would be easier to read if you avoided the lambdas inside std::max in favor of plain code here with temporary variable like types::global_dof_index max_has = ... and max_wants.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have made the change.

@kronbichler
Copy link
Member

/rebuild

Comment on lines 203 to 207
const types::global_dof_index local_n_dofs_has = [&indices_has_clean]() {
const auto it =
std::max_element(indices_has_clean.begin(), indices_has_clean.end());
return it == indices_has_clean.end() ? 0 : (*it + 1);
}();
Copy link
Member

Choose a reason for hiding this comment

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

We're almost there. I was thinking about this code and similar for the next block below:

Suggested change
const types::global_dof_index local_n_dofs_has = [&indices_has_clean]() {
const auto it =
std::max_element(indices_has_clean.begin(), indices_has_clean.end());
return it == indices_has_clean.end() ? 0 : (*it + 1);
}();
const types::global_dof_index local_n_dofs_has = indices_has_clean.empty() ?
0 : *std::max_element(indices_has_clean.begin(), indices_has_clean.end());

Copy link
Member Author

@peterrum peterrum Mar 18, 2020

Choose a reason for hiding this comment

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

I have made the change.

@kronbichler
Copy link
Member

Excellent, thank you!

@kronbichler kronbichler merged commit 31592ac into dealii:master Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants