From 5582180e31668e76115ad6cdcaba6b38fa0210f6 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Wed, 5 Oct 2022 17:45:51 -0400 Subject: [PATCH] Can now print build info --- CMakeLists.txt | 13 ++++++++++ include/openmc/output.h | 3 +++ src/initialize.cpp | 4 +++ src/output.cpp | 56 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 521b46cfc..ad1478de8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -482,6 +482,19 @@ if (OPENMC_USE_MPI) target_link_libraries(libopenmc MPI::MPI_CXX) endif() +#=============================================================================== +# Log build info that this executable can report later +#=============================================================================== +target_compile_definitions(libopenmc PRIVATE BUILD_TYPE=${CMAKE_BUILD_TYPE}) +target_compile_definitions(libopenmc PRIVATE COMPILER_ID=${CMAKE_CXX_COMPILER_ID}) +target_compile_definitions(libopenmc PRIVATE COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION}) +if (OPENMC_ENABLE_PROFILE) + target_compile_definitions(libopenmc PRIVATE PROFILINGBUILD) +endif() +if (OPENMC_ENABLE_COVERAGE) + target_compile_definitions(libopenmc PRIVATE COVERAGEBUILD) +endif() + #=============================================================================== # openmc executable #=============================================================================== diff --git a/include/openmc/output.h b/include/openmc/output.h index 2ebe2711f..cf5b49607 100644 --- a/include/openmc/output.h +++ b/include/openmc/output.h @@ -40,6 +40,9 @@ void print_usage(); //! Display current version and copright/license information void print_version(); +//! Display compile flags employed, etc +void print_build_info(); + //! Display header listing what physical values will displayed void print_columns(); diff --git a/src/initialize.cpp b/src/initialize.cpp index 9c20a1f3c..e2503bc6e 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -262,6 +262,10 @@ int parse_command_line(int argc, char* argv[]) print_version(); return OPENMC_E_UNASSIGNED; + } else if (arg == "-b" || arg == "--build-info") { + print_build_info(); + return OPENMC_E_UNASSIGNED; + } else if (arg == "-t" || arg == "--track") { settings::write_all_tracks = true; diff --git a/src/output.cpp b/src/output.cpp index 56fea4db9..5daf652dc 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -325,6 +325,7 @@ void print_usage() "max_tracks)\n" " -e, --event Run using event-based parallelism\n" " -v, --version Show version information\n" + " -b, --build-info Show compile options\n" " -h, --help Show this message\n"); } } @@ -347,6 +348,61 @@ void print_version() //============================================================================== +void print_build_info() +{ + const std::string n("no"); + const std::string y("yes"); + + std::string mpi(n); + std::string phdf5(n); + std::string dagmc(n); + std::string libmesh(n); + std::string png(n); + std::string profiling(n); + std::string coverage(n); + +#ifdef PHDF5 + phdf5 = y; +#endif +#ifdef OPENMC_MPI + mpi = y; +#endif +#ifdef DAGMC + dagmc = y; +#endif +#ifdef LIBMESH + libmesh = y; +#endif +#ifdef USE_LIBPNG + png = y; +#endif +#ifdef PROFILINGBUILD + profiling = y; +#endif +#ifdef COVERAGEBUILD + coverage = y; +#endif + + // Wraps macro variables in quotes +#define STRINGIFY(x) STRINGIFY2(x) +#define STRINGIFY2(x) #x + + if (mpi::master) { + fmt::print("Build type: {}\n", STRINGIFY(BUILD_TYPE)); + fmt::print("Compiler ID: {} {}\n", STRINGIFY(COMPILER_ID), + STRINGIFY(COMPILER_VERSION)); + fmt::print("MPI enabled: {}\n", mpi); + fmt::print("Parallel HDF5 enabled: {}\n", phdf5); + fmt::print("PNG support: {}\n", png); + fmt::print("DAGMC support: {}\n", dagmc); + fmt::print("libMesh support: {}\n", libmesh); + fmt::print("Coverage testing: {}\n", coverage); + fmt::print("Profiling flags: {}\n", profiling); + } +} + +//============================================================================== + void print_columns() { if (settings::entropy_on) {