Skip to content

Commit

Permalink
Merge pull request #15516 from kronbichler/simplify_job_supports_mpi
Browse files Browse the repository at this point in the history
Move job_supports_mpi() to a more central place
  • Loading branch information
bangerth committed Jun 30, 2023
2 parents d2febc7 + 52ba449 commit c4e9688
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion include/deal.II/lac/la_parallel_vector.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -1348,9 +1348,9 @@ namespace LinearAlgebra

// make sure that there are not outstanding requests from updating
// ghost values or compress
int flag = 1;
if (update_ghost_values_requests.size() > 0)
{
int flag = 1;
const int ierr = MPI_Testall(update_ghost_values_requests.size(),
update_ghost_values_requests.data(),
&flag,
Expand All @@ -1363,6 +1363,7 @@ namespace LinearAlgebra
}
if (compress_requests.size() > 0)
{
int flag = 1;
const int ierr = MPI_Testall(compress_requests.size(),
compress_requests.data(),
&flag,
Expand Down
16 changes: 9 additions & 7 deletions source/base/mpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,30 @@ namespace Utilities
unsigned int
n_mpi_processes(const MPI_Comm mpi_communicator)
{
int n_jobs = 1;
if (job_supports_mpi())
{
const int ierr = MPI_Comm_size(mpi_communicator, &n_jobs);
int n_jobs = 1;
const int ierr = MPI_Comm_size(mpi_communicator, &n_jobs);
AssertThrowMPI(ierr);
return n_jobs;
}

return n_jobs;
else
return 1;
}


unsigned int
this_mpi_process(const MPI_Comm mpi_communicator)
{
int rank = 0;
if (job_supports_mpi())
{
int rank = 0;
const int ierr = MPI_Comm_rank(mpi_communicator, &rank);
AssertThrowMPI(ierr);
return rank;
}

return rank;
else
return 0;
}


Expand Down

0 comments on commit c4e9688

Please sign in to comment.