From 93e74f89c6b91db1d57014c2b7b7ac4f59486121 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Wed, 4 Jan 2017 10:17:07 +0800 Subject: [PATCH] rename PServerUtil to PServerController --- paddle/pserver/CMakeLists.txt | 4 ++-- ...{PServerUtil.cpp => PServerController.cpp} | 21 ++++++++++--------- .../{PServerUtil.h => PServerController.h} | 14 ++++++------- paddle/pserver/ParameterServer2Main.cpp | 7 +++---- paddle/trainer/TrainerMain.cpp | 6 +++--- 5 files changed, 26 insertions(+), 26 deletions(-) rename paddle/pserver/{PServerUtil.cpp => PServerController.cpp} (83%) rename paddle/pserver/{PServerUtil.h => PServerController.h} (83%) diff --git a/paddle/pserver/CMakeLists.txt b/paddle/pserver/CMakeLists.txt index 9bc48294f0..ac52b8dbec 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 bf4cf0771c..2d00019cef 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 117dde37e3..6fb7e0a31a 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 8c1baea0ce..6e683cdd2c 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 52983e46eb..3ce3d67842 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; -- GitLab