Skip to content

Commit 267df67

Browse files
committed
config: mpi: let only rank 0 print help message
1 parent 1b98980 commit 267df67

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

include/pfasst/config.hpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ using namespace std;
1010
#include <boost/program_options.hpp>
1111
namespace po = boost::program_options;
1212

13+
#ifdef WITH_MPI
14+
#include <mpi.h>
15+
#endif
16+
1317

1418
namespace pfasst
1519
{
@@ -69,9 +73,27 @@ namespace pfasst
6973
po::store(parsed, options::get_instance().get_variables_map());
7074
po::notify(options::get_instance().get_variables_map());
7175

76+
#ifdef WITH_MPI
77+
int initialized = 0;
78+
MPI_Initialized(&initialized);
79+
assert((bool)initialized);
80+
int rank = 0;
81+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
82+
#endif
7283
if (options::get_instance().get_variables_map().count("help")) {
73-
cout << print_help() << endl;
74-
if (exit_on_help) exit(0);
84+
#ifdef WITH_MPI
85+
if (rank == 0) {
86+
#endif
87+
cout << print_help() << endl;
88+
#ifdef WITH_MPI
89+
}
90+
#endif
91+
if (exit_on_help) {
92+
#ifdef WITH_MPI
93+
MPI_Finalize();
94+
#endif
95+
exit(0);
96+
}
7597
}
7698
}
7799

0 commit comments

Comments
 (0)