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

Removing DEAL_II_MPI_CONST_CAST #13488

Merged
merged 1 commit into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions include/deal.II/base/mpi.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ namespace Utilities
}
# endif
const int ierr =
MPI_Allreduce(values != output ?
DEAL_II_MPI_CONST_CAST(values.data()) :
MPI_IN_PLACE,
MPI_Allreduce(values != output ? values.data() : MPI_IN_PLACE,
static_cast<void *>(output.data()),
static_cast<int>(values.size()),
mpi_type_id(values.data()),
Expand Down
28 changes: 8 additions & 20 deletions source/base/data_out_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7694,11 +7694,8 @@ DataOutInterface<dim, spacedim>::write_vtu_in_parallel(
int ierr = MPI_Info_create(&info);
AssertThrowMPI(ierr);
MPI_File fh;
ierr = MPI_File_open(comm,
DEAL_II_MPI_CONST_CAST(filename.c_str()),
MPI_MODE_CREATE | MPI_MODE_WRONLY,
info,
&fh);
ierr = MPI_File_open(
comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
AssertThrow(ierr == MPI_SUCCESS, ExcFileNotOpen(filename));

ierr = MPI_File_set_size(fh, 0); // delete the file contents
Expand All @@ -7720,11 +7717,8 @@ DataOutInterface<dim, spacedim>::write_vtu_in_parallel(
header_size = ss.str().size();
// Write the header on rank 0 and automatically move the
// shared file pointer to the location after header;
ierr = MPI_File_write_shared(fh,
DEAL_II_MPI_CONST_CAST(ss.str().c_str()),
header_size,
MPI_CHAR,
MPI_STATUS_IGNORE);
ierr = MPI_File_write_shared(
fh, ss.str().c_str(), header_size, MPI_CHAR, MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);
}

Expand All @@ -7747,11 +7741,8 @@ DataOutInterface<dim, spacedim>::write_vtu_in_parallel(
vtk_flags,
ss);

ierr = MPI_File_write_ordered(fh,
DEAL_II_MPI_CONST_CAST(ss.str().c_str()),
ss.str().size(),
MPI_CHAR,
MPI_STATUS_IGNORE);
ierr = MPI_File_write_ordered(
fh, ss.str().c_str(), ss.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);
}

Expand All @@ -7761,11 +7752,8 @@ DataOutInterface<dim, spacedim>::write_vtu_in_parallel(
std::stringstream ss;
DataOutBase::write_vtu_footer(ss);
unsigned int footer_size = ss.str().size();
ierr = MPI_File_write_shared(fh,
DEAL_II_MPI_CONST_CAST(ss.str().c_str()),
footer_size,
MPI_CHAR,
MPI_STATUS_IGNORE);
ierr = MPI_File_write_shared(
fh, ss.str().c_str(), footer_size, MPI_CHAR, MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);
}
ierr = MPI_File_close(&fh);
Expand Down
12 changes: 6 additions & 6 deletions source/distributed/fully_distributed_tria.cc
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ namespace parallel
// Open file.
MPI_File fh;
ierr = MPI_File_open(this->mpi_communicator,
DEAL_II_MPI_CONST_CAST(fname_tria.c_str()),
fname_tria.c_str(),
MPI_MODE_CREATE | MPI_MODE_WRONLY,
info,
&fh);
Expand Down Expand Up @@ -569,7 +569,7 @@ namespace parallel
// Write offsets to file.
ierr = MPI_File_write_at(fh,
myrank * sizeof(unsigned int),
DEAL_II_MPI_CONST_CAST(&buffer_size),
&buffer_size,
1,
MPI_UNSIGNED,
MPI_STATUS_IGNORE);
Expand All @@ -579,7 +579,7 @@ namespace parallel
ierr = MPI_File_write_at(fh,
mpisize * sizeof(unsigned int) +
offset, // global position in file
DEAL_II_MPI_CONST_CAST(buffer.data()),
buffer.data(),
buffer.size(), // local buffer
MPI_CHAR,
MPI_STATUS_IGNORE);
Expand Down Expand Up @@ -656,7 +656,7 @@ namespace parallel

MPI_File fh;
ierr = MPI_File_open(this->mpi_communicator,
DEAL_II_MPI_CONST_CAST(fname_tria.c_str()),
fname_tria.c_str(),
MPI_MODE_RDONLY,
info,
&fh);
Expand All @@ -670,7 +670,7 @@ namespace parallel

ierr = MPI_File_read_at(fh,
myrank * sizeof(unsigned int),
DEAL_II_MPI_CONST_CAST(&buffer_size),
&buffer_size,
1,
MPI_UNSIGNED,
MPI_STATUS_IGNORE);
Expand All @@ -691,7 +691,7 @@ namespace parallel
ierr = MPI_File_read_at(fh,
mpisize * sizeof(unsigned int) +
offset, // global position in file
DEAL_II_MPI_CONST_CAST(buffer.data()),
buffer.data(),
buffer.size(), // local buffer
MPI_CHAR,
MPI_STATUS_IGNORE);
Expand Down
59 changes: 24 additions & 35 deletions source/distributed/tria_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ namespace parallel

MPI_File fh;
ierr = MPI_File_open(mpi_communicator,
DEAL_II_MPI_CONST_CAST(fname_fixed.c_str()),
fname_fixed.c_str(),
MPI_MODE_CREATE | MPI_MODE_WRONLY,
info,
&fh);
Expand All @@ -1440,8 +1440,7 @@ namespace parallel
{
ierr = MPI_File_write_at(fh,
0,
DEAL_II_MPI_CONST_CAST(
sizes_fixed_cumulative.data()),
sizes_fixed_cumulative.data(),
sizes_fixed_cumulative.size(),
MPI_UNSIGNED,
MPI_STATUS_IGNORE);
Expand All @@ -1461,13 +1460,12 @@ namespace parallel
if (src_data_fixed.size() <=
static_cast<std::size_t>(std::numeric_limits<int>::max()))
{
ierr =
MPI_File_write_at(fh,
my_global_file_position,
DEAL_II_MPI_CONST_CAST(src_data_fixed.data()),
src_data_fixed.size(),
MPI_BYTE,
MPI_STATUS_IGNORE);
ierr = MPI_File_write_at(fh,
my_global_file_position,
src_data_fixed.data(),
src_data_fixed.size(),
MPI_BYTE,
MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);
}
else
Expand All @@ -1476,7 +1474,7 @@ namespace parallel
ierr =
MPI_File_write_at(fh,
my_global_file_position,
DEAL_II_MPI_CONST_CAST(src_data_fixed.data()),
src_data_fixed.data(),
1,
*Utilities::MPI::create_mpi_data_type_n_bytes(
src_data_fixed.size()),
Expand Down Expand Up @@ -1504,7 +1502,7 @@ namespace parallel

MPI_File fh;
ierr = MPI_File_open(mpi_communicator,
DEAL_II_MPI_CONST_CAST(fname_variable.c_str()),
fname_variable.c_str(),
MPI_MODE_CREATE | MPI_MODE_WRONLY,
info,
&fh);
Expand All @@ -1531,13 +1529,12 @@ namespace parallel
std::numeric_limits<int>::max()),
ExcNotImplemented());

ierr =
MPI_File_write_at(fh,
my_global_file_position,
DEAL_II_MPI_CONST_CAST(src_sizes_variable.data()),
src_sizes_variable.size(),
MPI_INT,
MPI_STATUS_IGNORE);
ierr = MPI_File_write_at(fh,
my_global_file_position,
src_sizes_variable.data(),
src_sizes_variable.size(),
MPI_INT,
MPI_STATUS_IGNORE);
AssertThrowMPI(ierr);
}

Expand All @@ -1546,7 +1543,7 @@ namespace parallel
// to avoid overflow for files larger than 4GB:
const std::uint64_t size_on_proc = src_data_variable.size();
std::uint64_t prefix_sum = 0;
ierr = MPI_Exscan(DEAL_II_MPI_CONST_CAST(&size_on_proc),
ierr = MPI_Exscan(&size_on_proc,
&prefix_sum,
1,
MPI_UINT64_T,
Comment on lines +1546 to 1549
Copy link
Member

Choose a reason for hiding this comment

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

Here and below: Interesting how clang-format handles these cases

Expand All @@ -1564,8 +1561,7 @@ namespace parallel
{
ierr = MPI_File_write_at(fh,
my_global_file_position,
DEAL_II_MPI_CONST_CAST(
src_data_variable.data()),
src_data_variable.data(),
src_data_variable.size(),
MPI_BYTE,
MPI_STATUS_IGNORE);
Expand All @@ -1577,8 +1573,7 @@ namespace parallel
ierr =
MPI_File_write_at(fh,
my_global_file_position,
DEAL_II_MPI_CONST_CAST(
src_data_variable.data()),
src_data_variable.data(),
1,
*Utilities::MPI::create_mpi_data_type_n_bytes(
src_data_variable.size()),
Expand Down Expand Up @@ -1632,11 +1627,8 @@ namespace parallel
AssertThrowMPI(ierr);

MPI_File fh;
ierr = MPI_File_open(mpi_communicator,
DEAL_II_MPI_CONST_CAST(fname_fixed.c_str()),
MPI_MODE_RDONLY,
info,
&fh);
ierr = MPI_File_open(
mpi_communicator, fname_fixed.c_str(), MPI_MODE_RDONLY, info, &fh);
AssertThrowMPI(ierr);

ierr = MPI_Info_free(&info);
Expand Down Expand Up @@ -1712,11 +1704,8 @@ namespace parallel
AssertThrowMPI(ierr);

MPI_File fh;
ierr = MPI_File_open(mpi_communicator,
DEAL_II_MPI_CONST_CAST(fname_variable.c_str()),
MPI_MODE_RDONLY,
info,
&fh);
ierr = MPI_File_open(
mpi_communicator, fname_variable.c_str(), MPI_MODE_RDONLY, info, &fh);
AssertThrowMPI(ierr);

ierr = MPI_Info_free(&info);
Expand Down Expand Up @@ -1745,7 +1734,7 @@ namespace parallel
0ULL);

std::uint64_t prefix_sum = 0;
ierr = MPI_Exscan(DEAL_II_MPI_CONST_CAST(&size_on_proc),
ierr = MPI_Exscan(&size_on_proc,
&prefix_sum,
1,
MPI_UINT64_T,
Expand Down
16 changes: 7 additions & 9 deletions source/dofs/dof_handler_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3913,13 +3913,12 @@ namespace internal
// --------- Phase 4: shift indices so that each processor has a unique
// range of indices
dealii::types::global_dof_index my_shift = 0;
const int ierr =
MPI_Exscan(DEAL_II_MPI_CONST_CAST(&n_locally_owned_dofs),
&my_shift,
1,
DEAL_II_DOF_INDEX_MPI_TYPE,
MPI_SUM,
triangulation->get_communicator());
const int ierr = MPI_Exscan(&n_locally_owned_dofs,
&my_shift,
1,
DEAL_II_DOF_INDEX_MPI_TYPE,
MPI_SUM,
triangulation->get_communicator());
AssertThrowMPI(ierr);

// make dof indices globally consecutive
Expand Down Expand Up @@ -4130,8 +4129,7 @@ namespace internal
//* 3. communicate local dofcount and shift ids to make
// them unique
dealii::types::global_dof_index my_shift = 0;
int ierr = MPI_Exscan(DEAL_II_MPI_CONST_CAST(
&level_number_cache.n_locally_owned_dofs),
int ierr = MPI_Exscan(&level_number_cache.n_locally_owned_dofs,
&my_shift,
1,
DEAL_II_DOF_INDEX_MPI_TYPE,
Expand Down
4 changes: 2 additions & 2 deletions source/lac/scalapack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ ScaLAPACKMatrix<NumberType>::copy_from(const LAPACKFullMatrix<NumberType> &B,
const int n = 1;
const std::vector<int> ranks(n, rank);
MPI_Group group_B;
MPI_Group_incl(group_A, n, DEAL_II_MPI_CONST_CAST(ranks.data()), &group_B);
MPI_Group_incl(group_A, n, ranks.data(), &group_B);
MPI_Comm communicator_B;

const int mpi_tag = Utilities::MPI::internal::Tags::scalapack_copy_from;
Expand Down Expand Up @@ -562,7 +562,7 @@ ScaLAPACKMatrix<NumberType>::copy_to(LAPACKFullMatrix<NumberType> &B,
const int n = 1;
const std::vector<int> ranks(n, rank);
MPI_Group group_B;
MPI_Group_incl(group_A, n, DEAL_II_MPI_CONST_CAST(ranks.data()), &group_B);
MPI_Group_incl(group_A, n, ranks.data(), &group_B);
MPI_Comm communicator_B;

const int mpi_tag = Utilities::MPI::internal::Tags::scalapack_copy_to;
Expand Down
15 changes: 7 additions & 8 deletions source/lac/sparsity_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1182,14 +1182,13 @@ namespace SparsityTools
unsigned int idx = 0;
for (const auto &sparsity_line : send_data)
{
const int ierr =
MPI_Isend(DEAL_II_MPI_CONST_CAST(sparsity_line.second.data()),
sparsity_line.second.size(),
DEAL_II_DOF_INDEX_MPI_TYPE,
sparsity_line.first,
mpi_tag,
mpi_comm,
&requests[idx++]);
const int ierr = MPI_Isend(sparsity_line.second.data(),
sparsity_line.second.size(),
DEAL_II_DOF_INDEX_MPI_TYPE,
sparsity_line.first,
mpi_tag,
mpi_comm,
&requests[idx++]);
AssertThrowMPI(ierr);
}
}
Expand Down