Skip to content
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

Fix MPI world creation of size 1 #114

Merged
merged 3 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/scheduler/MpiWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ void MpiWorld::create(const faabric::Message& call, int newId, int newSize)
msg.set_mpiworldsize(size);
}

// Send the init messages (note that message i corresponds to rank i+1)
std::vector<std::string> executedAt = sch.callFunctions(req);
std::vector<std::string> executedAt;
if (size > 1) {
// Send the init messages (note that message i corresponds to rank i+1)
executedAt = sch.callFunctions(req);
}
assert(executedAt.size() == size - 1);

// Prepend this host for rank 0
Expand Down
18 changes: 18 additions & 0 deletions tests/test/scheduler/test_mpi_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ TEST_CASE_METHOD(MpiBaseTestFixture, "Test world creation", "[mpi]")
world.destroy();
}

TEST_CASE_METHOD(MpiBaseTestFixture, "Test creating world of size 1", "[mpi]")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test could be a bit more specific in checking the effect we're trying to avoid (i.e. initialising the world but not sending messages). It would look a lot like the test above where we check a valid world initialisation.

// Create a world of size 1
MpiWorld world;
world.create(msg, worldId, 1);

// Check details are set up properly
REQUIRE(world.getSize() == 1);
REQUIRE(world.getId() == worldId);
REQUIRE(world.getUser() == user);
REQUIRE(world.getFunction() == func);

// Check no messages are sent
REQUIRE(sch.getRecordedMessagesAll().empty());

{
// Create a world of size 1
MpiWorld world;
int worldSize = 1;
REQUIRE_NOTHROW(world.create(msg, worldId, worldSize));

REQUIRE(world.getSize() == worldSize);
REQUIRE(world.getId() == worldId);
REQUIRE(world.getUser() == user);
REQUIRE(world.getFunction() == func);

// Check no messages are sent
REQUIRE(sch.getRecordedMessagesAll().empty());

world.destroy();
}

TEST_CASE_METHOD(MpiTestFixture, "Test world loading from msg", "[mpi]")
{
// Create another copy from state
Expand Down