-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track Message Type in Execution Graph #175
Changes from 3 commits
6921665
945de75
58dddfb
b34d53c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,7 @@ TEST_CASE_METHOD(MpiTestFixture, | |
auto buffer = new int[messageData.size()]; | ||
|
||
int numToSend = 10; | ||
std::string expectedKey = | ||
faabric::util::exec_graph::mpiMsgCountPrefix + std::to_string(rankA2); | ||
std::string expectedKey = MPI_MSG_COUNT_PREFIX + std::to_string(rankA2); | ||
|
||
for (int i = 0; i < numToSend; i++) { | ||
world.send(rankA1, | ||
|
@@ -36,7 +35,7 @@ TEST_CASE_METHOD(MpiTestFixture, | |
rankA1, rankA2, BYTES(buffer), MPI_INT, messageData.size(), &status); | ||
} | ||
|
||
REQUIRE(msg.intexecgraphdetails_size() == 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would have had to increase this number every time we tracked a different thing. It did not seem a useful thing to test/easy to forget to change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See point about constant above, I think this is worth testing. |
||
REQUIRE(msg.intexecgraphdetails_size() == NUM_MPI_EXEC_GRAPH_DETAILS); | ||
REQUIRE(msg.execgraphdetails_size() == 0); | ||
REQUIRE(msg.intexecgraphdetails().count(expectedKey) == 1); | ||
REQUIRE(msg.intexecgraphdetails().at(expectedKey) == numToSend); | ||
|
@@ -58,8 +57,7 @@ TEST_CASE_METHOD(MpiTestFixture, | |
auto buffer = new int[messageData.size()]; | ||
|
||
int numToSend = 10; | ||
std::string expectedKey = | ||
faabric::util::exec_graph::mpiMsgCountPrefix + std::to_string(rankA2); | ||
std::string expectedKey = MPI_MSG_COUNT_PREFIX + std::to_string(rankA2); | ||
|
||
for (int i = 0; i < numToSend; i++) { | ||
world.send(rankA1, | ||
|
@@ -123,11 +121,76 @@ TEST_CASE_METHOD(MpiBaseTestFixture, | |
otherWorldThread.join(); | ||
} | ||
|
||
std::string expectedKey = | ||
faabric::util::exec_graph::mpiMsgCountPrefix + std::to_string(rank); | ||
std::string expectedKey = MPI_MSG_COUNT_PREFIX + std::to_string(rank); | ||
REQUIRE(otherMsg.mpirank() == otherRank); | ||
REQUIRE(otherMsg.intexecgraphdetails_size() == 1); | ||
REQUIRE(otherMsg.intexecgraphdetails().count(expectedKey) == 1); | ||
REQUIRE(otherMsg.intexecgraphdetails().at(expectedKey) == 1); | ||
} | ||
|
||
TEST_CASE_METHOD(MpiTestFixture, | ||
"Test tracing the number of MPI messages by type", | ||
"[util][exec-graph]") | ||
{ | ||
msg.set_recordexecgraph(true); | ||
|
||
// Send one message | ||
int rankA1 = 0; | ||
int rankA2 = 1; | ||
MPI_Status status{}; | ||
|
||
std::vector<int> messageData = { 0, 1, 2 }; | ||
auto buffer = new int[messageData.size()]; | ||
|
||
std::string expectedKey; | ||
int msgCount; | ||
|
||
SECTION("Normal send") | ||
{ | ||
expectedKey = fmt::format("{}-{}-{}", | ||
MPI_MSGTYPE_COUNT_PREFIX, | ||
faabric::MPIMessage::NORMAL, | ||
std::to_string(rankA2)); | ||
msgCount = 1; | ||
|
||
world.send(rankA1, | ||
rankA2, | ||
BYTES(messageData.data()), | ||
MPI_INT, | ||
messageData.size()); | ||
world.recv( | ||
rankA1, rankA2, BYTES(buffer), MPI_INT, messageData.size(), &status); | ||
} | ||
|
||
SECTION("Reduce") | ||
{ | ||
std::vector<int> data(2, 0); | ||
|
||
expectedKey = fmt::format("{}-{}-{}", | ||
MPI_MSGTYPE_COUNT_PREFIX, | ||
faabric::MPIMessage::REDUCE, | ||
std::to_string(rankA2)); | ||
msgCount = worldSize - 1; | ||
|
||
// Reduce expects to receive a message from all other ranks | ||
for (int r = 0; r < worldSize; r++) { | ||
if (r != rankA2) { | ||
world.reduce( | ||
r, rankA2, BYTES(&data[0]), nullptr, MPI_INT, 1, MPI_SUM); | ||
} | ||
} | ||
|
||
world.reduce(rankA2, | ||
rankA2, | ||
BYTES(&data[1]), | ||
BYTES(&data[1]), | ||
MPI_INT, | ||
1, | ||
MPI_SUM); | ||
} | ||
|
||
REQUIRE(msg.intexecgraphdetails_size() == NUM_MPI_EXEC_GRAPH_DETAILS); | ||
REQUIRE(msg.execgraphdetails_size() == 0); | ||
REQUIRE(msg.intexecgraphdetails().count(expectedKey) == 1); | ||
REQUIRE(msg.intexecgraphdetails().at(expectedKey) == msgCount); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this string format then result in a double hyphen at the beginning (as the prefix already has a hyphen)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the
MSGTYPE_COUNT
we have to provide two values, so the constant actually hasn't got a trailing hyphen. I will change it to make them both consistent.