Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
9066b74f
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9066b74f
编写于
3月 15, 2021
作者:
W
WangXi
提交者:
GitHub
3月 15, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
c_gen_nccl_id add SocketServer to persit server (#31589)
上级
a32e8bf1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
40 addition
and
1 deletion
+40
-1
paddle/fluid/operators/collective/c_gen_nccl_id_op.cc
paddle/fluid/operators/collective/c_gen_nccl_id_op.cc
+2
-1
paddle/fluid/platform/gen_comm_id_helper.cc
paddle/fluid/platform/gen_comm_id_helper.cc
+18
-0
paddle/fluid/platform/gen_comm_id_helper.h
paddle/fluid/platform/gen_comm_id_helper.h
+20
-0
未找到文件。
paddle/fluid/operators/collective/c_gen_nccl_id_op.cc
浏览文件 @
9066b74f
...
@@ -75,7 +75,8 @@ class CGenNCCLIdOp : public framework::OperatorBase {
...
@@ -75,7 +75,8 @@ class CGenNCCLIdOp : public framework::OperatorBase {
platform
::
SendBroadCastCommID
(
endpoint_list
,
&
nccl_ids
);
platform
::
SendBroadCastCommID
(
endpoint_list
,
&
nccl_ids
);
}
else
{
}
else
{
std
::
string
endpoint
=
Attr
<
std
::
string
>
(
"endpoint"
);
std
::
string
endpoint
=
Attr
<
std
::
string
>
(
"endpoint"
);
platform
::
RecvBroadCastCommID
(
endpoint
,
&
nccl_ids
);
int
server_fd
=
platform
::
SocketServer
::
GetInstance
(
endpoint
).
socket
();
platform
::
RecvBroadCastCommID
(
server_fd
,
endpoint
,
&
nccl_ids
);
}
}
CopyNCCLIDToVar
(
nccl_ids
,
func
,
scope
);
CopyNCCLIDToVar
(
nccl_ids
,
func
,
scope
);
...
...
paddle/fluid/platform/gen_comm_id_helper.cc
浏览文件 @
9066b74f
...
@@ -36,6 +36,8 @@ limitations under the License. */
...
@@ -36,6 +36,8 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
platform
{
namespace
platform
{
std
::
once_flag
SocketServer
::
init_flag_
;
constexpr
char
COMM_HEAD
[]
=
"_pd_gen_comm_id_"
;
constexpr
char
COMM_HEAD
[]
=
"_pd_gen_comm_id_"
;
// Check system calls, such as socket, bind.
// Check system calls, such as socket, bind.
...
@@ -330,6 +332,22 @@ void RecvBroadCastCommID(int server_fd, std::string endpoint,
...
@@ -330,6 +332,22 @@ void RecvBroadCastCommID(int server_fd, std::string endpoint,
CloseSocket
(
client
);
CloseSocket
(
client
);
}
}
SocketServer
&
SocketServer
::
GetInstance
(
const
std
::
string
&
end_point
)
{
static
SocketServer
instance
;
std
::
call_once
(
init_flag_
,
[
&
]()
{
instance
.
server_fd_
=
CreateListenSocket
(
end_point
);
instance
.
end_point_
=
end_point
;
});
PADDLE_ENFORCE_NE
(
instance
.
server_fd_
,
-
1
,
platform
::
errors
::
Unavailable
(
"listen socket failed with end_point=%s"
,
end_point
));
PADDLE_ENFORCE_EQ
(
instance
.
end_point_
,
end_point
,
platform
::
errors
::
InvalidArgument
(
"old end_point=%s must equal with new end_point=%s"
,
instance
.
end_point_
,
end_point
));
return
instance
;
}
/// template instantiation
/// template instantiation
#define INSTANT_TEMPLATE(Type) \
#define INSTANT_TEMPLATE(Type) \
template void SendBroadCastCommID<Type>(std::vector<std::string> servers, \
template void SendBroadCastCommID<Type>(std::vector<std::string> servers, \
...
...
paddle/fluid/platform/gen_comm_id_helper.h
浏览文件 @
9066b74f
...
@@ -17,6 +17,8 @@ limitations under the License. */
...
@@ -17,6 +17,8 @@ limitations under the License. */
#if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) || \
#if defined(PADDLE_WITH_NCCL) || defined(PADDLE_WITH_RCCL) || \
defined(PADDLE_WITH_XPU_BKCL)
defined(PADDLE_WITH_XPU_BKCL)
#include <functional>
#include <functional>
#include <memory>
#include <mutex>
#include <string>
#include <string>
#include <vector>
#include <vector>
...
@@ -39,6 +41,24 @@ void RecvBroadCastCommID(std::string endpoint,
...
@@ -39,6 +41,24 @@ void RecvBroadCastCommID(std::string endpoint,
template
<
typename
CommUniqueId
>
template
<
typename
CommUniqueId
>
void
RecvBroadCastCommID
(
int
server_fd
,
std
::
string
endpoint
,
void
RecvBroadCastCommID
(
int
server_fd
,
std
::
string
endpoint
,
std
::
vector
<
CommUniqueId
>*
nccl_ids
);
std
::
vector
<
CommUniqueId
>*
nccl_ids
);
class
SocketServer
{
public:
SocketServer
()
=
default
;
~
SocketServer
()
{
CloseSocket
(
server_fd_
);
}
int
socket
()
const
{
return
server_fd_
;
}
static
SocketServer
&
GetInstance
(
const
std
::
string
&
end_point
);
private:
int
server_fd_
{
-
1
};
std
::
string
end_point_
;
static
std
::
once_flag
init_flag_
;
};
}
// namespace platform
}
// namespace platform
}
// namespace paddle
}
// namespace paddle
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录