Skip to content

Commit

Permalink
#1265: replay: clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
nlslatt committed May 9, 2022
1 parent 1300fc8 commit f27d0f8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
57 changes: 28 additions & 29 deletions src/vt/vrt/collection/balance/workload_replay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void replayWorkloads(
) {
// read in object loads from json files
auto const filename = theConfig()->getLBStatsFileIn();
auto workloads = WorkloadDataMigrator::readInWorkloads(filename);
auto workloads = readInWorkloads(filename);

replayWorkloads(initial_phase, phases_to_run, workloads);
}
Expand Down Expand Up @@ -207,6 +207,33 @@ void replayWorkloads(
}
}

std::shared_ptr<StatsData>
readInWorkloads(const std::string &filename) {
using util::json::Reader;

Reader r{filename};
auto json = r.readFile();
auto sd = std::make_shared<StatsData>(*json);

for (auto &phase_data : sd->node_data_) {
vt_debug_print(
normal, replay,
"found {} loads for phase {}\n",
phase_data.second.size(), phase_data.first
);
}

for (auto &phase_data : sd->node_comm_) {
vt_debug_print(
normal, replay,
"found {} comms for phase {}\n",
phase_data.second.size(), phase_data.first
);
}

return sd;
}


/*static*/
objgroup::proxy::Proxy<WorkloadDataMigrator>
Expand Down Expand Up @@ -258,34 +285,6 @@ WorkloadDataMigrator::updateCurrentNodes(
return modified_reassignment;
}

/*static*/
std::shared_ptr<StatsData>
WorkloadDataMigrator::readInWorkloads(std::string filename) {
using util::json::Reader;

Reader r{filename};
auto json = r.readFile();
auto sd = std::make_shared<StatsData>(*json);

for (auto &phase_data : sd->node_data_) {
vt_debug_print(
normal, replay,
"found {} loads for phase {}\n",
phase_data.second.size(), phase_data.first
);
}

for (auto &phase_data : sd->node_comm_) {
vt_debug_print(
normal, replay,
"found {} comms for phase {}\n",
phase_data.second.size(), phase_data.first
);
}

return sd;
}

/*static*/
std::shared_ptr<ProposedReassignment>
WorkloadDataMigrator::relocateWorkloadsForReplay(
Expand Down
21 changes: 11 additions & 10 deletions src/vt/vrt/collection/balance/workload_replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ void replayWorkloads(
std::shared_ptr<StatsData> workloads
);

/**
* \brief Build a StatsData object from the LB data in a json file
*
* \param[in] filename read in LB data from the specified json file
*
* \return the StatsData object built from the LB data
*/
std::shared_ptr<StatsData>
readInWorkloads(const std::string &filename);


/**
* \struct WorkloadDataMigrator
*
Expand Down Expand Up @@ -139,16 +150,6 @@ struct WorkloadDataMigrator : lb::BaseLB {
std::shared_ptr<const Reassignment> lb_reassignment
);

/**
* \brief Build a StatsData object from the LB data in a json file
*
* \param[in] filename read in LB data from the specified json file
*
* \return the StatsData object built from the LB data
*/
static std::shared_ptr<StatsData>
readInWorkloads(std::string filename);

/**
* \brief Relocate object workloads to the rank where the objects are supposed
* to exist during this phase
Expand Down

0 comments on commit f27d0f8

Please sign in to comment.