Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
aa9f5162
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
aa9f5162
编写于
1月 11, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code refine, add comment and some naming problem
上级
d32c7a6b
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
52 addition
and
35 deletion
+52
-35
paddle/pserver/ParameterServer2Main.cpp
paddle/pserver/ParameterServer2Main.cpp
+4
-4
paddle/pserver/ParameterServerController.cpp
paddle/pserver/ParameterServerController.cpp
+22
-21
paddle/pserver/ParameterServerController.h
paddle/pserver/ParameterServerController.h
+15
-7
paddle/trainer/TrainerMain.cpp
paddle/trainer/TrainerMain.cpp
+4
-3
proto/ParameterServerConfig.proto
proto/ParameterServerConfig.proto
+7
-0
未找到文件。
paddle/pserver/ParameterServer2Main.cpp
浏览文件 @
aa9f5162
...
...
@@ -20,10 +20,10 @@ using namespace paddle; // NOLINT
int
main
(
int
argc
,
char
**
argv
)
{
initMain
(
argc
,
argv
);
std
::
unique_ptr
<
ParameterServerController
>
pServerPtr
(
paddle
::
ParameterServerController
::
create
By
Gflags
());
pServerPtr
->
start
();
p
ServerPtr
->
join
();
std
::
unique_ptr
<
ParameterServerController
>
p
arameter
ServerPtr
(
paddle
::
ParameterServerController
::
create
From
Gflags
());
p
arameter
ServerPtr
->
start
();
p
arameterServerPtr
->
wait
();
return
0
;
}
paddle/pserver/ParameterServerController.cpp
浏览文件 @
aa9f5162
...
...
@@ -25,43 +25,44 @@ ParameterServerController::ParameterServerController(
int
numPorts
=
config
.
ports_num
()
+
config
.
ports_num_for_sparse
();
if
(
config
.
nics
().
empty
())
{
p
s
ervers_
.
resize
(
numPorts
);
p
arameterS
ervers_
.
resize
(
numPorts
);
for
(
int
i
=
0
;
i
<
numPorts
;
++
i
)
{
if
(
config
.
rdma_tcp
()
==
"rdma"
)
{
p
s
ervers_
[
i
].
reset
(
p
arameterS
ervers_
[
i
].
reset
(
new
ParameterServer2
(
std
::
string
(),
config
.
port
()
+
i
,
rdmaCpu
++
));
rdmaCpu
=
rdmaCpu
%
onlineCpus
;
}
else
{
p
s
ervers_
[
i
].
reset
(
p
arameterS
ervers_
[
i
].
reset
(
new
ParameterServer2
(
std
::
string
(),
config
.
port
()
+
i
));
}
CHECK
(
pservers_
[
i
]
->
init
())
<<
"Fail to initialize parameter server"
CHECK
(
parameterServers_
[
i
]
->
init
())
<<
"Fail to initialize parameter "
"server on port "
<<
config
.
port
()
+
i
;
}
}
else
{
str
::
split
(
config
.
nics
(),
','
,
&
devices
);
p
s
ervers_
.
resize
(
devices
.
size
()
*
numPorts
);
p
arameterS
ervers_
.
resize
(
devices
.
size
()
*
numPorts
);
for
(
int
i
=
0
;
i
<
numPorts
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
devices
.
size
();
++
j
)
{
if
(
config
.
rdma_tcp
()
==
"rdma"
)
{
p
s
ervers_
[
i
*
devices
.
size
()
+
j
].
reset
(
new
ParameterServer2
(
p
arameterS
ervers_
[
i
*
devices
.
size
()
+
j
].
reset
(
new
ParameterServer2
(
getIpAddr
(
devices
[
j
]),
config
.
port
()
+
i
,
rdmaCpu
++
));
rdmaCpu
=
rdmaCpu
%
onlineCpus
;
}
else
{
p
s
ervers_
[
i
*
devices
.
size
()
+
j
].
reset
(
p
arameterS
ervers_
[
i
*
devices
.
size
()
+
j
].
reset
(
new
ParameterServer2
(
getIpAddr
(
devices
[
j
]),
config
.
port
()
+
i
));
}
CHECK
(
p
s
ervers_
[
i
*
devices
.
size
()
+
j
]
->
init
())
<<
"Fail to initialize parameter server"
<<
devices
[
j
]
CHECK
(
p
arameterS
ervers_
[
i
*
devices
.
size
()
+
j
]
->
init
())
<<
"Fail to initialize parameter server
with device
"
<<
devices
[
j
]
<<
config
.
port
()
+
i
;
}
}
}
}
ParameterServerController
::~
ParameterServerController
()
{
this
->
join
();
}
ParameterServerController
::~
ParameterServerController
()
{
this
->
wait
();
}
ParameterServerController
*
ParameterServerController
::
create
By
Gflags
()
{
ParameterServerController
*
ParameterServerController
::
create
From
Gflags
()
{
ParameterServerConfig
config
;
config
.
set_nics
(
FLAGS_nics
);
...
...
@@ -79,21 +80,21 @@ ParameterServerController* ParameterServerController::create(
}
void
ParameterServerController
::
start
()
{
LOG
(
INFO
)
<<
"pserver sizes : "
<<
pservers_
.
size
();
LOG
(
INFO
)
<<
"number of parameterServer instances: "
<<
parameterServers_
.
size
();
int
i
=
0
;
for
(
const
auto
&
p
server
:
ps
ervers_
)
{
LOG
(
INFO
)
<<
"
pserver started : "
<<
i
;
p
s
erver
->
start
();
for
(
const
auto
&
p
arameterServer
:
parameterS
ervers_
)
{
LOG
(
INFO
)
<<
"
Starting parameterServer["
<<
i
<<
"]"
;
p
arameterS
erver
->
start
();
i
++
;
}
}
void
ParameterServerController
::
join
()
{
LOG
(
INFO
)
<<
"pserver sizes : "
<<
pservers_
.
size
();
void
ParameterServerController
::
wait
()
{
int
i
=
0
;
for
(
const
auto
&
p
server
:
ps
ervers_
)
{
LOG
(
INFO
)
<<
"
pserver join : "
<<
i
;
p
s
erver
->
join
();
for
(
const
auto
&
p
arameterServer
:
parameterS
ervers_
)
{
LOG
(
INFO
)
<<
"
Waiting parameterServer["
<<
i
<<
"]"
;
p
arameterS
erver
->
join
();
i
++
;
}
}
...
...
paddle/pserver/ParameterServerController.h
浏览文件 @
aa9f5162
...
...
@@ -21,6 +21,12 @@ limitations under the License. */
namespace
paddle
{
/**
* @brief ParameterServerController is used for create, init and manage multi
* parameter server instances. The num of the instances is decided by port
* num(the ports number for parameter send) and network devices configured
* by gflags or proto.
*/
class
ParameterServerController
final
{
public:
DISABLE_COPY
(
ParameterServerController
);
...
...
@@ -39,28 +45,30 @@ public:
* @brief create ParameterServerController from gflags, this is used for
* compatibility with the old usage of configuration by gflags.
*/
static
ParameterServerController
*
create
By
Gflags
();
static
ParameterServerController
*
create
From
Gflags
();
/**
* @brief create ParameterServerController with ParameterServerConfig, remove
* gflags from ParameterServer. Init all pservers thread according to the
* config.
* gflags from ParameterServer. Init all ParameterServer2 instances according
* to
* the config.
*/
static
ParameterServerController
*
create
(
const
ParameterServerConfig
&
config
);
/**
* @brief start all pserver thread in this ParameterServerController.
* @brief start all ParameterServer2 instances in this
* ParameterServerController.
*/
void
start
();
/**
* @brief join and wait for all
pserver
thread in this
* @brief join and wait for all
ParameterServer2 instances
thread in this
* ParameterServerController.
*/
void
join
();
void
wait
();
private:
std
::
vector
<
std
::
unique_ptr
<
ParameterServer2
>>
p
s
ervers_
;
std
::
vector
<
std
::
unique_ptr
<
ParameterServer2
>>
p
arameterS
ervers_
;
};
}
// namespace paddle
paddle/trainer/TrainerMain.cpp
浏览文件 @
aa9f5162
...
...
@@ -36,10 +36,11 @@ int main(int argc, char** argv) {
initMain
(
argc
,
argv
);
initPython
(
argc
,
argv
);
std
::
unique_ptr
<
ParameterServerController
>
pServerPtr
(
nullptr
);
std
::
unique_ptr
<
ParameterServerController
>
p
arameter
ServerPtr
(
nullptr
);
if
(
FLAGS_start_pserver
)
{
pServerPtr
.
reset
(
paddle
::
ParameterServerController
::
createByGflags
());
pServerPtr
->
start
();
parameterServerPtr
.
reset
(
paddle
::
ParameterServerController
::
createFromGflags
());
parameterServerPtr
->
start
();
}
Trainer
trainer
;
auto
config
=
TrainerConfigHelper
::
createFromFlags
();
...
...
proto/ParameterServerConfig.proto
浏览文件 @
aa9f5162
...
...
@@ -15,10 +15,17 @@ syntax = "proto2";
package
paddle
;
/**
* Configuration structure for ParameterClient2.
*/
message
ParameterClientConfig
{
required
int32
trainer_id
=
1
;
}
/**
* Configuration structure for ParameterServer2.
*/
message
ParameterServerConfig
{
// The ports number for parameter send,
// increment based on default port number
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录