Skip to content

Commit d1e50fb

Browse files
authored
Merge pull request #108 from DARMA-tasking/107-support-case-with-no-communications
#107: Support case with no communications
2 parents f024e75 + 729fed5 commit d1e50fb

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

src/vt-tv/utility/json_reader.cc

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -214,36 +214,38 @@ std::unique_ptr<Info> JSONReader::parse() {
214214
}
215215
}
216216

217-
auto communications = phase["communications"];
218-
if (communications.is_array()) {
219-
for (auto const& comm : communications) {
220-
auto type = comm["type"];
221-
if (type == "SendRecv") {
222-
auto bytes = comm["bytes"];
223-
auto messages = comm["messages"];
224-
225-
auto from = comm["from"];
226-
auto to = comm["to"];
227-
228-
ElementIDType from_id = from["id"];
229-
ElementIDType to_id = to["id"];
230-
231-
assert(bytes.is_number());
232-
// assert(from.is_number());
233-
// assert(to.is_number());
234-
235-
// fmt::print(" From: {}, to: {}\n", from_id, to_id);
236-
237-
// Object on this rank sent data
238-
auto from_it = objects.find(from_id);
239-
if (from_it != objects.end()) {
240-
from_it->second.addSentCommunications(to_id, bytes);
241-
} else {
242-
auto to_it = objects.find(to_id);
243-
if (to_it != objects.end()) {
244-
to_it->second.addReceivedCommunications(from_id, bytes);
217+
if (phase.count("communications") > 0) {
218+
auto communications = phase["communications"];
219+
if (communications.is_array()) {
220+
for (auto const& comm : communications) {
221+
auto type = comm["type"];
222+
if (type == "SendRecv") {
223+
auto bytes = comm["bytes"];
224+
auto messages = comm["messages"];
225+
226+
auto from = comm["from"];
227+
auto to = comm["to"];
228+
229+
ElementIDType from_id = from["id"];
230+
ElementIDType to_id = to["id"];
231+
232+
assert(bytes.is_number());
233+
// assert(from.is_number());
234+
// assert(to.is_number());
235+
236+
// fmt::print(" From: {}, to: {}\n", from_id, to_id);
237+
238+
// Object on this rank sent data
239+
auto from_it = objects.find(from_id);
240+
if (from_it != objects.end()) {
241+
from_it->second.addSentCommunications(to_id, bytes);
245242
} else {
246-
fmt::print("Warning: Communication {} -> {}: neither sender nor recipient was found in objects.\n", from_id, to_id);
243+
auto to_it = objects.find(to_id);
244+
if (to_it != objects.end()) {
245+
to_it->second.addReceivedCommunications(from_id, bytes);
246+
} else {
247+
fmt::print("Warning: Communication {} -> {}: neither sender nor recipient was found in objects.\n", from_id, to_id);
248+
}
247249
}
248250
}
249251
}

0 commit comments

Comments
 (0)