Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c413c469
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
c413c469
编写于
6月 21, 2018
作者:
Y
Yancey
提交者:
GitHub
6月 21, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11603 from Yancey1989/rename_details_folder
move dist codes from operaotrs/detail to operators/distributed
上级
9cc1eb43
712adc78
变更
39
显示空白变更内容
内联
并排
Showing
39 changed file
with
201 addition
and
204 deletion
+201
-204
paddle/fluid/framework/executor.cc
paddle/fluid/framework/executor.cc
+3
-3
paddle/fluid/operators/CMakeLists.txt
paddle/fluid/operators/CMakeLists.txt
+7
-14
paddle/fluid/operators/detail/macros.h
paddle/fluid/operators/detail/macros.h
+8
-8
paddle/fluid/operators/distributed/CMakeLists.txt
paddle/fluid/operators/distributed/CMakeLists.txt
+0
-5
paddle/fluid/operators/distributed/brpc_client.cc
paddle/fluid/operators/distributed/brpc_client.cc
+3
-3
paddle/fluid/operators/distributed/brpc_client.h
paddle/fluid/operators/distributed/brpc_client.h
+4
-4
paddle/fluid/operators/distributed/brpc_server.cc
paddle/fluid/operators/distributed/brpc_server.cc
+11
-11
paddle/fluid/operators/distributed/brpc_server.h
paddle/fluid/operators/distributed/brpc_server.h
+4
-4
paddle/fluid/operators/distributed/bytebuffer_stream.cc
paddle/fluid/operators/distributed/bytebuffer_stream.cc
+3
-3
paddle/fluid/operators/distributed/bytebuffer_stream.h
paddle/fluid/operators/distributed/bytebuffer_stream.h
+2
-2
paddle/fluid/operators/distributed/grpc_client.cc
paddle/fluid/operators/distributed/grpc_client.cc
+4
-4
paddle/fluid/operators/distributed/grpc_client.h
paddle/fluid/operators/distributed/grpc_client.h
+4
-4
paddle/fluid/operators/distributed/grpc_serde_test.cc
paddle/fluid/operators/distributed/grpc_serde_test.cc
+7
-7
paddle/fluid/operators/distributed/grpc_server.cc
paddle/fluid/operators/distributed/grpc_server.cc
+7
-6
paddle/fluid/operators/distributed/grpc_server.h
paddle/fluid/operators/distributed/grpc_server.h
+8
-8
paddle/fluid/operators/distributed/grpc_service.h
paddle/fluid/operators/distributed/grpc_service.h
+10
-9
paddle/fluid/operators/distributed/proto_encoder_helper.h
paddle/fluid/operators/distributed/proto_encoder_helper.h
+2
-2
paddle/fluid/operators/distributed/request_handler.h
paddle/fluid/operators/distributed/request_handler.h
+2
-2
paddle/fluid/operators/distributed/request_handler_impl.cc
paddle/fluid/operators/distributed/request_handler_impl.cc
+4
-4
paddle/fluid/operators/distributed/request_handler_impl.h
paddle/fluid/operators/distributed/request_handler_impl.h
+3
-3
paddle/fluid/operators/distributed/rpc_client.cc
paddle/fluid/operators/distributed/rpc_client.cc
+3
-3
paddle/fluid/operators/distributed/rpc_client.h
paddle/fluid/operators/distributed/rpc_client.h
+2
-2
paddle/fluid/operators/distributed/rpc_server.cc
paddle/fluid/operators/distributed/rpc_server.cc
+3
-3
paddle/fluid/operators/distributed/rpc_server.h
paddle/fluid/operators/distributed/rpc_server.h
+3
-3
paddle/fluid/operators/distributed/rpc_server_test.cc
paddle/fluid/operators/distributed/rpc_server_test.cc
+12
-10
paddle/fluid/operators/distributed/send_recv.proto
paddle/fluid/operators/distributed/send_recv.proto
+0
-0
paddle/fluid/operators/distributed/sendrecvop_utils.cc
paddle/fluid/operators/distributed/sendrecvop_utils.cc
+7
-7
paddle/fluid/operators/distributed/sendrecvop_utils.h
paddle/fluid/operators/distributed/sendrecvop_utils.h
+4
-4
paddle/fluid/operators/distributed/variable_response.cc
paddle/fluid/operators/distributed/variable_response.cc
+10
-10
paddle/fluid/operators/distributed/variable_response.h
paddle/fluid/operators/distributed/variable_response.h
+5
-5
paddle/fluid/operators/fetch_barrier_op.cc
paddle/fluid/operators/fetch_barrier_op.cc
+2
-2
paddle/fluid/operators/gen_nccl_id_op.cc
paddle/fluid/operators/gen_nccl_id_op.cc
+9
-8
paddle/fluid/operators/listen_and_serv_op.cc
paddle/fluid/operators/listen_and_serv_op.cc
+18
-16
paddle/fluid/operators/listen_and_serv_op.h
paddle/fluid/operators/listen_and_serv_op.h
+8
-7
paddle/fluid/operators/prefetch_op.cc
paddle/fluid/operators/prefetch_op.cc
+2
-2
paddle/fluid/operators/recv_op.cc
paddle/fluid/operators/recv_op.cc
+2
-2
paddle/fluid/operators/send_barrier_op.cc
paddle/fluid/operators/send_barrier_op.cc
+2
-2
paddle/fluid/operators/send_op.cc
paddle/fluid/operators/send_op.cc
+2
-2
paddle/fluid/operators/test_send_nccl_id.cc
paddle/fluid/operators/test_send_nccl_id.cc
+11
-10
未找到文件。
paddle/fluid/framework/executor.cc
浏览文件 @
c413c469
...
...
@@ -21,7 +21,7 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/reader.h"
#ifdef PADDLE_WITH_DISTRIBUTE
#include "paddle/fluid/operators/d
etail
/grpc_client.h"
#include "paddle/fluid/operators/d
istributed
/grpc_client.h"
#endif
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/profiler.h"
...
...
@@ -49,8 +49,8 @@ Executor::Executor(const platform::Place& place) : place_(place) {}
#ifdef PADDLE_WITH_DISTRIBUTE
void
Executor
::
Complete
()
{
::
paddle
::
operators
::
d
etail
::
RPCClient
::
GetInstance
<
::
paddle
::
operators
::
d
etail
::
GRPCClient
>
()
::
paddle
::
operators
::
d
istributed
::
RPCClient
::
GetInstance
<
::
paddle
::
operators
::
d
istributed
::
GRPCClient
>
()
->
SendComplete
();
}
#endif
...
...
paddle/fluid/operators/CMakeLists.txt
浏览文件 @
c413c469
...
...
@@ -184,8 +184,8 @@ else()
set
(
DEPS_OPS
${
DEPS_OPS
}
nccl_op
)
endif
()
add_subdirectory
(
detail
)
if
(
WITH_DISTRIBUTE
)
add_subdirectory
(
distributed
)
set
(
DISTRIBUTE_DEPS
""
)
if
(
WITH_GRPC
)
...
...
@@ -195,18 +195,11 @@ if(WITH_DISTRIBUTE)
endif
()
set
(
DISTRIBUTE_COMPILE_FLAGS
"-Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor"
)
op_library
(
prefetch_op DEPS
${
DISTRIBUTE_DEPS
}
)
set_source_files_properties
(
prefetch_op.cc PROPERTIES COMPILE_FLAGS
${
DISTRIBUTE_COMPILE_FLAGS
}
)
op_library
(
recv_op DEPS
${
DISTRIBUTE_DEPS
}
)
set_source_files_properties
(
recv_op.cc PROPERTIES COMPILE_FLAGS
${
DISTRIBUTE_COMPILE_FLAGS
}
)
op_library
(
listen_and_serv_op DEPS
${
DISTRIBUTE_DEPS
}
)
set_source_files_properties
(
listen_and_serv_op.cc PROPERTIES COMPILE_FLAGS
${
DISTRIBUTE_COMPILE_FLAGS
}
)
op_library
(
send_op DEPS
${
DISTRIBUTE_DEPS
}
)
set_source_files_properties
(
send_op.cc PROPERTIES COMPILE_FLAGS
${
DISTRIBUTE_COMPILE_FLAGS
}
)
op_library
(
send_barrier_op DEPS
${
DISTRIBUTE_DEPS
}
)
op_library
(
fetch_barrier_op DEPS
${
DISTRIBUTE_DEPS
}
)
set_source_files_properties
(
send_barrier_op.cc PROPERTIES COMPILE_FLAGS
${
DISTRIBUTE_COMPILE_FLAGS
}
)
set_source_files_properties
(
fetch_barrier_op.cc PROPERTIES COMPILE_FLAGS
${
DISTRIBUTE_COMPILE_FLAGS
}
)
foreach
(
dist_op
"prefetch_op"
"listen_and_serv_op"
"send_op"
"recv_op"
"send_barrier_op"
"fetch_barrier_op"
)
op_library
(
${
dist_op
}
DEPS
${
DISTRIBUTE_DEPS
}
)
set_source_files_properties
(
${
dist_op
}
.cc PROPERTIES COMPILE_FLAGS
${
DISTRIBUTE_COMPILE_FLAGS
}
)
endforeach
()
#set_source_files_properties(send_recv_op_test.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
#cc_test(test_send_recv SRCS send_recv_op_test.cc DEPS prefetch_op send_op
# listen_and_serv_op sum_op executor SERIAL)
...
...
paddle/fluid/operators/detail/macros.h
浏览文件 @
c413c469
...
...
@@ -15,13 +15,13 @@
#pragma once
#ifdef PADDLE_WITH_GRPC
#include "paddle/fluid/operators/d
etail
/grpc_client.h"
#include "paddle/fluid/operators/d
etail
/grpc_server.h"
#define RPCSERVER_T d
etail
::AsyncGRPCServer
#define RPCCLIENT_T d
etail
::GRPCClient
#include "paddle/fluid/operators/d
istributed
/grpc_client.h"
#include "paddle/fluid/operators/d
istributed
/grpc_server.h"
#define RPCSERVER_T d
istributed
::AsyncGRPCServer
#define RPCCLIENT_T d
istributed
::GRPCClient
#else
#include "paddle/fluid/operators/d
etail
/brpc_client.h"
#include "paddle/fluid/operators/d
etail
/brpc_server.h"
#define RPCSERVER_T d
etail
::AsyncBRPCServer
#define RPCCLIENT_T d
etail
::BRPCClient
#include "paddle/fluid/operators/d
istributed
/brpc_client.h"
#include "paddle/fluid/operators/d
istributed
/brpc_server.h"
#define RPCSERVER_T d
istributed
::AsyncBRPCServer
#define RPCCLIENT_T d
istributed
::BRPCClient
#endif
paddle/fluid/operators/d
etail
/CMakeLists.txt
→
paddle/fluid/operators/d
istributed
/CMakeLists.txt
浏览文件 @
c413c469
if
(
NOT WITH_DISTRIBUTE
)
return
()
endif
()
if
(
WITH_GRPC
)
grpc_library
(
sendrecvop_grpc SRCS bytebuffer_stream.cc sendrecvop_utils.cc grpc_client.cc
request_handler_impl.cc rpc_client.cc rpc_server.cc grpc_server.cc variable_response.cc PROTO send_recv.proto DEPS lod_tensor
...
...
paddle/fluid/operators/d
etail
/brpc_client.cc
→
paddle/fluid/operators/d
istributed
/brpc_client.cc
浏览文件 @
c413c469
...
...
@@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/operators/d
etail
/brpc_client.h"
#include "paddle/fluid/operators/d
istributed
/brpc_client.h"
#include "paddle/fluid/framework/threadpool.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
DEFINE_int32
(
brpc_channel_num
,
24
,
"Number of channels to send requests connected to one server"
);
...
...
@@ -175,6 +175,6 @@ ChannelQueuePtr BRPCClient::GetChannel(const std::string& ep) {
return
q
;
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/brpc_client.h
→
paddle/fluid/operators/d
istributed
/brpc_client.h
浏览文件 @
c413c469
...
...
@@ -31,13 +31,13 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/operators/d
etail
/rpc_client.h"
#include "paddle/fluid/operators/d
etail
/send_recv.pb.h"
#include "paddle/fluid/operators/d
istributed
/rpc_client.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.pb.h"
#include "paddle/fluid/platform/macros.h" // for DISABLE_COPY_AND_ASSIGN
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
struct
ChannelContext
{
brpc
::
Channel
channel
;
...
...
@@ -95,6 +95,6 @@ class BRPCClient : public RPCClient {
DISABLE_COPY_AND_ASSIGN
(
BRPCClient
);
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/brpc_server.cc
→
paddle/fluid/operators/d
istributed
/brpc_server.cc
浏览文件 @
c413c469
...
...
@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/operators/d
etail
/brpc_server.h"
#include "paddle/fluid/operators/d
etail
/request_handler.h"
#include "paddle/fluid/operators/d
istributed
/brpc_server.h"
#include "paddle/fluid/operators/d
istributed
/request_handler.h"
namespace
sendrecv
{
typedef
std
::
unordered_map
<
std
::
string
,
paddle
::
operators
::
d
etail
::
RequestHandler
*>
paddle
::
operators
::
d
istributed
::
RequestHandler
*>
HandlerMap
;
class
BRPCServiceImpl
:
public
SendRecvService
{
...
...
@@ -27,17 +27,17 @@ class BRPCServiceImpl : public SendRecvService {
:
request_send_h_
(
nullptr
),
request_get_h_
(
nullptr
),
request_prefetch_h_
(
nullptr
)
{
auto
it
=
rpc_call_map
.
find
(
paddle
::
operators
::
d
etail
::
kRequestSend
);
auto
it
=
rpc_call_map
.
find
(
paddle
::
operators
::
d
istributed
::
kRequestSend
);
if
(
it
!=
rpc_call_map
.
end
())
{
request_send_h_
=
it
->
second
;
}
it
=
rpc_call_map
.
find
(
paddle
::
operators
::
d
etail
::
kRequestSend
);
it
=
rpc_call_map
.
find
(
paddle
::
operators
::
d
istributed
::
kRequestSend
);
if
(
it
!=
rpc_call_map
.
end
())
{
request_get_h_
=
it
->
second
;
}
it
=
rpc_call_map
.
find
(
paddle
::
operators
::
d
etail
::
kRequestPrefetch
);
it
=
rpc_call_map
.
find
(
paddle
::
operators
::
d
istributed
::
kRequestPrefetch
);
if
(
it
!=
rpc_call_map
.
end
())
{
request_prefetch_h_
=
it
->
second
;
}
...
...
@@ -88,15 +88,15 @@ class BRPCServiceImpl : public SendRecvService {
}
private:
paddle
::
operators
::
d
etail
::
RequestHandler
*
request_send_h_
;
paddle
::
operators
::
d
etail
::
RequestHandler
*
request_get_h_
;
paddle
::
operators
::
d
etail
::
RequestHandler
*
request_prefetch_h_
;
paddle
::
operators
::
d
istributed
::
RequestHandler
*
request_send_h_
;
paddle
::
operators
::
d
istributed
::
RequestHandler
*
request_get_h_
;
paddle
::
operators
::
d
istributed
::
RequestHandler
*
request_prefetch_h_
;
};
}
// namespace sendrecv
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
void
AsyncBRPCServer
::
StartServer
()
{
// Instance of your service.
...
...
@@ -139,6 +139,6 @@ void AsyncBRPCServer::WaitServerReady() {
VLOG
(
3
)
<<
"AsyncGRPCServer WaitSeverReady"
;
}
};
// namespace d
etail
};
// namespace d
istributed
};
// namespace operators
};
// namespace paddle
paddle/fluid/operators/d
etail
/brpc_server.h
→
paddle/fluid/operators/d
istributed
/brpc_server.h
浏览文件 @
c413c469
...
...
@@ -19,12 +19,12 @@ limitations under the License. */
#include <string>
#include "brpc/server.h"
#include "paddle/fluid/operators/d
etail
/rpc_server.h"
#include "paddle/fluid/operators/d
etail
/send_recv.pb.h"
#include "paddle/fluid/operators/d
istributed
/rpc_server.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.pb.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
class
AsyncBRPCServer
final
:
public
RPCServer
{
public:
...
...
@@ -48,6 +48,6 @@ class AsyncBRPCServer final : public RPCServer {
int
ready_
;
};
};
// namespace d
etail
};
// namespace d
istributed
};
// namespace operators
};
// namespace paddle
paddle/fluid/operators/d
etail
/bytebuffer_stream.cc
→
paddle/fluid/operators/d
istributed
/bytebuffer_stream.cc
浏览文件 @
c413c469
...
...
@@ -17,11 +17,11 @@ limitations under the License. */
// file and did some modifications so that we can send gRPC
// requests without too much copying of the tensor data.
#include "paddle/fluid/operators/d
etail
/bytebuffer_stream.h"
#include "paddle/fluid/operators/d
istributed
/bytebuffer_stream.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
GrpcByteBufferSource
::
GrpcByteBufferSource
()
{}
...
...
@@ -83,6 +83,6 @@ google::protobuf::int64 GrpcByteBufferSource::ByteCount() const {
return
byte_count_
;
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/bytebuffer_stream.h
→
paddle/fluid/operators/d
istributed
/bytebuffer_stream.h
浏览文件 @
c413c469
...
...
@@ -106,7 +106,7 @@ class GrpcBufferReader final
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
// Source provides a way for a particular RPC implementation to provide
// received data to ParseFrom.
class
Source
{
...
...
@@ -183,6 +183,6 @@ class GrpcByteSource : public Source {
char
space_
[
sizeof
(
Reader
)];
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/grpc_client.cc
→
paddle/fluid/operators/d
istributed
/grpc_client.cc
浏览文件 @
c413c469
...
...
@@ -12,19 +12,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/d
etail
/grpc_client.h"
#include "paddle/fluid/operators/d
istributed
/grpc_client.h"
#include <sys/time.h>
#include <limits>
#include "paddle/fluid/framework/threadpool.h"
#include "paddle/fluid/operators/d
etail
/request_handler.h"
#include "paddle/fluid/operators/d
istributed
/request_handler.h"
#include "paddle/fluid/platform/profiler.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
void
GRPCClient
::
InitImpl
()
{
InitEventLoop
();
}
...
...
@@ -276,6 +276,6 @@ std::shared_ptr<grpc::Channel> GRPCClient::GetChannel(const std::string& ep) {
return
ch
;
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/grpc_client.h
→
paddle/fluid/operators/d
istributed
/grpc_client.h
浏览文件 @
c413c469
...
...
@@ -38,13 +38,13 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/operators/d
etail
/rpc_client.h"
#include "paddle/fluid/operators/d
etail
/sendrecvop_utils.h"
#include "paddle/fluid/operators/d
istributed
/rpc_client.h"
#include "paddle/fluid/operators/d
istributed
/sendrecvop_utils.h"
#include "paddle/fluid/platform/macros.h" // for DISABLE_COPY_AND_ASSIGN
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
struct
VarHandle
{
std
::
string
ep
;
...
...
@@ -226,6 +226,6 @@ class GRPCClient : public RPCClient {
DISABLE_COPY_AND_ASSIGN
(
GRPCClient
);
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/grpc_serde_test.cc
→
paddle/fluid/operators/d
istributed
/grpc_serde_test.cc
浏览文件 @
c413c469
...
...
@@ -21,8 +21,8 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/framework/variable.h"
#include "paddle/fluid/operators/d
etail
/sendrecvop_utils.h"
#include "paddle/fluid/operators/d
etail
/variable_response.h"
#include "paddle/fluid/operators/d
istributed
/sendrecvop_utils.h"
#include "paddle/fluid/operators/d
istributed
/variable_response.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/string/printf.h"
...
...
@@ -50,7 +50,7 @@ void RunSerdeTestSelectedRows(platform::Place place) {
for
(
int
i
=
0
;
i
<
564
;
++
i
)
rows
->
push_back
(
i
);
::
grpc
::
ByteBuffer
msg
;
operators
::
d
etail
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
operators
::
d
istributed
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
EXPECT_GT
(
msg
.
Length
(),
static_cast
<
size_t
>
(
0
));
// deserialize
...
...
@@ -81,10 +81,10 @@ void RunSerdeTestSelectedRows(platform::Place place) {
// deserialize zero-copy
// framework::Variable var2;
// operators::d
etail
::DeserializeFromByteBuffer(msg, ctx, &var2);
// operators::d
istributed
::DeserializeFromByteBuffer(msg, ctx, &var2);
framework
::
Scope
scope
;
scope
.
Var
(
"myvar"
);
operators
::
d
etail
::
VariableResponse
resp
(
&
scope
,
&
ctx
);
operators
::
d
istributed
::
VariableResponse
resp
(
&
scope
,
&
ctx
);
EXPECT_EQ
(
resp
.
Parse
(
msg
),
0
);
framework
::
Variable
*
var2
=
resp
.
GetVar
();
...
...
@@ -128,7 +128,7 @@ void RunTestLodTensor(platform::Place place, int from_type = 0) {
math
::
set_constant
(
ctx
,
tensor
,
31.9
);
::
grpc
::
ByteBuffer
msg
;
operators
::
d
etail
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
operators
::
d
istributed
::
SerializeToByteBuffer
(
"myvar"
,
&
var
,
ctx
,
&
msg
);
EXPECT_GT
(
msg
.
Length
(),
static_cast
<
size_t
>
(
0
));
// deserialize
...
...
@@ -171,7 +171,7 @@ void RunTestLodTensor(platform::Place place, int from_type = 0) {
// deserialize zero-copy
framework
::
Scope
scope
;
scope
.
Var
(
"myvar"
);
operators
::
d
etail
::
VariableResponse
resp
(
&
scope
,
&
ctx
);
operators
::
d
istributed
::
VariableResponse
resp
(
&
scope
,
&
ctx
);
if
(
from_type
==
0
)
{
EXPECT_EQ
(
resp
.
Parse
(
msg
),
0
);
}
else
{
...
...
paddle/fluid/operators/d
etail
/grpc_server.cc
→
paddle/fluid/operators/d
istributed
/grpc_server.cc
浏览文件 @
c413c469
...
...
@@ -15,13 +15,13 @@ limitations under the License. */
#include <limits>
#include <string>
#include "paddle/fluid/operators/d
etail
/grpc_server.h"
#include "paddle/fluid/operators/d
istributed
/grpc_server.h"
using
::
grpc
::
ServerAsyncResponseWriter
;
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
enum
CallStatus
{
PROCESS
=
0
,
FINISH
};
// reference:
...
...
@@ -74,7 +74,7 @@ class RequestSend final : public RequestBase {
request_
.
reset
(
new
VariableResponse
(
request_handler
->
scope
(),
request_handler
->
dev_ctx
(),
!
request_handler
->
sync_mode
()));
int
method_id
=
static_cast
<
int
>
(
d
etail
::
GrpcMethod
::
kSendVariable
);
int
method_id
=
static_cast
<
int
>
(
d
istributed
::
GrpcMethod
::
kSendVariable
);
service_
->
RequestAsyncUnary
(
method_id
,
&
ctx_
,
request_
.
get
(),
&
responder_
,
cq_
,
cq_
,
reinterpret_cast
<
void
*>
(
static_cast
<
intptr_t
>
(
req_id
)));
...
...
@@ -106,7 +106,7 @@ class RequestGet final : public RequestBase {
::
grpc
::
ServerCompletionQueue
*
cq
,
RequestHandler
*
request_handler
,
int
req_id
)
:
RequestBase
(
service
,
cq
,
request_handler
,
req_id
),
responder_
(
&
ctx_
)
{
auto
method_id
=
static_cast
<
int
>
(
d
etail
::
GrpcMethod
::
kGetVariable
);
auto
method_id
=
static_cast
<
int
>
(
d
istributed
::
GrpcMethod
::
kGetVariable
);
service_
->
RequestAsyncUnary
(
method_id
,
&
ctx_
,
&
request_
,
&
responder_
,
cq_
,
cq_
,
reinterpret_cast
<
void
*>
(
static_cast
<
intptr_t
>
(
req_id
)));
...
...
@@ -150,7 +150,8 @@ class RequestPrefetch final : public RequestBase {
local_scope_
(
nullptr
)
{
request_
.
reset
(
new
VariableResponse
(
request_handler
->
scope
(),
request_handler
->
dev_ctx
(),
true
));
int
method_id
=
static_cast
<
int
>
(
detail
::
GrpcMethod
::
kPrefetchVariable
);
int
method_id
=
static_cast
<
int
>
(
distributed
::
GrpcMethod
::
kPrefetchVariable
);
service_
->
RequestAsyncUnary
(
method_id
,
&
ctx_
,
request_
.
get
(),
&
responder_
,
cq_
,
cq_
,
reinterpret_cast
<
void
*>
(
static_cast
<
intptr_t
>
(
req_id
)));
...
...
@@ -354,6 +355,6 @@ void AsyncGRPCServer::HandleRequest(
}
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/grpc_server.h
→
paddle/fluid/operators/d
istributed
/grpc_server.h
浏览文件 @
c413c469
...
...
@@ -29,17 +29,17 @@ limitations under the License. */
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/framework/var_type.h"
#include "paddle/fluid/operators/d
etail
/grpc_service.h"
#include "paddle/fluid/operators/d
etail
/request_handler.h"
#include "paddle/fluid/operators/d
etail
/rpc_server.h"
#include "paddle/fluid/operators/d
etail
/send_recv.grpc.pb.h"
#include "paddle/fluid/operators/d
etail
/send_recv.pb.h"
#include "paddle/fluid/operators/d
etail
/sendrecvop_utils.h"
#include "paddle/fluid/operators/d
istributed
/grpc_service.h"
#include "paddle/fluid/operators/d
istributed
/request_handler.h"
#include "paddle/fluid/operators/d
istributed
/rpc_server.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.grpc.pb.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.pb.h"
#include "paddle/fluid/operators/d
istributed
/sendrecvop_utils.h"
#include "paddle/fluid/platform/profiler.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
class
RequestBase
;
...
...
@@ -84,6 +84,6 @@ class AsyncGRPCServer final : public RPCServer {
std
::
map
<
std
::
string
,
std
::
vector
<
RequestBase
*>>
rpc_reqs_
;
};
};
// namespace d
etail
};
// namespace d
istributed
};
// namespace operators
};
// namespace paddle
paddle/fluid/operators/d
etail
/grpc_service.h
→
paddle/fluid/operators/d
istributed
/grpc_service.h
浏览文件 @
c413c469
...
...
@@ -23,7 +23,7 @@
#include <grpc++/impl/codegen/stub_options.h>
#include <grpc++/impl/codegen/sync_stream.h>
#include <grpc++/support/byte_buffer.h>
#include "paddle/fluid/operators/d
etail
/variable_response.h"
#include "paddle/fluid/operators/d
istributed
/variable_response.h"
#include "paddle/fluid/platform/profiler.h"
...
...
@@ -42,16 +42,17 @@ class ServerContext;
// Support parsing/unparsing of tensorflow::VariableResponse.
// Wire-format is identical to RecvVariableResponse.
template
<
>
class
SerializationTraits
<
paddle
::
operators
::
d
etail
::
VariableResponse
>
{
class
SerializationTraits
<
paddle
::
operators
::
d
istributed
::
VariableResponse
>
{
public:
static
Status
Serialize
(
const
paddle
::
operators
::
d
etail
::
VariableResponse
&
msg
,
const
paddle
::
operators
::
d
istributed
::
VariableResponse
&
msg
,
grpc_byte_buffer
**
bp
,
bool
*
own_buffer
)
{
PADDLE_ENFORCE
(
false
,
"SerializationTraits::Serialize not implemented!"
);
return
Status
();
}
static
Status
Deserialize
(
grpc_byte_buffer
*
buffer
,
paddle
::
operators
::
detail
::
VariableResponse
*
msg
,
static
Status
Deserialize
(
grpc_byte_buffer
*
buffer
,
paddle
::
operators
::
distributed
::
VariableResponse
*
msg
,
int
max_message_size
=
INT_MAX
)
{
if
(
buffer
==
nullptr
)
{
return
Status
(
StatusCode
::
INTERNAL
,
"No payload"
);
...
...
@@ -59,7 +60,7 @@ class SerializationTraits<paddle::operators::detail::VariableResponse> {
Status
result
=
g_core_codegen_interface
->
ok
();
if
(
result
.
ok
())
{
paddle
::
operators
::
d
etail
::
GrpcByteSource
source
(
buffer
);
paddle
::
operators
::
d
istributed
::
GrpcByteSource
source
(
buffer
);
int
ret
=
msg
->
Parse
(
&
source
);
if
(
ret
!=
0
)
{
result
=
Status
(
StatusCode
::
INTERNAL
,
"VariableResponse parse error"
);
...
...
@@ -73,7 +74,7 @@ class SerializationTraits<paddle::operators::detail::VariableResponse> {
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
enum
class
GrpcMethod
{
kSendVariable
,
...
...
@@ -118,6 +119,6 @@ class GrpcService final {
};
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/proto_encoder_helper.h
→
paddle/fluid/operators/d
istributed
/proto_encoder_helper.h
浏览文件 @
c413c469
...
...
@@ -26,7 +26,7 @@ limitations under the License. */
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
char
*
EncodeVarint32
(
char
*
dst
,
uint32_t
v
)
{
// Operate on characters as unsigneds
...
...
@@ -144,6 +144,6 @@ class ProtoEncodeHelper {
char
*
limit_
;
// Just for CHECKs
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/request_handler.h
→
paddle/fluid/operators/d
istributed
/request_handler.h
浏览文件 @
c413c469
...
...
@@ -31,7 +31,7 @@
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
constexpr
char
kRequestSend
[]
=
"RequestSend"
;
constexpr
char
kRequestGet
[]
=
"RequestGet"
;
...
...
@@ -124,6 +124,6 @@ class RequestHandler {
RPCServer
*
rpc_server_
;
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/request_handler_impl.cc
→
paddle/fluid/operators/d
istributed
/request_handler_impl.cc
浏览文件 @
c413c469
...
...
@@ -20,12 +20,12 @@
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/operators/d
etail
/request_handler_impl.h"
#include "paddle/fluid/operators/d
etail
/rpc_server.h"
#include "paddle/fluid/operators/d
istributed
/request_handler_impl.h"
#include "paddle/fluid/operators/d
istributed
/rpc_server.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
bool
RequestSendHandler
::
Handle
(
const
std
::
string
&
varname
,
framework
::
Scope
*
scope
,
...
...
@@ -119,6 +119,6 @@ bool RequestPrefetchHandler::Handle(const std::string& varname,
return
true
;
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/request_handler_impl.h
→
paddle/fluid/operators/d
istributed
/request_handler_impl.h
浏览文件 @
c413c469
...
...
@@ -28,11 +28,11 @@
#include "paddle/fluid/framework/scope.h"
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/framework/var_type.h"
#include "paddle/fluid/operators/d
etail
/request_handler.h"
#include "paddle/fluid/operators/d
istributed
/request_handler.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
class
RequestSendHandler
final
:
public
RequestHandler
{
public:
...
...
@@ -66,6 +66,6 @@ class RequestPrefetchHandler final : public RequestHandler {
const
std
::
string
&
out_var_name
=
""
)
override
;
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/rpc_client.cc
→
paddle/fluid/operators/d
istributed
/rpc_client.cc
浏览文件 @
c413c469
...
...
@@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/operators/d
etail
/rpc_client.h"
#include "paddle/fluid/operators/d
istributed
/rpc_client.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
std
::
once_flag
RPCClient
::
init_flag_
;
std
::
unique_ptr
<
RPCClient
>
RPCClient
::
rpc_client_
(
nullptr
);
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/rpc_client.h
→
paddle/fluid/operators/d
istributed
/rpc_client.h
浏览文件 @
c413c469
...
...
@@ -22,7 +22,7 @@
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
class
RPCClient
{
public:
...
...
@@ -84,6 +84,6 @@ class RPCClient {
static
std
::
once_flag
init_flag_
;
static
std
::
unique_ptr
<
RPCClient
>
rpc_client_
;
};
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/rpc_server.cc
→
paddle/fluid/operators/d
istributed
/rpc_server.cc
浏览文件 @
c413c469
...
...
@@ -17,11 +17,11 @@
#include <limits>
#include <string>
#include "paddle/fluid/operators/d
etail
/rpc_server.h"
#include "paddle/fluid/operators/d
istributed
/rpc_server.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
void
RPCServer
::
ShutDown
()
{
LOG
(
INFO
)
<<
"RPCServer ShutDown "
;
...
...
@@ -112,6 +112,6 @@ void RPCServer::WaitCond(const std::string& rpc_name) {
lock
,
[
=
]
{
return
(
cur_cond_
.
load
()
==
cond
||
exit_flag_
.
load
());
});
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/rpc_server.h
→
paddle/fluid/operators/d
istributed
/rpc_server.h
浏览文件 @
c413c469
...
...
@@ -19,11 +19,11 @@
#include <thread> // NOLINT
#include <utility>
#include <vector>
#include "paddle/fluid/operators/d
etail
/request_handler.h"
#include "paddle/fluid/operators/d
istributed
/request_handler.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
class
RPCServer
{
public:
...
...
@@ -86,6 +86,6 @@ class RPCServer {
friend
class
RequestHandler
;
};
};
// namespace d
etail
};
// namespace d
istributed
};
// namespace operators
};
// namespace paddle
paddle/fluid/operators/d
etail
/rpc_server_test.cc
→
paddle/fluid/operators/d
istributed
/rpc_server_test.cc
浏览文件 @
c413c469
...
...
@@ -22,18 +22,18 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/operators/detail/macros.h"
#include "paddle/fluid/operators/d
etail
/request_handler_impl.h"
#include "paddle/fluid/operators/d
etail
/rpc_client.h"
#include "paddle/fluid/operators/d
etail
/rpc_server.h"
#include "paddle/fluid/operators/d
istributed
/request_handler_impl.h"
#include "paddle/fluid/operators/d
istributed
/rpc_client.h"
#include "paddle/fluid/operators/d
istributed
/rpc_server.h"
namespace
framework
=
paddle
::
framework
;
namespace
platform
=
paddle
::
platform
;
namespace
d
etail
=
paddle
::
operators
::
detail
;
namespace
d
istributed
=
paddle
::
operators
::
distributed
;
USE_OP
(
lookup_table
);
std
::
unique_ptr
<
d
etail
::
RPCServer
>
g_rpc_service
;
std
::
unique_ptr
<
d
etail
::
RequestHandler
>
g_req_handler
;
std
::
unique_ptr
<
d
istributed
::
RPCServer
>
g_rpc_service
;
std
::
unique_ptr
<
d
istributed
::
RequestHandler
>
g_req_handler
;
framework
::
BlockDesc
*
AppendPrefetchBlcok
(
framework
::
ProgramDesc
*
program
)
{
auto
root_block
=
program
->
MutableBlock
(
0
);
...
...
@@ -113,19 +113,21 @@ void StartServer() {
g_req_handler
->
SetScope
(
&
scope
);
g_req_handler
->
SetExecutor
(
&
exe
);
g_rpc_service
->
RegisterRPC
(
detail
::
kRequestPrefetch
,
g_req_handler
.
get
());
g_rpc_service
->
RegisterRPC
(
distributed
::
kRequestPrefetch
,
g_req_handler
.
get
());
g_req_handler
->
SetRPCServer
(
g_rpc_service
.
get
());
std
::
thread
server_thread
(
std
::
bind
(
&
d
etail
::
RPCServer
::
StartServer
,
g_rpc_service
.
get
()));
std
::
bind
(
&
d
istributed
::
RPCServer
::
StartServer
,
g_rpc_service
.
get
()));
server_thread
.
join
();
}
TEST
(
PREFETCH
,
CPU
)
{
g_req_handler
.
reset
(
new
d
etail
::
RequestPrefetchHandler
(
true
));
g_req_handler
.
reset
(
new
d
istributed
::
RequestPrefetchHandler
(
true
));
g_rpc_service
.
reset
(
new
RPCSERVER_T
(
"127.0.0.1:0"
,
1
));
detail
::
RPCClient
*
client
=
detail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
distributed
::
RPCClient
*
client
=
distributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
std
::
thread
server_thread
(
StartServer
);
g_rpc_service
->
WaitServerReady
();
...
...
paddle/fluid/operators/d
etail
/send_recv.proto
→
paddle/fluid/operators/d
istributed
/send_recv.proto
浏览文件 @
c413c469
文件已移动
paddle/fluid/operators/d
etail
/sendrecvop_utils.cc
→
paddle/fluid/operators/d
istributed
/sendrecvop_utils.cc
浏览文件 @
c413c469
...
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/d
etail
/sendrecvop_utils.h"
#include "paddle/fluid/operators/d
istributed
/sendrecvop_utils.h"
#ifdef PADDLE_WITH_CUDA
#include <nccl.h>
...
...
@@ -23,14 +23,14 @@ limitations under the License. */
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "paddle/fluid/framework/data_type.h"
#include "paddle/fluid/operators/d
etail
/bytebuffer_stream.h"
#include "paddle/fluid/operators/d
etail
/proto_encoder_helper.h"
#include "paddle/fluid/operators/d
etail
/variable_response.h"
#include "paddle/fluid/operators/d
istributed
/bytebuffer_stream.h"
#include "paddle/fluid/operators/d
istributed
/proto_encoder_helper.h"
#include "paddle/fluid/operators/d
istributed
/variable_response.h"
#include "paddle/fluid/platform/profiler.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
using
VarMsg
=
sendrecv
::
VariableMessage
;
...
...
@@ -222,11 +222,11 @@ void DeserializeFromByteBuffer(const ::grpc::ByteBuffer& msg,
const
platform
::
DeviceContext
&
ctx
,
const
framework
::
Scope
*
scope
,
framework
::
Variable
**
var
)
{
operators
::
d
etail
::
VariableResponse
resp
(
scope
,
&
ctx
);
operators
::
d
istributed
::
VariableResponse
resp
(
scope
,
&
ctx
);
PADDLE_ENFORCE
(
resp
.
Parse
(
msg
)
==
0
,
"parse bytebuffer to tensor error!"
);
*
var
=
resp
.
GetVar
();
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/sendrecvop_utils.h
→
paddle/fluid/operators/d
istributed
/sendrecvop_utils.h
浏览文件 @
c413c469
...
...
@@ -25,12 +25,12 @@ limitations under the License. */
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/framework/var_type.h"
#include "paddle/fluid/operators/d
etail
/send_recv.grpc.pb.h"
#include "paddle/fluid/operators/d
etail
/send_recv.pb.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.grpc.pb.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.pb.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
typedef
void
(
*
DestroyCallback
)(
void
*
);
...
...
@@ -61,6 +61,6 @@ inline std::type_index ToTypeIndex(sendrecv::VariableMessage::Type type) {
}
}
}
// namespace d
etail
}
// namespace d
istributed
}
// namespace operators
}
// namespace paddle
paddle/fluid/operators/d
etail
/variable_response.cc
→
paddle/fluid/operators/d
istributed
/variable_response.cc
浏览文件 @
c413c469
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/operators/d
etail
/variable_response.h"
#include "paddle/fluid/operators/d
istributed
/variable_response.h"
#include <string>
#include <utility>
...
...
@@ -22,12 +22,12 @@
#endif
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/operators/d
etail
/send_recv.pb.h"
#include "paddle/fluid/operators/d
etail
/sendrecvop_utils.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.pb.h"
#include "paddle/fluid/operators/d
istributed
/sendrecvop_utils.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
enum
WireType
{
WIRETYPE_VARINT
=
0
,
...
...
@@ -158,13 +158,13 @@ bool VariableResponse::CopySelectRowsTensorData(
slr
->
set_height
(
meta_
.
slr_height
());
auto
*
tensor
=
slr
->
mutable_value
();
tensor
->
Resize
(
dims
);
PADDLE_ENFORCE_EQ
(
static_cast
<
size_t
>
(
tensor
->
numel
()),
PADDLE_ENFORCE_EQ
(
static_cast
<
size_t
>
(
tensor
->
numel
()),
length
/
framework
::
SizeOfType
(
paddle
::
operators
::
detail
::
ToTypeIndex
(
meta_
.
data_type
())));
paddle
::
operators
::
distributed
::
ToTypeIndex
(
meta_
.
data_type
())));
void
*
tensor_data
=
tensor
->
mutable_data
(
ctx
.
GetPlace
(),
paddle
::
operators
::
d
etail
::
ToTypeIndex
(
meta_
.
data_type
()));
paddle
::
operators
::
d
istributed
::
ToTypeIndex
(
meta_
.
data_type
()));
if
(
!
ReadRaw
(
input
,
ctx
,
tensor
->
place
(),
tensor_data
,
length
))
{
return
false
;
...
...
@@ -480,6 +480,6 @@ int VariableResponse::Parse(Source* source) {
return
0
;
}
};
// namespace d
etail
};
// namespace d
istributed
};
// namespace operators
};
// namespace paddle
paddle/fluid/operators/d
etail
/variable_response.h
→
paddle/fluid/operators/d
istributed
/variable_response.h
浏览文件 @
c413c469
...
...
@@ -22,17 +22,17 @@
#include "paddle/fluid/framework/selected_rows.h"
#include "paddle/fluid/framework/var_type.h"
#include "paddle/fluid/operators/d
etail
/send_recv.grpc.pb.h"
#include "paddle/fluid/operators/d
etail
/send_recv.pb.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.grpc.pb.h"
#include "paddle/fluid/operators/d
istributed
/send_recv.pb.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/operators/d
etail
/bytebuffer_stream.h"
#include "paddle/fluid/operators/d
istributed
/bytebuffer_stream.h"
namespace
paddle
{
namespace
operators
{
namespace
d
etail
{
namespace
d
istributed
{
class
VariableResponse
{
public:
...
...
@@ -99,6 +99,6 @@ class VariableResponse {
sendrecv
::
VariableMessage
meta_
;
};
};
// namespace d
etail
};
// namespace d
istributed
};
// namespace operators
};
// namespace paddle
paddle/fluid/operators/fetch_barrier_op.cc
浏览文件 @
c413c469
...
...
@@ -42,8 +42,8 @@ class FetchBarrierOp : public framework::OperatorBase {
// For profiling
platform
::
RecordEvent
record_event
(
Type
(),
&
ctx
);
d
etail
::
RPCClient
*
rpc_client
=
d
etail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
d
istributed
::
RPCClient
*
rpc_client
=
d
istributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
rpc_client
->
Wait
();
...
...
paddle/fluid/operators/gen_nccl_id_op.cc
浏览文件 @
c413c469
...
...
@@ -22,7 +22,7 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/threadpool.h"
#include "paddle/fluid/operators/detail/macros.h"
#include "paddle/fluid/operators/d
etail
/request_handler_impl.h"
#include "paddle/fluid/operators/d
istributed
/request_handler_impl.h"
#include "paddle/fluid/platform/nccl_helper.h"
namespace
paddle
{
...
...
@@ -60,7 +60,8 @@ class GenNCCLIdOp : public framework::OperatorBase {
std
::
vector
<
std
::
string
>
endpoint_list
=
Attr
<
std
::
vector
<
std
::
string
>>
(
"endpoint_list"
);
detail
::
RPCClient
*
client
=
detail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
distributed
::
RPCClient
*
client
=
distributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
for
(
auto
&
ep
:
endpoint_list
)
{
VLOG
(
3
)
<<
"sending nccl id to "
<<
ep
;
...
...
@@ -80,11 +81,11 @@ class GenNCCLIdOp : public framework::OperatorBase {
// NOTE: Can not use unique_ptr here because the default
// deleter will call GRPC Server's base class's dtor and
// that will cause a wired crash.
d
etail
::
RequestSendHandler
rpc_h
(
true
);
std
::
unique_ptr
<
d
etail
::
RPCServer
>
rpc_service
(
d
istributed
::
RequestSendHandler
rpc_h
(
true
);
std
::
unique_ptr
<
d
istributed
::
RPCServer
>
rpc_service
(
new
RPCSERVER_T
(
endpoint
,
1
));
rpc_service
->
RegisterRPC
(
d
etail
::
kRequestSend
,
&
rpc_h
);
rpc_service
->
RegisterRPC
(
d
istributed
::
kRequestSend
,
&
rpc_h
);
rpc_h
.
SetRPCServer
(
rpc_service
.
get
());
framework
::
ProgramDesc
empty_program
;
...
...
@@ -95,11 +96,11 @@ class GenNCCLIdOp : public framework::OperatorBase {
rpc_h
.
SetExecutor
(
&
executor
);
std
::
thread
server_thread
(
std
::
bind
(
&
d
etail
::
RPCServer
::
StartServer
,
rpc_service
.
get
()));
std
::
bind
(
&
d
istributed
::
RPCServer
::
StartServer
,
rpc_service
.
get
()));
rpc_service
->
SetCond
(
d
etail
::
kRequestSend
);
rpc_service
->
SetCond
(
d
istributed
::
kRequestSend
);
VLOG
(
3
)
<<
"start getting nccl id from trainer 0..."
;
rpc_service
->
WaitBarrier
(
d
etail
::
kRequestSend
);
rpc_service
->
WaitBarrier
(
d
istributed
::
kRequestSend
);
VLOG
(
3
)
<<
"got nccl id and stop server..."
;
rpc_service
->
ShutDown
();
VLOG
(
3
)
<<
"rpc server stopped"
;
...
...
paddle/fluid/operators/listen_and_serv_op.cc
浏览文件 @
c413c469
...
...
@@ -21,14 +21,14 @@ limitations under the License. */
#include "paddle/fluid/operators/detail/macros.h"
#include "paddle/fluid/operators/d
etail
/request_handler_impl.h"
#include "paddle/fluid/operators/d
istributed
/request_handler_impl.h"
#include "paddle/fluid/operators/listen_and_serv_op.h"
#include "paddle/fluid/platform/profiler.h"
namespace
paddle
{
namespace
operators
{
void
RunServer
(
std
::
shared_ptr
<
d
etail
::
RPCServer
>
service
)
{
void
RunServer
(
std
::
shared_ptr
<
d
istributed
::
RPCServer
>
service
)
{
service
->
StartServer
();
VLOG
(
4
)
<<
"RunServer thread end"
;
}
...
...
@@ -121,12 +121,12 @@ void ListenAndServOp::RunSyncLoop(
while
(
true
)
{
// Get from multiple trainers, we don't care about the order in which
// the gradients arrives, just add suffix 0~n and merge the gradient.
rpc_service_
->
SetCond
(
d
etail
::
kRequestSend
);
rpc_service_
->
WaitBarrier
(
d
etail
::
kRequestSend
);
rpc_service_
->
SetCond
(
d
istributed
::
kRequestSend
);
rpc_service_
->
WaitBarrier
(
d
istributed
::
kRequestSend
);
if
(
rpc_service_
->
IsExit
())
{
LOG
(
WARNING
)
<<
"get exit!rpc_processor break!"
;
rpc_service_
->
SetCond
(
d
etail
::
kRequestGet
);
rpc_service_
->
SetCond
(
d
istributed
::
kRequestGet
);
break
;
}
...
...
@@ -154,11 +154,11 @@ void ListenAndServOp::RunSyncLoop(
recv_scope
);
VLOG
(
2
)
<<
"run all blocks spent "
<<
GetTimestamp
()
-
ts
<<
"(ms)"
;
rpc_service_
->
SetCond
(
d
etail
::
kRequestGet
);
rpc_service_
->
WaitBarrier
(
d
etail
::
kRequestGet
);
rpc_service_
->
SetCond
(
d
istributed
::
kRequestGet
);
rpc_service_
->
WaitBarrier
(
d
istributed
::
kRequestGet
);
rpc_service_
->
ResetBarrierCounter
();
// reset received sparse vars to avoid reuse it in the next mini-batch
dynamic_cast
<
d
etail
::
RequestSendHandler
*>
(
request_send_handler_
.
get
())
dynamic_cast
<
d
istributed
::
RequestSendHandler
*>
(
request_send_handler_
.
get
())
->
ResetSparseVarRecorder
();
}
// while(true)
}
...
...
@@ -215,13 +215,13 @@ void ListenAndServOp::RunAsyncLoop(framework::Executor *executor,
}
static
void
FillRequestCtx
(
d
etail
::
RequestHandler
*
h
,
framework
::
Scope
*
scope
,
d
istributed
::
RequestHandler
*
h
,
framework
::
Scope
*
scope
,
platform
::
DeviceContext
*
dev_ctx
,
framework
::
Executor
*
executor
,
framework
::
ProgramDesc
*
program
,
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
framework
::
ExecutorPrepareContext
>>
*
prefetch_ctx
,
d
etail
::
RPCServer
*
rpc_server
)
{
d
istributed
::
RPCServer
*
rpc_server
)
{
h
->
SetScope
(
scope
);
h
->
SetDevCtx
(
dev_ctx
);
h
->
SetExecutor
(
executor
);
...
...
@@ -249,14 +249,16 @@ void ListenAndServOp::RunImpl(const framework::Scope &scope,
rpc_service_
.
reset
(
new
RPCSERVER_T
(
endpoint
,
fan_in
));
request_send_handler_
.
reset
(
new
d
etail
::
RequestSendHandler
(
sync_mode
));
request_get_handler_
.
reset
(
new
d
etail
::
RequestGetHandler
(
sync_mode
));
request_send_handler_
.
reset
(
new
d
istributed
::
RequestSendHandler
(
sync_mode
));
request_get_handler_
.
reset
(
new
d
istributed
::
RequestGetHandler
(
sync_mode
));
request_prefetch_handler_
.
reset
(
new
d
etail
::
RequestPrefetchHandler
(
sync_mode
));
new
d
istributed
::
RequestPrefetchHandler
(
sync_mode
));
rpc_service_
->
RegisterRPC
(
detail
::
kRequestSend
,
request_send_handler_
.
get
());
rpc_service_
->
RegisterRPC
(
detail
::
kRequestGet
,
request_get_handler_
.
get
());
rpc_service_
->
RegisterRPC
(
detail
::
kRequestPrefetch
,
rpc_service_
->
RegisterRPC
(
distributed
::
kRequestSend
,
request_send_handler_
.
get
());
rpc_service_
->
RegisterRPC
(
distributed
::
kRequestGet
,
request_get_handler_
.
get
());
rpc_service_
->
RegisterRPC
(
distributed
::
kRequestPrefetch
,
request_prefetch_handler_
.
get
());
auto
*
optimize_block
=
Attr
<
framework
::
BlockDesc
*>
(
kOptimizeBlock
);
...
...
paddle/fluid/operators/listen_and_serv_op.h
浏览文件 @
c413c469
...
...
@@ -24,8 +24,8 @@ limitations under the License. */
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/threadpool.h"
#include "paddle/fluid/operators/d
etail
/request_handler.h"
#include "paddle/fluid/operators/d
etail
/rpc_server.h"
#include "paddle/fluid/operators/d
istributed
/request_handler.h"
#include "paddle/fluid/operators/d
istributed
/rpc_server.h"
namespace
paddle
{
namespace
operators
{
...
...
@@ -33,7 +33,7 @@ namespace operators {
constexpr
char
kOptimizeBlock
[]
=
"OptimizeBlock"
;
constexpr
char
kPrefetchVarNameToBlockId
[]
=
"prefetch_var_name_to_block_id"
;
void
RunServer
(
std
::
shared_ptr
<
d
etail
::
RPCServer
>
service
);
void
RunServer
(
std
::
shared_ptr
<
d
istributed
::
RPCServer
>
service
);
class
ListenAndServOp
:
public
framework
::
OperatorBase
{
public:
...
...
@@ -62,10 +62,11 @@ class ListenAndServOp : public framework::OperatorBase {
const
platform
::
Place
&
dev_place
)
const
override
;
protected:
mutable
std
::
shared_ptr
<
detail
::
RPCServer
>
rpc_service_
;
mutable
std
::
shared_ptr
<
detail
::
RequestHandler
>
request_send_handler_
;
mutable
std
::
shared_ptr
<
detail
::
RequestHandler
>
request_get_handler_
;
mutable
std
::
shared_ptr
<
detail
::
RequestHandler
>
request_prefetch_handler_
;
mutable
std
::
shared_ptr
<
distributed
::
RPCServer
>
rpc_service_
;
mutable
std
::
shared_ptr
<
distributed
::
RequestHandler
>
request_send_handler_
;
mutable
std
::
shared_ptr
<
distributed
::
RequestHandler
>
request_get_handler_
;
mutable
std
::
shared_ptr
<
distributed
::
RequestHandler
>
request_prefetch_handler_
;
mutable
std
::
shared_ptr
<
std
::
thread
>
server_thread_
;
};
...
...
paddle/fluid/operators/prefetch_op.cc
浏览文件 @
c413c469
...
...
@@ -41,8 +41,8 @@ class PrefetchOp : public framework::OperatorBase {
platform
::
DeviceContextPool
&
pool
=
platform
::
DeviceContextPool
::
Instance
();
auto
&
ctx
=
*
pool
.
Get
(
place
);
d
etail
::
RPCClient
*
rpc_client
=
d
etail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
d
istributed
::
RPCClient
*
rpc_client
=
d
istributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
for
(
size_t
i
=
0
;
i
<
ins
.
size
();
i
++
)
{
if
(
NeedSend
(
scope
,
ins
[
i
]))
{
...
...
paddle/fluid/operators/recv_op.cc
浏览文件 @
c413c469
...
...
@@ -43,8 +43,8 @@ class RecvOp : public framework::OperatorBase {
// For profiling
platform
::
RecordEvent
record_event
(
Type
(),
&
ctx
);
d
etail
::
RPCClient
*
rpc_client
=
d
etail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
d
istributed
::
RPCClient
*
rpc_client
=
d
istributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
for
(
size_t
i
=
0
;
i
<
outs
.
size
();
i
++
)
{
VLOG
(
3
)
<<
"getting "
<<
outs
[
i
]
<<
" from "
<<
epmap
[
i
];
...
...
paddle/fluid/operators/send_barrier_op.cc
浏览文件 @
c413c469
...
...
@@ -44,8 +44,8 @@ class SendBarrierOp : public framework::OperatorBase {
// For profiling
platform
::
RecordEvent
record_event
(
Type
(),
&
ctx
);
d
etail
::
RPCClient
*
rpc_client
=
d
etail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
d
istributed
::
RPCClient
*
rpc_client
=
d
istributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
VLOG
(
3
)
<<
"SendBarrierOp sync_mode:"
<<
sync_mode
;
...
...
paddle/fluid/operators/send_op.cc
浏览文件 @
c413c469
...
...
@@ -45,8 +45,8 @@ class SendOp : public framework::OperatorBase {
// For profiling
platform
::
RecordEvent
record_event
(
Type
(),
&
ctx
);
d
etail
::
RPCClient
*
rpc_client
=
d
etail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
d
istributed
::
RPCClient
*
rpc_client
=
d
istributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
for
(
size_t
i
=
0
;
i
<
ins
.
size
();
i
++
)
{
if
(
NeedSend
(
scope
,
ins
[
i
]))
{
...
...
paddle/fluid/operators/test_send_nccl_id.cc
浏览文件 @
c413c469
...
...
@@ -21,7 +21,7 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/detail/macros.h"
#include "paddle/fluid/operators/d
etail
/request_handler_impl.h"
#include "paddle/fluid/operators/d
istributed
/request_handler_impl.h"
#include "paddle/fluid/operators/listen_and_serv_op.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/selected_rows_functor.h"
...
...
@@ -37,11 +37,11 @@ USE_NO_KERNEL_OP(listen_and_serv);
namespace
f
=
paddle
::
framework
;
namespace
p
=
paddle
::
platform
;
namespace
m
=
paddle
::
operators
::
math
;
namespace
d
etail
=
paddle
::
operators
::
detail
;
namespace
d
istributed
=
paddle
::
operators
::
distributed
;
namespace
string
=
paddle
::
string
;
std
::
unique_ptr
<
d
etail
::
RPCServer
>
g_rpc_service
;
std
::
unique_ptr
<
d
etail
::
RequestHandler
>
g_req_handler
;
std
::
unique_ptr
<
d
istributed
::
RPCServer
>
g_rpc_service
;
std
::
unique_ptr
<
d
istributed
::
RequestHandler
>
g_req_handler
;
void
StartServer
()
{
f
::
Scope
scope
;
...
...
@@ -57,14 +57,14 @@ void StartServer() {
g_req_handler
->
SetProgram
(
&
empty_program
);
g_req_handler
->
SetExecutor
(
&
executor
);
g_rpc_service
->
RegisterRPC
(
d
etail
::
kRequestSend
,
g_req_handler
.
get
());
g_rpc_service
->
RegisterRPC
(
d
istributed
::
kRequestSend
,
g_req_handler
.
get
());
g_req_handler
->
SetRPCServer
(
g_rpc_service
.
get
());
std
::
thread
server_thread
(
std
::
bind
(
&
d
etail
::
RPCServer
::
StartServer
,
g_rpc_service
.
get
()));
std
::
bind
(
&
d
istributed
::
RPCServer
::
StartServer
,
g_rpc_service
.
get
()));
g_rpc_service
->
SetCond
(
d
etail
::
kRequestSend
);
g_rpc_service
->
WaitBarrier
(
d
etail
::
kRequestSend
);
g_rpc_service
->
SetCond
(
d
istributed
::
kRequestSend
);
g_rpc_service
->
WaitBarrier
(
d
istributed
::
kRequestSend
);
LOG
(
INFO
)
<<
"got nccl id and stop server..."
;
g_rpc_service
->
ShutDown
();
...
...
@@ -72,7 +72,7 @@ void StartServer() {
}
TEST
(
SendNcclId
,
RPCServer
)
{
g_req_handler
.
reset
(
new
d
etail
::
RequestSendHandler
(
true
));
g_req_handler
.
reset
(
new
d
istributed
::
RequestSendHandler
(
true
));
g_rpc_service
.
reset
(
new
RPCSERVER_T
(
"127.0.0.1:0"
,
1
));
std
::
thread
server_thread
(
StartServer
);
...
...
@@ -91,7 +91,8 @@ TEST(SendNcclId, RPCServer) {
std
::
string
ep
=
string
::
Sprintf
(
"127.0.0.1:%d"
,
port
);
detail
::
RPCClient
*
client
=
detail
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
distributed
::
RPCClient
*
client
=
distributed
::
RPCClient
::
GetInstance
<
RPCCLIENT_T
>
();
LOG
(
INFO
)
<<
"connect to server"
<<
ep
;
client
->
AsyncSendVar
(
ep
,
dev_ctx
,
scope
,
NCCL_ID_VARNAME
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录