Skip to content

Commit c1ab215

Browse files
committed
Merge branch 'develop' of github.com:PaddlePaddle/Paddle into dist_pass_barrier
2 parents 1366832 + 66c9191 commit c1ab215

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+561
-257
lines changed

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ option(EIGEN_USE_THREADS "Compile with multi-threaded Eigen" OFF)
6161
option(WITH_ARM_FP16 "Use half precision support on armv8.2-a cpu" OFF)
6262
option(WITH_FAST_BUNDLE_TEST "Bundle tests that can be run in a single process together to reduce launch overhead" OFF)
6363
option(WITH_CONTRIB "Compile the third-party contributation" OFF)
64+
option(REPLACE_ENFORCE_GLOG "Replace PADDLE_ENFORCE with glog/CHECK for better debug." OFF)
6465
option(WITH_ANAKIN "Compile with Anakin library" OFF)
6566
option(WITH_GRPC "Use grpc as the default rpc framework" ${WITH_DISTRIBUTE})
67+
option(WITH_BRPC_RDMA "Use brpc rdma as the rpc protocal" OFF)
6668

6769
# CMAKE_BUILD_TYPE
6870
if(NOT CMAKE_BUILD_TYPE)
@@ -131,6 +133,10 @@ if (NOT DEFINED WITH_MKLDNN)
131133
set(WITH_MKLDNN OFF)
132134
endif()
133135
endif()
136+
137+
if (REPLACE_ENFORCE_GLOG)
138+
add_definitions("-DREPLACE_ENFORCE_GLOG")
139+
endif()
134140
########################################################################################
135141

136142
include(external/mklml) # download mklml package
@@ -153,12 +159,24 @@ include(external/cares)
153159
if(WITH_DISTRIBUTE)
154160
if(WITH_GRPC)
155161
include(external/grpc)
162+
message(STATUS "Use grpc framework.")
156163
else()
164+
message(STATUS "Use brpc framework.")
157165
include(external/leveldb)
158166
include(external/brpc)
159167
endif()
160168
endif()
161169

170+
if(WITH_BRPC_RDMA)
171+
message(STATUS "Use brpc with rdma.")
172+
if(WITH_GRPC)
173+
message(FATAL_ERROR "Can't use grpc with brpc rdma.")
174+
endif()
175+
if(NOT WITH_DISTRIBUTE)
176+
message(FATAL_ERROR "Can't use brpc rdma in no distribute env.")
177+
endif()
178+
endif()
179+
162180
include(external/snappy) # download snappy
163181
include(external/snappystream)
164182
include(external/threadpool)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[![Build Status](https://travis-ci.org/PaddlePaddle/Paddle.svg?branch=develop)](https://travis-ci.org/PaddlePaddle/Paddle)
55
[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](http://www.paddlepaddle.org/docs/develop/documentation/en/getstarted/index_en.html)
66
[![Documentation Status](https://img.shields.io/badge/中文文档-最新-brightgreen.svg)](http://www.paddlepaddle.org/docs/develop/documentation/zh/getstarted/index_cn.html)
7-
[![Coverage Status](https://coveralls.io/repos/github/PaddlePaddle/Paddle/badge.svg?branch=develop)](https://coveralls.io/github/PaddlePaddle/Paddle?branch=develop)
87
[![Release](https://img.shields.io/github/release/PaddlePaddle/Paddle.svg)](https://github.com/PaddlePaddle/Paddle/releases)
98
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](LICENSE)
109

cmake/configure.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,7 @@ endif(WITH_GOLANG)
174174
if(WITH_GRPC)
175175
add_definitions(-DPADDLE_WITH_GRPC)
176176
endif(WITH_GRPC)
177+
178+
if(WITH_BRPC_RDMA)
179+
add_definitions(-DPADDLE_WITH_BRPC_RDMA)
180+
endif(WITH_BRPC_RDMA)

cmake/external/brpc.cmake

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515
INCLUDE(ExternalProject)
1616

17+
find_library(SSL_LIBRARY NAMES ssl)
18+
ADD_LIBRARY(ssl SHARED IMPORTED GLOBAL)
19+
SET_PROPERTY(TARGET ssl PROPERTY IMPORTED_LOCATION ${SSL_LIBRARY})
20+
21+
find_library(CRYPTO_LIBRARY NAMES crypto)
22+
ADD_LIBRARY(crypto SHARED IMPORTED GLOBAL)
23+
SET_PROPERTY(TARGET crypto PROPERTY IMPORTED_LOCATION ${CRYPTO_LIBRARY})
24+
25+
1726
SET(BRPC_SOURCES_DIR ${THIRD_PARTY_PATH}/brpc)
1827
SET(BRPC_INSTALL_DIR ${THIRD_PARTY_PATH}/install/brpc)
1928
SET(BRPC_INCLUDE_DIR "${BRPC_INSTALL_DIR}/include" CACHE PATH "brpc include directory." FORCE)
@@ -22,14 +31,14 @@ SET(BRPC_LIBRARIES "${BRPC_INSTALL_DIR}/lib/libbrpc.a" CACHE FILEPATH "brpc libr
2231
INCLUDE_DIRECTORIES(${BRPC_INCLUDE_DIR})
2332

2433
# Reference https://stackoverflow.com/questions/45414507/pass-a-list-of-prefix-paths-to-externalproject-add-in-cmake-args
25-
set(prefix_path "${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf")
34+
set(prefix_path "${THIRD_PARTY_PATH}/install/gflags|${THIRD_PARTY_PATH}/install/leveldb|${THIRD_PARTY_PATH}/install/snappy|${THIRD_PARTY_PATH}/install/gtest|${THIRD_PARTY_PATH}/install/protobuf|${THIRD_PARTY_PATH}/install/zlib")
2635

2736
# If minimal .a is need, you can set WITH_DEBUG_SYMBOLS=OFF
2837
ExternalProject_Add(
2938
extern_brpc
3039
${EXTERNAL_PROJECT_LOG_ARGS}
31-
GIT_REPOSITORY "https://github.com/brpc/brpc"
32-
GIT_TAG "6d153dd7ff00f960ae6895c9c5fff0ce9f07aff2"
40+
GIT_REPOSITORY "https://github.com/gongweibao/brpc"
41+
GIT_TAG "7dc04defad1fd4173aae170c3fcbde131b65155a"
3342
PREFIX ${BRPC_SOURCES_DIR}
3443
UPDATE_COMMAND ""
3544
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
@@ -42,14 +51,16 @@ ExternalProject_Add(
4251
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
4352
-DCMAKE_PREFIX_PATH=${prefix_path}
4453
-DBRPC_WITH_GLOG=ON
54+
-DIOBUF_WITH_HUGE_BLOCK=ON
55+
-DBRPC_WITH_RDMA=${WITH_BRPC_RDMA}
4556
${EXTERNAL_OPTIONAL_ARGS}
4657
LIST_SEPARATOR |
4758
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${BRPC_INSTALL_DIR}
4859
-DCMAKE_INSTALL_LIBDIR:PATH=${BRPC_INSTALL_DIR}/lib
4960
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
5061
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
5162
)
52-
ADD_DEPENDENCIES(extern_brpc protobuf leveldb gflags glog gtest snappy)
63+
ADD_DEPENDENCIES(extern_brpc protobuf ssl crypto leveldb gflags glog gtest snappy)
5364
ADD_LIBRARY(brpc STATIC IMPORTED GLOBAL)
5465
SET_PROPERTY(TARGET brpc PROPERTY IMPORTED_LOCATION ${BRPC_LIBRARIES})
5566
ADD_DEPENDENCIES(brpc extern_brpc)

cmake/generic.cmake

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ if(NOT APPLE AND NOT ANDROID)
9696
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -pthread -ldl -lrt")
9797
endif(NOT APPLE AND NOT ANDROID)
9898

99+
set_property(GLOBAL PROPERTY FLUID_MODULES "")
100+
# find all fluid modules is used for paddle fluid static library
101+
# for building inference libs
102+
function(find_fluid_modules TARGET_NAME)
103+
get_filename_component(__target_path ${TARGET_NAME} ABSOLUTE)
104+
string(REGEX REPLACE "^${PADDLE_SOURCE_DIR}/" "" __target_path ${__target_path})
105+
string(FIND "${__target_path}" "fluid" pos)
106+
if(pos GREATER 1)
107+
get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
108+
set(fluid_modules ${fluid_modules} ${TARGET_NAME})
109+
set_property(GLOBAL PROPERTY FLUID_MODULES "${fluid_modules}")
110+
endif()
111+
endfunction(find_fluid_modules)
112+
99113
function(merge_static_libs TARGET_NAME)
100114
set(libs ${ARGN})
101115
list(REMOVE_DUPLICATES libs)
@@ -250,6 +264,7 @@ function(cc_test TARGET_NAME)
250264
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
251265
if (${cc_test_SERIAL})
252266
set_property(TEST ${TARGET_NAME} PROPERTY SERIAL 1)
267+
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_init_allocated_mem=true)
253268
endif()
254269
endif()
255270
endfunction(cc_test)
@@ -314,6 +329,7 @@ function(nv_test TARGET_NAME)
314329
add_test(${TARGET_NAME} ${TARGET_NAME})
315330
if (nv_test_SERIAL)
316331
set_property(TEST ${TARGET_NAME} PROPERTY SERIAL 1)
332+
set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_init_allocated_mem=true)
317333
endif()
318334
endif()
319335
endfunction(nv_test)
@@ -561,7 +577,7 @@ function(py_test TARGET_NAME)
561577
set(multiValueArgs SRCS DEPS ARGS ENVS)
562578
cmake_parse_arguments(py_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
563579
add_test(NAME ${TARGET_NAME}
564-
COMMAND env PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_test_ENVS}
580+
COMMAND env FLAGS_init_allocated_mem=true PYTHONPATH=${PADDLE_BINARY_DIR}/python ${py_test_ENVS}
565581
${PYTHON_EXECUTABLE} -u ${py_test_SRCS} ${py_test_ARGS}
566582
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
567583
endif()

cmake/inference_lib.cmake

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
set_property(GLOBAL PROPERTY FLUID_MODULES "")
16-
# find all fluid modules is used for paddle fluid static library
17-
function(find_fluid_modules TARGET_NAME)
18-
get_filename_component(__target_path ${TARGET_NAME} ABSOLUTE)
19-
string(REGEX REPLACE "^${PADDLE_SOURCE_DIR}/" "" __target_path ${__target_path})
20-
string(FIND "${__target_path}" "fluid" pos)
21-
if(pos GREATER 1)
22-
get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
23-
set(fluid_modules ${fluid_modules} ${TARGET_NAME})
24-
set_property(GLOBAL PROPERTY FLUID_MODULES "${fluid_modules}")
25-
endif()
26-
endfunction(find_fluid_modules)
27-
2815
# make package for paddle fluid shared and static library
2916
function(copy TARGET)
3017
set(options "")
@@ -154,7 +141,7 @@ set(inference_deps paddle_fluid_shared paddle_fluid)
154141
if(WITH_CONTRIB)
155142
message(STATUS "installing contrib")
156143
set(contrib_dst_dir "${FLUID_INSTALL_DIR}/contrib/inference")
157-
if (WITH_ANAKIN)
144+
if (WITH_ANAKIN AND WITH_GPU)
158145
copy(contrib_anakin_inference_lib DEPS paddle_inference_api inference_anakin_api
159146
SRCS
160147
${PADDLE_BINARY_DIR}/paddle/contrib/inference/libinference_anakin_api* # compiled anakin api
@@ -163,9 +150,9 @@ if(WITH_CONTRIB)
163150
list(APPEND inference_deps contrib_anakin_inference_lib)
164151
endif()
165152

166-
copy(contrib_inference_lib DEPS paddle_inference_api
153+
copy(contrib_inference_lib DEPS paddle_inference_api paddle_inference_api_shared
167154
SRCS ${PADDLE_SOURCE_DIR}/paddle/contrib/inference/paddle_inference_api.h
168-
${PADDLE_BINARY_DIR}/paddle/contrib/inference/libpaddle_inference_api.*
155+
${PADDLE_BINARY_DIR}/paddle/contrib/inference/libpaddle_inference_api*
169156
DSTS ${contrib_dst_dir} ${contrib_dst_dir})
170157
list(APPEND inference_deps contrib_inference_lib)
171158
endif()

paddle/contrib/inference/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ cc_library(paddle_inference_api
4646
SRCS paddle_inference_api.cc paddle_inference_api_impl.cc
4747
DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB})
4848

49+
cc_library(paddle_inference_api_shared SHARED
50+
SRCS paddle_inference_api.cc paddle_inference_api_impl.cc
51+
DEPS ${FLUID_CORE_MODULES} ${GLOB_OP_LIB})
52+
4953
cc_test(test_paddle_inference_api
5054
SRCS test_paddle_inference_api.cc
5155
DEPS paddle_inference_api)

paddle/fluid/framework/data_layout_transform.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ void TransDataLayoutFromMKLDNN(const OpKernelType& kernel_type_for_var,
147147
"Input tensor type is not supported: ", in.type().name());
148148
memory::data_type out_type = in_type;
149149

150-
auto in_format = MKLDNNFormatForSize(in_tz.size(), in.format());
150+
auto in_format = platform::MKLDNNFormatForSize(in_tz.size(), in.format());
151151
auto out_format =
152-
MKLDNNFormatForSize(in_tz.size(), ToMKLDNNFormat(out_layout));
152+
platform::MKLDNNFormatForSize(in_tz.size(), ToMKLDNNFormat(out_layout));
153153

154154
void* in_data = GetDataFromTensor(in, in_type);
155155

paddle/fluid/framework/data_layout_transform.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ inline MKLDNNDataType ToMKLDNNDataType(const std::type_index type) {
6262
return MKLDNNDataType::data_undef;
6363
}
6464

65-
inline MKLDNNFormat MKLDNNFormatForSize(size_t dims_size,
66-
MKLDNNFormat default_format) {
67-
return (dims_size == 1
68-
? mkldnn::memory::format::x
69-
: dims_size == 2 ? mkldnn::memory::format::nc : default_format);
70-
}
7165
#endif
7266

7367
void TransDataLayoutFromMKLDNN(const OpKernelType& kernel_type_for_var,

paddle/fluid/framework/data_transform.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ limitations under the License. */
1818
#include "paddle/fluid/framework/data_layout_transform.h"
1919
#include "paddle/fluid/framework/data_type_transform.h"
2020

21+
#ifdef PADDLE_WITH_MKLDNN
22+
#include "paddle/fluid/platform/mkldnn_helper.h"
23+
#endif
24+
2125
namespace paddle {
2226
namespace framework {
2327

@@ -48,8 +52,8 @@ void TransformData(const OpKernelType &expected_kernel_type,
4852
// Case1 - transform from Non-MKLDNN OPKernel to MKLDNN OPKernel
4953
// Just set layout/format. No real transform occur
5054

51-
auto out_format =
52-
MKLDNNFormatForSize(in.dims().size(), ToMKLDNNFormat(lin));
55+
auto out_format = platform::MKLDNNFormatForSize(in.dims().size(),
56+
ToMKLDNNFormat(lin));
5357

5458
out.ShareDataWith(input_tensor);
5559
out.set_layout(DataLayout::kMKLDNN);

0 commit comments

Comments
 (0)