Skip to content

Commit

Permalink
Merge pull request #1064 from DARMA-tasking/1063-subphase-timings
Browse files Browse the repository at this point in the history
#1063 Properly record subphase timings
  • Loading branch information
PhilMiller authored Sep 21, 2020
2 parents 14b814c + 105b925 commit 0bfd3aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/vt/vrt/collection/balance/model/raw_data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ TimeType RawData::getWork(ElementIDType object, PhaseOffset offset)
auto phase = getNumCompletedPhases() + offset.phases;
if (offset.subphase == PhaseOffset::WHOLE_PHASE)
return proc_load_->at(phase).at(object);
else
return proc_subphase_load_->at(phase).at(object).at(offset.subphase);
else {
auto &phase_data = proc_subphase_load_->at(phase);
auto &object_data = phase_data.at(object);
auto retval = object_data.at(offset.subphase);

return retval;
}
}

int RawData::getNumPastPhasesNeeded(int look_back)
Expand Down
2 changes: 1 addition & 1 deletion src/vt/vrt/collection/balance/node_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ ElementIDType NodeStats::addNodeStats(
std::forward_as_tuple(time)
);

auto subphase_data = node_subphase_data_[phase];
auto &subphase_data = node_subphase_data_[phase];
auto elm_subphase_iter = subphase_data.find(temp_id);
vtAssert(elm_subphase_iter == subphase_data.end(), "Must not exist");
subphase_data.emplace(
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/collection/test_model_raw_data.nompi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ TEST_F(TestRawData, test_model_raw_data_scalar) {
std::make_shared<RawData>();

std::unordered_map<PhaseType, LoadMapType> proc_loads;
test_model->setLoads(&proc_loads, nullptr, nullptr);
std::unordered_map<PhaseType, SubphaseLoadMapType> subphase_loads;
test_model->setLoads(&proc_loads, &subphase_loads, nullptr);

// Work loads to be added in each test iteration
std::vector<LoadMapType> load_holder{
Expand All @@ -90,10 +91,13 @@ TEST_F(TestRawData, test_model_raw_data_scalar) {

for (size_t iter = 0; iter < load_holder.size(); ++iter) {
proc_loads[iter] = load_holder[iter];
subphase_loads[iter][1] = {load_holder[iter][1]};
subphase_loads[iter][2] = {load_holder[iter][2]};
test_model->updateLoads(iter);

EXPECT_EQ(test_model->getNumObjects(), 2);
EXPECT_EQ(test_model->getNumCompletedPhases(), iter+1);
EXPECT_EQ(test_model->getNumSubphases(), 1);

EXPECT_EQ(test_model->getNumPastPhasesNeeded(iter), iter);
EXPECT_EQ(test_model->getNumPastPhasesNeeded(2*iter), 2*iter);
Expand All @@ -105,6 +109,9 @@ TEST_F(TestRawData, test_model_raw_data_scalar) {

auto work_val = test_model->getWork(obj, PhaseOffset{-1, PhaseOffset::WHOLE_PHASE});
EXPECT_EQ(work_val, load_holder[iter][obj]);

auto sub_work_val = test_model->getWork(obj, PhaseOffset{-1, 0});
EXPECT_EQ(sub_work_val, load_holder[iter][obj]);
}
EXPECT_EQ(objects_seen, 2);
}
Expand Down

0 comments on commit 0bfd3aa

Please sign in to comment.