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
Utilities::MPI::create_mpi_data_type_n_bytes #12964
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.
Looks good. The design here invited resource deallocation failures because the type has no destructor associated with it. The function is probably still useful, but in a follow-up it might be useful to move the function into an internal namespace and write a wrapper function that returns something like std::unique_ptr<MPI_Datatype, ...>
with a custom deallocation function as second argument that takes care of the call to MPI_Type_free
. I can probably write that for you.
source/base/mpi.cc
Outdated
// https://github.com/jeffhammond/BigMPI/blob/5300b18cc8ec1b2431bf269ee494054ee7bd9f72/src/type_contiguous_x.c#L74 | ||
// (code is MIT licensed) | ||
|
||
// We create an MPI datatype that has the layout A*nB where A is |
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.
Did you mean this?
// We create an MPI datatype that has the layout A*nB where A is | |
// We create an MPI datatype that has the layout A*n+B where A is |
tests/mpi/create_mpi_datatype_01.cc
Outdated
using namespace dealii; | ||
|
||
void | ||
test_data_type(long long n_bytes) |
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.
test_data_type(long long n_bytes) | |
test_data_type(const std::uint64_t n_bytes) |
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.
ok. what is your preference for the argument ofcreate_mpi_data_type_n_bytes()? MPI_Count, size_t, std::uint64_t?
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.
The whole point of this function is to work around limitations in MPI data type sizes :-) So let's do std::uint64_t
.
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.
Or std::size_t
. Maybe that's the better choice because that's always going to be big enough to address all elements of any array you can think of.
I am not a big fan of mixing c-style MPI calls (which will happen with this newly created MPI_Datatype) with c++ style. See |
include/deal.II/base/mpi.h
Outdated
* </code> | ||
*/ | ||
MPI_Datatype | ||
create_mpi_data_type_n_bytes(std::size_t n_bytes); |
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.
create_mpi_data_type_n_bytes(std::size_t n_bytes); | |
create_mpi_data_type_n_bytes(const std::size_t n_bytes); |
include/deal.II/base/mpi.h
Outdated
* else | ||
* { | ||
* MPI_Datatype bigtype = | ||
* Utilities::MPI::create_mpi_data_type_n_bytes(buffer.size()); |
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.
indent this line a bit more
source/base/mpi.cc
Outdated
@@ -295,6 +297,85 @@ namespace Utilities | |||
|
|||
|
|||
|
|||
MPI_Datatype | |||
create_mpi_data_type_n_bytes(std::size_t n_bytes) |
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.
create_mpi_data_type_n_bytes(std::size_t n_bytes) | |
create_mpi_data_type_n_bytes(const std::size_t n_bytes) |
All good points. Thanks. |
part of #12752 and #12873