diff --git a/paddle/pserver/CMakeLists.txt b/paddle/pserver/CMakeLists.txt index 9bc48294f06b8ae38ff87fd3542f26c14a0e7795..ac52b8dbeced70aa556970e8f685df68e6b4e354 100644 --- a/paddle/pserver/CMakeLists.txt +++ b/paddle/pserver/CMakeLists.txt @@ -25,14 +25,14 @@ set(PSERVER_SOURCES ParameterClient2.cpp ParameterServer2.cpp SparseParameterDistribution.cpp - PServerUtil.cpp) + PServerController.cpp) set(PSERVER_HEADERS BaseClient.h ParameterClient2.h ParameterServer2.h SparseParameterDistribution.h - PServerUtil.h) + PServerController.h) add_library(paddle_pserver STATIC ${PSERVER_SOURCES}) diff --git a/paddle/pserver/PServerUtil.cpp b/paddle/pserver/PServerController.cpp similarity index 83% rename from paddle/pserver/PServerUtil.cpp rename to paddle/pserver/PServerController.cpp index bf4cf0771ccd6e08f2534947738d9d3143b28211..2d00019ceff6d01cbbfd30b67a31e353c8f1e0cb 100644 --- a/paddle/pserver/PServerUtil.cpp +++ b/paddle/pserver/PServerController.cpp @@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "PServerUtil.h" +#include "PServerController.h" namespace paddle { -PServerUtil::PServerUtil(const ParameterServerConfig& config) { +PServerController::PServerController(const ParameterServerConfig& config) { // round robin to load balance RDMA server ENGINE std::vector devices; int rdmaCpu = 0; @@ -58,9 +58,9 @@ PServerUtil::PServerUtil(const ParameterServerConfig& config) { } } -PServerUtil::~PServerUtil() { this->join(); } +PServerController::~PServerController() { this->join(); } -ParameterServerConfig* PServerUtil::initConfig() { +ParameterServerConfig* PServerController::initConfigByGflags() { ParameterServerConfig* config = new ParameterServerConfig(); config->set_nics(FLAGS_nics); config->set_port(FLAGS_port); @@ -69,16 +69,17 @@ ParameterServerConfig* PServerUtil::initConfig() { return config; } -PServerUtil* PServerUtil::createWithGflags() { - auto& pServerConfig = *paddle::PServerUtil::initConfig(); +PServerController* PServerController::createByGflags() { + auto& pServerConfig = *paddle::PServerController::initConfigByGflags(); return create(pServerConfig); } -PServerUtil* PServerUtil::create(const ParameterServerConfig& config) { - return new PServerUtil(config); +PServerController* PServerController::create( + const ParameterServerConfig& config) { + return new PServerController(config); } -void PServerUtil::start() { +void PServerController::start() { LOG(INFO) << "pserver sizes : " << pservers_.size(); int i = 0; for (const auto& pserver : pservers_) { @@ -88,7 +89,7 @@ void PServerUtil::start() { } } -void PServerUtil::join() { +void PServerController::join() { LOG(INFO) << "pserver sizes : " << pservers_.size(); int i = 0; for (const auto& pserver : pservers_) { diff --git a/paddle/pserver/PServerUtil.h b/paddle/pserver/PServerController.h similarity index 83% rename from paddle/pserver/PServerUtil.h rename to paddle/pserver/PServerController.h index 117dde37e3f8846505b1d75bec5033f3f4141c02..6fb7e0a31ab2264848cba3c2ad3a5f779bdb4501 100644 --- a/paddle/pserver/PServerUtil.h +++ b/paddle/pserver/PServerController.h @@ -21,31 +21,31 @@ limitations under the License. */ namespace paddle { -class PServerUtil { +class PServerController { public: - DISABLE_COPY(PServerUtil); + DISABLE_COPY(PServerController); /** * @brief Ctor, Create a PServerUtil from ParameterServerConfig. */ - explicit PServerUtil(const ParameterServerConfig& config); + explicit PServerController(const ParameterServerConfig& config); /** * @brief Dtor. */ - ~PServerUtil(); + ~PServerController(); /** * @brief create PServerUtil from gflags, this is used for * compatibility with the old usage of configuration by gflags. */ - static PServerUtil* createWithGflags(); + static PServerController* createByGflags(); /** * @brief create PServerUtil with ParameterServerConfig, remove gflags * from ParameterServer. Init all pservers thread according to the config. */ - static PServerUtil* create(const ParameterServerConfig& config); + static PServerController* create(const ParameterServerConfig& config); /** * @brief start all pserver thread in this PServerUtil. @@ -64,7 +64,7 @@ private: * @brief create ParameterServerConfig from gflags, this is used for * compatibility with the old usage of configuration by gflags. */ - static ParameterServerConfig* initConfig(); + static ParameterServerConfig* initConfigByGflags(); }; } // namespace paddle diff --git a/paddle/pserver/ParameterServer2Main.cpp b/paddle/pserver/ParameterServer2Main.cpp index 8c1baea0cef76849276c3dbbad6a2e0ef3a5689f..6e683cdd2c2c88450af90254e73cee0dced83440 100644 --- a/paddle/pserver/ParameterServer2Main.cpp +++ b/paddle/pserver/ParameterServer2Main.cpp @@ -13,16 +13,15 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include "PServerUtil.h" -#include "paddle/trainer/ParamUtil.h" +#include "PServerController.h" using namespace paddle; // NOLINT int main(int argc, char** argv) { initMain(argc, argv); - std::unique_ptr pServerPtr( - paddle::PServerUtil::createWithGflags()); + std::unique_ptr pServerPtr( + paddle::PServerController::createByGflags()); pServerPtr->start(); pServerPtr->join(); diff --git a/paddle/trainer/TrainerMain.cpp b/paddle/trainer/TrainerMain.cpp index 52983e46eb9071abcab4c529e4a28765e5bbe430..3ce3d67842ddaa195fdcae0b087bdf715abb967a 100644 --- a/paddle/trainer/TrainerMain.cpp +++ b/paddle/trainer/TrainerMain.cpp @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include -#include "paddle/pserver/PServerUtil.h" +#include "paddle/pserver/PServerController.h" #include "paddle/utils/Excepts.h" #include "paddle/utils/PythonUtil.h" @@ -37,9 +37,9 @@ int main(int argc, char** argv) { initMain(argc, argv); initPython(argc, argv); - std::unique_ptr pServerPtr(nullptr); + std::unique_ptr pServerPtr(nullptr); if (FLAGS_start_pserver) { - pServerPtr.reset(paddle::PServerUtil::createWithGflags()); + pServerPtr.reset(paddle::PServerController::createByGflags()); pServerPtr->start(); } Trainer trainer;