Skip to content

Commit ca9d038

Browse files
committed
#2201: reduce code duplication
1 parent b54ac12 commit ca9d038

File tree

4 files changed

+6
-19
lines changed

4 files changed

+6
-19
lines changed

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

+5-12
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,7 @@ std::unique_ptr<nlohmann::json> LBDataHolder::toJson(PhaseType phase) const {
252252

253253
i = 0;
254254
if (node_comm_.find(phase) != node_comm_.end()) {
255-
for (auto&& elm : node_comm_.at(phase)) {
256-
auto volume = elm.second;
257-
auto const& key = elm.first;
255+
for (auto const& [key, volume] : node_comm_.at(phase)) {
258256
j["communications"][i]["bytes"] = volume.bytes;
259257
j["communications"][i]["messages"] = volume.messages;
260258

@@ -296,16 +294,11 @@ std::unique_ptr<nlohmann::json> LBDataHolder::toJson(PhaseType phase) const {
296294
outputEntity(j["communications"][i]["from"], key.fromObj());
297295
break;
298296
}
299-
case elm::CommCategory::ReadOnlyShared: {
300-
j["communications"][i]["type"] = "ReadOnlyShared";
301-
j["communications"][i]["to"]["type"] = "node";
302-
j["communications"][i]["to"]["id"] = key.toNode();
303-
j["communications"][i]["from"]["type"] = "shared_id";
304-
j["communications"][i]["from"]["id"] = key.sharedID();
305-
break;
306-
}
297+
case elm::CommCategory::ReadOnlyShared:
307298
case elm::CommCategory::WriteShared: {
308-
j["communications"][i]["type"] = "WriteShared";
299+
j["communications"][i]["type"] =
300+
(key.cat_ == elm::CommCategory::ReadOnlyShared) ?
301+
"ReadOnlyShared" : "WriteShared";
309302
j["communications"][i]["to"]["type"] = "node";
310303
j["communications"][i]["to"]["id"] = key.toNode();
311304
j["communications"][i]["from"]["type"] = "shared_id";

src/vt/vrt/collection/balance/lb_data_holder.h

-3
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@
4646

4747
#include "vt/config.h"
4848
#include "vt/vrt/collection/balance/lb_common.h"
49-
#include "vt/elm/elm_comm.h"
5049

5150
#include <unordered_map>
5251
#include <memory>
53-
#include <variant>
54-
#include <string>
5552

5653
#include <nlohmann/json_fwd.hpp>
5754

src/vt/vrt/collection/balance/model/load_model.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,7 @@ struct LoadModel
222222
*
223223
* \return the comm info
224224
*/
225-
virtual CommMapType getComm([[maybe_unused]] PhaseOffset when) const {
226-
return CommMapType{};
227-
}
225+
virtual CommMapType getComm(PhaseOffset when) const = 0;
228226

229227
/**
230228
* \brief Provide an estimate of the given object's load during a specified interval

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

-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ getRecvSendDirection(elm::CommKeyType const& comm) {
272272
// this case is just to avoid warning of not handled enum
273273
case elm::CommCategory::CollectiveToCollectionBcast:
274274
case elm::CommCategory::LocalInvoke:
275-
return std::make_pair(ElementIDType{}, ElementIDType{});
276275
case elm::CommCategory::WriteShared:
277276
case elm::CommCategory::ReadOnlyShared:
278277
return std::make_pair(ElementIDType{}, ElementIDType{});

0 commit comments

Comments
 (0)