Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Oneflow-Inc
oneflow
提交
c126c1a9
O
oneflow
项目概览
Oneflow-Inc
/
oneflow
上一次同步 2 年多
通知
13
Star
2733
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oneflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c126c1a9
编写于
9月 28, 2017
作者:
W
willzhang4a58
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
request read msg
Former-commit-id:
a1b01564
上级
6e50be08
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
4 deletion
+53
-4
oneflow/core/comm_network/epoll/socket_message.h
oneflow/core/comm_network/epoll/socket_message.h
+19
-3
oneflow/core/comm_network/epoll/socket_write_helper.cpp
oneflow/core/comm_network/epoll/socket_write_helper.cpp
+30
-1
oneflow/core/comm_network/epoll/socket_write_helper.h
oneflow/core/comm_network/epoll/socket_write_helper.h
+4
-0
未找到文件。
oneflow/core/comm_network/epoll/socket_message.h
浏览文件 @
c126c1a9
...
@@ -18,7 +18,16 @@
...
@@ -18,7 +18,16 @@
namespace
oneflow
{
namespace
oneflow
{
enum
class
SocketMsgType
{
kRequestWrite
=
0
,
kActor
};
#define SOCKET_MSG_TYPE_SEQ \
OF_PP_MAKE_TUPLE_SEQ(RequestWrite, request_write) \
OF_PP_MAKE_TUPLE_SEQ(RequestRead, request_read) \
OF_PP_MAKE_TUPLE_SEQ(Actor, actor)
enum
class
SocketMsgType
{
#define MAKE_ENTRY(x, y) k##x,
OF_PP_FOR_EACH_TUPLE
(
MAKE_ENTRY
,
SOCKET_MSG_TYPE_SEQ
)
#undef MAKE_ENTRY
};
struct
RequestWriteMsg
{
struct
RequestWriteMsg
{
const
void
*
src_token
;
const
void
*
src_token
;
...
@@ -27,11 +36,18 @@ struct RequestWriteMsg {
...
@@ -27,11 +36,18 @@ struct RequestWriteMsg {
void
*
read_id
;
void
*
read_id
;
};
};
struct
RequestReadMsg
{
const
void
*
src_token
;
const
void
*
dst_token
;
void
*
read_id
;
};
struct
SocketMsg
{
struct
SocketMsg
{
SocketMsgType
msg_type
;
SocketMsgType
msg_type
;
union
{
union
{
RequestWriteMsg
request_write_msg
;
#define MAKE_ENTRY(x, y) x##Msg y##_msg;
ActorMsg
actor_msg
;
OF_PP_FOR_EACH_TUPLE
(
MAKE_ENTRY
,
SOCKET_MSG_TYPE_SEQ
)
#undef MAKE_ENTRY
};
};
};
};
...
...
oneflow/core/comm_network/epoll/socket_write_helper.cpp
浏览文件 @
c126c1a9
#include "oneflow/core/comm_network/epoll/socket_write_helper.h"
#include "oneflow/core/comm_network/epoll/socket_write_helper.h"
#include "oneflow/core/comm_network/epoll/socket_memory_desc.h"
#ifdef PLATFORM_POSIX
#ifdef PLATFORM_POSIX
...
@@ -93,13 +94,41 @@ bool SocketWriteHelper::DoCurWrite(
...
@@ -93,13 +94,41 @@ bool SocketWriteHelper::DoCurWrite(
}
}
}
}
bool
SocketWriteHelper
::
SetStatusWhenMsgHeadDone
()
{
TODO
();
}
bool
SocketWriteHelper
::
SetStatusWhenMsgHeadDone
()
{
switch
(
cur_msg_
.
msg_type
)
{
#define MAKE_ENTRY(x, y) \
case SocketMsgType::k##x: return SetStatusWhen##x##MsgHeadDone();
OF_PP_FOR_EACH_TUPLE
(
MAKE_ENTRY
,
SOCKET_MSG_TYPE_SEQ
);
#undef MAKE_ENTRY
default:
UNEXPECTED_RUN
();
}
UNEXPECTED_RUN
();
}
bool
SocketWriteHelper
::
SetStatusWhenMsgBodyDone
()
{
bool
SocketWriteHelper
::
SetStatusWhenMsgBodyDone
()
{
cur_write_handle_
=
&
SocketWriteHelper
::
InitMsgWriteHandle
;
cur_write_handle_
=
&
SocketWriteHelper
::
InitMsgWriteHandle
;
return
true
;
return
true
;
}
}
bool
SocketWriteHelper
::
SetStatusWhenRequestWriteMsgHeadDone
()
{
cur_write_handle_
=
&
SocketWriteHelper
::
InitMsgWriteHandle
;
return
true
;
}
bool
SocketWriteHelper
::
SetStatusWhenRequestReadMsgHeadDone
()
{
const
void
*
src_token
=
cur_msg_
.
request_read_msg
.
src_token
;
auto
src_mem_desc
=
static_cast
<
const
SocketMemDesc
*>
(
src_token
);
write_ptr_
=
reinterpret_cast
<
const
char
*>
(
src_mem_desc
->
mem_ptr
);
write_size_
=
src_mem_desc
->
byte_size
;
cur_write_handle_
=
&
SocketWriteHelper
::
MsgBodyWriteHandle
;
return
true
;
}
bool
SocketWriteHelper
::
SetStatusWhenActorMsgHeadDone
()
{
cur_write_handle_
=
&
SocketWriteHelper
::
InitMsgWriteHandle
;
return
true
;
}
}
// namespace oneflow
}
// namespace oneflow
#endif // PLATFORM_POSIX
#endif // PLATFORM_POSIX
oneflow/core/comm_network/epoll/socket_write_helper.h
浏览文件 @
c126c1a9
...
@@ -31,6 +31,10 @@ class SocketWriteHelper final {
...
@@ -31,6 +31,10 @@ class SocketWriteHelper final {
bool
SetStatusWhenMsgHeadDone
();
bool
SetStatusWhenMsgHeadDone
();
bool
SetStatusWhenMsgBodyDone
();
bool
SetStatusWhenMsgBodyDone
();
#define MAKE_ENTRY(x, y) bool SetStatusWhen##x##MsgHeadDone();
OF_PP_FOR_EACH_TUPLE
(
MAKE_ENTRY
,
SOCKET_MSG_TYPE_SEQ
);
#undef MAKE_ENTRY
int
sockfd_
;
int
sockfd_
;
CpuStream
*
cpu_stream_
;
CpuStream
*
cpu_stream_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录