diff --git a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc index 752d81d4a2..f12213fd38 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc @@ -450,12 +450,6 @@ void LBManager::destroyLB() { } } -void LBManager::initialize() { -#if vt_check_enabled(lblite) - createStatisticsFile(); -#endif -} - void LBManager::finalize() { closeStatisticsFile(); } @@ -548,13 +542,17 @@ void LBManager::statsHandler(StatsMsgType* msg) { void LBManager::stagePreLBStatistics(const StatisticMapType &statistics) { // Statistics output when LB is enabled and appropriate flag is enabled - if (!theConfig()->vt_lb_statistics) { + if (theContext()->getNode() != 0 or !theConfig()->vt_lb_statistics) { return; } nlohmann::json j; j["pre-LB"] = lb::jsonifyPhaseStatistics(statistics); + if (!statistics_writer_) { + createStatisticsFile(); + } + using JSONAppender = util::json::Appender; auto writer = static_cast(statistics_writer_.get()); writer->stageObject(j); @@ -564,7 +562,7 @@ void LBManager::stagePostLBStatistics( const StatisticMapType &statistics, int32_t migration_count ) { // Statistics output when LB is enabled and appropriate flag is enabled - if (!theConfig()->vt_lb_statistics) { + if (theContext()->getNode() != 0 or !theConfig()->vt_lb_statistics) { return; } @@ -572,6 +570,10 @@ void LBManager::stagePostLBStatistics( j["post-LB"] = lb::jsonifyPhaseStatistics(statistics); j["migration count"] = migration_count; + if (!statistics_writer_) { + createStatisticsFile(); + } + using JSONAppender = util::json::Appender; auto writer = static_cast(statistics_writer_.get()); writer->stageObject(j); @@ -579,7 +581,7 @@ void LBManager::stagePostLBStatistics( void LBManager::commitPhaseStatistics(PhaseType phase) { // Statistics output when LB is enabled and appropriate flag is enabled - if (!theConfig()->vt_lb_statistics) { + if (theContext()->getNode() != 0 or !theConfig()->vt_lb_statistics) { return; } @@ -591,6 +593,10 @@ void LBManager::commitPhaseStatistics(PhaseType phase) { nlohmann::json j; j["id"] = phase; + if (!statistics_writer_) { + createStatisticsFile(); + } + using JSONAppender = util::json::Appender; auto writer = static_cast(statistics_writer_.get()); writer->stageObject(j); diff --git a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h index 03eb63c751..04890bafc2 100644 --- a/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h +++ b/src/vt/vrt/collection/balance/lb_invoke/lb_manager.h @@ -90,7 +90,6 @@ struct LBManager : runtime::component::Component { std::string name() override { return "LBManager"; } void startup() override; - void initialize() override; void finalize() override; void fatalError() override;