Skip to content

Commit

Permalink
Merge pull request #2293 from DARMA-tasking/2279-fix-communication-json
Browse files Browse the repository at this point in the history
2279: Bug in communication JSON output
  • Loading branch information
lifflander authored Jun 11, 2024
2 parents 70cbb0d + 615efe1 commit ea8b2c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/vt/vrt/collection/balance/lb_data_holder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ std::unique_ptr<nlohmann::json> LBDataHolder::rankAttributesToJson() const {
return std::make_unique<nlohmann::json>(std::move(j));
}

void LBDataHolder::addInitialTask(nlohmann::json& j, std::size_t n) const {
j["tasks"][n]["resource"] = "cpu";
j["tasks"][n]["node"] = vt::theContext()->getNode();
j["tasks"][n]["time"] = 0;
outputEntity(
j["tasks"][n]["entity"], ElementIDStruct()
);
}

std::unique_ptr<nlohmann::json> LBDataHolder::toJson(PhaseType phase) const {
using json = nlohmann::json;

Expand Down Expand Up @@ -194,6 +203,10 @@ std::unique_ptr<nlohmann::json> LBDataHolder::toJson(PhaseType phase) const {

i++;
}

if ((phase == 0) and (i > 0)) {
addInitialTask(j, i);
}
}

i = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/vt/vrt/collection/balance/lb_data_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ struct LBDataHolder {
*/
void outputEntity(nlohmann::json& j, ElementIDStruct const& elm_id) const;

void addInitialTask(nlohmann::json& j, std::size_t n) const;

/**
* \brief Read the LB phase's metadata
*
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/collection/test_lb.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ TEST_P(TestNodeLBDataDumper, test_node_lb_data_dumping_with_interval) {
EXPECT_EQ(phase["user_defined"]["new_time"], static_cast<double>(phase["id"]));
}

auto num_tasks = json["phases"][0]["tasks"].size();
auto entity = json["phases"][0]["tasks"][num_tasks - 1]["entity"];
EXPECT_EQ(entity["home"], 0);
EXPECT_EQ(entity["id"], 0);
});

if (vt::theContext()->getNode() == 0) {
Expand Down Expand Up @@ -615,6 +619,10 @@ TEST_F(TestRestoreLBData, test_restore_lb_data_data_1) {
auto &orig_load_map = phase_data.second;
for (auto &entry : read_load_map) {
auto read_elm_id = entry.first;
if ((read_elm_id.id == vt::elm::no_element_id)
and (read_elm_id.getHomeNode() == 0)) {
continue;
}
EXPECT_FALSE(orig_load_map.find(read_elm_id) == orig_load_map.end());
if (orig_load_map.find(read_elm_id) == orig_load_map.end()) {
fmt::print(
Expand Down

0 comments on commit ea8b2c1

Please sign in to comment.