Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
csegarragonz committed Jun 16, 2021
1 parent 88bcb7d commit a3287fd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
run: inv dev.cc faabric_tests
# --- Tests ---
- name: "Run tests"
run: ./bin/faabric_tests
run: LOG_LEVEL=trace ./bin/faabric_tests
working-directory: /build/faabric/static

dist-tests:
Expand Down
57 changes: 57 additions & 0 deletions tests/test/scheduler/test_remote_mpi_worlds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,63 @@ TEST_CASE_METHOD(RemoteMpiTestFixture, "Test send across hosts", "[mpi]")
localWorld.destroy();
}

TEST_CASE_METHOD(RemoteMpiTestFixture,
"Test send and recv across hosts",
"[mpi]")
{
// Register two ranks (one on each host)
this->setWorldsSizes(2, 1, 1);
int rankA = 0;
int rankB = 1;
std::vector<int> messageData = { 0, 1, 2 };
std::vector<int> messageData2 = { 3, 4, 5 };

// Init worlds
MpiWorld& localWorld = getMpiWorldRegistry().createWorld(msg, worldId);
faabric::util::setMockMode(false);

std::thread senderThread([this, rankA, rankB, &messageData, &messageData2] {
remoteWorld.initialiseFromMsg(msg);

// Send a message that should get sent to this host
remoteWorld.send(
rankB, rankA, BYTES(messageData.data()), MPI_INT, messageData.size());

// Now recv
auto buffer = new int[messageData2.size()];
remoteWorld.recv(rankA,
rankB,
BYTES(buffer),
MPI_INT,
messageData2.size(),
MPI_STATUS_IGNORE);
std::vector<int> actual(buffer, buffer + messageData2.size());
REQUIRE(actual == messageData2);

remoteWorld.destroy();
});

// Receive the message for the given rank
MPI_Status status{};
auto buffer = new int[messageData.size()];
localWorld.recv(
rankB, rankA, BYTES(buffer), MPI_INT, messageData.size(), &status);
std::vector<int> actual(buffer, buffer + messageData.size());
REQUIRE(actual == messageData);

// Now send a message
localWorld.send(
rankA, rankB, BYTES(messageData2.data()), MPI_INT, messageData2.size());

REQUIRE(status.MPI_SOURCE == rankB);
REQUIRE(status.MPI_ERROR == MPI_SUCCESS);
REQUIRE(status.bytesSize == messageData.size() * sizeof(int));

// Destroy worlds
senderThread.join();
localWorld.destroy();
}

TEST_CASE_METHOD(RemoteMpiTestFixture,
"Test sending many messages across host",
"[mpi]")
Expand Down

0 comments on commit a3287fd

Please sign in to comment.