Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7d8402a8
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7d8402a8
编写于
9月 04, 2023
作者:
H
huangjiyi
提交者:
GitHub
9月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix paddle namespace conflict when using paddle_flags (#56913)
* update * update * update
上级
25a0b46d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
28 deletion
+20
-28
paddle/fluid/distributed/ps/service/heter_client.cc
paddle/fluid/distributed/ps/service/heter_client.cc
+12
-12
paddle/phi/core/flags.h
paddle/phi/core/flags.h
+4
-8
paddle/utils/flags_native.h
paddle/utils/flags_native.h
+4
-8
未找到文件。
paddle/fluid/distributed/ps/service/heter_client.cc
浏览文件 @
7d8402a8
...
...
@@ -85,7 +85,7 @@ void HeterClient::CreateClient2XpuConnection() {
xpu_channels_
[
i
].
reset
(
new
brpc
::
Channel
());
if
(
xpu_channels_
[
i
]
->
Init
(
xpu_list_
[
i
].
c_str
(),
""
,
&
options
)
!=
0
)
{
VLOG
(
0
)
<<
"HeterClient channel init fail. Try Again"
;
auto
ip_port
=
::
paddle
::
string
::
Split
(
xpu_list_
[
i
],
':'
);
auto
ip_port
=
paddle
::
string
::
Split
(
xpu_list_
[
i
],
':'
);
std
::
string
ip
=
ip_port
[
0
];
int
port
=
std
::
stoi
(
ip_port
[
1
]);
std
::
string
int_ip_port
=
GetIntTypeEndpoint
(
ip
,
port
);
...
...
@@ -100,7 +100,7 @@ void HeterClient::CreateClient2XpuConnection() {
if
(
previous_xpu_channels_
[
i
]
->
Init
(
previous_xpu_list_
[
i
].
c_str
(),
""
,
&
options
)
!=
0
)
{
VLOG
(
0
)
<<
"HeterClient channel init fail. Try Again"
;
auto
ip_port
=
::
paddle
::
string
::
Split
(
previous_xpu_list_
[
i
],
':'
);
auto
ip_port
=
paddle
::
string
::
Split
(
previous_xpu_list_
[
i
],
':'
);
std
::
string
ip
=
ip_port
[
0
];
int
port
=
std
::
stoi
(
ip_port
[
1
]);
std
::
string
int_ip_port
=
GetIntTypeEndpoint
(
ip
,
port
);
...
...
@@ -167,13 +167,13 @@ void HeterClient::SendAndRecvAsync(
// int idx = 1; // for test
// LOG(INFO) << "xpu_channels_ size: " << xpu_channels_.size();
// channel = xpu_channels_[idx].get(); // 为了适配 send_and_recv op
//
::
paddle::distributed::PsService_Stub stub(channel);
// paddle::distributed::PsService_Stub stub(channel);
// stub.SendToSwitch(&closure->cntl, &request, &closure->response,
// closure); fut.wait();
VLOG
(
4
)
<<
"calling switch service done"
;
return
;
}
::
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
stub
.
SendAndRecvVariable
(
&
closure
->
cntl
,
&
request
,
&
closure
->
response
,
closure
);
}
...
...
@@ -181,11 +181,11 @@ void HeterClient::SendAndRecvAsync(
std
::
future
<
int32_t
>
HeterClient
::
SendCmd
(
uint32_t
table_id
,
int
cmd_id
,
const
std
::
vector
<
std
::
string
>&
params
)
{
size_t
request_call_num
=
xpu_channels_
.
size
();
::
paddle
::
distributed
::
DownpourBrpcClosure
*
closure
=
new
::
paddle
::
distributed
::
DownpourBrpcClosure
(
paddle
::
distributed
::
DownpourBrpcClosure
*
closure
=
new
paddle
::
distributed
::
DownpourBrpcClosure
(
request_call_num
,
[
request_call_num
,
cmd_id
](
void
*
done
)
{
int
ret
=
0
;
auto
*
closure
=
(
::
paddle
::
distributed
::
DownpourBrpcClosure
*
)
done
;
auto
*
closure
=
(
paddle
::
distributed
::
DownpourBrpcClosure
*
)
done
;
for
(
size_t
i
=
0
;
i
<
request_call_num
;
++
i
)
{
if
(
closure
->
check_response
(
i
,
cmd_id
)
!=
0
)
{
ret
=
-
1
;
...
...
@@ -204,7 +204,7 @@ std::future<int32_t> HeterClient::SendCmd(
for
(
const
auto
&
param
:
params
)
{
closure
->
request
(
i
)
->
add_params
(
param
);
}
::
paddle
::
distributed
::
PsService_Stub
rpc_stub
(
xpu_channels_
[
i
].
get
());
paddle
::
distributed
::
PsService_Stub
rpc_stub
(
xpu_channels_
[
i
].
get
());
closure
->
cntl
(
i
)
->
set_timeout_ms
(
FLAGS_pserver_timeout_ms
);
// cmd msg don't limit timeout for save/load
rpc_stub
.
service
(
...
...
@@ -270,7 +270,7 @@ int HeterClient::Send(const platform::DeviceContext& ctx,
}
brpc
::
Channel
*
channel
=
send_switch_channels_
[
0
].
get
();
// brpc::Channel* channel = xpu_channels_[0].get();
::
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
stub
.
SendToSwitch
(
&
closure
->
cntl
,
&
request
,
&
closure
->
ps_response
,
closure
);
VLOG
(
4
)
<<
"waiting SendToSwitch response result......"
;
...
...
@@ -317,7 +317,7 @@ int HeterClient::Send(int group_id,
send_switch_channels_
.
push_back
(
xpu_channels_
[
0
]);
}
brpc
::
Channel
*
channel
=
send_switch_channels_
[
0
].
get
();
::
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
stub
.
SendToSwitch
(
&
closure
->
cntl
,
&
request
,
&
closure
->
ps_response
,
closure
);
fut
.
wait
();
delete
closure
;
...
...
@@ -362,7 +362,7 @@ int HeterClient::Recv(const platform::DeviceContext& ctx,
recv_switch_channels_
.
push_back
(
xpu_channels_
[
1
]);
}
brpc
::
Channel
*
channel
=
recv_switch_channels_
[
0
].
get
();
::
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
stub
.
RecvFromSwitch
(
&
closure
->
cntl
,
&
request
,
&
closure
->
response
,
closure
);
fut
.
wait
();
VLOG
(
4
)
<<
"RecvFromSwitch done"
;
...
...
@@ -412,7 +412,7 @@ int HeterClient::Recv(int group_id,
recv_switch_channels_
.
push_back
(
xpu_channels_
[
0
]);
}
brpc
::
Channel
*
channel
=
recv_switch_channels_
[
0
].
get
();
::
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
paddle
::
distributed
::
PsService_Stub
stub
(
channel
);
stub
.
RecvFromSwitch
(
&
closure
->
cntl
,
&
request
,
&
closure
->
response
,
closure
);
fut
.
wait
();
VLOG
(
4
)
<<
"RecvFromSwitch done"
;
...
...
paddle/phi/core/flags.h
浏览文件 @
7d8402a8
...
...
@@ -59,24 +59,20 @@
#else // PADDLE_WITH_GFLAGS
#define PHI_DECLARE_VARIABLE(type, shorttype, name) \
namespace paddle { \
namespace flags { \
namespace paddle_flags { \
extern PHI_IMPORT_FLAG type FLAGS_##name; \
} \
} \
using paddle::flags::FLAGS_##name
using paddle_flags::FLAGS_##name
#define PHI_DEFINE_VARIABLE(type, shorttype, name, default_value, description) \
namespace paddle { \
namespace flags { \
namespace paddle_flags { \
static const type FLAGS_##name##_default = default_value; \
PHI_EXPORT_FLAG type FLAGS_##name = default_value; \
/* Register FLAG */
\
static ::paddle::flags::FlagRegisterer flag_##name##_registerer( \
#name, description, __FILE__, &FLAGS_##name##_default, &FLAGS_##name); \
} \
} \
using paddle::flags::FLAGS_##name
using paddle_flags::FLAGS_##name
#endif
...
...
paddle/utils/flags_native.h
浏览文件 @
7d8402a8
...
...
@@ -74,12 +74,10 @@ void PrintAllFlagHelp(bool to_file = false,
// ----------------------------DECLARE FLAGS----------------------------
#define PD_DECLARE_VARIABLE(type, name) \
namespace paddle { \
namespace flags { \
namespace paddle_flags { \
extern type FLAGS_##name; \
} \
} \
using paddle::flags::FLAGS_##name
using paddle_flags::FLAGS_##name
#define PD_DECLARE_bool(name) PD_DECLARE_VARIABLE(bool, name)
#define PD_DECLARE_int32(name) PD_DECLARE_VARIABLE(int32_t, name)
...
...
@@ -105,16 +103,14 @@ class FlagRegisterer {
// ----------------------------DEFINE FLAGS----------------------------
#define PD_DEFINE_VARIABLE(type, name, default_value, description) \
namespace paddle { \
namespace flags { \
namespace paddle_flags { \
static const type FLAGS_##name##_default = default_value; \
type FLAGS_##name = default_value; \
/* Register FLAG */
\
static ::paddle::flags::FlagRegisterer flag_##name##_registerer( \
#name, description, __FILE__, &FLAGS_##name##_default, &FLAGS_##name); \
} \
} \
using paddle::flags::FLAGS_##name
using paddle_flags::FLAGS_##name
#define PD_DEFINE_bool(name, val, txt) PD_DEFINE_VARIABLE(bool, name, val, txt)
#define PD_DEFINE_int32(name, val, txt) \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录