Skip to content

Commit

Permalink
fix: rank 0 output only; info as flag; struct to ns
Browse files Browse the repository at this point in the history
  • Loading branch information
program-- authored and PhilMiller committed Nov 21, 2023
1 parent 46a4c91 commit 315ba38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions include/NGenConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace ngen {

struct exec_info
namespace exec_info
{
// Executable version

Expand All @@ -45,8 +45,8 @@ struct exec_info
//! Compile-time build summary
static constexpr const char* build_summary = R"(@NGEN_CONF_SUMMARY@)";

static void runtime_summary(std::ostream& stream) noexcept;
static void runtime_usage(const std::string& cmd, std::ostream& stream) noexcept;
void runtime_summary(std::ostream& stream) noexcept;
void runtime_usage(const std::string& cmd, std::ostream& stream) noexcept;
};

} // namespace ngen
Expand Down
20 changes: 12 additions & 8 deletions src/NGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,9 @@ void ngen::exec_info::runtime_summary(std::ostream& stream) noexcept
stream << "Runtime configuration summary:\n";

#if NGEN_WITH_MPI

MPI_Init(nullptr, nullptr);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_num_procs);

stream << " MPI:\n"
<< " Rank: " << mpi_rank << "\n"
<< " Processors: " << mpi_num_procs << "\n";

#endif // NGEN_WITH_MPI

#if NGEN_WITH_PYTHON // -------------------------------------------------------
Expand Down Expand Up @@ -131,14 +126,23 @@ void ngen::exec_info::runtime_summary(std::ostream& stream) noexcept

int main(int argc, char *argv[]) {

if (argc > 1 && std::string{argv[1]} == "info") {
if (argc > 1 && std::string{argv[1]} == "--info") {
#if NGEN_WITH_MPI
MPI_Init(nullptr, nullptr);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_num_procs);

if (mpi_rank == 0) {
#endif

std::ostringstream output;
output << ngen::exec_info::build_summary;
ngen::exec_info::runtime_summary(output);

std::cout << output.str() << std::endl;

#if NGEN_WITH_MPI
} // if (mpi_rank == 0)

MPI_Finalize();
#endif

Expand Down

0 comments on commit 315ba38

Please sign in to comment.