提交 93e74f89 编写于 作者: Q qiaolongfei

rename PServerUtil to PServerController

上级 77839826
...@@ -25,14 +25,14 @@ set(PSERVER_SOURCES ...@@ -25,14 +25,14 @@ set(PSERVER_SOURCES
ParameterClient2.cpp ParameterClient2.cpp
ParameterServer2.cpp ParameterServer2.cpp
SparseParameterDistribution.cpp SparseParameterDistribution.cpp
PServerUtil.cpp) PServerController.cpp)
set(PSERVER_HEADERS set(PSERVER_HEADERS
BaseClient.h BaseClient.h
ParameterClient2.h ParameterClient2.h
ParameterServer2.h ParameterServer2.h
SparseParameterDistribution.h SparseParameterDistribution.h
PServerUtil.h) PServerController.h)
add_library(paddle_pserver STATIC add_library(paddle_pserver STATIC
${PSERVER_SOURCES}) ${PSERVER_SOURCES})
......
...@@ -12,11 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ...@@ -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 See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "PServerUtil.h" #include "PServerController.h"
namespace paddle { namespace paddle {
PServerUtil::PServerUtil(const ParameterServerConfig& config) { PServerController::PServerController(const ParameterServerConfig& config) {
// round robin to load balance RDMA server ENGINE // round robin to load balance RDMA server ENGINE
std::vector<std::string> devices; std::vector<std::string> devices;
int rdmaCpu = 0; int rdmaCpu = 0;
...@@ -58,9 +58,9 @@ PServerUtil::PServerUtil(const ParameterServerConfig& config) { ...@@ -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(); ParameterServerConfig* config = new ParameterServerConfig();
config->set_nics(FLAGS_nics); config->set_nics(FLAGS_nics);
config->set_port(FLAGS_port); config->set_port(FLAGS_port);
...@@ -69,16 +69,17 @@ ParameterServerConfig* PServerUtil::initConfig() { ...@@ -69,16 +69,17 @@ ParameterServerConfig* PServerUtil::initConfig() {
return config; return config;
} }
PServerUtil* PServerUtil::createWithGflags() { PServerController* PServerController::createByGflags() {
auto& pServerConfig = *paddle::PServerUtil::initConfig(); auto& pServerConfig = *paddle::PServerController::initConfigByGflags();
return create(pServerConfig); return create(pServerConfig);
} }
PServerUtil* PServerUtil::create(const ParameterServerConfig& config) { PServerController* PServerController::create(
return new PServerUtil(config); const ParameterServerConfig& config) {
return new PServerController(config);
} }
void PServerUtil::start() { void PServerController::start() {
LOG(INFO) << "pserver sizes : " << pservers_.size(); LOG(INFO) << "pserver sizes : " << pservers_.size();
int i = 0; int i = 0;
for (const auto& pserver : pservers_) { for (const auto& pserver : pservers_) {
...@@ -88,7 +89,7 @@ void PServerUtil::start() { ...@@ -88,7 +89,7 @@ void PServerUtil::start() {
} }
} }
void PServerUtil::join() { void PServerController::join() {
LOG(INFO) << "pserver sizes : " << pservers_.size(); LOG(INFO) << "pserver sizes : " << pservers_.size();
int i = 0; int i = 0;
for (const auto& pserver : pservers_) { for (const auto& pserver : pservers_) {
......
...@@ -21,31 +21,31 @@ limitations under the License. */ ...@@ -21,31 +21,31 @@ limitations under the License. */
namespace paddle { namespace paddle {
class PServerUtil { class PServerController {
public: public:
DISABLE_COPY(PServerUtil); DISABLE_COPY(PServerController);
/** /**
* @brief Ctor, Create a PServerUtil from ParameterServerConfig. * @brief Ctor, Create a PServerUtil from ParameterServerConfig.
*/ */
explicit PServerUtil(const ParameterServerConfig& config); explicit PServerController(const ParameterServerConfig& config);
/** /**
* @brief Dtor. * @brief Dtor.
*/ */
~PServerUtil(); ~PServerController();
/** /**
* @brief create PServerUtil from gflags, this is used for * @brief create PServerUtil from gflags, this is used for
* compatibility with the old usage of configuration by gflags. * compatibility with the old usage of configuration by gflags.
*/ */
static PServerUtil* createWithGflags(); static PServerController* createByGflags();
/** /**
* @brief create PServerUtil with ParameterServerConfig, remove gflags * @brief create PServerUtil with ParameterServerConfig, remove gflags
* from ParameterServer. Init all pservers thread according to the config. * 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. * @brief start all pserver thread in this PServerUtil.
...@@ -64,7 +64,7 @@ private: ...@@ -64,7 +64,7 @@ private:
* @brief create ParameterServerConfig from gflags, this is used for * @brief create ParameterServerConfig from gflags, this is used for
* compatibility with the old usage of configuration by gflags. * compatibility with the old usage of configuration by gflags.
*/ */
static ParameterServerConfig* initConfig(); static ParameterServerConfig* initConfigByGflags();
}; };
} // namespace paddle } // namespace paddle
...@@ -13,16 +13,15 @@ See the License for the specific language governing permissions and ...@@ -13,16 +13,15 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include <fstream> #include <fstream>
#include "PServerUtil.h" #include "PServerController.h"
#include "paddle/trainer/ParamUtil.h"
using namespace paddle; // NOLINT using namespace paddle; // NOLINT
int main(int argc, char** argv) { int main(int argc, char** argv) {
initMain(argc, argv); initMain(argc, argv);
std::unique_ptr<PServerUtil> pServerPtr( std::unique_ptr<PServerController> pServerPtr(
paddle::PServerUtil::createWithGflags()); paddle::PServerController::createByGflags());
pServerPtr->start(); pServerPtr->start();
pServerPtr->join(); pServerPtr->join();
......
...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include <fenv.h> #include <fenv.h>
#include "paddle/pserver/PServerUtil.h" #include "paddle/pserver/PServerController.h"
#include "paddle/utils/Excepts.h" #include "paddle/utils/Excepts.h"
#include "paddle/utils/PythonUtil.h" #include "paddle/utils/PythonUtil.h"
...@@ -37,9 +37,9 @@ int main(int argc, char** argv) { ...@@ -37,9 +37,9 @@ int main(int argc, char** argv) {
initMain(argc, argv); initMain(argc, argv);
initPython(argc, argv); initPython(argc, argv);
std::unique_ptr<PServerUtil> pServerPtr(nullptr); std::unique_ptr<PServerController> pServerPtr(nullptr);
if (FLAGS_start_pserver) { if (FLAGS_start_pserver) {
pServerPtr.reset(paddle::PServerUtil::createWithGflags()); pServerPtr.reset(paddle::PServerController::createByGflags());
pServerPtr->start(); pServerPtr->start();
} }
Trainer trainer; Trainer trainer;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册