Skip to content

Commit

Permalink
#1014 revert pointless changes (squash this before merge)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Sep 17, 2020
1 parent dd3a766 commit 1cbbd80
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 28 deletions.
8 changes: 0 additions & 8 deletions src/vt/vrt/collection/balance/lb_invoke/lb_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,6 @@ LBManager::makeLB(MsgSharedPtr<StartLBMsg> msg) {
lb, node,
"LBManager: finished migrations\n"
);

// Statistics output when LB is enabled and appropriate flag is enabled
#if vt_check_enabled(lblite)
if (theConfig()->vt_lb_stats) {
theNodeStats()->outputStatsForPhase(phase);
}
#endif

theNodeStats()->startIterCleanup(phase, model_->getNumPastPhasesNeeded());
this->finishedRunningLB(phase);
});
Expand Down
43 changes: 42 additions & 1 deletion src/vt/vrt/collection/balance/node_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ void NodeStats::startIterCleanup(PhaseType phase, int look_back) {
}
node_data_[phase] = std::move(new_data);

// Statistics output when LB is enabled and appropriate flag is enabled
#if vt_check_enabled(lblite)
if (theConfig()->vt_lb_stats) {
outputStatsForPhase(phase);
}
#endif

if (phase - look_back >= 0) {
node_data_.erase(phase - look_back);
node_subphase_data_.erase(phase - look_back);
Expand Down Expand Up @@ -170,6 +177,14 @@ void NodeStats::releaseLB() {
CollectionManager::releaseLBPhase(msg_hold.get());
}

void NodeStats::initialize() {
#if vt_check_enabled(lblite)
if (theConfig()->vt_lb_stats) {
theNodeStats()->createStatsFile();
}
#endif
}

void NodeStats::createStatsFile() {
auto const node = theContext()->getNode();
auto const base_file = std::string(theConfig()->vt_lb_stats_file);
Expand All @@ -182,7 +197,33 @@ void NodeStats::createStatsFile() {
"NodeStats: createStatsFile file={}\n", file_name
);

// Node 0 creates the directory
if (not created_dir_ and node == 0) {
mkdir(dir.c_str(), S_IRWXU);
created_dir_ = true;
}

// Barrier: wait for node 0 to create directory before trying to put a file in
// the stats destination directory
if (curRT) {
curRT->systemSync();
} else {
// Something is wrong
vtAssert(false, "Trying to dump stats when VT runtime is deallocated?");
}

stats_file_ = fopen(file_name.c_str(), "w+");
vtAssertExpr(stats_file_ != nullptr);
}

void NodeStats::finalize() {
// If statistics are enabled, close output file and clear stats
#if vt_check_enabled(lblite)
if (theConfig()->vt_lb_stats) {
closeStatsFile();
clearStats();
}
#endif
}

void NodeStats::closeStatsFile() {
Expand All @@ -195,7 +236,7 @@ void NodeStats::closeStatsFile() {
void NodeStats::outputStatsForPhase(PhaseType phase) {
vtAssertExpr(stats_file_ != nullptr);

vt_print(lb, "NodeStats::outputStatsFile: file={}, phase={}\n", print_ptr(stats_file_), phase);
vt_print(lb, "NodeStats::outputStatsForPhase: file={}, phase={}\n", print_ptr(stats_file_), phase);

auto i = phase;
for (auto&& elm : node_data_.at(i)) {
Expand Down
4 changes: 4 additions & 0 deletions src/vt/vrt/collection/balance/node_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ struct NodeStats : runtime::component::Component<NodeStats> {
*/
VirtualProxyType getCollectionProxyForElement(ElementIDType temp_id) const;

void initialize() override;
void finalize() override;

private:
/**
* \internal \brief Create the stats file
*/
Expand Down
18 changes: 0 additions & 18 deletions src/vt/vrt/collection/manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,8 @@ namespace vt { namespace vrt { namespace collection {

CollectionManager::CollectionManager() { }

void CollectionManager::initialize() {
// If statistics are enabled create output directory and file
#if vt_check_enabled(lblite)
if (theConfig()->vt_lb_stats) {
mkdir(theConfig()->vt_lb_stats_dir.c_str(), S_IRWXU);
theNodeStats()->createStatsFile();
}
#endif
}

void CollectionManager::finalize() {
cleanupAll<>();

// If statistics are enabled, close output file and clear stats
#if vt_check_enabled(lblite)
if (theConfig()->vt_lb_stats) {
theNodeStats()->closeStatsFile();
theNodeStats()->clearStats();
}
#endif
}

/*virtual*/ CollectionManager::~CollectionManager() { }
Expand Down
1 change: 0 additions & 1 deletion src/vt/vrt/collection/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ struct CollectionManager

virtual ~CollectionManager();

void initialize() override;
void finalize() override;

std::string name() override { return "CollectionManager"; }
Expand Down

0 comments on commit 1cbbd80

Please sign in to comment.