From 89c2d48e56ddf0e2fc0b0032baed493bd9a42156 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Tue, 5 Oct 2021 16:05:23 +0000 Subject: [PATCH] change default mpi base port and allow value to be set through env variable --- include/faabric/scheduler/MpiWorld.h | 2 +- include/faabric/transport/common.h | 2 -- include/faabric/util/config.h | 1 + src/scheduler/MpiWorld.cpp | 1 + src/util/config.cpp | 2 ++ tests/test/util/test_config.cpp | 4 ++++ 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/faabric/scheduler/MpiWorld.h b/include/faabric/scheduler/MpiWorld.h index 12da2166e..d927bb5c6 100644 --- a/include/faabric/scheduler/MpiWorld.h +++ b/include/faabric/scheduler/MpiWorld.h @@ -188,7 +188,7 @@ class MpiWorld int id = -1; int size = -1; std::string thisHost; - int basePort = DEFAULT_MPI_BASE_PORT; + int basePort; faabric::util::TimePoint creationTime; std::atomic_flag isDestroyed = false; diff --git a/include/faabric/transport/common.h b/include/faabric/transport/common.h index 7ee8ee759..fc6e48547 100644 --- a/include/faabric/transport/common.h +++ b/include/faabric/transport/common.h @@ -10,5 +10,3 @@ #define FUNCTION_CALL_SYNC_PORT 8006 #define SNAPSHOT_ASYNC_PORT 8007 #define SNAPSHOT_SYNC_PORT 8008 - -#define DEFAULT_MPI_BASE_PORT 8800 diff --git a/include/faabric/util/config.h b/include/faabric/util/config.h index 42d87cf5b..7dfd9290e 100644 --- a/include/faabric/util/config.h +++ b/include/faabric/util/config.h @@ -35,6 +35,7 @@ class SystemConfig // MPI int defaultMpiWorldSize; + int mpiBasePort; // Endpoint std::string endpointInterface; diff --git a/src/scheduler/MpiWorld.cpp b/src/scheduler/MpiWorld.cpp index fcb7ed1b4..9d6524e3e 100644 --- a/src/scheduler/MpiWorld.cpp +++ b/src/scheduler/MpiWorld.cpp @@ -39,6 +39,7 @@ namespace faabric::scheduler { MpiWorld::MpiWorld() : thisHost(faabric::util::getSystemConfig().endpointHost) + , basePort(faabric::util::getSystemConfig().mpiBasePort) , creationTime(faabric::util::startTimer()) , cartProcsPerDim(2) {} diff --git a/src/util/config.cpp b/src/util/config.cpp index 6875b1854..93de36ac1 100644 --- a/src/util/config.cpp +++ b/src/util/config.cpp @@ -43,6 +43,7 @@ void SystemConfig::initialise() // MPI defaultMpiWorldSize = this->getSystemConfIntParam("DEFAULT_MPI_WORLD_SIZE", "5"); + mpiBasePort = this->getSystemConfIntParam("MPI_BASE_PORT", "10800"); // Endpoint endpointInterface = getEnvVar("ENDPOINT_INTERFACE", ""); @@ -96,6 +97,7 @@ void SystemConfig::print() SPDLOG_INFO("--- MPI ---"); SPDLOG_INFO("DEFAULT_MPI_WORLD_SIZE {}", defaultMpiWorldSize); + SPDLOG_INFO("MPI_BASE_PORT {}", mpiBasePort); SPDLOG_INFO("--- Endpoint ---"); SPDLOG_INFO("ENDPOINT_INTERFACE {}", endpointInterface); diff --git a/tests/test/util/test_config.cpp b/tests/test/util/test_config.cpp index 75c2d88ef..5132506f9 100644 --- a/tests/test/util/test_config.cpp +++ b/tests/test/util/test_config.cpp @@ -27,6 +27,7 @@ TEST_CASE("Test default system config initialisation", "[util]") REQUIRE(conf.boundTimeout == 30000); REQUIRE(conf.defaultMpiWorldSize == 5); + REQUIRE(conf.mpiBasePort == 10800); } TEST_CASE("Test overriding system config initialisation", "[util]") @@ -48,6 +49,7 @@ TEST_CASE("Test overriding system config initialisation", "[util]") std::string boundTimeout = setEnvVar("BOUND_TIMEOUT", "6666"); std::string mpiSize = setEnvVar("DEFAULT_MPI_WORLD_SIZE", "2468"); + std::string mpiPort = setEnvVar("MPI_BASE_PORT", "9999"); // Create new conf for test SystemConfig conf; @@ -67,6 +69,7 @@ TEST_CASE("Test overriding system config initialisation", "[util]") REQUIRE(conf.boundTimeout == 6666); REQUIRE(conf.defaultMpiWorldSize == 2468); + REQUIRE(conf.mpiBasePort == 9999); // Be careful with host type setEnvVar("LOG_LEVEL", logLevel); @@ -86,6 +89,7 @@ TEST_CASE("Test overriding system config initialisation", "[util]") setEnvVar("BOUND_TIMEOUT", boundTimeout); setEnvVar("DEFAULT_MPI_WORLD_SIZE", mpiSize); + setEnvVar("MPI_BASE_PORT", mpiPort); } }