Skip to content

Commit

Permalink
Avoid static init problem in insufficient_procs() (MPI) (#657)
Browse files Browse the repository at this point in the history
* Avoid static init problem in insufficient_procs() (MPI)

* Reduce number of times mpi_comm_world_size() needs to be called
  • Loading branch information
starintheuniverse committed Jun 15, 2022
1 parent 0cbd3fa commit 0663959
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doctest/extensions/doctest_mpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ namespace doctest {
extern std::unordered_map<int,mpi_sub_comm> sub_comms_by_size;
extern int nb_test_cases_skipped_insufficient_procs;
extern int world_size_before_init;
int mpi_comm_world_size();

int mpi_init_thread(int argc, char *argv[], int required_thread_support);
void mpi_finalize();
Expand All @@ -113,7 +114,8 @@ void execute_mpi_test_case(F func) {

inline bool
insufficient_procs(int test_nb_procs) {
bool insufficient = test_nb_procs>world_size_before_init;
static const int world_size = mpi_comm_world_size();
bool insufficient = test_nb_procs>world_size;
if (insufficient) {
++nb_test_cases_skipped_insufficient_procs;
}
Expand Down

0 comments on commit 0663959

Please sign in to comment.