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 11, 2021
1 parent 13200da commit cdaf39e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test/scheduler/test_remote_mpi_worlds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <faabric/util/macros.h>
#include <faabric_utils.h>

#include <faabric/util/logging.h>

#include <thread>

using namespace faabric::scheduler;
Expand Down Expand Up @@ -76,6 +78,50 @@ TEST_CASE_METHOD(RemoteMpiTestFixture, "Test send across hosts", "[mpi]")
localWorld.destroy();
}

TEST_CASE_METHOD(RemoteMpiTestFixture,
"Test sending many messages across host",
"[mpi]")
{
// Register two ranks (one on each host)
this->setWorldsSizes(2, 1, 1);
int rankA = 0;
int rankB = 1;
int numMessages = 1000;

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

std::thread senderThread([this, rankA, rankB, numMessages] {
std::vector<int> messageData = { 0, 1, 2 };

remoteWorld.initialiseFromMsg(msg);

for (int i = 0; i < numMessages; i++) {
// faabric::util::getLogger()->info("{}", i);
remoteWorld.send(rankB, rankA, BYTES(&i), MPI_INT, sizeof(int));
}
usleep(1000 * 500);
remoteWorld.destroy();
});

int recv;
for (int i = 0; i < numMessages; i++) {
localWorld.recv(
rankB, rankA, BYTES(&recv), MPI_INT, sizeof(int), MPI_STATUS_IGNORE);

// Check in-order delivery
if (i % (numMessages / 10) == 0) {
faabric::util::getLogger()->info("recv {} - i {}", recv, i);
REQUIRE(recv == i);
}
}

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

TEST_CASE_METHOD(RemoteMpiTestFixture,
"Test collective messaging across hosts",
"[mpi]")
Expand Down

0 comments on commit cdaf39e

Please sign in to comment.