Skip to content

Commit 441d27b

Browse files
committed
#2201: temperedlb: use new method of getting user data, fix error message for shared_id
1 parent 826d83c commit 441d27b

File tree

1 file changed

+50
-44
lines changed

1 file changed

+50
-44
lines changed

src/vt/vrt/collection/balance/temperedlb/temperedlb.cc

+50-44
Original file line numberDiff line numberDiff line change
@@ -520,58 +520,64 @@ void TemperedLB::runLB(LoadType total_load) {
520520
}
521521

522522
void TemperedLB::readClustersMemoryData() {
523-
if (user_data_) {
524-
for (auto const& [obj, data_map] : *user_data_) {
525-
SharedIDType shared_id = -1;
526-
BytesType shared_bytes = 0;
527-
BytesType working_bytes = 0;
528-
for (auto const& [key, variant] : data_map) {
529-
if (key == "shared_id") {
530-
// Because of how JSON is stored this is always a double, even though
531-
// it should be an integer
532-
if (double const* val = std::get_if<double>(&variant)) {
533-
shared_id = static_cast<int>(*val);
534-
} else {
535-
vtAbort("\"shared_id\" in variant does not match integer");
523+
if (load_model_->hasUserData()) {
524+
for (auto obj : *load_model_) {
525+
if (obj.isMigratable()) {
526+
auto data_map = load_model_->getUserData(
527+
obj, {balance::PhaseOffset::NEXT_PHASE, balance::PhaseOffset::WHOLE_PHASE}
528+
);
529+
530+
SharedIDType shared_id = -1;
531+
BytesType shared_bytes = 0;
532+
BytesType working_bytes = 0;
533+
for (auto const& [key, variant] : data_map) {
534+
if (key == "shared_id") {
535+
// Because of how JSON is stored this is always a double, even
536+
// though it should be an integer
537+
if (double const* val = std::get_if<double>(&variant)) {
538+
shared_id = static_cast<int>(*val);
539+
} else {
540+
vtAbort("\"shared_id\" in variant does not match double");
541+
}
536542
}
537-
}
538-
if (key == "shared_bytes") {
539-
if (BytesType const* val = std::get_if<BytesType>(&variant)) {
540-
shared_bytes = *val;
541-
} else {
542-
vtAbort("\"shared_bytes\" in variant does not match double");
543+
if (key == "shared_bytes") {
544+
if (BytesType const* val = std::get_if<BytesType>(&variant)) {
545+
shared_bytes = *val;
546+
} else {
547+
vtAbort("\"shared_bytes\" in variant does not match double");
548+
}
543549
}
544-
}
545-
if (key == "task_working_bytes") {
546-
if (BytesType const* val = std::get_if<BytesType>(&variant)) {
547-
working_bytes = *val;
548-
} else {
549-
vtAbort("\"working_bytes\" in variant does not match double");
550+
if (key == "task_working_bytes") {
551+
if (BytesType const* val = std::get_if<BytesType>(&variant)) {
552+
working_bytes = *val;
553+
} else {
554+
vtAbort("\"working_bytes\" in variant does not match double");
555+
}
550556
}
551-
}
552-
if (key == "rank_working_bytes") {
553-
if (BytesType const* val = std::get_if<BytesType>(&variant)) {
554-
rank_bytes_ = *val;
555-
} else {
556-
vtAbort("\"rank_bytes\" in variant does not match double");
557+
if (key == "rank_working_bytes") {
558+
if (BytesType const* val = std::get_if<BytesType>(&variant)) {
559+
rank_bytes_ = *val;
560+
} else {
561+
vtAbort("\"rank_bytes\" in variant does not match double");
562+
}
557563
}
564+
// @todo: for now, skip "task_serialized_bytes" and
565+
// "task_footprint_bytes"
558566
}
559-
// @todo: for now, skip "task_serialized_bytes" and
560-
// "task_footprint_bytes"
561-
}
562567

563-
// @todo: switch to debug print at some point
564-
vt_print(
565-
temperedlb, "obj={} shared_block={} bytes={}\n",
566-
obj, shared_id, shared_bytes
567-
);
568+
// @todo: switch to debug print at some point
569+
vt_print(
570+
temperedlb, "obj={} shared_block={} bytes={}\n",
571+
obj, shared_id, shared_bytes
572+
);
568573

569-
has_memory_data_ = true;
570-
obj_shared_block_[obj] = shared_id;
571-
obj_working_bytes_[obj] = working_bytes;
572-
shared_block_size_[shared_id] = shared_bytes;
574+
has_memory_data_ = true;
575+
obj_shared_block_[obj] = shared_id;
576+
obj_working_bytes_[obj] = working_bytes;
577+
shared_block_size_[shared_id] = shared_bytes;
578+
}
573579
}
574-
}
580+
}
575581
}
576582

577583
void TemperedLB::computeClusterSummary() {

0 commit comments

Comments
 (0)