From db2222583b097704f83251bdc5620fa1dc9f359a Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Fri, 14 Jan 2022 12:47:33 +0100 Subject: [PATCH 01/47] #1636 add API for temporarily enabling/disabling debug prints --- src/vt/configs/debug/debug_print.h | 67 ++++++++++ src/vt/runtime/runtime_get.cc | 12 +- .../test_temp_enabling_debug_prints.nompi.cc | 114 ++++++++++++++++++ 3 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 tests/unit/runtime/test_temp_enabling_debug_prints.nompi.cc diff --git a/src/vt/configs/debug/debug_print.h b/src/vt/configs/debug/debug_print.h index f252dd9d8a..c2db0c37a1 100644 --- a/src/vt/configs/debug/debug_print.h +++ b/src/vt/configs/debug/debug_print.h @@ -159,6 +159,73 @@ #define vt_option_check_enabled(mode, bit) ((mode & bit) not_eq 0) +#define vt_debug_temp_enable_opt(opt) \ + ::vt::debug::preConfigRef()->vt_debug_##opt = true + +#define vt_debug_temp_disable_opt(opt) \ + ::vt::debug::preConfigRef()->vt_debug_##opt = false + +#define vt_debug_scoped_enable_opt(opt) \ + ScopedModifier_##opt##_##true { } + +#define vt_debug_scoped_disable_opt(opt) \ + ScopedModifier_##opt##_##false { } + +#define vt_scoped_modifier_opt(opt, val) \ + struct ScopedModifier_##opt##_##val { \ + ScopedModifier_##opt##_##val() \ + : origVal{::vt::debug::preConfig()->vt_debug_##opt} { \ + ::vt::debug::preConfigRef()->vt_debug_##opt = val; \ + } \ + \ + ~ScopedModifier_##opt##_##val() { \ + ::vt::debug::preConfigRef()->vt_debug_##opt = origVal; \ + } \ + \ + private: \ + bool origVal; \ + } + +#define vt_define_debug_scoped_modifiers(opt) \ + vt_scoped_modifier_opt(opt, true); \ + vt_scoped_modifier_opt(opt, false) + +vt_define_debug_scoped_modifiers(all); +vt_define_debug_scoped_modifiers(none); +vt_define_debug_scoped_modifiers(gen); +vt_define_debug_scoped_modifiers(runtime); +vt_define_debug_scoped_modifiers(active); +vt_define_debug_scoped_modifiers(term); +vt_define_debug_scoped_modifiers(termds); +vt_define_debug_scoped_modifiers(barrier); +vt_define_debug_scoped_modifiers(event); +vt_define_debug_scoped_modifiers(pipe); +vt_define_debug_scoped_modifiers(pool); +vt_define_debug_scoped_modifiers(reduce); +vt_define_debug_scoped_modifiers(rdma); +vt_define_debug_scoped_modifiers(rdma_channel); +vt_define_debug_scoped_modifiers(rdma_state); +vt_define_debug_scoped_modifiers(param); +vt_define_debug_scoped_modifiers(handler); +vt_define_debug_scoped_modifiers(hierlb); +vt_define_debug_scoped_modifiers(temperedlb); +vt_define_debug_scoped_modifiers(scatter); +vt_define_debug_scoped_modifiers(sequence); +vt_define_debug_scoped_modifiers(sequence_vrt); +vt_define_debug_scoped_modifiers(serial_msg); +vt_define_debug_scoped_modifiers(trace); +vt_define_debug_scoped_modifiers(location); +vt_define_debug_scoped_modifiers(lb); +vt_define_debug_scoped_modifiers(vrt); +vt_define_debug_scoped_modifiers(vrt_coll); +vt_define_debug_scoped_modifiers(worker); +vt_define_debug_scoped_modifiers(group); +vt_define_debug_scoped_modifiers(broadcast); +vt_define_debug_scoped_modifiers(objgroup); +vt_define_debug_scoped_modifiers(phase); +vt_define_debug_scoped_modifiers(context); +vt_define_debug_scoped_modifiers(epoch); + namespace vt { namespace runtime { struct Runtime; }} /* end namespace vt::runtime */ diff --git a/src/vt/runtime/runtime_get.cc b/src/vt/runtime/runtime_get.cc index 2a3d86a574..014cc0f07b 100644 --- a/src/vt/runtime/runtime_get.cc +++ b/src/vt/runtime/runtime_get.cc @@ -168,8 +168,16 @@ static arguments::AppConfig preInitAppConfig{}; * * \return A modifiable configuration */ -arguments::AppConfig* preConfigRef(){ - return &preInitAppConfig; +arguments::AppConfig* preConfigRef() { + if (not curRT) + return &preInitAppConfig; + + auto* config = curRT->theArgConfig; + if (not config) { + return &preInitAppConfig; + } + + return &config->config_; } /** diff --git a/tests/unit/runtime/test_temp_enabling_debug_prints.nompi.cc b/tests/unit/runtime/test_temp_enabling_debug_prints.nompi.cc new file mode 100644 index 0000000000..50352f32cf --- /dev/null +++ b/tests/unit/runtime/test_temp_enabling_debug_prints.nompi.cc @@ -0,0 +1,114 @@ +/* +//@HEADER +// ***************************************************************************** +// +// test_temp_enabling_debug_prints.nompi.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact darma@sandia.gov +// +// ***************************************************************************** +//@HEADER +*/ + +#include + +#include "test_harness.h" + +#include +#include + +namespace vt { namespace tests { namespace unit { + +struct TestTempEnablingDisablingDebugPrints : TestHarness { }; + +TEST_F(TestTempEnablingDisablingDebugPrints, test_manual_enabling_disabling) { + vt::initialize(); + + EXPECT_EQ(theConfig()->vt_debug_all, false); + EXPECT_EQ(theConfig()->vt_debug_termds, false); + EXPECT_EQ(theConfig()->vt_debug_param, false); + EXPECT_EQ(theConfig()->vt_debug_scatter, false); + + vt_debug_temp_enable_opt(all); + vt_debug_temp_enable_opt(termds); + vt_debug_temp_enable_opt(param); + vt_debug_temp_enable_opt(scatter); + + EXPECT_EQ(theConfig()->vt_debug_all, true); + EXPECT_EQ(theConfig()->vt_debug_termds, true); + EXPECT_EQ(theConfig()->vt_debug_param, true); + EXPECT_EQ(theConfig()->vt_debug_scatter, true); + + vt_debug_temp_disable_opt(all); + vt_debug_temp_disable_opt(termds); + vt_debug_temp_disable_opt(param); + vt_debug_temp_disable_opt(scatter); + + EXPECT_EQ(theConfig()->vt_debug_all, false); + EXPECT_EQ(theConfig()->vt_debug_termds, false); + EXPECT_EQ(theConfig()->vt_debug_param, false); + EXPECT_EQ(theConfig()->vt_debug_scatter, false); + + vt::finalize(); +} + +TEST_F(TestTempEnablingDisablingDebugPrints, test_scoped_enabling_disabling) { + vt::initialize(); + + EXPECT_EQ(theConfig()->vt_debug_none, false); + EXPECT_EQ(theConfig()->vt_debug_active, false); + EXPECT_EQ(theConfig()->vt_debug_reduce, false); + EXPECT_EQ(theConfig()->vt_debug_context, false); + + { + auto const scopedEnabledNone = vt_debug_scoped_enable_opt(none); + auto const scopedEnabledActive = vt_debug_scoped_enable_opt(active); + auto const scopedEnabledReduce = vt_debug_scoped_enable_opt(reduce); + auto const scopedEnabledContext = vt_debug_scoped_enable_opt(context); + + EXPECT_EQ(theConfig()->vt_debug_none, true); + EXPECT_EQ(theConfig()->vt_debug_active, true); + EXPECT_EQ(theConfig()->vt_debug_reduce, true); + EXPECT_EQ(theConfig()->vt_debug_context, true); + } + + EXPECT_EQ(theConfig()->vt_debug_none, false); + EXPECT_EQ(theConfig()->vt_debug_active, false); + EXPECT_EQ(theConfig()->vt_debug_reduce, false); + EXPECT_EQ(theConfig()->vt_debug_context, false); + + vt::finalize(); +} + +}}} // end namespace vt::tests::unit From e6d3e569636fb0e0cb18dad1e476484a4e9a5c0b Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Tue, 18 Jan 2022 14:50:34 +0100 Subject: [PATCH 02/47] #1636 document new functionality --- src/vt/configs/debug/debug_print.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/vt/configs/debug/debug_print.h b/src/vt/configs/debug/debug_print.h index c2db0c37a1..19c1dd50aa 100644 --- a/src/vt/configs/debug/debug_print.h +++ b/src/vt/configs/debug/debug_print.h @@ -159,15 +159,45 @@ #define vt_option_check_enabled(mode, bit) ((mode & bit) not_eq 0) +/** + * \brief Temporarily enable debug print option +*/ #define vt_debug_temp_enable_opt(opt) \ ::vt::debug::preConfigRef()->vt_debug_##opt = true +/** + * \brief Temporarily disable debug print option +*/ #define vt_debug_temp_disable_opt(opt) \ ::vt::debug::preConfigRef()->vt_debug_##opt = false +/** + * \brief Temporarily enable debug print option in given scope. When exiting + * a scope, it restores original option value. + * + * Usage: + * { + * ... + * auto const scopedEnabledContext = vt_debug_scoped_enable_opt(context); + * ... + * } + } +*/ #define vt_debug_scoped_enable_opt(opt) \ ScopedModifier_##opt##_##true { } +/** + * \brief Temporarily disable debug print option in given scope. When exiting + * a scope, it restores original option value. + * + * Usage: + * { + * ... + * auto const scopedDisabledContext = vt_debug_scoped_disable_opt(context); + * ... + * } + } +*/ #define vt_debug_scoped_disable_opt(opt) \ ScopedModifier_##opt##_##false { } From 9896d945efb97375aa45b5a0845f7c45cf40bbd9 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 19 Jan 2022 19:24:27 +0100 Subject: [PATCH 03/47] #1636 use theConfig instead of preConfigRef --- src/vt/configs/debug/debug_print.h | 38 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/vt/configs/debug/debug_print.h b/src/vt/configs/debug/debug_print.h index 19c1dd50aa..007cfabe1f 100644 --- a/src/vt/configs/debug/debug_print.h +++ b/src/vt/configs/debug/debug_print.h @@ -160,20 +160,23 @@ #define vt_option_check_enabled(mode, bit) ((mode & bit) not_eq 0) /** - * \brief Temporarily enable debug print option + * \brief Temporarily enable debug print option. + * vt needs to be initialized before usage. */ #define vt_debug_temp_enable_opt(opt) \ - ::vt::debug::preConfigRef()->vt_debug_##opt = true + ::vt::theConfig()->vt_debug_##opt = true /** - * \brief Temporarily disable debug print option + * \brief Temporarily disable debug print option. + * vt needs to be initialized before usage. */ #define vt_debug_temp_disable_opt(opt) \ - ::vt::debug::preConfigRef()->vt_debug_##opt = false + ::vt::theConfig()->vt_debug_##opt = false /** * \brief Temporarily enable debug print option in given scope. When exiting * a scope, it restores original option value. + * vt needs to be initialized before usage. * * Usage: * { @@ -189,6 +192,7 @@ /** * \brief Temporarily disable debug print option in given scope. When exiting * a scope, it restores original option value. + * vt needs to be initialized before usage. * * Usage: * { @@ -201,19 +205,19 @@ #define vt_debug_scoped_disable_opt(opt) \ ScopedModifier_##opt##_##false { } -#define vt_scoped_modifier_opt(opt, val) \ - struct ScopedModifier_##opt##_##val { \ - ScopedModifier_##opt##_##val() \ - : origVal{::vt::debug::preConfig()->vt_debug_##opt} { \ - ::vt::debug::preConfigRef()->vt_debug_##opt = val; \ - } \ - \ - ~ScopedModifier_##opt##_##val() { \ - ::vt::debug::preConfigRef()->vt_debug_##opt = origVal; \ - } \ - \ - private: \ - bool origVal; \ +#define vt_scoped_modifier_opt(opt, val) \ + struct ScopedModifier_##opt##_##val { \ + ScopedModifier_##opt##_##val() \ + : origVal{::vt::theConfig()->vt_debug_##opt} { \ + ::vt::theConfig()->vt_debug_##opt = val; \ + } \ + \ + ~ScopedModifier_##opt##_##val() { \ + ::vt::theConfig()->vt_debug_##opt = origVal; \ + } \ + \ + private: \ + bool origVal; \ } #define vt_define_debug_scoped_modifiers(opt) \ From 5db473cdc3f680fa36f5f5535183cd3fbe2faa97 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 19 Jan 2022 19:25:27 +0100 Subject: [PATCH 04/47] #1636 revert preConfigRef changes --- src/vt/runtime/runtime_get.cc | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/vt/runtime/runtime_get.cc b/src/vt/runtime/runtime_get.cc index 014cc0f07b..e7260d5882 100644 --- a/src/vt/runtime/runtime_get.cc +++ b/src/vt/runtime/runtime_get.cc @@ -169,15 +169,7 @@ static arguments::AppConfig preInitAppConfig{}; * \return A modifiable configuration */ arguments::AppConfig* preConfigRef() { - if (not curRT) - return &preInitAppConfig; - - auto* config = curRT->theArgConfig; - if (not config) { - return &preInitAppConfig; - } - - return &config->config_; + return &preInitAppConfig; } /** From fd710cb2dcc7333a900e756a32322642c18041a7 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Mon, 24 Jan 2022 19:34:07 +0100 Subject: [PATCH 05/47] #1636 change preprocessor directives indenting setting --- .clang-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 5e636a0797..6d9adac5a3 100644 --- a/.clang-format +++ b/.clang-format @@ -60,7 +60,7 @@ FixNamespaceComments: true IncludeBlocks: Preserve IndentCaseLabels: false IndentGotoLabels: false -IndentPPDirectives: BeforeHash +IndentPPDirectives: PPDIS_None IndentWidth: 2 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: false From 75f6630c7332c9cdee796d684912110cd81173db Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Mon, 24 Jan 2022 19:44:23 +0100 Subject: [PATCH 06/47] #1636 abort if vt is not yet initialized --- src/vt/configs/debug/debug_print.cc | 107 ++++++++++++++++++++++ src/vt/configs/debug/debug_print.h | 136 ++++++++++++++-------------- 2 files changed, 177 insertions(+), 66 deletions(-) create mode 100644 src/vt/configs/debug/debug_print.cc diff --git a/src/vt/configs/debug/debug_print.cc b/src/vt/configs/debug/debug_print.cc new file mode 100644 index 0000000000..bb947163b0 --- /dev/null +++ b/src/vt/configs/debug/debug_print.cc @@ -0,0 +1,107 @@ +/* +//@HEADER +// ***************************************************************************** +// +// debug_print.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact darma@sandia.gov +// +// ***************************************************************************** +//@HEADER +*/ + +#include "vt/configs/debug/debug_print.h" +#include "vt/configs/error/hard_error.h" + +#define vt_scoped_modifier_opt_definition(opt, val) \ + ScopedModifier_##opt##_##val::ScopedModifier_##opt##_##val() \ + : orig_val{::vt::theConfig()->vt_debug_##opt} { \ + ::vt::theConfig()->vt_debug_##opt = val; \ + } \ + \ + ScopedModifier_##opt##_##val::~ScopedModifier_##opt##_##val() { \ + ::vt::theConfig()->vt_debug_##opt = orig_val; \ + } \ + \ + ScopedModifier_##opt##_##val createScopedModifier_##opt##_##val() { \ + if (not ::vt::curRT) { \ + vtAbort("Trying to read config when VT is not initialized"); \ + } \ + \ + return ScopedModifier_##opt##_##val{}; \ + } + +#define vt_define_debug_scoped_modifiers(opt) \ + vt_scoped_modifier_opt_definition(opt, true) \ + vt_scoped_modifier_opt_definition(opt, false) + +namespace vt { + +vt_define_debug_scoped_modifiers(all) +vt_define_debug_scoped_modifiers(none) +vt_define_debug_scoped_modifiers(gen) +vt_define_debug_scoped_modifiers(runtime) +vt_define_debug_scoped_modifiers(active) +vt_define_debug_scoped_modifiers(term) +vt_define_debug_scoped_modifiers(termds) +vt_define_debug_scoped_modifiers(barrier) +vt_define_debug_scoped_modifiers(event) +vt_define_debug_scoped_modifiers(pipe) +vt_define_debug_scoped_modifiers(pool) +vt_define_debug_scoped_modifiers(reduce) +vt_define_debug_scoped_modifiers(rdma) +vt_define_debug_scoped_modifiers(rdma_channel) +vt_define_debug_scoped_modifiers(rdma_state) +vt_define_debug_scoped_modifiers(param) +vt_define_debug_scoped_modifiers(handler) +vt_define_debug_scoped_modifiers(hierlb) +vt_define_debug_scoped_modifiers(temperedlb) +vt_define_debug_scoped_modifiers(scatter) +vt_define_debug_scoped_modifiers(sequence) +vt_define_debug_scoped_modifiers(sequence_vrt) +vt_define_debug_scoped_modifiers(serial_msg) +vt_define_debug_scoped_modifiers(trace) +vt_define_debug_scoped_modifiers(location) +vt_define_debug_scoped_modifiers(lb) +vt_define_debug_scoped_modifiers(vrt) +vt_define_debug_scoped_modifiers(vrt_coll) +vt_define_debug_scoped_modifiers(worker) +vt_define_debug_scoped_modifiers(group) +vt_define_debug_scoped_modifiers(broadcast) +vt_define_debug_scoped_modifiers(objgroup) +vt_define_debug_scoped_modifiers(phase) +vt_define_debug_scoped_modifiers(context) +vt_define_debug_scoped_modifiers(epoch) + +} diff --git a/src/vt/configs/debug/debug_print.h b/src/vt/configs/debug/debug_print.h index 007cfabe1f..2310efaf3a 100644 --- a/src/vt/configs/debug/debug_print.h +++ b/src/vt/configs/debug/debug_print.h @@ -162,15 +162,23 @@ /** * \brief Temporarily enable debug print option. * vt needs to be initialized before usage. -*/ -#define vt_debug_temp_enable_opt(opt) \ + */ +#define vt_debug_temp_enable_opt(opt) \ + if (not ::vt::curRT) { \ + vtAbort("Trying to read config when VT is not initialized"); \ + } \ + \ ::vt::theConfig()->vt_debug_##opt = true /** * \brief Temporarily disable debug print option. * vt needs to be initialized before usage. -*/ -#define vt_debug_temp_disable_opt(opt) \ + */ +#define vt_debug_temp_disable_opt(opt) \ + if (not ::vt::curRT) { \ + vtAbort("Trying to read config when VT is not initialized"); \ + } \ + \ ::vt::theConfig()->vt_debug_##opt = false /** @@ -184,10 +192,8 @@ * auto const scopedEnabledContext = vt_debug_scoped_enable_opt(context); * ... * } - } -*/ -#define vt_debug_scoped_enable_opt(opt) \ - ScopedModifier_##opt##_##true { } + */ +#define vt_debug_scoped_enable_opt(opt) createScopedModifier_##opt##_true() /** * \brief Temporarily disable debug print option in given scope. When exiting @@ -200,65 +206,63 @@ * auto const scopedDisabledContext = vt_debug_scoped_disable_opt(context); * ... * } - } -*/ -#define vt_debug_scoped_disable_opt(opt) \ - ScopedModifier_##opt##_##false { } - -#define vt_scoped_modifier_opt(opt, val) \ - struct ScopedModifier_##opt##_##val { \ - ScopedModifier_##opt##_##val() \ - : origVal{::vt::theConfig()->vt_debug_##opt} { \ - ::vt::theConfig()->vt_debug_##opt = val; \ - } \ - \ - ~ScopedModifier_##opt##_##val() { \ - ::vt::theConfig()->vt_debug_##opt = origVal; \ - } \ - \ - private: \ - bool origVal; \ - } + */ +#define vt_debug_scoped_disable_opt(opt) createScopedModifier_##opt##_##false() + +#define vt_scoped_modifier_opt_declaration(opt, val) \ + struct ScopedModifier_##opt##_##val { \ + ScopedModifier_##opt##_##val(); \ + ~ScopedModifier_##opt##_##val(); \ + \ + private: \ + bool orig_val; \ + }; \ + \ + ScopedModifier_##opt##_##val createScopedModifier_##opt##_##val() + +#define vt_declare_debug_scoped_modifiers(opt) \ + vt_scoped_modifier_opt_declaration(opt, true); \ + vt_scoped_modifier_opt_declaration(opt, false) + +namespace vt { -#define vt_define_debug_scoped_modifiers(opt) \ - vt_scoped_modifier_opt(opt, true); \ - vt_scoped_modifier_opt(opt, false) - -vt_define_debug_scoped_modifiers(all); -vt_define_debug_scoped_modifiers(none); -vt_define_debug_scoped_modifiers(gen); -vt_define_debug_scoped_modifiers(runtime); -vt_define_debug_scoped_modifiers(active); -vt_define_debug_scoped_modifiers(term); -vt_define_debug_scoped_modifiers(termds); -vt_define_debug_scoped_modifiers(barrier); -vt_define_debug_scoped_modifiers(event); -vt_define_debug_scoped_modifiers(pipe); -vt_define_debug_scoped_modifiers(pool); -vt_define_debug_scoped_modifiers(reduce); -vt_define_debug_scoped_modifiers(rdma); -vt_define_debug_scoped_modifiers(rdma_channel); -vt_define_debug_scoped_modifiers(rdma_state); -vt_define_debug_scoped_modifiers(param); -vt_define_debug_scoped_modifiers(handler); -vt_define_debug_scoped_modifiers(hierlb); -vt_define_debug_scoped_modifiers(temperedlb); -vt_define_debug_scoped_modifiers(scatter); -vt_define_debug_scoped_modifiers(sequence); -vt_define_debug_scoped_modifiers(sequence_vrt); -vt_define_debug_scoped_modifiers(serial_msg); -vt_define_debug_scoped_modifiers(trace); -vt_define_debug_scoped_modifiers(location); -vt_define_debug_scoped_modifiers(lb); -vt_define_debug_scoped_modifiers(vrt); -vt_define_debug_scoped_modifiers(vrt_coll); -vt_define_debug_scoped_modifiers(worker); -vt_define_debug_scoped_modifiers(group); -vt_define_debug_scoped_modifiers(broadcast); -vt_define_debug_scoped_modifiers(objgroup); -vt_define_debug_scoped_modifiers(phase); -vt_define_debug_scoped_modifiers(context); -vt_define_debug_scoped_modifiers(epoch); +vt_declare_debug_scoped_modifiers(all); +vt_declare_debug_scoped_modifiers(none); +vt_declare_debug_scoped_modifiers(gen); +vt_declare_debug_scoped_modifiers(runtime); +vt_declare_debug_scoped_modifiers(active); +vt_declare_debug_scoped_modifiers(term); +vt_declare_debug_scoped_modifiers(termds); +vt_declare_debug_scoped_modifiers(barrier); +vt_declare_debug_scoped_modifiers(event); +vt_declare_debug_scoped_modifiers(pipe); +vt_declare_debug_scoped_modifiers(pool); +vt_declare_debug_scoped_modifiers(reduce); +vt_declare_debug_scoped_modifiers(rdma); +vt_declare_debug_scoped_modifiers(rdma_channel); +vt_declare_debug_scoped_modifiers(rdma_state); +vt_declare_debug_scoped_modifiers(param); +vt_declare_debug_scoped_modifiers(handler); +vt_declare_debug_scoped_modifiers(hierlb); +vt_declare_debug_scoped_modifiers(temperedlb); +vt_declare_debug_scoped_modifiers(scatter); +vt_declare_debug_scoped_modifiers(sequence); +vt_declare_debug_scoped_modifiers(sequence_vrt); +vt_declare_debug_scoped_modifiers(serial_msg); +vt_declare_debug_scoped_modifiers(trace); +vt_declare_debug_scoped_modifiers(location); +vt_declare_debug_scoped_modifiers(lb); +vt_declare_debug_scoped_modifiers(vrt); +vt_declare_debug_scoped_modifiers(vrt_coll); +vt_declare_debug_scoped_modifiers(worker); +vt_declare_debug_scoped_modifiers(group); +vt_declare_debug_scoped_modifiers(broadcast); +vt_declare_debug_scoped_modifiers(objgroup); +vt_declare_debug_scoped_modifiers(phase); +vt_declare_debug_scoped_modifiers(context); +vt_declare_debug_scoped_modifiers(epoch); + +} // namespace vt namespace vt { namespace runtime { struct Runtime; From c7379fd64913d0a1a1a63b8c7948666ca6b8c99b Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Tue, 1 Feb 2022 10:09:46 +0100 Subject: [PATCH 07/47] #1636 add missing include --- src/vt/configs/debug/debug_print.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vt/configs/debug/debug_print.cc b/src/vt/configs/debug/debug_print.cc index bb947163b0..0e2df5f60d 100644 --- a/src/vt/configs/debug/debug_print.cc +++ b/src/vt/configs/debug/debug_print.cc @@ -41,6 +41,7 @@ //@HEADER */ +#include "vt/configs/debug/debug_masterconfig.h" #include "vt/configs/debug/debug_print.h" #include "vt/configs/error/hard_error.h" From 3575997aba97524e53753aa800f600f2f9876520 Mon Sep 17 00:00:00 2001 From: Jakub Domagala Date: Thu, 1 Jul 2021 20:54:54 +0200 Subject: [PATCH 08/47] #1445: active: schedule messages on self-send --- src/vt/messaging/active.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 323339c308..b45ac2e21d 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -233,7 +233,7 @@ EventType ActiveMessenger::sendMsgBytesWithPut( vtWarnIf( !(dest != theContext()->getNode() || is_bcast), - "Destination {} should != this node" + fmt::format("Destination {} should != this node", dest) ); MsgSizeType new_msg_size = base.size(); @@ -522,8 +522,16 @@ EventType ActiveMessenger::doMessageSend( base, uninitialized_destination, true, &deliver ); + // Don't go through MPI with self-send, schedule the message locally instead + auto const this_node = theContext()->getNode(); if (deliver) { - sendMsgBytesWithPut(dest, base, send_tag); + if (dest != this_node) { + sendMsgBytesWithPut(dest, base, send_tag); + } else { + runnable::makeRunnable(base, true, envelopeGetHandler(msg->env), dest) + .withTDEpochFromMsg(is_term) + .enqueue(); + } return no_event; } From a4ececd09eace595eed3fa039a7b657505ef5475 Mon Sep 17 00:00:00 2001 From: Jacob Domagala Date: Tue, 18 Jan 2022 18:54:20 +0100 Subject: [PATCH 09/47] #1445: active: Add LB stats instrumentation for self-send runnable object --- src/vt/messaging/active.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index b45ac2e21d..fc567f7aa3 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -528,8 +528,21 @@ EventType ActiveMessenger::doMessageSend( if (dest != this_node) { sendMsgBytesWithPut(dest, base, send_tag); } else { + if (theContext()->getTask() != nullptr) { + auto lb = theContext()->getTask()->get(); + if (lb) { + auto const already_recorded = + envelopeCommStatsRecordedAboveBareHandler(msg->env); + if (not already_recorded) { + auto dest_elm_id = elm::ElmIDBits::createBareHandler(dest); + theContext()->getTask()->send(dest_elm_id, base.size()); + } + } + } + runnable::makeRunnable(base, true, envelopeGetHandler(msg->env), dest) .withTDEpochFromMsg(is_term) + .withLBStats(&bare_handler_stats_, bare_handler_dummy_elm_id_for_lb_stats_) .enqueue(); } return no_event; From 0ba79931edbb985fd1bde343eba5fdfc416c1d1f Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Thu, 3 Feb 2022 14:09:10 +0100 Subject: [PATCH 10/47] #1667 remove features_enableif.h --- src/vt/configs/debug/debug_config.h | 1 - src/vt/configs/debug/debug_masterconfig.h | 2 - src/vt/configs/features/features_defines.h | 4 ++ src/vt/configs/features/features_enableif.h | 51 --------------------- src/vt/runtime/mpi_access.h | 2 +- src/vt/trace/trace_lite.h | 2 +- 6 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 src/vt/configs/features/features_enableif.h diff --git a/src/vt/configs/debug/debug_config.h b/src/vt/configs/debug/debug_config.h index 0109ef2aaf..c034e5beb4 100644 --- a/src/vt/configs/debug/debug_config.h +++ b/src/vt/configs/debug/debug_config.h @@ -206,7 +206,6 @@ struct Configuration { #include "vt/configs/features/features_featureswitch.h" #include "vt/configs/features/features_defines.h" -#include "vt/configs/features/features_enableif.h" #include "vt/configs/debug/debug_printconst.h" #endif /*INCLUDED_VT_CONFIGS_DEBUG_DEBUG_CONFIG_H*/ diff --git a/src/vt/configs/debug/debug_masterconfig.h b/src/vt/configs/debug/debug_masterconfig.h index d4b2044567..716c0264a4 100644 --- a/src/vt/configs/debug/debug_masterconfig.h +++ b/src/vt/configs/debug/debug_masterconfig.h @@ -44,8 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_DEBUG_DEBUG_MASTERCONFIG_H #define INCLUDED_VT_CONFIGS_DEBUG_DEBUG_MASTERCONFIG_H -#include - /* * Define the compile-time configuration options. Eventually this will be * partially defined with cmake options diff --git a/src/vt/configs/features/features_defines.h b/src/vt/configs/features/features_defines.h index 166ad98848..52fba7d23d 100644 --- a/src/vt/configs/features/features_defines.h +++ b/src/vt/configs/features/features_defines.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_CONFIGS_FEATURES_FEATURES_DEFINES_H #define INCLUDED_VT_CONFIGS_FEATURES_FEATURES_DEFINES_H +#include + /* * All the defined features/options for debugging and backend enable-ifs */ @@ -72,4 +74,6 @@ #define vt_feature_libfort 0 || vt_feature_cmake_libfort #define vt_feature_production_build 0 || vt_feature_cmake_production_build +#define vt_check_enabled(test_option) (vt_feature_ ## test_option != 0) + #endif /*INCLUDED_VT_CONFIGS_FEATURES_FEATURES_DEFINES_H*/ diff --git a/src/vt/configs/features/features_enableif.h b/src/vt/configs/features/features_enableif.h deleted file mode 100644 index 24b40876ee..0000000000 --- a/src/vt/configs/features/features_enableif.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// features_enableif.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_CONFIGS_FEATURES_FEATURES_ENABLEIF_H -#define INCLUDED_VT_CONFIGS_FEATURES_FEATURES_ENABLEIF_H - -#include "vt/configs/features/features_defines.h" - -#define vt_check_enabled(test_option) (vt_feature_ ## test_option != 0) - -#endif /*INCLUDED_VT_CONFIGS_FEATURES_FEATURES_ENABLEIF_H*/ diff --git a/src/vt/runtime/mpi_access.h b/src/vt/runtime/mpi_access.h index 9b2deaf7c7..413f98cac4 100644 --- a/src/vt/runtime/mpi_access.h +++ b/src/vt/runtime/mpi_access.h @@ -44,7 +44,7 @@ #if !defined INCLUDED_VT_RUNTIME_MPI_ACCESS_H #define INCLUDED_VT_RUNTIME_MPI_ACCESS_H -#include "vt/configs/features/features_enableif.h" +#include "vt/configs/features/features_defines.h" #if vt_check_enabled(mpi_access_guards) #define VT_ALLOW_MPI_CALLS vt::runtime::ScopedMPIAccess _vt_allow_scoped_mpi{}; diff --git a/src/vt/trace/trace_lite.h b/src/vt/trace/trace_lite.h index b7f3e9dbfc..7ed64ba559 100644 --- a/src/vt/trace/trace_lite.h +++ b/src/vt/trace/trace_lite.h @@ -44,7 +44,7 @@ #if !defined INCLUDED_VT_TRACE_TRACE_LITE_H #define INCLUDED_VT_TRACE_TRACE_LITE_H -#include "vt/configs/features/features_enableif.h" +#include "vt/configs/features/features_defines.h" #include "vt/trace/trace_common.h" #include "vt/trace/trace_log.h" #include "vt/trace/trace_user_event.h" From f8f74d1c6967934626e7718f4fc276334a3d99f0 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Mon, 7 Feb 2022 13:18:06 +0100 Subject: [PATCH 11/47] #1667 clean up configs/types --- src/vt/collective/reduce/scoping/strong_types.h | 1 + src/vt/configs/debug/debug_var_unused.h | 2 ++ src/vt/configs/error/stack_out.h | 5 +++-- src/vt/configs/types/types_headers.h | 1 + src/vt/configs/types/types_rdma.h | 1 - src/vt/configs/types/types_sentinels.h | 1 - src/vt/configs/types/types_type.h | 3 --- src/vt/context/runnable_context/td.h | 1 + src/vt/epoch/epoch_impl_type.h | 2 ++ src/vt/utils/bits/bits_counter.h | 2 ++ src/vt/utils/strong/strong_type.h | 3 +++ 11 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/vt/collective/reduce/scoping/strong_types.h b/src/vt/collective/reduce/scoping/strong_types.h index 3e24a4b481..c4e8eeffd8 100644 --- a/src/vt/collective/reduce/scoping/strong_types.h +++ b/src/vt/collective/reduce/scoping/strong_types.h @@ -46,6 +46,7 @@ #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_sentinels.h" +#include "vt/epoch/epoch_type.h" #include "vt/utils/strong/strong_type.h" namespace vt { namespace collective { namespace reduce { namespace detail { diff --git a/src/vt/configs/debug/debug_var_unused.h b/src/vt/configs/debug/debug_var_unused.h index 481ebc70c3..c461fc6203 100644 --- a/src/vt/configs/debug/debug_var_unused.h +++ b/src/vt/configs/debug/debug_var_unused.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_CONFIGS_DEBUG_DEBUG_VAR_UNUSED_H #define INCLUDED_VT_CONFIGS_DEBUG_DEBUG_VAR_UNUSED_H +#include + #define vt_force_use(...) vt::debug::useVars(__VA_ARGS__); namespace vt { namespace debug { diff --git a/src/vt/configs/error/stack_out.h b/src/vt/configs/error/stack_out.h index 57a0b2aacf..1858ab0022 100644 --- a/src/vt/configs/error/stack_out.h +++ b/src/vt/configs/error/stack_out.h @@ -47,12 +47,13 @@ #include #include #include +#include namespace vt { namespace debug { namespace stack { -using StackTupleType = std::tuple; +using StackTupleType = std::tuple; using StackVectorType = std::vector; -using DumpStackType = std::tuple; +using DumpStackType = std::tuple; /* * This function automatically produce a backtrace of the stack with demangled diff --git a/src/vt/configs/types/types_headers.h b/src/vt/configs/types/types_headers.h index f1ebde4d3e..606db97d04 100644 --- a/src/vt/configs/types/types_headers.h +++ b/src/vt/configs/types/types_headers.h @@ -49,5 +49,6 @@ #include "vt/configs/types/types_rdma.h" #include "vt/configs/types/types_size.h" #include "vt/configs/types/types_sentinels.h" +#include "vt/epoch/epoch_type.h" #endif /*INCLUDED_VT_CONFIGS_TYPES_TYPES_HEADERS_H*/ diff --git a/src/vt/configs/types/types_rdma.h b/src/vt/configs/types/types_rdma.h index 787ccdb69f..91383a153a 100644 --- a/src/vt/configs/types/types_rdma.h +++ b/src/vt/configs/types/types_rdma.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_TYPES_TYPES_RDMA_H #define INCLUDED_VT_CONFIGS_TYPES_TYPES_RDMA_H -#include "vt/configs/debug/debug_masterconfig.h" #include "vt/configs/types/types_type.h" #include diff --git a/src/vt/configs/types/types_sentinels.h b/src/vt/configs/types/types_sentinels.h index 06faefa1f0..7fd67a7a38 100644 --- a/src/vt/configs/types/types_sentinels.h +++ b/src/vt/configs/types/types_sentinels.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_TYPES_TYPES_SENTINELS_H #define INCLUDED_VT_CONFIGS_TYPES_TYPES_SENTINELS_H -#include "vt/configs/debug/debug_masterconfig.h" #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_rdma.h" diff --git a/src/vt/configs/types/types_type.h b/src/vt/configs/types/types_type.h index adaf543d72..ed125fea76 100644 --- a/src/vt/configs/types/types_type.h +++ b/src/vt/configs/types/types_type.h @@ -128,7 +128,4 @@ using ActionNodeType = std::function; } // end namespace vt -// Include the epoch type, which is a strong, named type -#include "vt/epoch/epoch_type.h" - #endif /*INCLUDED_VT_CONFIGS_TYPES_TYPES_TYPE_H*/ diff --git a/src/vt/context/runnable_context/td.h b/src/vt/context/runnable_context/td.h index 40174e188e..b991a8760e 100644 --- a/src/vt/context/runnable_context/td.h +++ b/src/vt/context/runnable_context/td.h @@ -47,6 +47,7 @@ #include "vt/context/runnable_context/base.h" #include "vt/configs/types/types_type.h" #include "vt/configs/types/types_sentinels.h" +#include "vt/epoch/epoch_type.h" #include diff --git a/src/vt/epoch/epoch_impl_type.h b/src/vt/epoch/epoch_impl_type.h index f04bc1dd51..30631d44bd 100644 --- a/src/vt/epoch/epoch_impl_type.h +++ b/src/vt/epoch/epoch_impl_type.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_EPOCH_EPOCH_IMPL_TYPE_H #define INCLUDED_VT_EPOCH_EPOCH_IMPL_TYPE_H +#include + namespace vt { namespace epoch { namespace detail { /// Epoch tag type for the strong type diff --git a/src/vt/utils/bits/bits_counter.h b/src/vt/utils/bits/bits_counter.h index 1d6b968bb1..8994f65d0a 100644 --- a/src/vt/utils/bits/bits_counter.h +++ b/src/vt/utils/bits/bits_counter.h @@ -44,6 +44,8 @@ #if !defined INCLUDED_VT_UTILS_BITS_BITS_COUNTER_H #define INCLUDED_VT_UTILS_BITS_BITS_COUNTER_H +#include + // Do not pull in other VT dependencies here namespace vt { namespace utils { diff --git a/src/vt/utils/strong/strong_type.h b/src/vt/utils/strong/strong_type.h index bc82096074..5088b5928e 100644 --- a/src/vt/utils/strong/strong_type.h +++ b/src/vt/utils/strong/strong_type.h @@ -44,6 +44,9 @@ #if !defined INCLUDED_VT_UTILS_STRONG_STRONG_TYPE_H #define INCLUDED_VT_UTILS_STRONG_STRONG_TYPE_H +#include +#include + namespace vt { namespace util { namespace strong { namespace detail { /** From 26650edd62b927a08ffbc7862b84c9d06b83b13a Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Mon, 7 Feb 2022 15:42:14 +0100 Subject: [PATCH 12/47] #1667 clean up configs/debug --- src/vt/configs/debug/debug_colorize.h | 5 +---- src/vt/configs/debug/debug_print.h | 2 -- src/vt/runtime/runtime.cc | 12 ++++++++++-- tests/perf/common/test_harness.cc | 12 ++++++++++-- tests/unit/test_harness.h | 12 ++++++++++-- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/vt/configs/debug/debug_colorize.h b/src/vt/configs/debug/debug_colorize.h index c6c6f8a2c5..16a1cc4952 100644 --- a/src/vt/configs/debug/debug_colorize.h +++ b/src/vt/configs/debug/debug_colorize.h @@ -50,11 +50,8 @@ #include namespace vt { namespace debug { -arguments::AppConfig * preConfigRef(); -arguments::AppConfig const* preConfig(); -}} /* end namespace vt::debug */ -namespace vt { namespace debug { +arguments::AppConfig const* preConfig(); inline bool colorizeOutput() { return vt::debug::preConfig()->colorize_output; diff --git a/src/vt/configs/debug/debug_print.h b/src/vt/configs/debug/debug_print.h index 2310efaf3a..aac28b217f 100644 --- a/src/vt/configs/debug/debug_print.h +++ b/src/vt/configs/debug/debug_print.h @@ -44,7 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_DEBUG_DEBUG_PRINT_H #define INCLUDED_VT_CONFIGS_DEBUG_DEBUG_PRINT_H -#include "vt/configs/arguments/app_config.h" #include "vt/configs/types/types_headers.h" #include "vt/configs/debug/debug_config.h" #include "vt/configs/debug/debug_colorize.h" @@ -273,7 +272,6 @@ extern runtime::Runtime* curRT; } /* end namespace vt */ namespace vt { namespace debug { -arguments::AppConfig const* preConfig(); NodeType preNode(); }} /* end namespace vt::debug */ diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 837bc76363..eded754d0f 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -94,7 +94,13 @@ #include #include -namespace vt { namespace runtime { +namespace vt { + +namespace debug { +arguments::AppConfig * preConfigRef(); +} // namespace debug + +namespace runtime { /*static*/ bool volatile Runtime::sig_user_1_ = false; @@ -1230,4 +1236,6 @@ arguments::AppConfig const* Runtime::getAppConfig() const { return app_config_; } -}} //end namespace vt::runtime +} // namespace runtime + +} // namespace vt diff --git a/tests/perf/common/test_harness.cc b/tests/perf/common/test_harness.cc index c8e33a136e..41ae367bc3 100644 --- a/tests/perf/common/test_harness.cc +++ b/tests/perf/common/test_harness.cc @@ -52,7 +52,13 @@ #include #include -namespace vt { namespace tests { namespace perf { namespace common { +namespace vt { + +namespace debug { +arguments::AppConfig *preConfigRef(); +} // namespace debug + +namespace tests { namespace perf { namespace common { ///////////////////////////////////////////////// /////////////// HELPERS /////////////// @@ -445,4 +451,6 @@ void PerfTestHarness::GetMemoryUsage() { memory_use_[current_run_].push_back(mem_tracker_.getUsage()); } -}}}} // namespace vt::tests::perf::common +}}} // namespace tests::perf::common + +} // namespace vt diff --git a/tests/unit/test_harness.h b/tests/unit/test_harness.h index 43ba2e9867..4ed1744260 100644 --- a/tests/unit/test_harness.h +++ b/tests/unit/test_harness.h @@ -52,7 +52,13 @@ #include "test_config.h" #include "data_message.h" -namespace vt { namespace tests { namespace unit { +namespace vt { + +namespace debug { +arguments::AppConfig *preConfigRef(); +} // namespace debug + +namespace tests { namespace unit { template struct TestHarnessAny : TestBase { @@ -73,6 +79,8 @@ using TestHarness = TestHarnessAny; template using TestHarnessParam = TestHarnessAny>; -}}} // end namespace vt::tests::unit +}} // end namespace tests::unit + +} // namespace vt #endif /* INCLUDED_UNIT_TEST_HARNESS_H */ From e4e188e125d5c764d203f0bf9941e594178c60a3 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Tue, 8 Feb 2022 11:06:05 +0100 Subject: [PATCH 13/47] #1667 clean up configs/error --- src/vt/configs/error/code.h | 2 -- src/vt/configs/error/common.h | 3 +-- src/vt/configs/error/config_assert.h | 4 ---- src/vt/configs/error/error.h | 2 -- src/vt/configs/error/error.impl.h | 1 + src/vt/configs/error/keyval_printer.h | 3 --- src/vt/configs/error/pretty_print_stack.h | 3 +-- src/vt/configs/error/soft_error.h | 2 ++ 8 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/vt/configs/error/code.h b/src/vt/configs/error/code.h index 73b33012b4..1f77cd4384 100644 --- a/src/vt/configs/error/code.h +++ b/src/vt/configs/error/code.h @@ -44,8 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_ERROR_CODE_H #define INCLUDED_VT_CONFIGS_ERROR_CODE_H -#include "vt/configs/error/code_class.h" - #include namespace vt { namespace error { diff --git a/src/vt/configs/error/common.h b/src/vt/configs/error/common.h index 068d262b0b..7a215d25f1 100644 --- a/src/vt/configs/error/common.h +++ b/src/vt/configs/error/common.h @@ -44,8 +44,7 @@ #if !defined INCLUDED_VT_CONFIGS_ERROR_COMMON_H #define INCLUDED_VT_CONFIGS_ERROR_COMMON_H -#include "vt/configs/types/types_headers.h" -#include "vt/collective/basic.h" +#include "vt/configs/types/types_type.h" #define INVERT_COND(cond) (!(cond)) #define DEBUG_LOCATION __FILE__,__LINE__,__func__ diff --git a/src/vt/configs/error/config_assert.h b/src/vt/configs/error/config_assert.h index 427b880bef..8b41608954 100644 --- a/src/vt/configs/error/config_assert.h +++ b/src/vt/configs/error/config_assert.h @@ -49,12 +49,8 @@ * build/runtime mode when the assertion breaks */ -#include "vt/configs/debug/debug_config.h" -#include "vt/configs/types/types_type.h" -#include "vt/configs/error/common.h" #include "vt/configs/error/assert_out.h" #include "vt/configs/error/assert_out_info.h" -#include "vt/configs/error/keyval_printer.h" #include #include diff --git a/src/vt/configs/error/error.h b/src/vt/configs/error/error.h index 438601b137..83ffc42b96 100644 --- a/src/vt/configs/error/error.h +++ b/src/vt/configs/error/error.h @@ -45,8 +45,6 @@ #define INCLUDED_VT_CONFIGS_ERROR_ERROR_H #include "vt/configs/types/types_headers.h" -#include "vt/configs/debug/debug_config.h" -#include "vt/configs/error/common.h" #include #include diff --git a/src/vt/configs/error/error.impl.h b/src/vt/configs/error/error.impl.h index 7f3317cf57..a92c09f82a 100644 --- a/src/vt/configs/error/error.impl.h +++ b/src/vt/configs/error/error.impl.h @@ -49,6 +49,7 @@ #include "vt/configs/error/common.h" #include "vt/configs/error/error.h" #include "vt/configs/error/pretty_print_message.h" +#include "vt/collective/basic.h" #include #include diff --git a/src/vt/configs/error/keyval_printer.h b/src/vt/configs/error/keyval_printer.h index 7008152875..db714b0544 100644 --- a/src/vt/configs/error/keyval_printer.h +++ b/src/vt/configs/error/keyval_printer.h @@ -44,9 +44,6 @@ #if !defined INCLUDED_VT_CONFIGS_ERROR_KEYVAL_PRINTER_H #define INCLUDED_VT_CONFIGS_ERROR_KEYVAL_PRINTER_H -#include "vt/configs/error/common.h" -#include "vt/configs/debug/debug_config.h" - #include #include #include diff --git a/src/vt/configs/error/pretty_print_stack.h b/src/vt/configs/error/pretty_print_stack.h index 3d89e26307..c625864574 100644 --- a/src/vt/configs/error/pretty_print_stack.h +++ b/src/vt/configs/error/pretty_print_stack.h @@ -45,8 +45,7 @@ #define INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H #include "vt/config.h" -#include "vt/configs/error/stack_out.h" -#include "vt/configs/debug/debug_colorize.h" +#include "vt/context/context.h" #include diff --git a/src/vt/configs/error/soft_error.h b/src/vt/configs/error/soft_error.h index 7b939081fe..67edd3bf7a 100644 --- a/src/vt/configs/error/soft_error.h +++ b/src/vt/configs/error/soft_error.h @@ -51,9 +51,11 @@ * the cost of these checks can be fully optimized out. */ +#include "vt/collective/basic.h" #include "vt/configs/types/types_type.h" #include "vt/configs/error/common.h" #include "vt/configs/error/pretty_print_message.h" +#include "vt/configs/features/features_defines.h" #include From 67a9e57f16d4202d74a21b751e0bdc97962950b8 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Tue, 8 Feb 2022 11:41:45 +0100 Subject: [PATCH 14/47] #1667 fix trace cmake --- cmake/trace_only_functions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/trace_only_functions.cmake b/cmake/trace_only_functions.cmake index 0987892c80..700833891b 100644 --- a/cmake/trace_only_functions.cmake +++ b/cmake/trace_only_functions.cmake @@ -30,7 +30,7 @@ function(create_trace_only_target) # vt/configs vt/configs/generated/vt_git_revision.h vt/configs/error/hard_error.h - vt/configs/features/features_enableif.h vt/configs/features/features_featureswitch.h + vt/configs/features/features_featureswitch.h vt/configs/features/features_defines.h vt/configs/types/types_type.h vt/configs/error/pretty_print_message.h vt/configs/debug/debug_masterconfig.h vt/configs/debug/debug_config.h From ffc9800e090f63bb63489820b934fb48bc4e5629 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 9 Feb 2022 12:24:04 +0100 Subject: [PATCH 15/47] #1667 move preConfigRef() forward decleration back to debug_colorize.h --- src/vt/configs/debug/debug_colorize.h | 5 ++++- src/vt/runtime/runtime.cc | 12 ++---------- tests/perf/common/test_harness.cc | 12 ++---------- tests/unit/test_harness.h | 12 ++---------- 4 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/vt/configs/debug/debug_colorize.h b/src/vt/configs/debug/debug_colorize.h index 16a1cc4952..c6c6f8a2c5 100644 --- a/src/vt/configs/debug/debug_colorize.h +++ b/src/vt/configs/debug/debug_colorize.h @@ -50,8 +50,11 @@ #include namespace vt { namespace debug { - +arguments::AppConfig * preConfigRef(); arguments::AppConfig const* preConfig(); +}} /* end namespace vt::debug */ + +namespace vt { namespace debug { inline bool colorizeOutput() { return vt::debug::preConfig()->colorize_output; diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index eded754d0f..837bc76363 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -94,13 +94,7 @@ #include #include -namespace vt { - -namespace debug { -arguments::AppConfig * preConfigRef(); -} // namespace debug - -namespace runtime { +namespace vt { namespace runtime { /*static*/ bool volatile Runtime::sig_user_1_ = false; @@ -1236,6 +1230,4 @@ arguments::AppConfig const* Runtime::getAppConfig() const { return app_config_; } -} // namespace runtime - -} // namespace vt +}} //end namespace vt::runtime diff --git a/tests/perf/common/test_harness.cc b/tests/perf/common/test_harness.cc index 41ae367bc3..c8e33a136e 100644 --- a/tests/perf/common/test_harness.cc +++ b/tests/perf/common/test_harness.cc @@ -52,13 +52,7 @@ #include #include -namespace vt { - -namespace debug { -arguments::AppConfig *preConfigRef(); -} // namespace debug - -namespace tests { namespace perf { namespace common { +namespace vt { namespace tests { namespace perf { namespace common { ///////////////////////////////////////////////// /////////////// HELPERS /////////////// @@ -451,6 +445,4 @@ void PerfTestHarness::GetMemoryUsage() { memory_use_[current_run_].push_back(mem_tracker_.getUsage()); } -}}} // namespace tests::perf::common - -} // namespace vt +}}}} // namespace vt::tests::perf::common diff --git a/tests/unit/test_harness.h b/tests/unit/test_harness.h index 4ed1744260..43ba2e9867 100644 --- a/tests/unit/test_harness.h +++ b/tests/unit/test_harness.h @@ -52,13 +52,7 @@ #include "test_config.h" #include "data_message.h" -namespace vt { - -namespace debug { -arguments::AppConfig *preConfigRef(); -} // namespace debug - -namespace tests { namespace unit { +namespace vt { namespace tests { namespace unit { template struct TestHarnessAny : TestBase { @@ -79,8 +73,6 @@ using TestHarness = TestHarnessAny; template using TestHarnessParam = TestHarnessAny>; -}} // end namespace tests::unit - -} // namespace vt +}}} // end namespace vt::tests::unit #endif /* INCLUDED_UNIT_TEST_HARNESS_H */ From 07f5d90f543940d39fe0898d3fa0b6e67fcd3ce5 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 9 Feb 2022 17:39:52 +0100 Subject: [PATCH 16/47] #1667 extract prettyPrintStack() to *.cc file --- src/vt/configs/error/pretty_print_stack.cc | 94 ++++++++++++++++++++++ src/vt/configs/error/pretty_print_stack.h | 45 +---------- 2 files changed, 96 insertions(+), 43 deletions(-) create mode 100644 src/vt/configs/error/pretty_print_stack.cc diff --git a/src/vt/configs/error/pretty_print_stack.cc b/src/vt/configs/error/pretty_print_stack.cc new file mode 100644 index 0000000000..192e8b0af9 --- /dev/null +++ b/src/vt/configs/error/pretty_print_stack.cc @@ -0,0 +1,94 @@ +/* +//@HEADER +// ***************************************************************************** +// +// pretty_print_stack.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact darma@sandia.gov +// +// ***************************************************************************** +//@HEADER +*/ + +#include "vt/configs/error/pretty_print_stack.h" +#include "vt/configs/debug/debug_colorize.h" +#include "vt/context/context.h" + +#include + +namespace vt { namespace debug { namespace stack { + +std::string prettyPrintStack(StackVectorType const& stack) { + auto green = ::vt::debug::green(); + auto red = ::vt::debug::red(); + auto bred = ::vt::debug::bred(); + auto reset = ::vt::debug::reset(); + auto bd_green = ::vt::debug::bd_green(); + auto magenta = ::vt::debug::magenta(); + auto blue = ::vt::debug::blue(); + auto yellow = ::vt::debug::yellow(); + auto vt_pre = ::vt::debug::vtPre(); + auto node = ::vt::theContext()->getNode(); + auto node_str = ::vt::debug::proc(node); + auto prefix = vt_pre + node_str + " "; + auto seperator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset); + auto title_node = fmt::format("on Node {}", node); + auto title = fmt::format(" Dump Stack Backtrace {} ", title_node); + + std::string out = ""; + + out += fmt::format("{}", seperator); + out += fmt::format("{}{}{:-^120}{}\n", prefix, yellow, title, reset); + out += fmt::format("{}", seperator); + + int i = 0; + for (auto&& t : stack) { + auto ret_str = fmt::format( + "{}{}{:<3}{} {}{:<3} {:<13}{} {}{}{} + {}{}\n", + prefix, + bred, i, reset, + magenta, std::get<0>(t), std::get<1>(t), reset, + green, std::get<2>(t), reset, + std::get<3>(t), reset + ); + out += ret_str; + i++; + } + + //out += seperator + seperator + seperator; + + return out; +} + +}}} /* end namespace vt::debug::stack */ diff --git a/src/vt/configs/error/pretty_print_stack.h b/src/vt/configs/error/pretty_print_stack.h index c625864574..8ea23d84d7 100644 --- a/src/vt/configs/error/pretty_print_stack.h +++ b/src/vt/configs/error/pretty_print_stack.h @@ -44,54 +44,13 @@ #if !defined INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H #define INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H -#include "vt/config.h" -#include "vt/context/context.h" +#include "vt/configs/error/stack_out.h" #include namespace vt { namespace debug { namespace stack { -inline std::string prettyPrintStack(StackVectorType const& stack) { - auto green = ::vt::debug::green(); - auto red = ::vt::debug::red(); - auto bred = ::vt::debug::bred(); - auto reset = ::vt::debug::reset(); - auto bd_green = ::vt::debug::bd_green(); - auto magenta = ::vt::debug::magenta(); - auto blue = ::vt::debug::blue(); - auto yellow = ::vt::debug::yellow(); - auto vt_pre = ::vt::debug::vtPre(); - auto node = ::vt::theContext()->getNode(); - auto node_str = ::vt::debug::proc(node); - auto prefix = vt_pre + node_str + " "; - auto seperator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset); - auto title_node = fmt::format("on Node {}", node); - auto title = fmt::format(" Dump Stack Backtrace {} ", title_node); - - std::string out = ""; - - out += fmt::format("{}", seperator); - out += fmt::format("{}{}{:-^120}{}\n", prefix, yellow, title, reset); - out += fmt::format("{}", seperator); - - int i = 0; - for (auto&& t : stack) { - auto ret_str = fmt::format( - "{}{}{:<3}{} {}{:<3} {:<13}{} {}{}{} + {}{}\n", - prefix, - bred, i, reset, - magenta, std::get<0>(t), std::get<1>(t), reset, - green, std::get<2>(t), reset, - std::get<3>(t), reset - ); - out += ret_str; - i++; - } - - //out += seperator + seperator + seperator; - - return out; -} +std::string prettyPrintStack(StackVectorType const& stack); }}} /* end namespace vt::debug::stack */ From 8d7ce4a829240109cf2bd657ea6d5cd51131b408 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 9 Feb 2022 22:07:25 +0100 Subject: [PATCH 17/47] #1667 Move prettyPrintStack to stack_out --- src/vt/configs/error/pretty_print_stack.cc | 94 ---------------------- src/vt/configs/error/pretty_print_stack.h | 57 ------------- src/vt/configs/error/stack_out.cc | 42 +++++++++- src/vt/configs/error/stack_out.h | 2 + src/vt/runtime/runtime.cc | 1 - 5 files changed, 43 insertions(+), 153 deletions(-) delete mode 100644 src/vt/configs/error/pretty_print_stack.cc delete mode 100644 src/vt/configs/error/pretty_print_stack.h diff --git a/src/vt/configs/error/pretty_print_stack.cc b/src/vt/configs/error/pretty_print_stack.cc deleted file mode 100644 index 192e8b0af9..0000000000 --- a/src/vt/configs/error/pretty_print_stack.cc +++ /dev/null @@ -1,94 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// pretty_print_stack.cc -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#include "vt/configs/error/pretty_print_stack.h" -#include "vt/configs/debug/debug_colorize.h" -#include "vt/context/context.h" - -#include - -namespace vt { namespace debug { namespace stack { - -std::string prettyPrintStack(StackVectorType const& stack) { - auto green = ::vt::debug::green(); - auto red = ::vt::debug::red(); - auto bred = ::vt::debug::bred(); - auto reset = ::vt::debug::reset(); - auto bd_green = ::vt::debug::bd_green(); - auto magenta = ::vt::debug::magenta(); - auto blue = ::vt::debug::blue(); - auto yellow = ::vt::debug::yellow(); - auto vt_pre = ::vt::debug::vtPre(); - auto node = ::vt::theContext()->getNode(); - auto node_str = ::vt::debug::proc(node); - auto prefix = vt_pre + node_str + " "; - auto seperator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset); - auto title_node = fmt::format("on Node {}", node); - auto title = fmt::format(" Dump Stack Backtrace {} ", title_node); - - std::string out = ""; - - out += fmt::format("{}", seperator); - out += fmt::format("{}{}{:-^120}{}\n", prefix, yellow, title, reset); - out += fmt::format("{}", seperator); - - int i = 0; - for (auto&& t : stack) { - auto ret_str = fmt::format( - "{}{}{:<3}{} {}{:<3} {:<13}{} {}{}{} + {}{}\n", - prefix, - bred, i, reset, - magenta, std::get<0>(t), std::get<1>(t), reset, - green, std::get<2>(t), reset, - std::get<3>(t), reset - ); - out += ret_str; - i++; - } - - //out += seperator + seperator + seperator; - - return out; -} - -}}} /* end namespace vt::debug::stack */ diff --git a/src/vt/configs/error/pretty_print_stack.h b/src/vt/configs/error/pretty_print_stack.h deleted file mode 100644 index 8ea23d84d7..0000000000 --- a/src/vt/configs/error/pretty_print_stack.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// pretty_print_stack.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H -#define INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H - -#include "vt/configs/error/stack_out.h" - -#include - -namespace vt { namespace debug { namespace stack { - -std::string prettyPrintStack(StackVectorType const& stack); - -}}} /* end namespace vt::debug::stack */ - -#endif /*INCLUDED_VT_CONFIGS_ERROR_PRETTY_PRINT_STACK_H*/ diff --git a/src/vt/configs/error/stack_out.cc b/src/vt/configs/error/stack_out.cc index 040d49fe82..d98b5e098e 100644 --- a/src/vt/configs/error/stack_out.cc +++ b/src/vt/configs/error/stack_out.cc @@ -44,6 +44,8 @@ #include #include "vt/configs/error/stack_out.h" +#include "vt/configs/debug/debug_colorize.h" +#include "vt/context/context.h" #include #include @@ -117,5 +119,43 @@ DumpStackType dumpStack(int skip) { return std::make_tuple(trace_buf.str(),tuple); } -}}} /* end namespace vt::debug::stack */ +std::string prettyPrintStack(StackVectorType const& stack) { + auto green = ::vt::debug::green(); + auto bred = ::vt::debug::bred(); + auto reset = ::vt::debug::reset(); + auto magenta = ::vt::debug::magenta(); + auto yellow = ::vt::debug::yellow(); + auto vt_pre = ::vt::debug::vtPre(); + auto node = ::vt::theContext()->getNode(); + auto node_str = ::vt::debug::proc(node); + auto prefix = vt_pre + node_str + " "; + auto seperator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset); + auto title_node = fmt::format("on Node {}", node); + auto title = fmt::format(" Dump Stack Backtrace {} ", title_node); + + std::string out = ""; + + out += fmt::format("{}", seperator); + out += fmt::format("{}{}{:-^120}{}\n", prefix, yellow, title, reset); + out += fmt::format("{}", seperator); + + int i = 0; + for (auto&& t : stack) { + auto ret_str = fmt::format( + "{}{}{:<3}{} {}{:<3} {:<13}{} {}{}{} + {}{}\n", + prefix, + bred, i, reset, + magenta, std::get<0>(t), std::get<1>(t), reset, + green, std::get<2>(t), reset, + std::get<3>(t), reset + ); + out += ret_str; + i++; + } + + //out += seperator + seperator + seperator; + return out; +} + +}}} /* end namespace vt::debug::stack */ diff --git a/src/vt/configs/error/stack_out.h b/src/vt/configs/error/stack_out.h index 1858ab0022..cf50a829e0 100644 --- a/src/vt/configs/error/stack_out.h +++ b/src/vt/configs/error/stack_out.h @@ -61,6 +61,8 @@ using DumpStackType = std::tuple; */ DumpStackType dumpStack(int skip = 0); +std::string prettyPrintStack(StackVectorType const& stack); + }}} /* end namespace vt::debug::stack */ #endif /*INCLUDED_VT_CONFIGS_ERROR_STACK_OUT_H*/ diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 837bc76363..12fff50c84 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -64,7 +64,6 @@ #include "vt/worker/worker_headers.h" #include "vt/configs/debug/debug_colorize.h" #include "vt/configs/error/stack_out.h" -#include "vt/configs/error/pretty_print_stack.h" #include "vt/utils/memory/memory_usage.h" #include "vt/runtime/component/component_pack.h" #include "vt/utils/mpi_limits/mpi_max_tag.h" From b9c93147242a4b53a828a8fed086afbdb584dfd6 Mon Sep 17 00:00:00 2001 From: Nicole Lemaster Slattengren Date: Tue, 15 Feb 2022 14:05:19 -0800 Subject: [PATCH 18/47] #1673: termination: use ds by default for rooted epochs --- src/vt/termination/termination.h | 4 ++-- tests/unit/collection/test_mapping.cc | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vt/termination/termination.h b/src/vt/termination/termination.h index e0466b540d..8834006308 100644 --- a/src/vt/termination/termination.h +++ b/src/vt/termination/termination.h @@ -213,7 +213,7 @@ struct TerminationDetector : * \return the new epoch */ EpochType makeEpochRooted( - UseDS use_ds = UseDS{false}, + UseDS use_ds = UseDS{true}, ParentEpochCapture parent = ParentEpochCapture{} ); @@ -239,7 +239,7 @@ struct TerminationDetector : */ EpochType makeEpochRooted( std::string const& label, - UseDS use_ds = UseDS{false}, + UseDS use_ds = UseDS{true}, ParentEpochCapture parent = ParentEpochCapture{} ); diff --git a/tests/unit/collection/test_mapping.cc b/tests/unit/collection/test_mapping.cc index a09b25e414..62ed3439e2 100644 --- a/tests/unit/collection/test_mapping.cc +++ b/tests/unit/collection/test_mapping.cc @@ -256,7 +256,6 @@ struct MyDistMapper : vt::mapping::BaseMapper { /// get to decide the mapping return (val ^ my_state) % num_nodes; } else { - // runInEpochRooted is not DS? auto ep = theTerm()->makeEpochRooted("mapTest", term::UseDS{true}); theMsg()->pushEpoch(ep); proxy[owner].template send::getMap>( From 0e178e167ceff48671bf81356ef432314fd18c93 Mon Sep 17 00:00:00 2001 From: Nicole Lemaster Slattengren Date: Tue, 15 Feb 2022 14:43:43 -0800 Subject: [PATCH 19/47] #1673: collection: use non-ds epoch for construction --- src/vt/vrt/collection/collection_builder.impl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vt/vrt/collection/collection_builder.impl.h b/src/vt/vrt/collection/collection_builder.impl.h index f33a463927..81137355bf 100644 --- a/src/vt/vrt/collection/collection_builder.impl.h +++ b/src/vt/vrt/collection/collection_builder.impl.h @@ -62,7 +62,9 @@ std::tuple CollectionManager::makeCollection( po.proxy_bits_ = proxy_bits; if (not is_collective) { - auto ep = theTerm()->makeEpochRooted("collection construction"); + auto ep = theTerm()->makeEpochRooted( + "collection construction", term::UseDS{false} + ); theMsg()->pushEpoch(ep); using MsgType = param::ConstructParamMsg; auto m = makeMessage(po); From 49fb6da62cd0dd91d283c36c83c0e63e4b3feb7a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 23 Feb 2022 15:53:05 -0800 Subject: [PATCH 20/47] #1685: trace: fix handler type for objgroup messages --- src/vt/objgroup/manager.static.h | 6 ++++-- src/vt/runnable/make_runnable.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vt/objgroup/manager.static.h b/src/vt/objgroup/manager.static.h index 1de65daeb4..0bd36b4940 100644 --- a/src/vt/objgroup/manager.static.h +++ b/src/vt/objgroup/manager.static.h @@ -66,8 +66,9 @@ void send(MsgSharedPtr msg, HandlerType han, NodeType dest_node) { auto holder = detail::getHolderBase(han); auto const& elm_id = holder->getElmID(); auto stats = &holder->getStats(); + auto han_type = auto_registry::RegistryTypeEnum::RegObjGroup; - runnable::makeRunnable(msg, true, han, this_node) + runnable::makeRunnable(msg, true, han, this_node, han_type) .withTDEpoch(cur_epoch) .withLBStats(stats, elm_id) .enqueue(); @@ -87,7 +88,8 @@ void invoke(messaging::MsgPtrThief msg, HandlerType han, NodeType dest_nod ); // this is a local invocation.. no thread required - runnable::makeRunnable(msg.msg_, false, han, this_node) + auto han_type = auto_registry::RegistryTypeEnum::RegObjGroup; + runnable::makeRunnable(msg.msg_, false, han, this_node, han_type) .withTDEpochFromMsg() .run(); } diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 5b8ccd8527..16c565eb0c 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -325,7 +325,8 @@ RunnableMaker makeRunnable( ) { auto r = std::make_unique(msg, is_threaded); if (han_type == auto_registry::RegistryTypeEnum::RegVrt or - han_type == auto_registry::RegistryTypeEnum::RegGeneral) { + han_type == auto_registry::RegistryTypeEnum::RegGeneral or + han_type == auto_registry::RegistryTypeEnum::RegObjGroup) { r->template addContext(msg, handler, from, han_type); } r->template addContext(from); From 66fc586baa03ec807e3d6c75d2b4f98aeb95e595 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 17 Feb 2022 12:17:29 -0800 Subject: [PATCH 21/47] #1680: lb: only add to migration if its actually a migration --- src/vt/vrt/collection/balance/baselb/baselb.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vt/vrt/collection/balance/baselb/baselb.cc b/src/vt/vrt/collection/balance/baselb/baselb.cc index 2035b69608..07cc718ad9 100644 --- a/src/vt/vrt/collection/balance/baselb/baselb.cc +++ b/src/vt/vrt/collection/balance/baselb/baselb.cc @@ -228,7 +228,9 @@ void BaseLB::notifyNewHostNodeOfObjectsArriving( } void BaseLB::migrateObjectTo(ObjIDType const obj_id, NodeType const to) { - transfers_.push_back(TransferDestType{obj_id, to}); + if (obj_id.curr_node != to) { + transfers_.push_back(TransferDestType{obj_id, to}); + } } void BaseLB::finalize(CountMsg* msg) { From a6156df65221e34099ec72e543251f68890e5bf9 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 16:31:13 -0800 Subject: [PATCH 22/47] #1677: cmake: Move git configuration detection into a standalone cmake script --- cmake/build_git_info.cmake | 60 ++++++++++++----------- cmake/run-git.cmake | 98 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+), 29 deletions(-) create mode 100644 cmake/run-git.cmake diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index be71af34ff..4f7f37f1cc 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -1,34 +1,36 @@ +function(get_git_dir _git_dir) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() -include(GetGitRevisionDescription) + set(${_git_dir} ${GIT_DIR} PARENT_SCOPE) +endfunction() -get_git_head_revision(GIT_REFSPEC GIT_SHA1) +get_git_dir(GIT_DIR) -# set some variables related to GIT state information -get_git_head_revision(GIT_REFSPEC GIT_SHA1) -git_describe(GIT_EXACT_TAG --tags --abbrev=0 --all) -git_describe(GIT_DESCRIPTION --abbrev=10 --always --tags --long --all) -git_local_changes(GIT_CLEAN_STATUS) +if(NOT EXISTS "${GIT_DIR}/HEAD") + message(FATAL_ERROR "no such file: \"${GIT_DIR}/HEAD\"") +endif() +set(HEAD_FILE "${GIT_DIR}/HEAD") -message(STATUS "REF:${GIT_REFSPEC}") -message(STATUS "REF:${GIT_SHA1}") -message(STATUS "REF:${GIT_DESCRIPTION}") -message(STATUS "REF:${GIT_CLEAN_STATUS}") -message(STATUS "REF:${GIT_EXACT_TAG}") +message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") -configure_file( - ${PROJECT_BASE_DIR}/vt_git_revision.cc.in - ${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc - @ONLY -) - -# install( -# FILES "${PROJECT_BINARY_DIR}/${cur_build_type}/cmake_config.h" -# DESTINATION include -# CONFIGURATIONS ${cur_build_type} -# ) - -# configure_file( -# "${PROJECT_SOURCE_DIR}/vt_git_revision.cc.in" -# "${CMAKE_CURRENT_BINARY_DIR}/vt_git_revision.cc" -# @ONLY -# ) +find_package(Git REQUIRED) +execute_process(COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake) diff --git a/cmake/run-git.cmake b/cmake/run-git.cmake new file mode 100644 index 0000000000..2138bbf3ef --- /dev/null +++ b/cmake/run-git.cmake @@ -0,0 +1,98 @@ +# This file is intented to be run with cmake -P + +# Derived from +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +message(STATUS "Reading head file ${HEAD_FILE}") +message(STATUS "Using git executable at \"${GIT_EXECUTABLE}\"") + +set(GIT_SHA1) + +file(READ "${HEAD_FILE}" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" GIT_REFSPEC "${HEAD_CONTENTS}") + if(EXISTS "${GIT_DIR}/${GIT_REFSPEC}") + file(READ "${GIT_DIR}/${GIT_REFSPEC}" GIT_SHA1 LIMIT 1024) + string(STRIP "${GIT_SHA1}" GIT_SHA1) + else() + file(READ "${GIT_DIR}/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${GIT_REFSPEC}") + set(GIT_SHA1 "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + string(STRIP "${HEAD_CONTENTS}" GIT_SHA1) +endif() + +message(STATUS "GIT_REFSPEC: \"${GIT_REFSPEC}\"") +message(STATUS "GIT_SHA1: \"${GIT_SHA1}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${GIT_SHA1} + --tags --abbrev=0 --all + WORKING_DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + GIT_EXACT_TAG + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT res EQUAL 0) + message(FATAL_ERROR "could not get the exact git tag") +endif() + +message(STATUS "GIT_EXACT_TAG: \"${GIT_EXACT_TAG}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${GIT_SHA1} + --abbrev=10 --always --tags --long --all + WORKING_DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + GIT_DESCRIPTION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT res EQUAL 0) + message(FATAL_ERROR "could not get the description") +endif() + +message(STATUS "GIT_DESCRIPTION: \"${GIT_DESCRIPTION}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + diff-index --quiet HEAD -- + WORKING_DIRECTORY + "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE + res + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(res EQUAL 0) + set(GIT_CLEAN_STATUS "CLEAN") +else() + set(GIT_CLEAN_STATUS "DIRTY") +endif() + +message(STATUS "Git Clean Status: \"${GIT_CLEAN_STATUS}\"") + +message(STATUS "Configuring ${IN_FILE} to generate ${OUT_FILE}.") +configure_file(${IN_FILE} ${OUT_FILE} @ONLY) \ No newline at end of file From 3f1ed14810a497ebe51f5c96afc036b42e690f85 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 23 Feb 2022 15:53:28 -0800 Subject: [PATCH 23/47] #1685: runnable: require the handler type everywhere --- src/vt/collective/reduce/reduce.impl.h | 6 ++++-- src/vt/messaging/active.cc | 9 ++++++--- .../pipe/callback/handler_send/callback_send.impl.h | 3 ++- .../callback/handler_send/callback_send_tl.impl.h | 3 ++- src/vt/runnable/make_runnable.h | 12 +++++------- .../messaging/serialized_messenger.impl.h | 12 ++++++++---- src/vt/topos/location/location.impl.h | 3 ++- 7 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/vt/collective/reduce/reduce.impl.h b/src/vt/collective/reduce/reduce.impl.h index 566cb33279..6fbc3d7183 100644 --- a/src/vt/collective/reduce/reduce.impl.h +++ b/src/vt/collective/reduce/reduce.impl.h @@ -78,9 +78,10 @@ void Reduce::reduceRootRecv(MsgT* msg) { msg->is_root_ = true; auto const& from_node = theContext()->getFromNodeCurrentTask(); + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; auto m = promoteMsg(msg); - runnable::makeRunnable(m, false, handler, from_node) + runnable::makeRunnable(m, false, handler, from_node, han_type) .withTDEpochFromMsg() .run(); } @@ -258,7 +259,8 @@ void Reduce::startReduce(detail::ReduceStamp id, bool use_num_contrib) { // this needs to run inline.. threaded not allowed for reduction // combination - runnable::makeRunnable(state.msgs[0], false, handler, from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(state.msgs[0], false, handler, from_node, han_type) .withTDEpochFromMsg() .run(); } diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index fc567f7aa3..df37e99653 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -540,8 +540,10 @@ EventType ActiveMessenger::doMessageSend( } } - runnable::makeRunnable(base, true, envelopeGetHandler(msg->env), dest) - .withTDEpochFromMsg(is_term) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable( + base, true, envelopeGetHandler(msg->env), dest, han_type + ) .withTDEpochFromMsg(is_term) .withLBStats(&bare_handler_stats_, bare_handler_dummy_elm_id_for_lb_stats_) .enqueue(); } @@ -1000,7 +1002,8 @@ bool ActiveMessenger::prepareActiveMsgToRun( } if (has_handler) { - runnable::makeRunnable(base, not is_term, handler, from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(base, not is_term, handler, from_node, han_type) .withContinuation(cont) .withTag(tag) .withTDEpochFromMsg(is_term) diff --git a/src/vt/pipe/callback/handler_send/callback_send.impl.h b/src/vt/pipe/callback/handler_send/callback_send.impl.h index fd172c0eab..c716d75327 100644 --- a/src/vt/pipe/callback/handler_send/callback_send.impl.h +++ b/src/vt/pipe/callback/handler_send/callback_send.impl.h @@ -110,7 +110,8 @@ CallbackSend::triggerDispatch(SignalDataType* data, PipeType const& pid) { if (this_node == send_node_) { auto msg = reinterpret_cast(data); auto m = promoteMsg(msg); - runnable::makeRunnable(m, true, handler_, this_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(m, true, handler_, this_node, han_type) .withTDEpochFromMsg() .enqueue(); } else { diff --git a/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h b/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h index 91c0581ba0..b9fc3859a6 100644 --- a/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h +++ b/src/vt/pipe/callback/handler_send/callback_send_tl.impl.h @@ -71,7 +71,8 @@ void CallbackSendTypeless::trigger(MsgT* msg, PipeType const& pipe) { ); auto pmsg = promoteMsg(msg); if (this_node == send_node_) { - runnable::makeRunnable(pmsg, true, handler_, this_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(pmsg, true, handler_, this_node, han_type) .withTDEpochFromMsg() .enqueue(); } else { diff --git a/src/vt/runnable/make_runnable.h b/src/vt/runnable/make_runnable.h index 16c565eb0c..40bf4d585e 100644 --- a/src/vt/runnable/make_runnable.h +++ b/src/vt/runnable/make_runnable.h @@ -313,15 +313,14 @@ struct RunnableMaker { * \param[in] is_threaded whether it is threaded * \param[in] handler the handler bits * \param[in] from the node that caused this runnable to execute - * \param[in] han_type the type of handler (default RegGeneral) + * \param[in] han_type the type of handler * * \return the maker for further customization */ template RunnableMaker makeRunnable( MsgSharedPtr const& msg, bool is_threaded, HandlerType handler, - NodeType from, auto_registry::RegistryTypeEnum han_type = - auto_registry::RegistryTypeEnum::RegGeneral + NodeType from, auto_registry::RegistryTypeEnum han_type ) { auto r = std::make_unique(msg, is_threaded); if (han_type == auto_registry::RegistryTypeEnum::RegVrt or @@ -340,15 +339,14 @@ RunnableMaker makeRunnable( * \param[in] is_threaded whether it is threaded * \param[in] handler the handler bits * \param[in] from the node that caused this runnable to execute - * \param[in] han_type the type of handler (default RegGeneral) * * \return the maker for further customization */ inline RunnableMaker makeRunnableVoid( - bool is_threaded, HandlerType handler, - NodeType from, auto_registry::RegistryTypeEnum han_type = - auto_registry::RegistryTypeEnum::RegGeneral + bool is_threaded, HandlerType handler, NodeType from ) { + // These are currently only types of registry entries that can be void + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; auto r = std::make_unique(is_threaded); // @todo: figure out how to trace this? r->template addContext(from); diff --git a/src/vt/serialization/messaging/serialized_messenger.impl.h b/src/vt/serialization/messaging/serialized_messenger.impl.h index d8c189a81b..efd9d4c2a5 100644 --- a/src/vt/serialization/messaging/serialized_messenger.impl.h +++ b/src/vt/serialization/messaging/serialized_messenger.impl.h @@ -88,7 +88,8 @@ template auto msg_data = ptr_offset; auto user_msg = deserializeFullMessage(msg_data); - runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node, han_type) .withTDEpochFromMsg() .enqueue(); } @@ -132,7 +133,8 @@ template handler, recv_tag, envelopeGetEpoch(msg->env) ); - runnable::makeRunnable(msg, true, handler, node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(msg, true, handler, node, han_type) .withTDEpoch(epoch, not is_valid_epoch) .withContinuation(action) .enqueue(); @@ -174,7 +176,8 @@ template print_ptr(user_msg.get()), envelopeGetEpoch(sys_msg->env) ); - runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(user_msg, true, handler, sys_msg->from_node, han_type) .withTDEpochFromMsg() .enqueue(); } @@ -407,7 +410,8 @@ template auto base_msg = msg.template to(); return messaging::PendingSend(base_msg, [=](MsgPtr in){ - runnable::makeRunnable(msg, true, typed_handler, node) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(msg, true, typed_handler, node, han_type) .withTDEpochFromMsg() .enqueue(); }); diff --git a/src/vt/topos/location/location.impl.h b/src/vt/topos/location/location.impl.h index 2bd01c2b85..4b0ea48ca5 100644 --- a/src/vt/topos/location/location.impl.h +++ b/src/vt/topos/location/location.impl.h @@ -538,7 +538,8 @@ void EntityLocationCoord::routeMsgNode( hid, from, handler, envelopeGetRef(msg->env) ); - runnable::makeRunnable(msg, true, handler, from) + auto han_type = auto_registry::RegistryTypeEnum::RegGeneral; + runnable::makeRunnable(msg, true, handler, from, han_type) .withTDEpochFromMsg() .run(); } else { From 82e299ba44d4b46ff201a6c564561ff571abe519 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 16:53:59 -0800 Subject: [PATCH 24/47] #1677: cmake: run generator for git configurator as a custom command dependency of VT --- CMakeLists.txt | 2 -- cmake/build_git_info.cmake | 11 ++++++++++- src/CMakeLists.txt | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c597d5b586..cd6d37e24d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,8 +64,6 @@ include(cmake/link_vt.cmake) # Load packages that are required for core VT build include(cmake/load_packages.cmake) -include(cmake/build_git_info.cmake) - include(cmake/check_compiler.cmake) option(vt_gold_linker_enabled "Build VT using the `gold' linker" ON) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index 4f7f37f1cc..628a4e651c 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -33,4 +33,13 @@ set(HEAD_FILE "${GIT_DIR}/HEAD") message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") find_package(Git REQUIRED) -execute_process(COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake) +#execute_process(COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake) + +set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc") +add_custom_command( + OUTPUT ${VT_GIT_CONFIG_FILE} + COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${VT_GIT_CONFIG_FILE} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake + DEPENDS ${HEAD_FILE} + ) + +target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b3f1969656..52fa0bab8c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -204,6 +204,8 @@ add_library( ${HEADER_FILES} ${SOURCE_FILES} ) +include(${CMAKE_CURRENT_LIST_DIR}/../cmake/build_git_info.cmake) + option(vt_no_color_enabled "Build VT with option --vt_no_color set to true by default" OFF) if(vt_no_color_enabled) message(STATUS "Building VT with --vt_no_color set to true by default") From eef0906a8207a06be66b386cfa8ab3f666349f7b Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 17:02:33 -0800 Subject: [PATCH 25/47] #1677: cmake: watch for changes in git refspec files --- cmake/build_git_info.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index 628a4e651c..56328a323a 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -30,6 +30,13 @@ if(NOT EXISTS "${GIT_DIR}/HEAD") endif() set(HEAD_FILE "${GIT_DIR}/HEAD") +file(READ "${HEAD_FILE}" HEAD_CONTENTS LIMIT 1024) +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" REFSPEC "${HEAD_CONTENTS}") +endif() + message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") find_package(Git REQUIRED) @@ -39,7 +46,7 @@ set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revis add_custom_command( OUTPUT ${VT_GIT_CONFIG_FILE} COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${VT_GIT_CONFIG_FILE} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake - DEPENDS ${HEAD_FILE} + DEPENDS ${HEAD_FILE} ${GIT_DIR}/packed-refs ${GIT_DIR}/${REFSPEC} ) target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) \ No newline at end of file From 2e6d4c255ddc1456fc3d61e2998db66388cbc057 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 17:06:35 -0800 Subject: [PATCH 26/47] #1677: cmake: set a secondary variable for refspec files so it can be empty if not on a named branch --- cmake/build_git_info.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index 56328a323a..3212bdfe75 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -35,6 +35,7 @@ string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) if(HEAD_CONTENTS MATCHES "ref") # named branch string(REPLACE "ref: " "" REFSPEC "${HEAD_CONTENTS}") + set(REFFILE ${GIT_DIR}/${REFSPEC}) endif() message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") @@ -46,7 +47,7 @@ set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revis add_custom_command( OUTPUT ${VT_GIT_CONFIG_FILE} COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${VT_GIT_CONFIG_FILE} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake - DEPENDS ${HEAD_FILE} ${GIT_DIR}/packed-refs ${GIT_DIR}/${REFSPEC} + DEPENDS ${HEAD_FILE} ${GIT_DIR}/packed-refs ${REFFILE} ) target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) \ No newline at end of file From 93ad318258c96d0928282b92ab194b4cf776ea94 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 17:08:08 -0800 Subject: [PATCH 27/47] #1677: cmake: clean up old git revision scripts --- cmake-modules/GetGitRevisionDescription.cmake | 166 ------------------ .../GetGitRevisionDescription.cmake.in | 41 ----- 2 files changed, 207 deletions(-) delete mode 100644 cmake-modules/GetGitRevisionDescription.cmake delete mode 100644 cmake-modules/GetGitRevisionDescription.cmake.in diff --git a/cmake-modules/GetGitRevisionDescription.cmake b/cmake-modules/GetGitRevisionDescription.cmake deleted file mode 100644 index 2ebfd40d20..0000000000 --- a/cmake-modules/GetGitRevisionDescription.cmake +++ /dev/null @@ -1,166 +0,0 @@ -# - Returns a version string from Git -# -# These functions force a re-configure on each git commit so that you can -# trust the values of the variables in your build system. -# -# get_git_head_revision( [ ...]) -# -# Returns the refspec and sha hash of the current head revision -# -# git_describe( [ ...]) -# -# Returns the results of git describe on the source tree, and adjusting -# the output so that it tests false if an error occurs. -# -# git_get_exact_tag( [ ...]) -# -# Returns the results of git describe --exact-match on the source tree, -# and adjusting the output so that it tests false if there was no exact -# matching tag. -# -# git_local_changes() -# -# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes. -# Uses the return code of "git diff-index --quiet HEAD --". -# Does not regard untracked files. -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -if(__get_git_revision_description) - return() -endif() -set(__get_git_revision_description YES) - -# We must run the following at "include" time, not at function call time, -# to find the path to this module rather than the path to a calling list file -get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) - -function(get_git_head_revision _refspecvar _hashvar) - set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories - set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") - get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) - if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) - # We have reached the root directory, we are not in git - set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - return() - endif() - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - endwhile() - # check if this is a submodule - if(NOT IS_DIRECTORY ${GIT_DIR}) - file(READ ${GIT_DIR} submodule) - string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) - get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) - get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) - endif() - set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") - if(NOT EXISTS "${GIT_DATA}") - file(MAKE_DIRECTORY "${GIT_DATA}") - endif() - - if(NOT EXISTS "${GIT_DIR}/HEAD") - return() - endif() - set(HEAD_FILE "${GIT_DATA}/HEAD") - configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) - - configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" - "${GIT_DATA}/grabRef.cmake" - @ONLY) - include("${GIT_DATA}/grabRef.cmake") - - set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) - set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) -endfunction() - -function(git_describe _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) - return() - endif() - - # TODO sanitize - #if((${ARGN}" MATCHES "&&") OR - # (ARGN MATCHES "||") OR - # (ARGN MATCHES "\\;")) - # message("Please report the following error to the project!") - # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") - #endif() - - execute_process(COMMAND - "${GIT_EXECUTABLE}" - describe - ${hash} - ${ARGN} - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT res EQUAL 0) - set(out "${out}-${res}-NOTFOUND") - endif() - - set(${_var} "${out}" PARENT_SCOPE) -endfunction() - -function(git_get_exact_tag _var) - git_describe(out --exact-match ${ARGN}) - set(${_var} "${out}" PARENT_SCOPE) -endfunction() - -function(git_local_changes _var) - if(NOT GIT_FOUND) - find_package(Git QUIET) - endif() - get_git_head_revision(refspec hash) - if(NOT GIT_FOUND) - set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) - return() - endif() - if(NOT hash) - set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) - return() - endif() - - execute_process(COMMAND - "${GIT_EXECUTABLE}" - diff-index --quiet HEAD -- - WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" - RESULT_VARIABLE - res - OUTPUT_VARIABLE - out - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(res EQUAL 0) - set(${_var} "CLEAN" PARENT_SCOPE) - else() - set(${_var} "DIRTY" PARENT_SCOPE) - endif() -endfunction() diff --git a/cmake-modules/GetGitRevisionDescription.cmake.in b/cmake-modules/GetGitRevisionDescription.cmake.in deleted file mode 100644 index 6d8b708efe..0000000000 --- a/cmake-modules/GetGitRevisionDescription.cmake.in +++ /dev/null @@ -1,41 +0,0 @@ -# -# Internal file for GetGitRevisionDescription.cmake -# -# Requires CMake 2.6 or newer (uses the 'function' command) -# -# Original Author: -# 2009-2010 Ryan Pavlik -# http://academic.cleardefinition.com -# Iowa State University HCI Graduate Program/VRAC -# -# Copyright Iowa State University 2009-2010. -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -set(HEAD_HASH) - -file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) - -string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) -if(HEAD_CONTENTS MATCHES "ref") - # named branch - string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") - if(EXISTS "@GIT_DIR@/${HEAD_REF}") - configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) - else() - configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) - file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") - set(HEAD_HASH "${CMAKE_MATCH_1}") - endif() - endif() -else() - # detached HEAD - configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) -endif() - -if(NOT HEAD_HASH) - file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) - string(STRIP "${HEAD_HASH}" HEAD_HASH) -endif() From 2e9f85fe18a3477bae264617543eae5ed72a22d2 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 17:21:01 -0800 Subject: [PATCH 28/47] #1677: cmake: only depend on packed refs file if it exists --- cmake/build_git_info.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index 3212bdfe75..5d0bde060e 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -35,7 +35,11 @@ string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) if(HEAD_CONTENTS MATCHES "ref") # named branch string(REPLACE "ref: " "" REFSPEC "${HEAD_CONTENTS}") - set(REFFILE ${GIT_DIR}/${REFSPEC}) + set(REF_FILE ${GIT_DIR}/${REFSPEC}) +endif() + +if (EXISTS ${GIT_DIR}/packed-refs) + set(PACKED_REF_FILE ${GIT_DIR}/packed-refs) endif() message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") @@ -47,7 +51,7 @@ set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revis add_custom_command( OUTPUT ${VT_GIT_CONFIG_FILE} COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${VT_GIT_CONFIG_FILE} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake - DEPENDS ${HEAD_FILE} ${GIT_DIR}/packed-refs ${REFFILE} + DEPENDS ${HEAD_FILE} ${PACKED_REF_FILE} ${REF_FILE} ) target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) \ No newline at end of file From 046bf6d21b5e2a3583e6bc28fd77d63cf30149c5 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 17:27:33 -0800 Subject: [PATCH 29/47] #1677: cmake: don't silence git command errors --- cmake/run-git.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/cmake/run-git.cmake b/cmake/run-git.cmake index 2138bbf3ef..31204fc37d 100644 --- a/cmake/run-git.cmake +++ b/cmake/run-git.cmake @@ -50,7 +50,6 @@ execute_process(COMMAND res OUTPUT_VARIABLE GIT_EXACT_TAG - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT res EQUAL 0) message(FATAL_ERROR "could not get the exact git tag") @@ -69,7 +68,6 @@ execute_process(COMMAND res OUTPUT_VARIABLE GIT_DESCRIPTION - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT res EQUAL 0) message(FATAL_ERROR "could not get the description") @@ -84,7 +82,6 @@ execute_process(COMMAND "${CMAKE_CURRENT_SOURCE_DIR}" RESULT_VARIABLE res - ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if(res EQUAL 0) set(GIT_CLEAN_STATUS "CLEAN") From 8903884aedf594b3061a52e324b03f370dd128b8 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 17:33:24 -0800 Subject: [PATCH 30/47] #1677: cmake: use the parent directory of the .git folder to locate the git repository directory --- cmake/run-git.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/run-git.cmake b/cmake/run-git.cmake index 31204fc37d..7dffeb1176 100644 --- a/cmake/run-git.cmake +++ b/cmake/run-git.cmake @@ -14,6 +14,8 @@ message(STATUS "Reading head file ${HEAD_FILE}") message(STATUS "Using git executable at \"${GIT_EXECUTABLE}\"") +get_filename_component(ROOT_DIR ${GIT_DIR} DIRECTORY) + set(GIT_SHA1) file(READ "${HEAD_FILE}" HEAD_CONTENTS LIMIT 1024) @@ -45,7 +47,7 @@ execute_process(COMMAND ${GIT_SHA1} --tags --abbrev=0 --all WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" + "${ROOT_DIR}" RESULT_VARIABLE res OUTPUT_VARIABLE @@ -63,7 +65,7 @@ execute_process(COMMAND ${GIT_SHA1} --abbrev=10 --always --tags --long --all WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" + "${ROOT_DIR}" RESULT_VARIABLE res OUTPUT_VARIABLE @@ -79,7 +81,7 @@ execute_process(COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD -- WORKING_DIRECTORY - "${CMAKE_CURRENT_SOURCE_DIR}" + "${ROOT_DIR}" RESULT_VARIABLE res OUTPUT_STRIP_TRAILING_WHITESPACE) From 6daf3ffe603fbd084761c8493893fe4905873965 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Mon, 21 Feb 2022 17:37:49 -0800 Subject: [PATCH 31/47] #1677: cmake: set dependency on entire .git folder --- cmake/build_git_info.cmake | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index 5d0bde060e..c5eb649591 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -30,18 +30,6 @@ if(NOT EXISTS "${GIT_DIR}/HEAD") endif() set(HEAD_FILE "${GIT_DIR}/HEAD") -file(READ "${HEAD_FILE}" HEAD_CONTENTS LIMIT 1024) -string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) -if(HEAD_CONTENTS MATCHES "ref") - # named branch - string(REPLACE "ref: " "" REFSPEC "${HEAD_CONTENTS}") - set(REF_FILE ${GIT_DIR}/${REFSPEC}) -endif() - -if (EXISTS ${GIT_DIR}/packed-refs) - set(PACKED_REF_FILE ${GIT_DIR}/packed-refs) -endif() - message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") find_package(Git REQUIRED) @@ -51,7 +39,7 @@ set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revis add_custom_command( OUTPUT ${VT_GIT_CONFIG_FILE} COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${VT_GIT_CONFIG_FILE} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake - DEPENDS ${HEAD_FILE} ${PACKED_REF_FILE} ${REF_FILE} + DEPENDS ${GIT_DIR} ) target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) \ No newline at end of file From 40ea610c5db8fbd3b8fd82bc4e8c144d57e2568d Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Tue, 22 Feb 2022 17:37:11 -0800 Subject: [PATCH 32/47] #1677: cmake: get git folder using git rev-parse and similarly for the current sha1 --- cmake/build_git_info.cmake | 45 ++++++++++++++------------------------ cmake/run-git.cmake | 27 +++++++++++++---------- 2 files changed, 32 insertions(+), 40 deletions(-) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index c5eb649591..606a5f8714 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -1,29 +1,21 @@ -function(get_git_dir _git_dir) - set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories - set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") - get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) - if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) - # We have reached the root directory, we are not in git - set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) - return() - endif() - set(GIT_DIR "${GIT_PARENT_DIR}/.git") - endwhile() - # check if this is a submodule - if(NOT IS_DIRECTORY ${GIT_DIR}) - file(READ ${GIT_DIR} submodule) - string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) - get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) - get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) - endif() - - set(${_git_dir} ${GIT_DIR} PARENT_SCOPE) -endfunction() +find_package(Git REQUIRED) +execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir + WORKING_DIRECTORY + "${PROJECT_BASE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + REL_GIT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) +if (NOT res EQUAL 0) + message(FATAL_ERROR "git invocation failed") +endif() -get_git_dir(GIT_DIR) +get_filename_component(GIT_DIR ${REL_GIT_DIR} ABSOLUTE BASE_DIR ${PROJECT_BASE_DIR}) +message(STATUS "Git DIR: ${GIT_DIR}") +if (NOT GIT_DIR) + message(FATAL_ERROR "not a git directory") +endif() if(NOT EXISTS "${GIT_DIR}/HEAD") message(FATAL_ERROR "no such file: \"${GIT_DIR}/HEAD\"") @@ -32,9 +24,6 @@ set(HEAD_FILE "${GIT_DIR}/HEAD") message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") -find_package(Git REQUIRED) -#execute_process(COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake) - set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc") add_custom_command( OUTPUT ${VT_GIT_CONFIG_FILE} diff --git a/cmake/run-git.cmake b/cmake/run-git.cmake index 7dffeb1176..8ac835a1c2 100644 --- a/cmake/run-git.cmake +++ b/cmake/run-git.cmake @@ -24,21 +24,24 @@ string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) if(HEAD_CONTENTS MATCHES "ref") # named branch string(REPLACE "ref: " "" GIT_REFSPEC "${HEAD_CONTENTS}") - if(EXISTS "${GIT_DIR}/${GIT_REFSPEC}") - file(READ "${GIT_DIR}/${GIT_REFSPEC}" GIT_SHA1 LIMIT 1024) - string(STRIP "${GIT_SHA1}" GIT_SHA1) - else() - file(READ "${GIT_DIR}/packed-refs" PACKED_REFS) - if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${GIT_REFSPEC}") - set(GIT_SHA1 "${CMAKE_MATCH_1}") - endif() - endif() -else() - # detached HEAD - string(STRIP "${HEAD_CONTENTS}" GIT_SHA1) endif() message(STATUS "GIT_REFSPEC: \"${GIT_REFSPEC}\"") + +execute_process(COMMAND + "${GIT_EXECUTABLE}" + rev-parse --verify HEAD + WORKING_DIRECTORY + "${ROOT_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + GIT_SHA1 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT res EQUAL 0) + message(FATAL_ERROR "could not get the git sha1") +endif() + message(STATUS "GIT_SHA1: \"${GIT_SHA1}\"") execute_process(COMMAND From b5c084ae842f71cf99631388e06e904133c151c1 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Mon, 14 Feb 2022 21:58:59 +0100 Subject: [PATCH 33/47] #1550 allow users to pass AppConfig to vt during init --- examples/hello_world/objgroup.cc | 2 +- src/vt/collective/collective_ops.cc | 5 +- src/vt/collective/collective_ops.h | 3 +- src/vt/collective/startup.cc | 28 +- src/vt/collective/startup.h | 11 +- src/vt/configs/arguments/args.cc | 377 ++++++++++++---------- src/vt/configs/arguments/args.h | 46 +-- src/vt/runtime/runtime.cc | 7 +- src/vt/runtime/runtime.h | 3 +- tests/unit/runtime/test_initialization.cc | 117 +++++-- 10 files changed, 367 insertions(+), 232 deletions(-) diff --git a/examples/hello_world/objgroup.cc b/examples/hello_world/objgroup.cc index e5e36c1c32..4c07e01d2c 100644 --- a/examples/hello_world/objgroup.cc +++ b/examples/hello_world/objgroup.cc @@ -57,7 +57,7 @@ struct MyObjGroup { }; int main(int argc, char** argv) { - vt::initialize(argc, argv, nullptr); + vt::initialize(argc, argv); vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); diff --git a/src/vt/collective/collective_ops.cc b/src/vt/collective/collective_ops.cc index 8da2080fdd..c41ae93049 100644 --- a/src/vt/collective/collective_ops.cc +++ b/src/vt/collective/collective_ops.cc @@ -56,7 +56,7 @@ namespace vt { template RuntimePtrType CollectiveAnyOps::initialize( int& argc, char**& argv, WorkerCountType const num_workers, - bool is_interop, MPI_Comm* comm + bool is_interop, MPI_Comm* comm, arguments::AppConfig const* appConfig ) { using vt::runtime::RuntimeInst; using vt::runtime::Runtime; @@ -66,7 +66,8 @@ RuntimePtrType CollectiveAnyOps::initialize( #pragma sst global rt RuntimeInst::rt = std::make_unique( - argc, argv, num_workers, is_interop, resolved_comm + argc, argv, num_workers, is_interop, resolved_comm, + eRuntimeInstance::DefaultInstance, appConfig ); #pragma sst global rt diff --git a/src/vt/collective/collective_ops.h b/src/vt/collective/collective_ops.h index 2fb310e40e..849ac3a6a7 100644 --- a/src/vt/collective/collective_ops.h +++ b/src/vt/collective/collective_ops.h @@ -63,7 +63,8 @@ struct CollectiveAnyOps { // The general methods that interact with the managed runtime holder static RuntimePtrType initialize( int& argc, char**& argv, WorkerCountType const num_workers = no_workers, - bool is_interop = false, MPI_Comm* comm = nullptr + bool is_interop = false, MPI_Comm* comm = nullptr, + arguments::AppConfig const* appConfig = nullptr ); static void finalize(RuntimePtrType in_rt = nullptr); static void scheduleThenFinalize( diff --git a/src/vt/collective/startup.cc b/src/vt/collective/startup.cc index f6c862ab12..5f3bdbea02 100644 --- a/src/vt/collective/startup.cc +++ b/src/vt/collective/startup.cc @@ -52,14 +52,20 @@ namespace vt { // vt::{initialize,finalize} for main ::vt namespace RuntimePtrType initialize( int& argc, char**& argv, WorkerCountType const num_workers, - bool is_interop, MPI_Comm* comm + bool is_interop, MPI_Comm* comm, arguments::AppConfig const* appConfig ) { - return CollectiveOps::initialize(argc,argv,num_workers,is_interop,comm); + return CollectiveOps::initialize( + argc, argv, num_workers, is_interop, comm, appConfig + ); } -RuntimePtrType initialize(int& argc, char**& argv, MPI_Comm* comm) { +RuntimePtrType initialize( + int& argc, char**& argv, MPI_Comm* comm, arguments::AppConfig const* appConfig +) { bool const is_interop = comm != nullptr; - return CollectiveOps::initialize(argc,argv,no_workers,is_interop,comm); + return CollectiveOps::initialize( + argc, argv, no_workers, is_interop, comm, appConfig + ); } RuntimePtrType initialize(MPI_Comm* comm) { @@ -69,6 +75,20 @@ RuntimePtrType initialize(MPI_Comm* comm) { return CollectiveOps::initialize(argc,argv,no_workers,is_interop,comm); } +RuntimePtrType initialize( + int& argc, char**& argv, arguments::AppConfig const* appConfig +) { + auto mpiComm = MPI_COMM_WORLD; + return initialize(argc, argv, &mpiComm, appConfig); +} + +RuntimePtrType initialize(arguments::AppConfig const* appConfig) { + int argc = 0; + char** argv = nullptr; + auto mpiComm = MPI_COMM_WORLD; + return initialize(argc, argv, &mpiComm, appConfig); +} + void finalize(RuntimePtrType in_rt) { if (in_rt) { return CollectiveOps::finalize(std::move(in_rt)); diff --git a/src/vt/collective/startup.h b/src/vt/collective/startup.h index e03a09c36d..1c8c27bb72 100644 --- a/src/vt/collective/startup.h +++ b/src/vt/collective/startup.h @@ -51,10 +51,17 @@ namespace vt { RuntimePtrType initialize( int& argc, char**& argv, WorkerCountType const num_workers, - bool is_interop = false, MPI_Comm* comm = nullptr + bool is_interop = false, MPI_Comm* comm = nullptr, + arguments::AppConfig const* appConfig = nullptr +); +RuntimePtrType initialize( + int& argc, char**& argv, MPI_Comm* comm = nullptr, + arguments::AppConfig const* appConfig = nullptr ); -RuntimePtrType initialize(int& argc, char**& argv, MPI_Comm* comm = nullptr); RuntimePtrType initialize(MPI_Comm* comm = nullptr); +RuntimePtrType initialize( + int& argc, char**& argv, arguments::ArgConfig const* appConfig +); void finalize(RuntimePtrType in_rt); void finalize(); diff --git a/src/vt/configs/arguments/args.cc b/src/vt/configs/arguments/args.cc index 7a8dfc1218..207ea5b998 100644 --- a/src/vt/configs/arguments/args.cc +++ b/src/vt/configs/arguments/args.cc @@ -64,13 +64,13 @@ ArgConfig::construct(std::unique_ptr arg) { return arg; } -void ArgConfig::addColorArgs(CLI::App& app) { +void ArgConfig::addColorArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto quiet = "Quiet the output from vt (only errors, warnings)"; auto always = "Colorize output (default)"; auto never = "Do not colorize output (overrides --vt_color)"; - auto a = app.add_flag("--vt_color", config_.vt_color, always); - auto b = app.add_flag("--vt_no_color", config_.vt_no_color, never); - auto a1 = app.add_flag("--vt_quiet", config_.vt_quiet, quiet); + auto a = app.add_flag("--vt_color", appConfig.vt_color, always); + auto b = app.add_flag("--vt_no_color", appConfig.vt_no_color, never); + auto a1 = app.add_flag("--vt_quiet", appConfig.vt_quiet, quiet); auto outputGroup = "Output Control"; a->group(outputGroup); b->group(outputGroup); @@ -81,15 +81,15 @@ void ArgConfig::addColorArgs(CLI::App& app) { // b->excludes(a); } -void ArgConfig::addSignalArgs(CLI::App& app) { +void ArgConfig::addSignalArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto no_sigint = "Do not register signal handler for SIGINT"; auto no_sigsegv = "Do not register signal handler for SIGSEGV"; auto no_sigbus = "Do not register signal handler for SIGBUS"; auto no_terminate = "Do not register handler for std::terminate"; - auto d = app.add_flag("--vt_no_SIGINT", config_.vt_no_sigint, no_sigint); - auto e = app.add_flag("--vt_no_SIGSEGV", config_.vt_no_sigsegv, no_sigsegv); - auto g = app.add_flag("--vt_no_SIGBUS", config_.vt_no_sigbus, no_sigbus); - auto f = app.add_flag("--vt_no_terminate", config_.vt_no_terminate, no_terminate); + auto d = app.add_flag("--vt_no_SIGINT", appConfig.vt_no_sigint, no_sigint); + auto e = app.add_flag("--vt_no_SIGSEGV", appConfig.vt_no_sigsegv, no_sigsegv); + auto g = app.add_flag("--vt_no_SIGBUS", appConfig.vt_no_sigbus, no_sigbus); + auto f = app.add_flag("--vt_no_terminate", appConfig.vt_no_terminate, no_terminate); auto signalGroup = "Signal Handling"; d->group(signalGroup); e->group(signalGroup); @@ -97,7 +97,7 @@ void ArgConfig::addSignalArgs(CLI::App& app) { g->group(signalGroup); } -void ArgConfig::addMemUsageArgs(CLI::App& app) { +void ArgConfig::addMemUsageArgs(CLI::App& app, arguments::AppConfig& appConfig) { /* * Flags for controlling memory usage reporting */ @@ -109,14 +109,14 @@ void ArgConfig::addMemUsageArgs(CLI::App& app) { auto mem_thresh = "The threshold increments to print memory usage: \" {GiB,MiB,KiB,B}\""; auto mem_sched = "The frequency to query the memory threshold check (some memory reporters might be expensive)"; auto mem_footprint = "Print live components' memory footprint after initialization and before shutdown"; - auto mm = app.add_option("--vt_memory_reporters", config_.vt_memory_reporters, mem_desc, true); - auto mn = app.add_flag("--vt_print_memory_each_phase", config_.vt_print_memory_each_phase, mem_phase); - auto mo = app.add_option("--vt_print_memory_node", config_.vt_print_memory_node, mem_node, true); - auto mp = app.add_flag("--vt_allow_memory_report_with_ps", config_.vt_allow_memory_report_with_ps, mem_ps); - auto mq = app.add_flag("--vt_print_memory_at_threshold", config_.vt_print_memory_at_threshold, mem_at_thresh); - auto mr = app.add_option("--vt_print_memory_threshold", config_.vt_print_memory_threshold, mem_thresh, true); - auto ms = app.add_option("--vt_print_memory_sched_poll", config_.vt_print_memory_sched_poll, mem_sched, true); - auto mf = app.add_flag("--vt_print_memory_footprint", config_.vt_print_memory_footprint, mem_footprint); + auto mm = app.add_option("--vt_memory_reporters", appConfig.vt_memory_reporters, mem_desc, true); + auto mn = app.add_flag("--vt_print_memory_each_phase", appConfig.vt_print_memory_each_phase, mem_phase); + auto mo = app.add_option("--vt_print_memory_node", appConfig.vt_print_memory_node, mem_node, true); + auto mp = app.add_flag("--vt_allow_memory_report_with_ps", appConfig.vt_allow_memory_report_with_ps, mem_ps); + auto mq = app.add_flag("--vt_print_memory_at_threshold", appConfig.vt_print_memory_at_threshold, mem_at_thresh); + auto mr = app.add_option("--vt_print_memory_threshold", appConfig.vt_print_memory_threshold, mem_thresh, true); + auto ms = app.add_option("--vt_print_memory_sched_poll", appConfig.vt_print_memory_sched_poll, mem_sched, true); + auto mf = app.add_flag("--vt_print_memory_footprint", appConfig.vt_print_memory_footprint, mem_footprint); auto memoryGroup = "Memory Usage Reporting"; mm->group(memoryGroup); mn->group(memoryGroup); @@ -129,7 +129,7 @@ void ArgConfig::addMemUsageArgs(CLI::App& app) { } -void ArgConfig::addStackDumpArgs(CLI::App& app) { +void ArgConfig::addStackDumpArgs(CLI::App& app, arguments::AppConfig& appConfig) { /* * Flags to control stack dumping */ @@ -140,13 +140,13 @@ void ArgConfig::addStackDumpArgs(CLI::App& app) { auto file = "Dump stack traces to file instead of stdout"; auto dir = "Name of directory to write stack files"; auto mod = "Write stack dump if (node % config_.vt_stack_mod) == 0"; - auto g = app.add_flag("--vt_no_warn_stack", config_.vt_no_warn_stack, warn); - auto h = app.add_flag("--vt_no_assert_stack", config_.vt_no_assert_stack, assert); - auto i = app.add_flag("--vt_no_abort_stack", config_.vt_no_abort_stack, abort); - auto j = app.add_flag("--vt_no_stack", config_.vt_no_stack, stack); - auto k = app.add_option("--vt_stack_file", config_.vt_stack_file, file, ""); - auto l = app.add_option("--vt_stack_dir", config_.vt_stack_dir, dir, ""); - auto m = app.add_option("--vt_stack_mod", config_.vt_stack_mod, mod, 1); + auto g = app.add_flag("--vt_no_warn_stack", appConfig.vt_no_warn_stack, warn); + auto h = app.add_flag("--vt_no_assert_stack", appConfig.vt_no_assert_stack, assert); + auto i = app.add_flag("--vt_no_abort_stack", appConfig.vt_no_abort_stack, abort); + auto j = app.add_flag("--vt_no_stack", appConfig.vt_no_stack, stack); + auto k = app.add_option("--vt_stack_file", appConfig.vt_stack_file, file, ""); + auto l = app.add_option("--vt_stack_dir", appConfig.vt_stack_dir, dir, ""); + auto m = app.add_option("--vt_stack_mod", appConfig.vt_stack_mod, mod, 1); auto stackGroup = "Dump Stack Backtrace"; g->group(stackGroup); h->group(stackGroup); @@ -157,7 +157,7 @@ void ArgConfig::addStackDumpArgs(CLI::App& app) { m->group(stackGroup); } -void ArgConfig::addTraceArgs(CLI::App& app) { +void ArgConfig::addTraceArgs(CLI::App& app, arguments::AppConfig& appConfig) { /* * Flags to control tracing output */ @@ -179,24 +179,24 @@ void ArgConfig::addTraceArgs(CLI::App& app) { auto tmemusage = "Trace memory usage using first memory reporter"; auto tpolled = "Trace AsyncEvent component polling (inc. MPI_Isend requests)"; auto tirecv = "Trace MPI_Irecv request polling"; - auto n = app.add_flag("--vt_trace", config_.vt_trace, trace); + auto n = app.add_flag("--vt_trace", appConfig.vt_trace, trace); auto nm = app.add_option("--vt_trace_mpi", arg_trace_mpi, trace_mpi) ->check(CLI::IsMember({"internal", "external"})); - auto o = app.add_option("--vt_trace_file", config_.vt_trace_file, tfile, ""); - auto p = app.add_option("--vt_trace_dir", config_.vt_trace_dir, tdir, ""); - auto q = app.add_option("--vt_trace_mod", config_.vt_trace_mod, tmod, 1); - auto qf = app.add_option("--vt_trace_flush_size", config_.vt_trace_flush_size, tflushmod, 0); - auto qg = app.add_flag("--vt_trace_gzip_finish_flush", config_.vt_trace_gzip_finish_flush, zflush); - auto qt = app.add_flag("--vt_trace_sys_all", config_.vt_trace_sys_all, tsysall); - auto qw = app.add_flag("--vt_trace_sys_term", config_.vt_trace_sys_term, tsysTD); - auto qx = app.add_flag("--vt_trace_sys_location", config_.vt_trace_sys_location, tsysloc); - auto qy = app.add_flag("--vt_trace_sys_collection", config_.vt_trace_sys_collection, tsyscoll); - auto qz = app.add_flag("--vt_trace_sys_serial_msg", config_.vt_trace_sys_serial_msg, tsyssmsg); - auto qza = app.add_flag("--vt_trace_spec", config_.vt_trace_spec, tspec); - auto qzb = app.add_option("--vt_trace_spec_file", config_.vt_trace_spec_file, tspecfile, ""); - auto qzc = app.add_flag("--vt_trace_memory_usage", config_.vt_trace_memory_usage, tmemusage); - auto qzd = app.add_flag("--vt_trace_event_polling", config_.vt_trace_event_polling, tpolled); - auto qze = app.add_flag("--vt_trace_irecv_polling", config_.vt_trace_irecv_polling, tirecv); + auto o = app.add_option("--vt_trace_file", appConfig.vt_trace_file, tfile, ""); + auto p = app.add_option("--vt_trace_dir", appConfig.vt_trace_dir, tdir, ""); + auto q = app.add_option("--vt_trace_mod", appConfig.vt_trace_mod, tmod, 1); + auto qf = app.add_option("--vt_trace_flush_size", appConfig.vt_trace_flush_size, tflushmod, 0); + auto qg = app.add_flag("--vt_trace_gzip_finish_flush", appConfig.vt_trace_gzip_finish_flush, zflush); + auto qt = app.add_flag("--vt_trace_sys_all", appConfig.vt_trace_sys_all, tsysall); + auto qw = app.add_flag("--vt_trace_sys_term", appConfig.vt_trace_sys_term, tsysTD); + auto qx = app.add_flag("--vt_trace_sys_location", appConfig.vt_trace_sys_location, tsysloc); + auto qy = app.add_flag("--vt_trace_sys_collection", appConfig.vt_trace_sys_collection, tsyscoll); + auto qz = app.add_flag("--vt_trace_sys_serial_msg", appConfig.vt_trace_sys_serial_msg, tsyssmsg); + auto qza = app.add_flag("--vt_trace_spec", appConfig.vt_trace_spec, tspec); + auto qzb = app.add_option("--vt_trace_spec_file", appConfig.vt_trace_spec_file, tspecfile, ""); + auto qzc = app.add_flag("--vt_trace_memory_usage", appConfig.vt_trace_memory_usage, tmemusage); + auto qzd = app.add_flag("--vt_trace_event_polling", appConfig.vt_trace_event_polling, tpolled); + auto qze = app.add_flag("--vt_trace_irecv_polling", appConfig.vt_trace_irecv_polling, tirecv); auto traceGroup = "Tracing Configuration"; n->group(traceGroup); nm->group(traceGroup); @@ -217,7 +217,7 @@ void ArgConfig::addTraceArgs(CLI::App& app) { qze->group(traceGroup); } -void ArgConfig::addDebugPrintArgs(CLI::App& app) { +void ArgConfig::addDebugPrintArgs(CLI::App& app, arguments::AppConfig& appConfig) { #define debug_pp(opt) +std::string(vt::config::PrettyPrintCat::str)+ auto rp = "Enable all debug prints"; @@ -257,43 +257,43 @@ void ArgConfig::addDebugPrintArgs(CLI::App& app) { auto ddp = "Enable debug_context = \"" debug_pp(context) "\""; auto dep = "Enable debug_epoch = \"" debug_pp(epoch) "\""; - auto r1 = app.add_option("--vt_debug_level", config_.vt_debug_level, rq); - - auto r = app.add_flag("--vt_debug_all", config_.vt_debug_all, rp); - auto aa = app.add_flag("--vt_debug_none", config_.vt_debug_none, aap); - auto ba = app.add_flag("--vt_debug_gen", config_.vt_debug_gen, bap); - auto ca = app.add_flag("--vt_debug_runtime", config_.vt_debug_runtime, cap); - auto da = app.add_flag("--vt_debug_active", config_.vt_debug_active, dap); - auto ea = app.add_flag("--vt_debug_term", config_.vt_debug_term, eap); - auto fa = app.add_flag("--vt_debug_termds", config_.vt_debug_termds, fap); - auto ga = app.add_flag("--vt_debug_barrier", config_.vt_debug_barrier, gap); - auto ha = app.add_flag("--vt_debug_event", config_.vt_debug_event, hap); - auto ia = app.add_flag("--vt_debug_pipe", config_.vt_debug_pipe, iap); - auto ja = app.add_flag("--vt_debug_pool", config_.vt_debug_pool, jap); - auto ka = app.add_flag("--vt_debug_reduce", config_.vt_debug_reduce, kap); - auto la = app.add_flag("--vt_debug_rdma", config_.vt_debug_rdma, lap); - auto ma = app.add_flag("--vt_debug_rdma_channel", config_.vt_debug_rdma_channel, map); - auto na = app.add_flag("--vt_debug_rdma_state", config_.vt_debug_rdma_state, nap); - auto oa = app.add_flag("--vt_debug_param", config_.vt_debug_param, oap); - auto pa = app.add_flag("--vt_debug_handler", config_.vt_debug_handler, pap); - auto qa = app.add_flag("--vt_debug_hierlb", config_.vt_debug_hierlb, qap); - auto qb = app.add_flag("--vt_debug_temperedlb", config_.vt_debug_temperedlb, qbp); - auto ra = app.add_flag("--vt_debug_scatter", config_.vt_debug_scatter, rap); - auto sa = app.add_flag("--vt_debug_sequence", config_.vt_debug_sequence, sap); - auto ta = app.add_flag("--vt_debug_sequence_vrt", config_.vt_debug_sequence_vrt, tap); - auto ua = app.add_flag("--vt_debug_serial_msg", config_.vt_debug_serial_msg, uap); - auto va = app.add_flag("--vt_debug_trace", config_.vt_debug_trace, vap); - auto wa = app.add_flag("--vt_debug_location", config_.vt_debug_location, wap); - auto xa = app.add_flag("--vt_debug_lb", config_.vt_debug_lb, xap); - auto ya = app.add_flag("--vt_debug_vrt", config_.vt_debug_vrt, yap); - auto za = app.add_flag("--vt_debug_vrt_coll", config_.vt_debug_vrt_coll, zap); - auto ab = app.add_flag("--vt_debug_worker", config_.vt_debug_worker, abp); - auto bb = app.add_flag("--vt_debug_group", config_.vt_debug_group, bbp); - auto cb = app.add_flag("--vt_debug_broadcast", config_.vt_debug_broadcast, cbp); - auto db = app.add_flag("--vt_debug_objgroup", config_.vt_debug_objgroup, dbp); - auto dc = app.add_flag("--vt_debug_phase", config_.vt_debug_phase, dcp); - auto dd = app.add_flag("--vt_debug_context", config_.vt_debug_context, ddp); - auto de = app.add_flag("--vt_debug_epoch", config_.vt_debug_epoch, dep); + auto r1 = app.add_option("--vt_debug_level", appConfig.vt_debug_level, rq); + + auto r = app.add_flag("--vt_debug_all", appConfig.vt_debug_all, rp); + auto aa = app.add_flag("--vt_debug_none", appConfig.vt_debug_none, aap); + auto ba = app.add_flag("--vt_debug_gen", appConfig.vt_debug_gen, bap); + auto ca = app.add_flag("--vt_debug_runtime", appConfig.vt_debug_runtime, cap); + auto da = app.add_flag("--vt_debug_active", appConfig.vt_debug_active, dap); + auto ea = app.add_flag("--vt_debug_term", appConfig.vt_debug_term, eap); + auto fa = app.add_flag("--vt_debug_termds", appConfig.vt_debug_termds, fap); + auto ga = app.add_flag("--vt_debug_barrier", appConfig.vt_debug_barrier, gap); + auto ha = app.add_flag("--vt_debug_event", appConfig.vt_debug_event, hap); + auto ia = app.add_flag("--vt_debug_pipe", appConfig.vt_debug_pipe, iap); + auto ja = app.add_flag("--vt_debug_pool", appConfig.vt_debug_pool, jap); + auto ka = app.add_flag("--vt_debug_reduce", appConfig.vt_debug_reduce, kap); + auto la = app.add_flag("--vt_debug_rdma", appConfig.vt_debug_rdma, lap); + auto ma = app.add_flag("--vt_debug_rdma_channel", appConfig.vt_debug_rdma_channel, map); + auto na = app.add_flag("--vt_debug_rdma_state", appConfig.vt_debug_rdma_state, nap); + auto oa = app.add_flag("--vt_debug_param", appConfig.vt_debug_param, oap); + auto pa = app.add_flag("--vt_debug_handler", appConfig.vt_debug_handler, pap); + auto qa = app.add_flag("--vt_debug_hierlb", appConfig.vt_debug_hierlb, qap); + auto qb = app.add_flag("--vt_debug_temperedlb", appConfig.vt_debug_temperedlb, qbp); + auto ra = app.add_flag("--vt_debug_scatter", appConfig.vt_debug_scatter, rap); + auto sa = app.add_flag("--vt_debug_sequence", appConfig.vt_debug_sequence, sap); + auto ta = app.add_flag("--vt_debug_sequence_vrt", appConfig.vt_debug_sequence_vrt, tap); + auto ua = app.add_flag("--vt_debug_serial_msg", appConfig.vt_debug_serial_msg, uap); + auto va = app.add_flag("--vt_debug_trace", appConfig.vt_debug_trace, vap); + auto wa = app.add_flag("--vt_debug_location", appConfig.vt_debug_location, wap); + auto xa = app.add_flag("--vt_debug_lb", appConfig.vt_debug_lb, xap); + auto ya = app.add_flag("--vt_debug_vrt", appConfig.vt_debug_vrt, yap); + auto za = app.add_flag("--vt_debug_vrt_coll", appConfig.vt_debug_vrt_coll, zap); + auto ab = app.add_flag("--vt_debug_worker", appConfig.vt_debug_worker, abp); + auto bb = app.add_flag("--vt_debug_group", appConfig.vt_debug_group, bbp); + auto cb = app.add_flag("--vt_debug_broadcast", appConfig.vt_debug_broadcast, cbp); + auto db = app.add_flag("--vt_debug_objgroup", appConfig.vt_debug_objgroup, dbp); + auto dc = app.add_flag("--vt_debug_phase", appConfig.vt_debug_phase, dcp); + auto dd = app.add_flag("--vt_debug_context", appConfig.vt_debug_context, ddp); + auto de = app.add_flag("--vt_debug_epoch", appConfig.vt_debug_epoch, dep); auto debugGroup = "Debug Print Configuration (must be compile-time enabled)"; r->group(debugGroup); @@ -334,11 +334,11 @@ void ArgConfig::addDebugPrintArgs(CLI::App& app) { de->group(debugGroup); auto dbq = "Always flush VT runtime prints"; - auto eb = app.add_flag("--vt_debug_print_flush", config_.vt_debug_print_flush, dbq); + auto eb = app.add_flag("--vt_debug_print_flush", appConfig.vt_debug_print_flush, dbq); eb->group(debugGroup); } -void ArgConfig::addLbArgs(CLI::App& app) { +void ArgConfig::addLbArgs(CLI::App& app, arguments::AppConfig& appConfig) { /* * Flags for enabling load balancing and configuring it */ @@ -362,21 +362,21 @@ void ArgConfig::addLbArgs(CLI::App& app) { auto lbd = "vt_lb_stats"; auto lbs = "stats"; auto lba = ""; - auto s = app.add_flag("--vt_lb", config_.vt_lb, lb); - auto t1 = app.add_flag("--vt_lb_quiet", config_.vt_lb_quiet, lb_quiet); - auto u = app.add_option("--vt_lb_file_name", config_.vt_lb_file_name, lb_file_name, lbf) + auto s = app.add_flag("--vt_lb", appConfig.vt_lb, lb); + auto t1 = app.add_flag("--vt_lb_quiet", appConfig.vt_lb_quiet, lb_quiet); + auto u = app.add_option("--vt_lb_file_name", appConfig.vt_lb_file_name, lb_file_name, lbf) ->check(CLI::ExistingFile); - auto u1 = app.add_flag("--vt_lb_show_spec", config_.vt_lb_show_spec, lb_show_spec); - auto v = app.add_option("--vt_lb_name", config_.vt_lb_name, lb_name, lbn); - auto v1 = app.add_option("--vt_lb_args", config_.vt_lb_args, lb_args, lba); - auto w = app.add_option("--vt_lb_interval", config_.vt_lb_interval, lb_interval, lbi); - auto wl = app.add_flag("--vt_lb_keep_last_elm", config_.vt_lb_keep_last_elm, lb_keep_last_elm); - auto ww = app.add_flag("--vt_lb_stats", config_.vt_lb_stats, lb_stats); - auto xz = app.add_flag("--vt_lb_stats_compress", config_.vt_lb_stats_compress, lb_stats_comp); - auto wx = app.add_option("--vt_lb_stats_dir", config_.vt_lb_stats_dir, lb_stats_dir, lbd); - auto wy = app.add_option("--vt_lb_stats_file", config_.vt_lb_stats_file, lb_stats_file,lbs); - auto xx = app.add_option("--vt_lb_stats_dir_in", config_.vt_lb_stats_dir_in, lb_stats_dir_in, lbd); - auto xy = app.add_option("--vt_lb_stats_file_in", config_.vt_lb_stats_file_in, lb_stats_file_in,lbs); + auto u1 = app.add_flag("--vt_lb_show_spec", appConfig.vt_lb_show_spec, lb_show_spec); + auto v = app.add_option("--vt_lb_name", appConfig.vt_lb_name, lb_name, lbn); + auto v1 = app.add_option("--vt_lb_args", appConfig.vt_lb_args, lb_args, lba); + auto w = app.add_option("--vt_lb_interval", appConfig.vt_lb_interval, lb_interval, lbi); + auto wl = app.add_flag("--vt_lb_keep_last_elm", appConfig.vt_lb_keep_last_elm, lb_keep_last_elm); + auto ww = app.add_flag("--vt_lb_stats", appConfig.vt_lb_stats, lb_stats); + auto xz = app.add_flag("--vt_lb_stats_compress", appConfig.vt_lb_stats_compress, lb_stats_comp); + auto wx = app.add_option("--vt_lb_stats_dir", appConfig.vt_lb_stats_dir, lb_stats_dir, lbd); + auto wy = app.add_option("--vt_lb_stats_file", appConfig.vt_lb_stats_file, lb_stats_file,lbs); + auto xx = app.add_option("--vt_lb_stats_dir_in", appConfig.vt_lb_stats_dir_in, lb_stats_dir_in, lbd); + auto xy = app.add_option("--vt_lb_stats_file_in", appConfig.vt_lb_stats_file_in, lb_stats_file_in,lbs); auto debugLB = "Load Balancing"; s->group(debugLB); @@ -397,11 +397,11 @@ void ArgConfig::addLbArgs(CLI::App& app) { // help options deliberately omitted from the debugLB group above so that // they appear grouped with --vt_help when --vt_help is used auto help_lb_args = "Print help for --vt_lb_args"; - auto h1 = app.add_flag("--vt_help_lb_args", config_.vt_help_lb_args, help_lb_args); + auto h1 = app.add_flag("--vt_help_lb_args", appConfig.vt_help_lb_args, help_lb_args); (void) h1; } -void ArgConfig::addDiagnosticArgs(CLI::App& app) { +void ArgConfig::addDiagnosticArgs(CLI::App& app, arguments::AppConfig& appConfig) { /* * Flags for controlling diagnostic collection and output */ @@ -410,11 +410,11 @@ void ArgConfig::addDiagnosticArgs(CLI::App& app) { auto file = "Output diagnostic summary table to text file"; auto csv = "Output diagnostic summary table to a comma-separated file"; auto base = "Use base units (seconds, units, etc.) for CSV file output"; - auto a = app.add_flag("--vt_diag_enable,!--vt_diag_disable", config_.vt_diag_enable, diag); - auto b = app.add_flag("--vt_diag_print_summary", config_.vt_diag_print_summary, sum); - auto c = app.add_option("--vt_diag_summary_file", config_.vt_diag_summary_file, file); - auto d = app.add_option("--vt_diag_summary_csv_file", config_.vt_diag_summary_csv_file, csv); - auto e = app.add_flag("--vt_diag_csv_base_units", config_.vt_diag_csv_base_units, base); + auto a = app.add_flag("--vt_diag_enable,!--vt_diag_disable", appConfig.vt_diag_enable, diag); + auto b = app.add_flag("--vt_diag_print_summary", appConfig.vt_diag_print_summary, sum); + auto c = app.add_option("--vt_diag_summary_file", appConfig.vt_diag_summary_file, file); + auto d = app.add_option("--vt_diag_summary_csv_file", appConfig.vt_diag_summary_csv_file, csv); + auto e = app.add_flag("--vt_diag_csv_base_units", appConfig.vt_diag_csv_base_units, base); auto diagnosticGroup = "Diagnostics"; a->group(diagnosticGroup); @@ -424,7 +424,7 @@ void ArgConfig::addDiagnosticArgs(CLI::App& app) { e->group(diagnosticGroup); } -void ArgConfig::addTerminationArgs(CLI::App& app) { +void ArgConfig::addTerminationArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto hang = "Disable termination hang detection"; auto hang_freq = "The number of tree traversals before a hang is detected"; auto ds = "Force use of Dijkstra-Scholten (DS) algorithm for rooted epoch termination detection"; @@ -433,13 +433,13 @@ void ArgConfig::addTerminationArgs(CLI::App& app) { auto terse = "Output epoch graph to file in terse mode"; auto progress = "Print termination counts when progress is stalled"; auto hfd = 1024; - auto x = app.add_flag("--vt_no_detect_hang", config_.vt_no_detect_hang, hang); - auto x1 = app.add_flag("--vt_term_rooted_use_ds", config_.vt_term_rooted_use_ds, ds); - auto x2 = app.add_flag("--vt_term_rooted_use_wave", config_.vt_term_rooted_use_wave, wave); - auto x3 = app.add_option("--vt_epoch_graph_on_hang", config_.vt_epoch_graph_on_hang, graph_on, true); - auto x4 = app.add_flag("--vt_epoch_graph_terse", config_.vt_epoch_graph_terse, terse); - auto x5 = app.add_option("--vt_print_no_progress", config_.vt_print_no_progress, progress, true); - auto y = app.add_option("--vt_hang_freq", config_.vt_hang_freq, hang_freq, hfd); + auto x = app.add_flag("--vt_no_detect_hang", appConfig.vt_no_detect_hang, hang); + auto x1 = app.add_flag("--vt_term_rooted_use_ds", appConfig.vt_term_rooted_use_ds, ds); + auto x2 = app.add_flag("--vt_term_rooted_use_wave", appConfig.vt_term_rooted_use_wave, wave); + auto x3 = app.add_option("--vt_epoch_graph_on_hang", appConfig.vt_epoch_graph_on_hang, graph_on, true); + auto x4 = app.add_flag("--vt_epoch_graph_terse", appConfig.vt_epoch_graph_terse, terse); + auto x5 = app.add_option("--vt_print_no_progress", appConfig.vt_print_no_progress, progress, true); + auto y = app.add_option("--vt_hang_freq", appConfig.vt_hang_freq, hang_freq, hfd); auto debugTerm = "Termination"; x->group(debugTerm); x1->group(debugTerm); @@ -450,14 +450,14 @@ void ArgConfig::addTerminationArgs(CLI::App& app) { y->group(debugTerm); } -void ArgConfig::addDebuggerArgs(CLI::App& app) { +void ArgConfig::addDebuggerArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto pause = "Pause at startup so GDB/LLDB can be attached"; - auto z = app.add_flag("--vt_pause", config_.vt_pause, pause); + auto z = app.add_flag("--vt_pause", appConfig.vt_pause, pause); auto launchTerm = "Debugging/Launch"; z->group(launchTerm); } -void ArgConfig::addUserArgs(CLI::App& app) { +void ArgConfig::addUserArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto user1 = "User Option 1a (boolean)"; auto user2 = "User Option 2a (boolean)"; auto user3 = "User Option 3a (boolean)"; @@ -467,15 +467,15 @@ void ArgConfig::addUserArgs(CLI::App& app) { auto userstr1 = "User Option 1c (std::string)"; auto userstr2 = "User Option 2c (std::string)"; auto userstr3 = "User Option 3c (std::string)"; - auto u1 = app.add_flag("--vt_user_1", config_.vt_user_1, user1); - auto u2 = app.add_flag("--vt_user_2", config_.vt_user_2, user2); - auto u3 = app.add_flag("--vt_user_3", config_.vt_user_3, user3); - auto ui1 = app.add_option("--vt_user_int_1", config_.vt_user_int_1, userint1, 0); - auto ui2 = app.add_option("--vt_user_int_2", config_.vt_user_int_2, userint2, 0); - auto ui3 = app.add_option("--vt_user_int_3", config_.vt_user_int_3, userint3, 0); - auto us1 = app.add_option("--vt_user_str_1", config_.vt_user_str_1, userstr1, ""); - auto us2 = app.add_option("--vt_user_str_2", config_.vt_user_str_2, userstr2, ""); - auto us3 = app.add_option("--vt_user_str_3", config_.vt_user_str_3, userstr3, ""); + auto u1 = app.add_flag("--vt_user_1", appConfig.vt_user_1, user1); + auto u2 = app.add_flag("--vt_user_2", appConfig.vt_user_2, user2); + auto u3 = app.add_flag("--vt_user_3", appConfig.vt_user_3, user3); + auto ui1 = app.add_option("--vt_user_int_1", appConfig.vt_user_int_1, userint1, 0); + auto ui2 = app.add_option("--vt_user_int_2", appConfig.vt_user_int_2, userint2, 0); + auto ui3 = app.add_option("--vt_user_int_3", appConfig.vt_user_int_3, userint3, 0); + auto us1 = app.add_option("--vt_user_str_1", appConfig.vt_user_str_1, userstr1, ""); + auto us2 = app.add_option("--vt_user_str_2", appConfig.vt_user_str_2, userstr2, ""); + auto us3 = app.add_option("--vt_user_str_3", appConfig.vt_user_str_3, userstr3, ""); auto userOpts = "User Options"; u1->group(userOpts); u2->group(userOpts); @@ -488,32 +488,32 @@ void ArgConfig::addUserArgs(CLI::App& app) { us3->group(userOpts); } -void ArgConfig::addSchedulerArgs(CLI::App& app) { +void ArgConfig::addSchedulerArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto nsched = "Number of times to run the progress function in scheduler"; auto ksched = "Run the MPI progress function at least every k handlers that run"; auto ssched = "Run the MPI progress function at least every s seconds"; - auto sca = app.add_option("--vt_sched_num_progress", config_.vt_sched_num_progress, nsched, 2); - auto hca = app.add_option("--vt_sched_progress_han", config_.vt_sched_progress_han, ksched, 0); - auto kca = app.add_option("--vt_sched_progress_sec", config_.vt_sched_progress_sec, ssched, 0.0); + auto sca = app.add_option("--vt_sched_num_progress", appConfig.vt_sched_num_progress, nsched, 2); + auto hca = app.add_option("--vt_sched_progress_han", appConfig.vt_sched_progress_han, ksched, 0); + auto kca = app.add_option("--vt_sched_progress_sec", appConfig.vt_sched_progress_sec, ssched, 0.0); auto schedulerGroup = "Scheduler Configuration"; sca->group(schedulerGroup); hca->group(schedulerGroup); kca->group(schedulerGroup); } -void ArgConfig::addConfigFileArgs(CLI::App& app) { +void ArgConfig::addConfigFileArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto doconfig = "Output all VT args to configuration file"; auto configname = "Name of configuration file to output"; - auto a1 = app.add_flag("--vt_output_config", config_.vt_output_config, doconfig); - auto a2 = app.add_option("--vt_output_config_file", config_.vt_output_config_file, configname, true); + auto a1 = app.add_flag("--vt_output_config", appConfig.vt_output_config, doconfig); + auto a2 = app.add_option("--vt_output_config_file", appConfig.vt_output_config_file, configname, true); auto configGroup = "Configuration File"; a1->group(configGroup); a2->group(configGroup); } -void ArgConfig::addRuntimeArgs(CLI::App& app) { +void ArgConfig::addRuntimeArgs(CLI::App& app, arguments::AppConfig& appConfig) { auto max_size = "Maximum MPI send size (causes larger messages to be split " "into multiple MPI sends)"; auto assert = "Do not abort the program when vtAssert(..) is invoked"; @@ -521,13 +521,13 @@ void ArgConfig::addRuntimeArgs(CLI::App& app) { auto a1 = app.add_option( - "--vt_max_mpi_send_size", config_.vt_max_mpi_send_size, max_size, true + "--vt_max_mpi_send_size", appConfig.vt_max_mpi_send_size, max_size, true ); auto a2 = app.add_flag( - "--vt_no_assert_fail", config_.vt_no_assert_fail, assert + "--vt_no_assert_fail", appConfig.vt_no_assert_fail, assert ); auto a3 = app.add_flag( - "--vt_throw_on_abort", config_.vt_throw_on_abort, throw_on_abort + "--vt_throw_on_abort", appConfig.vt_throw_on_abort, throw_on_abort ); @@ -537,16 +537,16 @@ void ArgConfig::addRuntimeArgs(CLI::App& app) { a3->group(configRuntime); } -void ArgConfig::addThreadingArgs(CLI::App& app) { +void ArgConfig::addThreadingArgs(CLI::App& app, arguments::AppConfig& appConfig) { #if (vt_feature_fcontext != 0) auto ult_disable = "Disable running handlers in user-level threads"; auto stack_size = "The default stack size for user-level threads"; auto a1 = app.add_flag( - "--vt_ult_disable", config_.vt_ult_disable, ult_disable + "--vt_ult_disable", appConfig.vt_ult_disable, ult_disable ); auto a2 = app.add_option( - "--vt_ult_stack_size", config_.vt_ult_stack_size, stack_size, true + "--vt_ult_stack_size", appConfig.vt_ult_stack_size, stack_size, true ); auto configThreads = "Threads"; @@ -582,7 +582,26 @@ class VtFormatter : public CLI::Formatter { } }; -std::tuple ArgConfig::parse(int& argc, char**& argv) { +std::tuple ArgConfig::parse( + int& argc, char**& argv, arguments::AppConfig const* appConfig +) { + // If user didn't define appConfig, parse into this->config_. + if (not appConfig) { + return parseToConfig(argc, argv, config_); + } + + // if user defines appConfig, parse into temporary config for later comparison. + arguments::AppConfig config{*appConfig}; + auto const parse_result = parseToConfig(argc, argv, config); + + config_ = config; + + return parse_result; +} + +std::tuple ArgConfig::parseToConfig( + int& argc, char**& argv, arguments::AppConfig& appConfig +) { if (parsed_ || argc == 0 || argv == nullptr) { // Odd case.. pretend nothing bad happened. return std::make_tuple(-1, std::string{}); @@ -594,35 +613,35 @@ std::tuple ArgConfig::parse(int& argc, char**& argv) { app.set_help_flag("--vt_help", "Display help"); - addColorArgs(app); - addSignalArgs(app); - addMemUsageArgs(app); - addStackDumpArgs(app); - addTraceArgs(app); - addDebugPrintArgs(app); - addLbArgs(app); - addDiagnosticArgs(app); - addTerminationArgs(app); - addDebuggerArgs(app); - addUserArgs(app); - addSchedulerArgs(app); - addConfigFileArgs(app); - addRuntimeArgs(app); - addThreadingArgs(app); - - std::tuple result = parseArguments(app, /*out*/ argc, /*out*/ argv); + addColorArgs(app, appConfig); + addSignalArgs(app, appConfig); + addMemUsageArgs(app, appConfig); + addStackDumpArgs(app, appConfig); + addTraceArgs(app, appConfig); + addDebugPrintArgs(app, appConfig); + addLbArgs(app, appConfig); + addDiagnosticArgs(app, appConfig); + addTerminationArgs(app, appConfig); + addDebuggerArgs(app, appConfig); + addUserArgs(app, appConfig); + addSchedulerArgs(app, appConfig); + addConfigFileArgs(app, appConfig); + addRuntimeArgs(app, appConfig); + addThreadingArgs(app, appConfig); + + std::tuple result = parseArguments(app, argc, argv, appConfig); if (std::get<0>(result) not_eq -1) { // non-success return result; } // Determine the final colorization setting. - if (config_.vt_no_color) { - config_.colorize_output = false; + if (appConfig.vt_no_color) { + appConfig.colorize_output = false; } else { // Otherwise, colorize. // (Within MPI there is no good method to auto-detect.) - config_.colorize_output = true; + appConfig.colorize_output = true; } parsed_ = true; @@ -634,30 +653,32 @@ std::tuple ArgConfig::parse(int& argc, char**& argv) { * \internal * Application specific cleanup and mapping to actual app args. */ -void ArgConfig::postParseTransform() { +void ArgConfig::postParseTransform(vt::arguments::AppConfig& appConfig) { auto contains = [](std::vector &v, std::string str){ return std::find(v.begin(), v.end(), str) not_eq v.end(); }; - config_.vt_trace_mpi = contains(arg_trace_mpi, "internal"); - config_.vt_trace_pmpi = contains(arg_trace_mpi, "external"); + appConfig.vt_trace_mpi = contains(arg_trace_mpi, "internal"); + appConfig.vt_trace_pmpi = contains(arg_trace_mpi, "external"); - using config::ModeEnum; + using vt::config::ModeEnum; - auto const& level = config_.vt_debug_level; + auto const& level = appConfig.vt_debug_level; if (level == "terse" or level == "0") { - config_.vt_debug_level_val = ModeEnum::terse; + appConfig.vt_debug_level_val = ModeEnum::terse; } else if (level == "normal" or level == "1") { - config_.vt_debug_level_val = ModeEnum::terse | ModeEnum::normal; + appConfig.vt_debug_level_val = ModeEnum::terse | ModeEnum::normal; } else if (level == "verbose" or level == "2") { - config_.vt_debug_level_val = + appConfig.vt_debug_level_val = ModeEnum::terse | ModeEnum::normal | ModeEnum::verbose; } else { vtAbort("Invalid value passed to --vt_debug_level"); } } -std::tuple ArgConfig::parseArguments(CLI::App& app, int& argc, char**& argv) { +std::tuple ArgConfig::parseArguments( + CLI::App& app, int& argc, char**& argv, arguments::AppConfig& appConfig +) { std::vector vt_args; @@ -668,7 +689,7 @@ std::tuple ArgConfig::parseArguments(CLI::App& app, int& argc, if (0 == strcmp(c, "--vt_args")) { rargs = &vt_args; } else if (0 == strcmp(c, "--")) { - rargs = &config_.passthru_args; + rargs = &appConfig.passthru_args; } else if (rargs) { rargs->push_back(c); } else if (0 == strncmp(c, "--vt_", 5)) { @@ -677,7 +698,7 @@ std::tuple ArgConfig::parseArguments(CLI::App& app, int& argc, rargs = &vt_args; rargs->push_back(c); } else { - config_.passthru_args.push_back(c); + appConfig.passthru_args.push_back(c); } } @@ -711,8 +732,8 @@ std::tuple ArgConfig::parseArguments(CLI::App& app, int& argc, // If the user specified to output the full configuration, save it in a string // so node 0 can output in the runtime once MPI is init'ed - if (config_.vt_output_config) { - config_.vt_output_config_str = app.config_to_str(true, true); + if (appConfig.vt_output_config) { + appConfig.vt_output_config_str = app.config_to_str(true, true); } // Get the clean prog name; don't allow path bleed in usages. @@ -723,25 +744,25 @@ std::tuple ArgConfig::parseArguments(CLI::App& app, int& argc, clean_prog_name = clean_prog_name.substr(l + 1, std::string::npos); } - config_.prog_name = clean_prog_name; - config_.argv_prog_name = argv[0]; + appConfig.prog_name = clean_prog_name; + appConfig.argv_prog_name = argv[0]; - postParseTransform(); + postParseTransform(appConfig); // Rebuild passthru into ref-returned argc/argv // It should be possible to modify the original argv as the outgoing // number of arguments is always less. As currently allocated here, // ownership of the new object is ill-defined. - int new_argc = config_.passthru_args.size() + 1; // does not include argv[0] + int new_argc = appConfig.passthru_args.size() + 1; // does not include argv[0] static std::unique_ptr new_argv = nullptr; new_argv = std::make_unique(new_argc + 1); int i = 0; - new_argv[i++] = config_.argv_prog_name; - for (auto&& arg : config_.passthru_args) { + new_argv[i++] = appConfig.argv_prog_name; + for (auto&& arg : appConfig.passthru_args) { new_argv[i++] = arg; } new_argv[i++] = nullptr; diff --git a/src/vt/configs/arguments/args.h b/src/vt/configs/arguments/args.h index 0efe341fa7..cfcaf7ee76 100644 --- a/src/vt/configs/arguments/args.h +++ b/src/vt/configs/arguments/args.h @@ -73,8 +73,9 @@ struct ArgConfig : runtime::component::Component { /// On success the tuple will be {-1, ""}. Otherwise the exit code /// (which may be 0 if help was requested) will be returned along /// with an appropriate display message. - std::tuple parse(int& argc, char**& argv); - std::tuple parseArguments(CLI::App& app, int& argc, char**& argv); + std::tuple parse( + int& argc, char**& argv, arguments::AppConfig const* appConfig + ); static std::unique_ptr construct(std::unique_ptr arg); @@ -89,23 +90,30 @@ struct ArgConfig : runtime::component::Component { AppConfig config_; private: - void addColorArgs(CLI::App& app); - void addSignalArgs(CLI::App& app); - void addMemUsageArgs(CLI::App& app); - void addStackDumpArgs(CLI::App& app); - void addTraceArgs(CLI::App& app); - void addDebugPrintArgs(CLI::App& app); - void addLbArgs(CLI::App& app); - void addDiagnosticArgs(CLI::App& app); - void addTerminationArgs(CLI::App& app); - void addDebuggerArgs(CLI::App& app); - void addUserArgs(CLI::App& app); - void addSchedulerArgs(CLI::App& app); - void addConfigFileArgs(CLI::App& app); - void addRuntimeArgs(CLI::App& app); - void addThreadingArgs(CLI::App& app); - - void postParseTransform(); + std::tuple parseToConfig( + int& argc, char**& argv, arguments::AppConfig& appConfig + ); + std::tuple parseArguments( + CLI::App& app, int& argc, char**& argv, arguments::AppConfig& appConfig + ); + + void addColorArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addSignalArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addMemUsageArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addStackDumpArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addTraceArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addDebugPrintArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addLbArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addDiagnosticArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addTerminationArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addDebuggerArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addUserArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addSchedulerArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addConfigFileArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addRuntimeArgs(CLI::App& app, arguments::AppConfig& appConfig); + void addThreadingArgs(CLI::App& app, arguments::AppConfig& appConfig); + + void postParseTransform(arguments::AppConfig& appConfig); bool parsed_ = false; }; diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 12fff50c84..8e13ad17b4 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -99,7 +99,8 @@ namespace vt { namespace runtime { Runtime::Runtime( int& argc, char**& argv, WorkerCountType in_num_workers, - bool const interop_mode, MPI_Comm in_comm, RuntimeInstType const in_instance + bool const interop_mode, MPI_Comm in_comm, RuntimeInstType const in_instance, + arguments::AppConfig const* appConfig ) : instance_(in_instance), runtime_active_(false), is_interop_(interop_mode), num_workers_(in_num_workers), initial_communicator_(in_comm), @@ -151,8 +152,10 @@ Runtime::Runtime( } // n.b. ref-update of args with pass-through arguments + // If appConfig is not nullptr, compare CLI arguments with user-defined ones, + // and report overwritten ones. std::tuple result = - arg_config_->parse(/*out*/ argc, /*out*/ argv); + arg_config_->parse(argc, argv, appConfig); int exit_code = std::get<0>(result); if (getAppConfig()->vt_help_lb_args) { diff --git a/src/vt/runtime/runtime.h b/src/vt/runtime/runtime.h index 9820150378..0c76211beb 100644 --- a/src/vt/runtime/runtime.h +++ b/src/vt/runtime/runtime.h @@ -101,7 +101,8 @@ struct Runtime { WorkerCountType in_num_workers = no_workers, bool const interop_mode = false, MPI_Comm in_comm = MPI_COMM_WORLD, - RuntimeInstType const in_instance = RuntimeInstType::DefaultInstance + RuntimeInstType const in_instance = RuntimeInstType::DefaultInstance, + arguments::AppConfig const* appConfig = nullptr ); Runtime(Runtime const&) = delete; diff --git a/tests/unit/runtime/test_initialization.cc b/tests/unit/runtime/test_initialization.cc index d47fb7afb5..fdf6ed030c 100644 --- a/tests/unit/runtime/test_initialization.cc +++ b/tests/unit/runtime/test_initialization.cc @@ -49,38 +49,111 @@ namespace vt { namespace tests { namespace unit { -struct TestInitialization : TestParallelHarness { - void SetUp() override { - using namespace vt; +struct TestInitialization : TestParallelHarness { }; - TestHarness::SetUp(); +TEST_F(TestInitialization, test_initialize_with_args) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + static char vt_no_terminate[]{"--vt_no_terminate"}; - // communicator is duplicated. - MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + std::vector custom_args; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(vt_no_terminate); + custom_args.emplace_back(nullptr); - static char prog_name[]{"vt_program"}; - static char cli_argument[]{"--cli_argument=100"}; - static char vt_no_terminate[]{"--vt_no_terminate"}; - custom_args.emplace_back(prog_name); - custom_args.emplace_back(cli_argument); - custom_args.emplace_back(vt_no_terminate); - custom_args.emplace_back(nullptr); + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); - custom_argc = custom_args.size() - 1; - custom_argv = custom_args.data(); - EXPECT_EQ(custom_argc, 3); + EXPECT_EQ(custom_argc, 3); - vt::initialize(custom_argc, custom_argv, no_workers, true, &comm); - } + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm); + + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_no_terminate, true); + + EXPECT_EQ(custom_argc, 2); + EXPECT_STREQ(custom_argv[0], "vt_program"); + EXPECT_STREQ(custom_argv[1], "--cli_argument=100"); + EXPECT_EQ(custom_argv[2], nullptr); +} + +TEST_F(TestInitialization, test_initialize_with_appconfig) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; std::vector custom_args; - int custom_argc; - char** custom_argv; -}; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(nullptr); + + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 2); + + arguments::AppConfig appConfig{}; + appConfig.vt_lb = true; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm, &appConfig); + + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_lb, true); + EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); + EXPECT_EQ(theConfig()->vt_lb_stats, true); + + // vt_no_detect_hang wasn't set, should be default + EXPECT_EQ(theConfig()->vt_no_detect_hang, false); + + EXPECT_EQ(custom_argc, 2); + EXPECT_STREQ(custom_argv[0], "vt_program"); + EXPECT_STREQ(custom_argv[1], "--cli_argument=100"); + EXPECT_EQ(custom_argv[2], nullptr); +} + +TEST_F(TestInitialization, test_initialize_with_args_and_appconfig) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + static char vt_no_terminate[]{"--vt_no_terminate"}; + static char vt_no_detect_hang[]{"--vt_no_detect_hang"}; + + std::vector custom_args; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(vt_no_terminate); + custom_args.emplace_back(vt_no_detect_hang); + custom_args.emplace_back(nullptr); + + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 4); + + arguments::AppConfig appConfig{}; + appConfig.vt_color = false; + appConfig.vt_lb = true; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + appConfig.vt_no_detect_hang = false; + + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm, &appConfig); -TEST_F(TestInitialization, test_initialize_with_args) { EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_color, false); + EXPECT_EQ(theConfig()->vt_lb, true); + EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); + EXPECT_EQ(theConfig()->vt_lb_stats, true); EXPECT_EQ(theConfig()->vt_no_terminate, true); + // CLI args should overwritten hardcoded appConfig + EXPECT_EQ(theConfig()->vt_no_detect_hang, true); EXPECT_EQ(custom_argc, 2); EXPECT_STREQ(custom_argv[0], "vt_program"); From 068808ed186ba46308c8a022701c9f5b24a55dad Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Tue, 15 Feb 2022 08:17:49 +0100 Subject: [PATCH 34/47] #1550 fix parameter type --- src/vt/collective/startup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/collective/startup.h b/src/vt/collective/startup.h index 1c8c27bb72..2f50850c0c 100644 --- a/src/vt/collective/startup.h +++ b/src/vt/collective/startup.h @@ -60,7 +60,7 @@ RuntimePtrType initialize( ); RuntimePtrType initialize(MPI_Comm* comm = nullptr); RuntimePtrType initialize( - int& argc, char**& argv, arguments::ArgConfig const* appConfig + int& argc, char**& argv, arguments::AppConfig const* appConfig ); void finalize(RuntimePtrType in_rt); From ab6d241f891f432943517486a41a6e96d94111c6 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Tue, 15 Feb 2022 10:56:57 +0100 Subject: [PATCH 35/47] #1550 fix runtime init --- src/vt/collective/startup.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/vt/collective/startup.cc b/src/vt/collective/startup.cc index 5f3bdbea02..1c01d3d56d 100644 --- a/src/vt/collective/startup.cc +++ b/src/vt/collective/startup.cc @@ -78,15 +78,13 @@ RuntimePtrType initialize(MPI_Comm* comm) { RuntimePtrType initialize( int& argc, char**& argv, arguments::AppConfig const* appConfig ) { - auto mpiComm = MPI_COMM_WORLD; - return initialize(argc, argv, &mpiComm, appConfig); + return initialize(argc, argv, nullptr, appConfig); } RuntimePtrType initialize(arguments::AppConfig const* appConfig) { int argc = 0; char** argv = nullptr; - auto mpiComm = MPI_COMM_WORLD; - return initialize(argc, argv, &mpiComm, appConfig); + return initialize(argc, argv, nullptr, appConfig); } void finalize(RuntimePtrType in_rt) { From 489ddffc3af6af4cc8c89f74ff9d6d9594632031 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 16 Feb 2022 21:52:57 +0100 Subject: [PATCH 36/47] #1550 print predefined options overwritten by CLI arguments --- src/vt/collective/collective_ops.cc | 161 ++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/src/vt/collective/collective_ops.cc b/src/vt/collective/collective_ops.cc index c41ae93049..b27656c32d 100644 --- a/src/vt/collective/collective_ops.cc +++ b/src/vt/collective/collective_ops.cc @@ -42,6 +42,7 @@ */ #include "vt/collective/collective_ops.h" +#include "vt/context/context.h" #include "vt/runtime/runtime.h" #include "vt/scheduler/scheduler.h" #include "vt/runtime/runtime_inst.h" @@ -53,6 +54,162 @@ namespace vt { +namespace { + +#define printIfOverwritten(opt) \ + do { \ + if (cliConfig.opt != appConfig.opt) { \ + ++overwrittens; \ + fmt::print( \ + "{}\t{}--" #opt "{}\n", \ + vt_pre, magenta, reset \ + ); \ + } \ + } while (0) + +void printOverwrittens( + vt::arguments::AppConfig const &cliConfig, + vt::arguments::AppConfig const &appConfig +) { + auto const green = debug::green(); + auto const reset = debug::reset(); + auto const magenta = debug::magenta(); + auto const vt_pre = debug::vtPre(); + + fmt::print( + "{}{}Predefined options overwritten by CLI arguments:{}\n", + vt_pre, green, reset + ); + + int overwrittens = 0; + + printIfOverwritten(vt_color); + printIfOverwritten(vt_no_color); + printIfOverwritten(vt_quiet); + printIfOverwritten(vt_sched_progress_han); + printIfOverwritten(vt_sched_progress_sec); + printIfOverwritten(vt_no_sigint); + printIfOverwritten(vt_no_sigsegv); + printIfOverwritten(vt_no_sigbus); + printIfOverwritten(vt_no_terminate); + printIfOverwritten(vt_memory_reporters); + printIfOverwritten(vt_print_memory_each_phase); + printIfOverwritten(vt_print_memory_node); + printIfOverwritten(vt_allow_memory_report_with_ps); + printIfOverwritten(vt_print_memory_at_threshold); + printIfOverwritten(vt_print_memory_threshold); + printIfOverwritten(vt_print_memory_sched_poll); + printIfOverwritten(vt_print_memory_footprint); + printIfOverwritten(vt_no_warn_stack); + printIfOverwritten(vt_no_assert_stack); + printIfOverwritten(vt_no_abort_stack); + printIfOverwritten(vt_no_stack); + printIfOverwritten(vt_stack_file); + printIfOverwritten(vt_stack_dir); + printIfOverwritten(vt_stack_mod); + printIfOverwritten(vt_trace); + printIfOverwritten(vt_trace_mpi); + printIfOverwritten(vt_trace_pmpi); + printIfOverwritten(vt_trace_sys_all); + printIfOverwritten(vt_trace_sys_term); + printIfOverwritten(vt_trace_sys_location); + printIfOverwritten(vt_trace_sys_collection); + printIfOverwritten(vt_trace_sys_serial_msg); + printIfOverwritten(vt_trace_file); + printIfOverwritten(vt_trace_dir); + printIfOverwritten(vt_trace_mod); + printIfOverwritten(vt_trace_flush_size); + printIfOverwritten(vt_trace_spec); + printIfOverwritten(vt_trace_spec_file); + printIfOverwritten(vt_trace_memory_usage); + printIfOverwritten(vt_trace_event_polling); + printIfOverwritten(vt_trace_irecv_polling); + printIfOverwritten(vt_lb); + printIfOverwritten(vt_lb_show_spec); + printIfOverwritten(vt_lb_quiet); + printIfOverwritten(vt_lb_file_name); + printIfOverwritten(vt_lb_name); + printIfOverwritten(vt_lb_args); + printIfOverwritten(vt_lb_interval); + printIfOverwritten(vt_lb_stats); + printIfOverwritten(vt_lb_stats_compress); + printIfOverwritten(vt_lb_stats_dir); + printIfOverwritten(vt_lb_stats_file); + printIfOverwritten(vt_lb_stats_dir_in); + printIfOverwritten(vt_lb_stats_file_in); + printIfOverwritten(vt_help_lb_args); + printIfOverwritten(vt_no_detect_hang); + printIfOverwritten(vt_print_no_progress); + printIfOverwritten(vt_epoch_graph_on_hang); + printIfOverwritten(vt_epoch_graph_terse); + printIfOverwritten(vt_term_rooted_use_ds); + printIfOverwritten(vt_term_rooted_use_wave); + printIfOverwritten(vt_hang_freq); + printIfOverwritten(vt_diag_enable); + printIfOverwritten(vt_diag_print_summary); + printIfOverwritten(vt_diag_summary_csv_file); + printIfOverwritten(vt_diag_summary_file); + printIfOverwritten(vt_diag_csv_base_units); + printIfOverwritten(vt_pause); + printIfOverwritten(vt_no_assert_fail); + printIfOverwritten(vt_throw_on_abort); + printIfOverwritten(vt_max_mpi_send_size); + printIfOverwritten(vt_debug_level); + printIfOverwritten(vt_debug_all); + printIfOverwritten(vt_debug_none); + printIfOverwritten(vt_debug_gen); + printIfOverwritten(vt_debug_runtime); + printIfOverwritten(vt_debug_active); + printIfOverwritten(vt_debug_term); + printIfOverwritten(vt_debug_termds); + printIfOverwritten(vt_debug_barrier); + printIfOverwritten(vt_debug_event); + printIfOverwritten(vt_debug_pipe); + printIfOverwritten(vt_debug_pool); + printIfOverwritten(vt_debug_reduce); + printIfOverwritten(vt_debug_rdma); + printIfOverwritten(vt_debug_rdma_channel); + printIfOverwritten(vt_debug_rdma_state); + printIfOverwritten(vt_debug_param); + printIfOverwritten(vt_debug_handler); + printIfOverwritten(vt_debug_hierlb); + printIfOverwritten(vt_debug_temperedlb); + printIfOverwritten(vt_debug_scatter); + printIfOverwritten(vt_debug_sequence); + printIfOverwritten(vt_debug_sequence_vrt); + printIfOverwritten(vt_debug_serial_msg); + printIfOverwritten(vt_debug_trace); + printIfOverwritten(vt_debug_location); + printIfOverwritten(vt_debug_lb); + printIfOverwritten(vt_debug_vrt); + printIfOverwritten(vt_debug_vrt_coll); + printIfOverwritten(vt_debug_worker); + printIfOverwritten(vt_debug_group); + printIfOverwritten(vt_debug_broadcast); + printIfOverwritten(vt_debug_objgroup); + printIfOverwritten(vt_debug_phase); + printIfOverwritten(vt_debug_context); + printIfOverwritten(vt_debug_epoch); + printIfOverwritten(vt_debug_print_flush); + printIfOverwritten(vt_user_1); + printIfOverwritten(vt_user_2); + printIfOverwritten(vt_user_3); + printIfOverwritten(vt_user_int_1); + printIfOverwritten(vt_user_int_2); + printIfOverwritten(vt_user_int_3); + printIfOverwritten(vt_user_str_1); + printIfOverwritten(vt_user_str_2); + printIfOverwritten(vt_user_str_3); + printIfOverwritten(vt_output_config); + printIfOverwritten(vt_output_config_file); + + if (overwrittens == 0) { + fmt::print("{}\tNone.\n", vt_pre); + } +} + +} /* end anon namespace */ + template RuntimePtrType CollectiveAnyOps::initialize( int& argc, char**& argv, WorkerCountType const num_workers, @@ -80,6 +237,10 @@ RuntimePtrType CollectiveAnyOps::initialize( #pragma sst global rt RuntimeInst::rt->initialize(); + if (appConfig && theContext()->getNode() == 0) { + printOverwrittens(*rt->getAppConfig(), *appConfig); + } + return runtime::makeRuntimePtr(rt_ptr); } From f90ddfe95ab24c43b9143c9238e6ec68e080423c Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 16 Feb 2022 22:24:08 +0100 Subject: [PATCH 37/47] #1550 clean up ArgConfig struct --- src/vt/configs/arguments/args.cc | 299 ++++++++++++++++--------------- src/vt/configs/arguments/args.h | 25 +-- 2 files changed, 152 insertions(+), 172 deletions(-) diff --git a/src/vt/configs/arguments/args.cc b/src/vt/configs/arguments/args.cc index 207ea5b998..084c47e9d2 100644 --- a/src/vt/configs/arguments/args.cc +++ b/src/vt/configs/arguments/args.cc @@ -56,15 +56,135 @@ namespace vt { namespace arguments { // Temporary variables used only for parsing artifacts. namespace { + std::vector arg_trace_mpi; -} /* end anon namespace */ -/*static*/ std::unique_ptr -ArgConfig::construct(std::unique_ptr arg) { - return arg; +/** + * \internal + * Application specific cleanup and mapping to actual app args. + */ +void postParseTransform(AppConfig& appConfig) { + auto contains = [](std::vector &v, std::string str){ + return std::find(v.begin(), v.end(), str) not_eq v.end(); + }; + + appConfig.vt_trace_mpi = contains(arg_trace_mpi, "internal"); + appConfig.vt_trace_pmpi = contains(arg_trace_mpi, "external"); + + using config::ModeEnum; + + auto const& level = appConfig.vt_debug_level; + if (level == "terse" or level == "0") { + appConfig.vt_debug_level_val = ModeEnum::terse; + } else if (level == "normal" or level == "1") { + appConfig.vt_debug_level_val = ModeEnum::terse | ModeEnum::normal; + } else if (level == "verbose" or level == "2") { + appConfig.vt_debug_level_val = + ModeEnum::terse | ModeEnum::normal | ModeEnum::verbose; + } else { + vtAbort("Invalid value passed to --vt_debug_level"); + } } -void ArgConfig::addColorArgs(CLI::App& app, arguments::AppConfig& appConfig) { +std::tuple parseArguments( + CLI::App& app, int& argc, char**& argv, AppConfig& appConfig +) { + + std::vector vt_args; + + // Load up vectors (has curious ability to altnerate vt/mpi/passthru) + std::vector* rargs = nullptr; + for (int i = 1; i < argc; i++) { + char* c = argv[i]; + if (0 == strcmp(c, "--vt_args")) { + rargs = &vt_args; + } else if (0 == strcmp(c, "--")) { + rargs = &appConfig.passthru_args; + } else if (rargs) { + rargs->push_back(c); + } else if (0 == strncmp(c, "--vt_", 5)) { + // Implicit start of VT args allows pass-thru 'for compatibility' + // although the recommended calling pattern to always provide VT args first. + rargs = &vt_args; + rargs->push_back(c); + } else { + appConfig.passthru_args.push_back(c); + } + } + + // All must be accounted for + app.allow_extras(false); + + // Build string-vector and reverse order to parse (CLI quirk) + std::vector args_to_parse; + for (auto it = vt_args.crbegin(); it != vt_args.crend(); ++it) { + args_to_parse.push_back(*it); + } + + // Allow a input config file + app.set_config( + "--vt_input_config", + "", // no default file name + "Read in an ini config file for VT", + false // not required + ); + + try { + app.parse(args_to_parse); + } catch (CLI::Error &ex) { + // Return exit code and message, delaying logic processing of such. + // The default exit code for 'help' is 0. + std::stringstream message_stream; + int result = app.exit(ex, message_stream, message_stream); + + return std::make_tuple(result, message_stream.str()); + } + + // If the user specified to output the full configuration, save it in a string + // so node 0 can output in the runtime once MPI is init'ed + if (appConfig.vt_output_config) { + appConfig.vt_output_config_str = app.config_to_str(true, true); + } + + // Get the clean prog name; don't allow path bleed in usages. + // std::filesystem is C++17. + std::string clean_prog_name = argv[0]; + size_t l = clean_prog_name.find_last_of("/\\"); + if (l not_eq std::string::npos and l + 1 < clean_prog_name.size()) { + clean_prog_name = clean_prog_name.substr(l + 1, std::string::npos); + } + + appConfig.prog_name = clean_prog_name; + appConfig.argv_prog_name = argv[0]; + + postParseTransform(appConfig); + + // Rebuild passthru into ref-returned argc/argv + + // It should be possible to modify the original argv as the outgoing + // number of arguments is always less. As currently allocated here, + // ownership of the new object is ill-defined. + int new_argc = appConfig.passthru_args.size() + 1; // does not include argv[0] + + static std::unique_ptr new_argv = nullptr; + + new_argv = std::make_unique(new_argc + 1); + + int i = 0; + new_argv[i++] = appConfig.argv_prog_name; + for (auto&& arg : appConfig.passthru_args) { + new_argv[i++] = arg; + } + new_argv[i++] = nullptr; + + // Set them back with all vt (and MPI) arguments elided + argc = new_argc; + argv = new_argv.get(); + + return std::make_tuple(-1, std::string{}); +} + +void addColorArgs(CLI::App& app, AppConfig& appConfig) { auto quiet = "Quiet the output from vt (only errors, warnings)"; auto always = "Colorize output (default)"; auto never = "Do not colorize output (overrides --vt_color)"; @@ -81,7 +201,7 @@ void ArgConfig::addColorArgs(CLI::App& app, arguments::AppConfig& appConfig) { // b->excludes(a); } -void ArgConfig::addSignalArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addSignalArgs(CLI::App& app, AppConfig& appConfig) { auto no_sigint = "Do not register signal handler for SIGINT"; auto no_sigsegv = "Do not register signal handler for SIGSEGV"; auto no_sigbus = "Do not register signal handler for SIGBUS"; @@ -97,7 +217,7 @@ void ArgConfig::addSignalArgs(CLI::App& app, arguments::AppConfig& appConfig) { g->group(signalGroup); } -void ArgConfig::addMemUsageArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addMemUsageArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags for controlling memory usage reporting */ @@ -128,8 +248,7 @@ void ArgConfig::addMemUsageArgs(CLI::App& app, arguments::AppConfig& appConfig) mf->group(memoryGroup); } - -void ArgConfig::addStackDumpArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addStackDumpArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags to control stack dumping */ @@ -157,7 +276,7 @@ void ArgConfig::addStackDumpArgs(CLI::App& app, arguments::AppConfig& appConfig) m->group(stackGroup); } -void ArgConfig::addTraceArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addTraceArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags to control tracing output */ @@ -217,8 +336,8 @@ void ArgConfig::addTraceArgs(CLI::App& app, arguments::AppConfig& appConfig) { qze->group(traceGroup); } -void ArgConfig::addDebugPrintArgs(CLI::App& app, arguments::AppConfig& appConfig) { - #define debug_pp(opt) +std::string(vt::config::PrettyPrintCat::str)+ +void addDebugPrintArgs(CLI::App& app, AppConfig& appConfig) { + #define debug_pp(opt) +std::string(config::PrettyPrintCat::str)+ auto rp = "Enable all debug prints"; auto rq = "Set level for debug prints (0=>terse, 1=>normal, 2=>verbose)"; @@ -338,7 +457,7 @@ void ArgConfig::addDebugPrintArgs(CLI::App& app, arguments::AppConfig& appConfig eb->group(debugGroup); } -void ArgConfig::addLbArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addLbArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags for enabling load balancing and configuring it */ @@ -401,7 +520,7 @@ void ArgConfig::addLbArgs(CLI::App& app, arguments::AppConfig& appConfig) { (void) h1; } -void ArgConfig::addDiagnosticArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addDiagnosticArgs(CLI::App& app, AppConfig& appConfig) { /* * Flags for controlling diagnostic collection and output */ @@ -424,7 +543,7 @@ void ArgConfig::addDiagnosticArgs(CLI::App& app, arguments::AppConfig& appConfig e->group(diagnosticGroup); } -void ArgConfig::addTerminationArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addTerminationArgs(CLI::App& app, AppConfig& appConfig) { auto hang = "Disable termination hang detection"; auto hang_freq = "The number of tree traversals before a hang is detected"; auto ds = "Force use of Dijkstra-Scholten (DS) algorithm for rooted epoch termination detection"; @@ -450,14 +569,14 @@ void ArgConfig::addTerminationArgs(CLI::App& app, arguments::AppConfig& appConfi y->group(debugTerm); } -void ArgConfig::addDebuggerArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addDebuggerArgs(CLI::App& app, AppConfig& appConfig) { auto pause = "Pause at startup so GDB/LLDB can be attached"; auto z = app.add_flag("--vt_pause", appConfig.vt_pause, pause); auto launchTerm = "Debugging/Launch"; z->group(launchTerm); } -void ArgConfig::addUserArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addUserArgs(CLI::App& app, AppConfig& appConfig) { auto user1 = "User Option 1a (boolean)"; auto user2 = "User Option 2a (boolean)"; auto user3 = "User Option 3a (boolean)"; @@ -488,7 +607,7 @@ void ArgConfig::addUserArgs(CLI::App& app, arguments::AppConfig& appConfig) { us3->group(userOpts); } -void ArgConfig::addSchedulerArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addSchedulerArgs(CLI::App& app, AppConfig& appConfig) { auto nsched = "Number of times to run the progress function in scheduler"; auto ksched = "Run the MPI progress function at least every k handlers that run"; auto ssched = "Run the MPI progress function at least every s seconds"; @@ -501,7 +620,7 @@ void ArgConfig::addSchedulerArgs(CLI::App& app, arguments::AppConfig& appConfig) kca->group(schedulerGroup); } -void ArgConfig::addConfigFileArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addConfigFileArgs(CLI::App& app, AppConfig& appConfig) { auto doconfig = "Output all VT args to configuration file"; auto configname = "Name of configuration file to output"; @@ -513,7 +632,7 @@ void ArgConfig::addConfigFileArgs(CLI::App& app, arguments::AppConfig& appConfig a2->group(configGroup); } -void ArgConfig::addRuntimeArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addRuntimeArgs(CLI::App& app, AppConfig& appConfig) { auto max_size = "Maximum MPI send size (causes larger messages to be split " "into multiple MPI sends)"; auto assert = "Do not abort the program when vtAssert(..) is invoked"; @@ -537,7 +656,7 @@ void ArgConfig::addRuntimeArgs(CLI::App& app, arguments::AppConfig& appConfig) { a3->group(configRuntime); } -void ArgConfig::addThreadingArgs(CLI::App& app, arguments::AppConfig& appConfig) { +void addThreadingArgs(CLI::App& app, AppConfig& appConfig) { #if (vt_feature_fcontext != 0) auto ult_disable = "Disable running handlers in user-level threads"; auto stack_size = "The default stack size for user-level threads"; @@ -555,6 +674,13 @@ void ArgConfig::addThreadingArgs(CLI::App& app, arguments::AppConfig& appConfig) #endif } +} /* end anon namespace */ + +/*static*/ std::unique_ptr +ArgConfig::construct(std::unique_ptr arg) { + return arg; +} + class VtFormatter : public CLI::Formatter { public: std::string make_usage(const CLI::App *, std::string name) const override { @@ -583,7 +709,7 @@ class VtFormatter : public CLI::Formatter { }; std::tuple ArgConfig::parse( - int& argc, char**& argv, arguments::AppConfig const* appConfig + int& argc, char**& argv, AppConfig const* appConfig ) { // If user didn't define appConfig, parse into this->config_. if (not appConfig) { @@ -591,7 +717,7 @@ std::tuple ArgConfig::parse( } // if user defines appConfig, parse into temporary config for later comparison. - arguments::AppConfig config{*appConfig}; + AppConfig config{*appConfig}; auto const parse_result = parseToConfig(argc, argv, config); config_ = config; @@ -600,7 +726,7 @@ std::tuple ArgConfig::parse( } std::tuple ArgConfig::parseToConfig( - int& argc, char**& argv, arguments::AppConfig& appConfig + int& argc, char**& argv, AppConfig& appConfig ) { if (parsed_ || argc == 0 || argv == nullptr) { // Odd case.. pretend nothing bad happened. @@ -649,131 +775,6 @@ std::tuple ArgConfig::parseToConfig( return result; } -/** - * \internal - * Application specific cleanup and mapping to actual app args. - */ -void ArgConfig::postParseTransform(vt::arguments::AppConfig& appConfig) { - auto contains = [](std::vector &v, std::string str){ - return std::find(v.begin(), v.end(), str) not_eq v.end(); - }; - - appConfig.vt_trace_mpi = contains(arg_trace_mpi, "internal"); - appConfig.vt_trace_pmpi = contains(arg_trace_mpi, "external"); - - using vt::config::ModeEnum; - - auto const& level = appConfig.vt_debug_level; - if (level == "terse" or level == "0") { - appConfig.vt_debug_level_val = ModeEnum::terse; - } else if (level == "normal" or level == "1") { - appConfig.vt_debug_level_val = ModeEnum::terse | ModeEnum::normal; - } else if (level == "verbose" or level == "2") { - appConfig.vt_debug_level_val = - ModeEnum::terse | ModeEnum::normal | ModeEnum::verbose; - } else { - vtAbort("Invalid value passed to --vt_debug_level"); - } -} - -std::tuple ArgConfig::parseArguments( - CLI::App& app, int& argc, char**& argv, arguments::AppConfig& appConfig -) { - - std::vector vt_args; - - // Load up vectors (has curious ability to altnerate vt/mpi/passthru) - std::vector* rargs = nullptr; - for (int i = 1; i < argc; i++) { - char* c = argv[i]; - if (0 == strcmp(c, "--vt_args")) { - rargs = &vt_args; - } else if (0 == strcmp(c, "--")) { - rargs = &appConfig.passthru_args; - } else if (rargs) { - rargs->push_back(c); - } else if (0 == strncmp(c, "--vt_", 5)) { - // Implicit start of VT args allows pass-thru 'for compatibility' - // although the recommended calling pattern to always provide VT args first. - rargs = &vt_args; - rargs->push_back(c); - } else { - appConfig.passthru_args.push_back(c); - } - } - - // All must be accounted for - app.allow_extras(false); - - // Build string-vector and reverse order to parse (CLI quirk) - std::vector args_to_parse; - for (auto it = vt_args.crbegin(); it != vt_args.crend(); ++it) { - args_to_parse.push_back(*it); - } - - // Allow a input config file - app.set_config( - "--vt_input_config", - "", // no default file name - "Read in an ini config file for VT", - false // not required - ); - - try { - app.parse(args_to_parse); - } catch (CLI::Error &ex) { - // Return exit code and message, delaying logic processing of such. - // The default exit code for 'help' is 0. - std::stringstream message_stream; - int result = app.exit(ex, message_stream, message_stream); - - return std::make_tuple(result, message_stream.str()); - } - - // If the user specified to output the full configuration, save it in a string - // so node 0 can output in the runtime once MPI is init'ed - if (appConfig.vt_output_config) { - appConfig.vt_output_config_str = app.config_to_str(true, true); - } - - // Get the clean prog name; don't allow path bleed in usages. - // std::filesystem is C++17. - std::string clean_prog_name = argv[0]; - size_t l = clean_prog_name.find_last_of("/\\"); - if (l not_eq std::string::npos and l + 1 < clean_prog_name.size()) { - clean_prog_name = clean_prog_name.substr(l + 1, std::string::npos); - } - - appConfig.prog_name = clean_prog_name; - appConfig.argv_prog_name = argv[0]; - - postParseTransform(appConfig); - - // Rebuild passthru into ref-returned argc/argv - - // It should be possible to modify the original argv as the outgoing - // number of arguments is always less. As currently allocated here, - // ownership of the new object is ill-defined. - int new_argc = appConfig.passthru_args.size() + 1; // does not include argv[0] - - static std::unique_ptr new_argv = nullptr; - - new_argv = std::make_unique(new_argc + 1); - - int i = 0; - new_argv[i++] = appConfig.argv_prog_name; - for (auto&& arg : appConfig.passthru_args) { - new_argv[i++] = arg; - } - new_argv[i++] = nullptr; - - // Set them back with all vt (and MPI) arguments elided - argc = new_argc; - argv = new_argv.get(); - - return std::make_tuple(-1, std::string{}); -} - namespace { static std::string buildFile(std::string const& file, std::string const& dir) { std::string name = file; diff --git a/src/vt/configs/arguments/args.h b/src/vt/configs/arguments/args.h index cfcaf7ee76..c2da8ae1da 100644 --- a/src/vt/configs/arguments/args.h +++ b/src/vt/configs/arguments/args.h @@ -74,7 +74,7 @@ struct ArgConfig : runtime::component::Component { /// (which may be 0 if help was requested) will be returned along /// with an appropriate display message. std::tuple parse( - int& argc, char**& argv, arguments::AppConfig const* appConfig + int& argc, char**& argv, AppConfig const* appConfig ); static std::unique_ptr construct(std::unique_ptr arg); @@ -91,29 +91,8 @@ struct ArgConfig : runtime::component::Component { private: std::tuple parseToConfig( - int& argc, char**& argv, arguments::AppConfig& appConfig + int& argc, char**& argv, AppConfig& appConfig ); - std::tuple parseArguments( - CLI::App& app, int& argc, char**& argv, arguments::AppConfig& appConfig - ); - - void addColorArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addSignalArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addMemUsageArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addStackDumpArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addTraceArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addDebugPrintArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addLbArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addDiagnosticArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addTerminationArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addDebuggerArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addUserArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addSchedulerArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addConfigFileArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addRuntimeArgs(CLI::App& app, arguments::AppConfig& appConfig); - void addThreadingArgs(CLI::App& app, arguments::AppConfig& appConfig); - - void postParseTransform(arguments::AppConfig& appConfig); bool parsed_ = false; }; From dc177bd446a3efe7199393dabfbef46245b646dc Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Wed, 23 Feb 2022 17:02:41 -0800 Subject: [PATCH 38/47] #1677: cmake: fix newline EOF --- cmake/build_git_info.cmake | 2 +- cmake/run-git.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index 606a5f8714..15689502af 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -31,4 +31,4 @@ add_custom_command( DEPENDS ${GIT_DIR} ) -target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) \ No newline at end of file +target_sources(${VIRTUAL_TRANSPORT_LIBRARY} PRIVATE ${VT_GIT_CONFIG_FILE}) diff --git a/cmake/run-git.cmake b/cmake/run-git.cmake index 8ac835a1c2..feb6528767 100644 --- a/cmake/run-git.cmake +++ b/cmake/run-git.cmake @@ -97,4 +97,4 @@ endif() message(STATUS "Git Clean Status: \"${GIT_CLEAN_STATUS}\"") message(STATUS "Configuring ${IN_FILE} to generate ${OUT_FILE}.") -configure_file(${IN_FILE} ${OUT_FILE} @ONLY) \ No newline at end of file +configure_file(${IN_FILE} ${OUT_FILE} @ONLY) From f628a7d36e0d46930a16c76f9192342964fa3f76 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 16 Feb 2022 22:29:42 +0100 Subject: [PATCH 39/47] #1550 move comment to suitable place --- src/vt/collective/collective_ops.cc | 2 ++ src/vt/runtime/runtime.cc | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vt/collective/collective_ops.cc b/src/vt/collective/collective_ops.cc index b27656c32d..93a2d2d6c9 100644 --- a/src/vt/collective/collective_ops.cc +++ b/src/vt/collective/collective_ops.cc @@ -237,6 +237,8 @@ RuntimePtrType CollectiveAnyOps::initialize( #pragma sst global rt RuntimeInst::rt->initialize(); + // If appConfig is not nullptr, compare CLI arguments with user-defined ones, + // and report overwritten ones. if (appConfig && theContext()->getNode() == 0) { printOverwrittens(*rt->getAppConfig(), *appConfig); } diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 8e13ad17b4..b63befaecb 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -152,8 +152,6 @@ Runtime::Runtime( } // n.b. ref-update of args with pass-through arguments - // If appConfig is not nullptr, compare CLI arguments with user-defined ones, - // and report overwritten ones. std::tuple result = arg_config_->parse(argc, argv, appConfig); int exit_code = std::get<0>(result); From 0dd4a65f811d1be7e03bf4c07e8e4e358a451a9e Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Thu, 17 Feb 2022 10:57:17 +0100 Subject: [PATCH 40/47] #1550 fix gcc10 unit tests failures --- tests/unit/runtime/test_initialization.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/runtime/test_initialization.cc b/tests/unit/runtime/test_initialization.cc index fdf6ed030c..257fc1995d 100644 --- a/tests/unit/runtime/test_initialization.cc +++ b/tests/unit/runtime/test_initialization.cc @@ -97,14 +97,14 @@ TEST_F(TestInitialization, test_initialize_with_appconfig) { EXPECT_EQ(custom_argc, 2); arguments::AppConfig appConfig{}; - appConfig.vt_lb = true; + appConfig.vt_epoch_graph_on_hang = false; appConfig.vt_lb_name = "RotateLB"; appConfig.vt_lb_stats = true; vt::initialize(custom_argc, custom_argv, no_workers, true, &comm, &appConfig); EXPECT_EQ(theConfig()->prog_name, "vt_program"); - EXPECT_EQ(theConfig()->vt_lb, true); + EXPECT_EQ(theConfig()->vt_epoch_graph_on_hang, false); EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); EXPECT_EQ(theConfig()->vt_lb_stats, true); @@ -139,7 +139,7 @@ TEST_F(TestInitialization, test_initialize_with_args_and_appconfig) { arguments::AppConfig appConfig{}; appConfig.vt_color = false; - appConfig.vt_lb = true; + appConfig.vt_epoch_graph_on_hang = false; appConfig.vt_lb_name = "RotateLB"; appConfig.vt_lb_stats = true; appConfig.vt_no_detect_hang = false; @@ -148,7 +148,7 @@ TEST_F(TestInitialization, test_initialize_with_args_and_appconfig) { EXPECT_EQ(theConfig()->prog_name, "vt_program"); EXPECT_EQ(theConfig()->vt_color, false); - EXPECT_EQ(theConfig()->vt_lb, true); + EXPECT_EQ(theConfig()->vt_epoch_graph_on_hang, false); EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); EXPECT_EQ(theConfig()->vt_lb_stats, true); EXPECT_EQ(theConfig()->vt_no_terminate, true); From c3c25d73659d7ee83a8565c774f6fbb16aacfd03 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Thu, 17 Feb 2022 16:09:14 +0100 Subject: [PATCH 41/47] #1550 fix typo in comment --- tests/unit/runtime/test_initialization.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/runtime/test_initialization.cc b/tests/unit/runtime/test_initialization.cc index 257fc1995d..346b70c477 100644 --- a/tests/unit/runtime/test_initialization.cc +++ b/tests/unit/runtime/test_initialization.cc @@ -152,7 +152,7 @@ TEST_F(TestInitialization, test_initialize_with_args_and_appconfig) { EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); EXPECT_EQ(theConfig()->vt_lb_stats, true); EXPECT_EQ(theConfig()->vt_no_terminate, true); - // CLI args should overwritten hardcoded appConfig + // CLI args should overwrite hardcoded appConfig EXPECT_EQ(theConfig()->vt_no_detect_hang, true); EXPECT_EQ(custom_argc, 2); From 808a149f7cec34f0892a144b3c0ee24f5a548a6c Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Tue, 22 Feb 2022 19:03:09 +0100 Subject: [PATCH 42/47] #1550 add documentation --- docs/md/tutorial.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/md/tutorial.md b/docs/md/tutorial.md index e0b042a30d..b13bbce1b8 100644 --- a/docs/md/tutorial.md +++ b/docs/md/tutorial.md @@ -30,6 +30,39 @@ int main(int argc, char** argv) { } \endcode +If, for any reason, you want to predefine configuration, you can do it +by creating AppConfig object, setting its members as you wish, +and passing it to `vt::initialize`: + +\code{.cpp} +int main(int argc, char** argv) { + arguments::AppConfig appConfig{}; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + + vt::initialize(argc, argv, &appConfig); + // program here + vt::finalize(); +} +\endcode + +You can do also do it if you initialized MPI on your own: + +\code{.cpp} +int main(int argc, char** argv) { + MPI_Init(&argc, &argv); + + arguments::AppConfig appConfig{}; + appConfig.vt_lb_name = "RotateLB"; + appConfig.vt_lb_stats = true; + + vt::initialize(argc, argv, &MPI_COMM_WORLD, &appConfig); + // program here + vt::finalize(); + MPI_Finalize(); +} +\endcode + \section tutorial-walkthrough Tutorial Code Snippets This page walks through the tutorial that exists in the source code. See From 5464427ee587969b46a6d58e43877f2c646a3523 Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 23 Feb 2022 17:40:29 +0100 Subject: [PATCH 43/47] #1550 document command line arguments processing precedence --- docs/md/tutorial.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/md/tutorial.md b/docs/md/tutorial.md index b13bbce1b8..ad780bf86e 100644 --- a/docs/md/tutorial.md +++ b/docs/md/tutorial.md @@ -31,7 +31,7 @@ int main(int argc, char** argv) { \endcode If, for any reason, you want to predefine configuration, you can do it -by creating AppConfig object, setting its members as you wish, +by creating `AppConfig` object, setting its members as you wish, and passing it to `vt::initialize`: \code{.cpp} @@ -63,6 +63,8 @@ int main(int argc, char** argv) { } \endcode +It is worth noting that if you run your application with any of vt's command-line arguments and at the same time you define and pass `AppConfig` to `vt::initialize`, CLI arguments have a higher priority. In other words, if you predefine in source code and give from the command line the same vt's argument, but with a different value, the program will use the CLI one. + \section tutorial-walkthrough Tutorial Code Snippets This page walks through the tutorial that exists in the source code. See From 1408cc01974e3eaf33838e27152a6a70a910dadb Mon Sep 17 00:00:00 2001 From: Jakub Strzebonski Date: Wed, 23 Feb 2022 18:50:01 +0100 Subject: [PATCH 44/47] #1550 document and test order of parsing arguments passed from cli, file and appConfig --- docs/md/tutorial.md | 2 + src/vt/configs/arguments/args.cc | 2 +- tests/unit/runtime/test_initialization.cc | 91 +++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/docs/md/tutorial.md b/docs/md/tutorial.md index ad780bf86e..93dbbe71c8 100644 --- a/docs/md/tutorial.md +++ b/docs/md/tutorial.md @@ -65,6 +65,8 @@ int main(int argc, char** argv) { It is worth noting that if you run your application with any of vt's command-line arguments and at the same time you define and pass `AppConfig` to `vt::initialize`, CLI arguments have a higher priority. In other words, if you predefine in source code and give from the command line the same vt's argument, but with a different value, the program will use the CLI one. +There is also an option to use configuration file. Refer to CLI11 documentation for details https://cliutils.github.io/CLI11/book/chapters/config.html. Important thing to remember - CLI11 processes configuration file before command line arguments, so in the end command line arguments might overwrite values defined in configuration file. + \section tutorial-walkthrough Tutorial Code Snippets This page walks through the tutorial that exists in the source code. See diff --git a/src/vt/configs/arguments/args.cc b/src/vt/configs/arguments/args.cc index 084c47e9d2..1f3b92a0a7 100644 --- a/src/vt/configs/arguments/args.cc +++ b/src/vt/configs/arguments/args.cc @@ -716,7 +716,7 @@ std::tuple ArgConfig::parse( return parseToConfig(argc, argv, config_); } - // if user defines appConfig, parse into temporary config for later comparison. + // If user defines appConfig, parse into temporary config for later comparison. AppConfig config{*appConfig}; auto const parse_result = parseToConfig(argc, argv, config); diff --git a/tests/unit/runtime/test_initialization.cc b/tests/unit/runtime/test_initialization.cc index 346b70c477..efa91da93e 100644 --- a/tests/unit/runtime/test_initialization.cc +++ b/tests/unit/runtime/test_initialization.cc @@ -47,6 +47,8 @@ #include +#include + namespace vt { namespace tests { namespace unit { struct TestInitialization : TestParallelHarness { }; @@ -161,4 +163,93 @@ TEST_F(TestInitialization, test_initialize_with_args_and_appconfig) { EXPECT_EQ(custom_argv[2], nullptr); } +TEST_F(TestInitialization, test_initialize_with_file_and_args) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + static char vt_no_terminate[]{"--vt_no_terminate"}; + static char vt_lb_name[]{"--vt_lb_name=RotateLB"}; + static char vt_input_config[]{"--vt_input_config=test_cfg.toml"}; + + std::vector custom_args; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(vt_no_terminate); + custom_args.emplace_back(vt_input_config); + custom_args.emplace_back(vt_lb_name); + custom_args.emplace_back(nullptr); + + int custom_argc = custom_args.size() - 1; + char **custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 5); + + int this_rank; + MPI_Comm_rank(comm, &this_rank); + if (this_rank == 0) { + std::ofstream cfg_file_{"test_cfg.toml", std::ofstream::out | std::ofstream::trunc}; + cfg_file_ << "vt_lb_name = RandomLB\n"; + cfg_file_.close(); + } + MPI_Barrier(comm); + + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm); + + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_no_terminate, true); + EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); + + EXPECT_EQ(custom_argc, 2); + EXPECT_STREQ(custom_argv[0], "vt_program"); + EXPECT_STREQ(custom_argv[1], "--cli_argument=100"); + EXPECT_EQ(custom_argv[2], nullptr); +} + +TEST_F(TestInitialization, test_initialize_with_file_args_and_appconfig) { + MPI_Comm comm = MPISingletonMultiTest::Get()->getComm(); + + static char prog_name[]{"vt_program"}; + static char cli_argument[]{"--cli_argument=100"}; + static char vt_no_terminate[]{"--vt_no_terminate"}; + static char vt_lb_name[]{"--vt_lb_name=RotateLB"}; + static char vt_input_config[]{"--vt_input_config=test_cfg.toml"}; + + std::vector custom_args; + custom_args.emplace_back(prog_name); + custom_args.emplace_back(cli_argument); + custom_args.emplace_back(vt_no_terminate); + custom_args.emplace_back(vt_input_config); + custom_args.emplace_back(vt_lb_name); + custom_args.emplace_back(nullptr); + + int custom_argc = custom_args.size() - 1; + char** custom_argv = custom_args.data(); + + EXPECT_EQ(custom_argc, 5); + + arguments::AppConfig appConfig{}; + appConfig.vt_lb_name = "GreedyLB"; + + int this_rank; + MPI_Comm_rank(comm, &this_rank); + if (this_rank == 0) { + std::ofstream cfg_file_{"test_cfg.toml", std::ofstream::out | std::ofstream::trunc}; + cfg_file_ << "vt_lb_name = RandomLB\n"; + cfg_file_.close(); + } + MPI_Barrier(comm); + + vt::initialize(custom_argc, custom_argv, no_workers, true, &comm, &appConfig); + + EXPECT_EQ(theConfig()->prog_name, "vt_program"); + EXPECT_EQ(theConfig()->vt_no_terminate, true); + EXPECT_EQ(theConfig()->vt_lb_name, "RotateLB"); + + EXPECT_EQ(custom_argc, 2); + EXPECT_STREQ(custom_argv[0], "vt_program"); + EXPECT_STREQ(custom_argv[1], "--cli_argument=100"); + EXPECT_EQ(custom_argv[2], nullptr); +} + }}} // end namespace vt::tests::unit From 0b74ed163fdd7ea39e0e71d0af7b8adb7506b0ad Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 3 Mar 2022 09:55:22 -0800 Subject: [PATCH 45/47] #1692: make build script not error out when running cmake if .git folder is not available --- cmake/build_git_info.cmake | 42 ++++++++++++++++++++++++-------------- cmake/run-git.cmake | 11 ++++++---- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/cmake/build_git_info.cmake b/cmake/build_git_info.cmake index 15689502af..8d47e28479 100644 --- a/cmake/build_git_info.cmake +++ b/cmake/build_git_info.cmake @@ -1,4 +1,7 @@ find_package(Git REQUIRED) + +set(GIT_DIR) +set(HEAD_FILE) execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir WORKING_DIRECTORY "${PROJECT_BASE_DIR}" @@ -8,26 +11,35 @@ execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir REL_GIT_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) if (NOT res EQUAL 0) - message(FATAL_ERROR "git invocation failed") -endif() - -get_filename_component(GIT_DIR ${REL_GIT_DIR} ABSOLUTE BASE_DIR ${PROJECT_BASE_DIR}) -message(STATUS "Git DIR: ${GIT_DIR}") -if (NOT GIT_DIR) - message(FATAL_ERROR "not a git directory") + message(STATUS "git invocation failed, git info cannot be obtained") +else() + get_filename_component(GIT_DIR ${REL_GIT_DIR} ABSOLUTE BASE_DIR ${PROJECT_BASE_DIR}) + message(STATUS "Git DIR: ${GIT_DIR}") + if (NOT GIT_DIR) + message(STATUS "no git directory present") + else() + if(NOT EXISTS "${GIT_DIR}/HEAD") + message(STATUS "no such file: \"${GIT_DIR}/HEAD\"") + else() + set(HEAD_FILE "${GIT_DIR}/HEAD") + message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") + endif() + endif() endif() -if(NOT EXISTS "${GIT_DIR}/HEAD") - message(FATAL_ERROR "no such file: \"${GIT_DIR}/HEAD\"") -endif() -set(HEAD_FILE "${GIT_DIR}/HEAD") - -message(STATUS "Git HEAD file: \"${HEAD_FILE}\"") - set(VT_GIT_CONFIG_FILE "${PROJECT_BIN_DIR}/src/vt/configs/generated/vt_git_revision.cc") add_custom_command( OUTPUT ${VT_GIT_CONFIG_FILE} - COMMAND ${CMAKE_COMMAND} -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in -DOUT_FILE=${VT_GIT_CONFIG_FILE} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DGIT_DIR=${GIT_DIR} -DHEAD_FILE=${HEAD_FILE} -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake + COMMAND ${CMAKE_COMMAND} + -DIN_FILE=${PROJECT_BASE_DIR}/vt_git_revision.cc.in + -DOUT_FILE=${VT_GIT_CONFIG_FILE} + -DGIT_EXECUTABLE=${GIT_EXECUTABLE} + -DGIT_DIR=${GIT_DIR} + -DHEAD_FILE=${HEAD_FILE} + -DPROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} + -DPROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR} + -DPROJECT_VERSION_PATCH=${PROJECT_VERSION_PATCH} + -P ${CMAKE_CURRENT_LIST_DIR}/run-git.cmake DEPENDS ${GIT_DIR} ) diff --git a/cmake/run-git.cmake b/cmake/run-git.cmake index feb6528767..73c341e0fb 100644 --- a/cmake/run-git.cmake +++ b/cmake/run-git.cmake @@ -14,7 +14,10 @@ message(STATUS "Reading head file ${HEAD_FILE}") message(STATUS "Using git executable at \"${GIT_EXECUTABLE}\"") -get_filename_component(ROOT_DIR ${GIT_DIR} DIRECTORY) +set(ROOT_DIR) +if (GIT_DIR) + get_filename_component(ROOT_DIR ${GIT_DIR} DIRECTORY) +endif() set(GIT_SHA1) @@ -39,7 +42,7 @@ execute_process(COMMAND GIT_SHA1 OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT res EQUAL 0) - message(FATAL_ERROR "could not get the git sha1") + message(STATUS "could not get the git sha1") endif() message(STATUS "GIT_SHA1: \"${GIT_SHA1}\"") @@ -57,7 +60,7 @@ execute_process(COMMAND GIT_EXACT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT res EQUAL 0) - message(FATAL_ERROR "could not get the exact git tag") + message(STATUS "could not get the exact git tag") endif() message(STATUS "GIT_EXACT_TAG: \"${GIT_EXACT_TAG}\"") @@ -75,7 +78,7 @@ execute_process(COMMAND GIT_DESCRIPTION OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT res EQUAL 0) - message(FATAL_ERROR "could not get the description") + message(STATUS "could not get the description") endif() message(STATUS "GIT_DESCRIPTION: \"${GIT_DESCRIPTION}\"") From ae489a24b2e9ca476dd0281a0221883b78e05037 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 3 Mar 2022 09:55:56 -0800 Subject: [PATCH 46/47] #1692: remove vt_git_revision.h from root directory because it's not actually used; a copy in the src folder is used instead --- vt_git_revision.h | 55 ----------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 vt_git_revision.h diff --git a/vt_git_revision.h b/vt_git_revision.h deleted file mode 100644 index 086d6b8abf..0000000000 --- a/vt_git_revision.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// vt_git_revision.h -// DARMA/vt => Virtual Transport -// -// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC -// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. -// Government retains certain rights in this software. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact darma@sandia.gov -// -// ***************************************************************************** -//@HEADER -*/ - -#if !defined VT_CONFIG_GIT_REVISION_H -#define VT_CONFIG_GIT_REVISION_H - -#include - -extern std::string const vt_git_sha1; -extern std::string const vt_git_exact_tag; -extern std::string const vt_git_refspec; -extern std::string const vt_git_description; -extern std::string const vt_git_clean_status; - -#endif /*VT_CONFIG_GIT_REVISION_H*/ From 2ff27b9e8720e1854f4647230030f684b3248fc4 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Thu, 3 Mar 2022 09:56:50 -0800 Subject: [PATCH 47/47] #1692: cmake: make version consistent and only modified in one place (the VERSION file). This also allows us to print out the version in the banner, which is useful if not git info is available --- CMakeLists.txt | 5 ++- cmake/load_doxygen.cmake | 6 +-- src/vt/configs/generated/vt_git_revision.h | 3 ++ src/vt/runtime/runtime_banner.cc | 48 +++++++++++----------- vt_git_revision.cc.in | 6 +++ 5 files changed, 40 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd6d37e24d..04fd094cab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.17 FATAL_ERROR) -project(vt VERSION 1.1.0) + +file(READ "VERSION" _vt_version_str) +string(STRIP "${_vt_version_str}" _vt_version_str) +project(vt VERSION ${_vt_version_str}) # To generate output file with compilation errors and warnings # CMake generator needs to be known diff --git a/cmake/load_doxygen.cmake b/cmake/load_doxygen.cmake index 81849cd175..616dcdf7cd 100644 --- a/cmake/load_doxygen.cmake +++ b/cmake/load_doxygen.cmake @@ -10,9 +10,9 @@ if (${vt_doxygen_enabled}) set(doxygen_out ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) set(DOXYGEN_PROJECT_NAME "vt") - set(VERSION_MAJOR "1") - set(VERSION_MINOR "0") - set(VERSION_PATCH "0") + set(VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") + set(VERSION_MINOR "${PROJECT_VERSION_MINOR}") + set(VERSION_PATCH "${PROJECT_VERSION_PATCH}") set(DOXYGEN_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/") set(DOXYGEN_CHECKPOINT_SHARED_DOCS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/checkpoint/docs/shared") set(DOXYGEN_CHECKPOINT_EXAMPLE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/checkpoint/examples") diff --git a/src/vt/configs/generated/vt_git_revision.h b/src/vt/configs/generated/vt_git_revision.h index a2595f2bc6..f84d6b54af 100644 --- a/src/vt/configs/generated/vt_git_revision.h +++ b/src/vt/configs/generated/vt_git_revision.h @@ -46,6 +46,9 @@ #include +extern int const vt_version_major; +extern int const vt_version_minor; +extern int const vt_version_patch; extern std::string const vt_git_sha1; extern std::string const vt_git_exact_tag; extern std::string const vt_git_refspec; diff --git a/src/vt/runtime/runtime_banner.cc b/src/vt/runtime/runtime_banner.cc index c59f24b1bd..f5f9e09c18 100644 --- a/src/vt/runtime/runtime_banner.cc +++ b/src/vt/runtime/runtime_banner.cc @@ -164,7 +164,7 @@ void Runtime::printStartupBanner() { #endif std::string dirty = ""; - if (strncmp(vt_git_clean_status.c_str(), "DIRTY", 5) == 0) { + if (vt_git_clean_status == "DIRTY") { dirty = red + std::string("*dirty*") + reset; } @@ -174,29 +174,29 @@ void Runtime::printStartupBanner() { auto const version = std::to_string(std::get<0>(version_tuple)); auto const subversion = std::to_string(std::get<1>(version_tuple)); - auto f1 = fmt::format("{} {}{}\n", reg(init), reg(mode), emph(mode_type + thd)); - auto f2a = fmt::format("{}Program: {} ({})\n", green, - emph(getAppConfig()->prog_name), emph(getAppConfig()->argv_prog_name)); - auto f2b = fmt::format("{}Running on: {}\n", green, emph(all_node)); - auto f3 = fmt::format("{}Machine Hostname: {}\n", green, emph(hostname)); - auto f3a = fmt::format("{}MPI Version: {}.{}\n", green, emph(version), emph(subversion)); - auto f3b = fmt::format("{}MPI Max tag: {}\n", green, emph(max_tag_str)); - - auto f4 = fmt::format("{}Build SHA: {}\n", green, emph(vt_git_sha1)); - auto f5 = fmt::format("{}Build Ref: {}\n", green, emph(vt_git_refspec)); - auto f6 = fmt::format("{}Description: {} {}\n", green, emph(vt_git_description), dirty); - auto f7 = fmt::format("{}Compile-time Features Enabled:{}\n", green, reset); - - fmt::print("{}{}{}", vt_pre, f1, reset); - fmt::print("{}{}{}", vt_pre, f2a, reset); - fmt::print("{}{}{}", vt_pre, f2b, reset); - fmt::print("{}{}{}", vt_pre, f3, reset); - fmt::print("{}{}{}", vt_pre, f3a, reset); - fmt::print("{}{}{}", vt_pre, f3b, reset); - fmt::print("{}{}{}", vt_pre, f4, reset); - fmt::print("{}{}{}", vt_pre, f5, reset); - fmt::print("{}{}{}", vt_pre, f6, reset); - fmt::print("{}{}{}", vt_pre, f7, reset); + auto vt_version_string = fmt::format("{}.{}.{}", vt_version_major, vt_version_minor, vt_version_patch); + std::array< std::string, 11 > info_lines = { + fmt::format("{}Version: {}\n", green, emph(vt_version_string)), + + fmt::format("{} {}{}\n", reg(init), reg(mode), emph(mode_type + thd)), + fmt::format("{}Program: {} ({})\n", green, + emph(getAppConfig()->prog_name), emph(getAppConfig()->argv_prog_name)), + fmt::format("{}Running on: {}\n", green, emph(all_node)), + fmt::format("{}Machine Hostname: {}\n", green, emph(hostname)), + fmt::format("{}MPI Version: {}.{}\n", green, emph(version), emph(subversion)), + fmt::format("{}MPI Max tag: {}\n", green, emph(max_tag_str)), + + fmt::format("{}Build SHA: {}\n", green, emph(vt_git_sha1)), + fmt::format("{}Build Ref: {}\n", green, emph(vt_git_refspec)), + fmt::format("{}Description: {} {}\n", green, emph(vt_git_description), dirty), + fmt::format("{}Compile-time Features Enabled:{}\n", green, reset) + }; + + for (auto &&line: info_lines) + { + fmt::print("{}{}{}", vt_pre, line, reset); + } + for (size_t i = 0; i < features.size(); i++) { fmt::print("{}\t{}\n", vt_pre, emph(features.at(i))); } diff --git a/vt_git_revision.cc.in b/vt_git_revision.cc.in index 300c991267..e5516088a3 100644 --- a/vt_git_revision.cc.in +++ b/vt_git_revision.cc.in @@ -45,12 +45,18 @@ #include +#define VT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define VT_VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define VT_VERSION_PATCH @PROJECT_VERSION_PATCH@ #define VT_GIT_SHA1 "@GIT_SHA1@" #define VT_GIT_EXACT_TAG "@GIT_EXACT_TAG@" #define VT_GIT_REFSPEC "@GIT_REFSPEC@" #define VT_GIT_DESCRIPTION "@GIT_DESCRIPTION@" #define VT_GIT_CLEAN_STATUS "@GIT_CLEAN_STATUS@" +int const vt_version_major = VT_VERSION_MAJOR; +int const vt_version_minor = VT_VERSION_MINOR; +int const vt_version_patch = VT_VERSION_PATCH; std::string const vt_git_sha1 = VT_GIT_SHA1; std::string const vt_git_exact_tag = VT_GIT_EXACT_TAG; std::string const vt_git_refspec = VT_GIT_REFSPEC;