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
Address the pesky 'MPI_Comm as void*' problem with the SUNDIALS interfaces #15113
Conversation
The correct comment is here: #15086 (review) |
Assert(v->content != nullptr, ExcInternalError()); | ||
auto *pContent = | ||
reinterpret_cast<NVectorContent<VectorType> *>(v->content); | ||
return pContent->get_mpi_communicator(); | ||
} |
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.
Why did
template <typename VectorType,
std::enable_if_t<is_serial_vector<VectorType>::value, int>>
void *get_communicator_as_void_ptr(N_Vector)
{
// required by SUNDIALS: MPI-unaware vectors should return the nullptr
// as comm
return nullptr;
}
disappear? Is &MPI_COMM_SELF==nullptr
?
edit: Clarified "this".
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.
There were two specializations of the function, one for serial and one for parallel vectors (enabled or disabled via std::enable_if
) because the former do not have a get_communicator()
member function.
I've outsourced that decision to the get_mpi_communicator()
free function above now that returns MPI_COMM_SELF
for serial vectors. Are you saying that we should just return nullptr
if a vector is serial, regardless of whether we configured for MPI or not?
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.
Maybe something like this in the current place?
diff --git a/include/deal.II/sundials/n_vector.templates.h b/include/deal.II/sundials/n_vector.templates.h
index e5e9db4bd2..e4a42d659a 100644
--- a/include/deal.II/sundials/n_vector.templates.h
+++ b/include/deal.II/sundials/n_vector.templates.h
@@ -619,8 +619,12 @@ namespace SUNDIALS
(void)v;
return nullptr;
# else
- // We need to cast away const here, as SUNDIALS demands a pure `void *`.
- return &(const_cast<MPI_Comm &>(get_communicator<VectorType>(v)));
+ if (is_serial_vector<VectorType>::value == false)
+ // We need to cast away const here, as SUNDIALS demands a pure `void
+ // *`.
+ return &(const_cast<MPI_Comm &>(get_communicator<VectorType>(v)));
+ else
+ return nullptr;
# endif
}
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 convinced myself that that is the right way to go and pushed an updated commit.
We can't ask a default-created vector for its MPI communicator if we only later initialize it.
This required a bit more work, but it works now at least locally. |
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.
Looks OK to me.
This patch block #15086, and so I would ask for expedited review.
See #15086 (review) Fundamentally, this patch works around the issue mentioned here: LLNL/sundials#275
@sebproell @stefanozampini FYI.