Skip to content

Commit

Permalink
Merge pull request #13488 from pengfej/fbranch
Browse files Browse the repository at this point in the history
Removing DEAL_II_MPI_CONST_CAST
  • Loading branch information
bangerth committed Mar 6, 2022
2 parents be5704d + b05dc25 commit f09bc52
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 83 deletions.
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_for_type<decltype(*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 @@ -517,7 +517,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 @@ -559,7 +559,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 @@ -569,7 +569,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 @@ -646,7 +646,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 @@ -660,7 +660,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 @@ -681,7 +681,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 @@ -1451,7 +1451,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 @@ -1475,8 +1475,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 @@ -1496,13 +1495,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 @@ -1511,7 +1509,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 @@ -1539,7 +1537,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 @@ -1566,13 +1564,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 @@ -1581,7 +1578,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,
Expand All @@ -1599,8 +1596,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 @@ -1612,8 +1608,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 @@ -1667,11 +1662,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 @@ -1747,11 +1739,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 @@ -1780,7 +1769,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

0 comments on commit f09bc52

Please sign in to comment.