From 5582180e31668e76115ad6cdcaba6b38fa0210f6 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Wed, 5 Oct 2022 17:45:51 -0400 Subject: [PATCH 1/3] 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 521b46cfc6..ad1478de8b 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 2ebe2711f1..cf5b49607c 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 9c20a1f3cb..e2503bc6ec 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 56fea4db91..5daf652dcb 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) { From f07b0295f9909c20c62c08b8046deb09db0f1e21 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Thu, 20 Oct 2022 12:12:36 -0400 Subject: [PATCH 2/3] buildinfo printed on -v flag --- CMakeLists.txt | 4 ++-- src/initialize.cpp | 3 --- src/output.cpp | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad1478de8b..04c712a17b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,10 +489,10 @@ 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) + target_compile_definitions(libopenmc PRIVATE PROFILINGBUILD) endif() if (OPENMC_ENABLE_COVERAGE) - target_compile_definitions(libopenmc PRIVATE COVERAGEBUILD) + target_compile_definitions(libopenmc PRIVATE COVERAGEBUILD) endif() #=============================================================================== diff --git a/src/initialize.cpp b/src/initialize.cpp index e2503bc6ec..aa353aa9cb 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -260,9 +260,6 @@ int parse_command_line(int argc, char* argv[]) } else if (arg == "-v" || arg == "--version") { print_version(); - return OPENMC_E_UNASSIGNED; - - } else if (arg == "-b" || arg == "--build-info") { print_build_info(); return OPENMC_E_UNASSIGNED; diff --git a/src/output.cpp b/src/output.cpp index 5daf652dcb..84e50462cc 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -325,7 +325,6 @@ 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"); } } From f58f4783751334ee35b6667c083f55e793d39250 Mon Sep 17 00:00:00 2001 From: Gavin Ridley Date: Thu, 20 Oct 2022 16:58:50 -0400 Subject: [PATCH 3/3] align spaces --- src/output.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/output.cpp b/src/output.cpp index 84e50462cc..59cb157127 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -396,7 +396,7 @@ void print_build_info() fmt::print("DAGMC support: {}\n", dagmc); fmt::print("libMesh support: {}\n", libmesh); fmt::print("Coverage testing: {}\n", coverage); - fmt::print("Profiling flags: {}\n", profiling); + fmt::print("Profiling flags: {}\n", profiling); } }