Skip to content

Commit 6aed264

Browse files
authored
Merge pull request #896 from gangliao/glog
Remove custom glog-like and gflags-like macros
2 parents 5bfa28f + ae174b3 commit 6aed264

File tree

86 files changed

+426
-1444
lines changed

Some content is hidden

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

86 files changed

+426
-1444
lines changed

CMakeLists.txt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ find_package(ZLIB REQUIRED)
2525
find_package(NumPy REQUIRED)
2626
find_package(Threads REQUIRED)
2727
find_package(AVX QUIET)
28-
find_package(Glog)
29-
find_package(Gflags QUIET)
28+
find_package(Glog REQUIRED)
29+
find_package(Gflags REQUIRED)
3030
find_package(GTest)
3131
find_package(Sphinx)
3232
find_package(Doxygen)
@@ -40,8 +40,6 @@ option(WITH_AVX "Compile PaddlePaddle with avx intrinsics" ${AVX_FOUND})
4040
option(WITH_PYTHON "Compile PaddlePaddle with python interpreter" ON)
4141
option(WITH_STYLE_CHECK "Style Check for PaddlePaddle" ${PYTHONINTERP_FOUND})
4242
option(WITH_RDMA "Compile PaddlePaddle with rdma support" OFF)
43-
option(WITH_GLOG "Compile PaddlePaddle use glog, otherwise use a log implement internally" ${LIBGLOG_FOUND})
44-
option(WITH_GFLAGS "Compile PaddlePaddle use gflags, otherwise use a flag implement internally" ${GFLAGS_FOUND})
4543
option(WITH_TIMER "Compile PaddlePaddle use timer" OFF)
4644
option(WITH_PROFILER "Compile PaddlePaddle use gpu profiler" OFF)
4745
option(WITH_TESTING "Compile and run unittest for PaddlePaddle" ${GTEST_FOUND})
@@ -136,16 +134,12 @@ else(WITH_RDMA)
136134
add_definitions(-DPADDLE_DISABLE_RDMA)
137135
endif(WITH_RDMA)
138136

139-
if(WITH_GLOG)
140-
add_definitions(-DPADDLE_USE_GLOG)
141-
include_directories(${LIBGLOG_INCLUDE_DIR})
142-
endif()
137+
# glog
138+
include_directories(${LIBGLOG_INCLUDE_DIR})
143139

144-
if(WITH_GFLAGS)
145-
add_definitions(-DPADDLE_USE_GFLAGS)
146-
add_definitions(-DGFLAGS_NS=${GFLAGS_NAMESPACE})
147-
include_directories(${GFLAGS_INCLUDE_DIRS})
148-
endif()
140+
#gflags
141+
add_definitions(-DGFLAGS_NS=${GFLAGS_NAMESPACE})
142+
include_directories(${GFLAGS_INCLUDE_DIRS})
149143

150144
if(WITH_TESTING)
151145
enable_testing()

cmake/check_packages.cmake

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,9 @@ if(WITH_STYLE_CHECK)
1414
find_package(PythonInterp REQUIRED)
1515
endif()
1616

17-
if(WITH_GLOG)
18-
find_package(Glog REQUIRED)
19-
endif()
17+
find_package(Glog REQUIRED)
2018

21-
if(WITH_GFLAGS)
22-
find_package(Gflags REQUIRED)
23-
endif()
19+
find_package(Gflags REQUIRED)
2420

2521
if(WITH_TESTING)
2622
find_package(GTest REQUIRED)

cmake/util.cmake

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ endmacro()
6565
# link_paddle_exe
6666
# add paddle library for a paddle executable, such as trainer, pserver.
6767
#
68-
# It will handle WITH_PYTHON/WITH_GLOG etc.
68+
# It will handle WITH_PYTHON etc.
6969
function(link_paddle_exe TARGET_NAME)
7070
if(WITH_RDMA)
7171
generate_rdma_links()
@@ -108,6 +108,8 @@ function(link_paddle_exe TARGET_NAME)
108108
paddle_cuda
109109
${METRIC_LIBS}
110110
${PROTOBUF_LIBRARY}
111+
${LIBGLOG_LIBRARY}
112+
${GFLAGS_LIBRARIES}
111113
${CMAKE_THREAD_LIBS_INIT}
112114
${CBLAS_LIBS}
113115
${ZLIB_LIBRARIES}
@@ -125,16 +127,6 @@ function(link_paddle_exe TARGET_NAME)
125127
${PYTHON_LIBRARIES})
126128
endif()
127129

128-
if(WITH_GLOG)
129-
target_link_libraries(${TARGET_NAME}
130-
${LIBGLOG_LIBRARY})
131-
endif()
132-
133-
if(WITH_GFLAGS)
134-
target_link_libraries(${TARGET_NAME}
135-
${GFLAGS_LIBRARIES})
136-
endif()
137-
138130
if(WITH_GPU)
139131
if(NOT WITH_DSO OR WITH_METRIC)
140132
target_link_libraries(${TARGET_NAME}

doc/getstarted/build_and_install/build_from_source_en.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ PaddlePaddle supports some build options. To enable it, first you need to instal
4949
<tbody>
5050
<tr><td class="left">WITH_GPU</td><td class="left">Compile with GPU mode.</td></tr>
5151
<tr><td class="left">WITH_DOUBLE</td><td class="left">Compile with double precision floating-point, default: single precision.</td></tr>
52-
<tr><td class="left">WITH_GLOG</td><td class="left">Compile with glog. If not found, default: an internal log implementation.</td></tr>
53-
<tr><td class="left">WITH_GFLAGS</td><td class="left">Compile with gflags. If not found, default: an internal flag implementation.</td></tr>
5452
<tr><td class="left">WITH_TESTING</td><td class="left">Compile with gtest for PaddlePaddle's unit testing.</td></tr>
55-
<tr><td class="left">WITH_DOC</td><td class="left"> Compile to generate PaddlePaddle's docs, default: disabled (OFF).</td></tr>
53+
<tr><td class="left">WITH_DOC</td><td class="left"> Compile to generate PaddlePaddle's docs, default: disabled (OFF).</td></tr>
5654
<tr><td class="left">WITH_SWIG_PY</td><td class="left">Compile with python predict API, default: disabled (OFF).</td></tr>
5755
<tr><td class="left">WITH_STYLE_CHECK</td><td class="left">Compile with code style check, default: enabled (ON).</td></tr>
5856
</tbody>

doc/getstarted/build_and_install/cmake/compile_options.csv

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ WITH_AVX,是否编译含有AVX指令集的PaddlePaddle二进制文件,是
66
WITH_PYTHON,是否内嵌PYTHON解释器。方便今后的嵌入式移植工作。,是
77
WITH_STYLE_CHECK,是否编译时进行代码风格检查,是
88
WITH_RDMA,是否开启RDMA,否
9-
WITH_GLOG,是否开启GLOG。如果不开启,则会使用一个简化版的日志,同时方便今后的嵌入式移植工作。,取决于是否寻找到GLOG
10-
WITH_GFLAGS,是否使用GFLAGS。如果不开启,则会使用一个简化版的命令行参数解析器,同时方便今后的嵌入式移植工作。,取决于是否寻找到GFLAGS
119
WITH_TIMER,是否开启计时功能。如果开启会导致运行略慢,打印的日志变多,但是方便调试和测Benchmark,否
1210
WITH_TESTING,是否开启单元测试,取决于是否寻找到GTEST
1311
WITH_DOC,是否编译中英文文档,否

doc/getstarted/build_and_install/ubuntu_install_cn.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ PaddlePaddle提供了ubuntu 14.04 deb安装包。
4646
with_double: OFF
4747
with_python: ON
4848
with_rdma: OFF
49-
with_glog: ON
50-
with_gflags: ON
5149
with_metric_learning:
5250
with_timer: OFF
5351
with_predict_sdk:

paddle/api/CMakeLists.txt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,18 @@ add_library(paddle_api STATIC
1717
${API_SOURCES})
1818
add_dependencies(paddle_api gen_proto_cpp)
1919

20+
list(LENGTH "${GFLAGS_LIBRARIES}" GFLAGS_LIBRARIES_LENGTH)
2021

21-
if(WITH_GFLAGS)
22-
list(LENGTH "${GFLAGS_LIBRARIES}" GFLAGS_LIBRARIES_LENGTH)
23-
24-
if(${GFLAGS_LIBRARIES_LENGTH} EQUAL 0 AND TARGET "${GFLAGS_LIBRARIES}")
25-
# Because gflags compiled by cmake, so it is imported by cmake target,
26-
# not a real library path. Get the real library path here.
27-
message(STATUS "GFLAGS Libraries is ${GFLAGS_LIBRARIES}")
28-
get_target_property(GFLAGS_LOCATION ${GFLAGS_LIBRARIES} LOCATION)
29-
message(STATUS "GFLAGS Target location is ${GFLAGS_LOCATION}")
30-
else()
31-
set(GFLAGS_LOCATION ${GFLAGS_LIBRARIES})
32-
endif()
22+
if(${GFLAGS_LIBRARIES_LENGTH} EQUAL 0 AND TARGET "${GFLAGS_LIBRARIES}")
23+
# Because gflags compiled by cmake, so it is imported by cmake target,
24+
# not a real library path. Get the real library path here.
25+
message(STATUS "GFLAGS Libraries is ${GFLAGS_LIBRARIES}")
26+
get_target_property(GFLAGS_LOCATION ${GFLAGS_LIBRARIES} LOCATION)
27+
message(STATUS "GFLAGS Target location is ${GFLAGS_LOCATION}")
28+
else()
29+
set(GFLAGS_LOCATION ${GFLAGS_LIBRARIES})
3330
endif()
3431

35-
3632
configure_file(
3733
paddle_api_config.py.in
3834
${PROJ_ROOT}/paddle/api/paddle_api_config.py
@@ -57,7 +53,7 @@ add_custom_command(OUTPUT ${PROJ_ROOT}/paddle/dist/.timestamp
5753
paddle_trainer
5854
paddle_api
5955
paddle_cuda
60-
${PY_PADDLE_PYTHON_FILES}
56+
${PY_PADDLE_PYTHON_FILES}
6157
)
6258

6359
install(DIRECTORY ${PROJ_ROOT}/paddle/dist/

paddle/api/Trainer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ limitations under the License. */
2727

2828
using paddle::real;
2929

30-
P_DECLARE_string(config);
31-
P_DECLARE_string(init_model_path);
32-
P_DECLARE_int32(start_pass);
30+
DECLARE_string(config);
31+
DECLARE_string(init_model_path);
32+
DECLARE_int32(start_pass);
3333

3434
struct TrainerPrivate : public paddle::Trainer {
3535
bool _trainOneBatch(size_t batchSize);

paddle/api/paddle_api_config.py.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ CMAKE_DL_LIBS="@CMAKE_DL_LIBS@"
88

99
WITH_PYTHON="@WITH_PYTHON@"
1010
PYTHON_LIBRARIES="@PYTHON_LIBRARIES@"
11-
WITH_GLOG="@WITH_GLOG@"
1211
LIBGLOG_LIBRARY="@LIBGLOG_LIBRARY@"
13-
WITH_GFLAGS="@WITH_GFLAGS@"
1412
GFLAGS_LIBRARIES="@GFLAGS_LIBRARIES@"
1513
GFLAGS_LOCATION="@GFLAGS_LOCATION@"
1614
CBLAS_LIBRARIES="@CBLAS_LIBS@"

paddle/api/paddle_ld_flags.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ def __init__(self):
4747
self.with_python = PaddleLDFlag.cmake_bool(WITH_PYTHON)
4848
self.python_libs = PYTHON_LIBRARIES
4949

50-
self.with_glog = PaddleLDFlag.cmake_bool(WITH_GLOG)
5150
self.glog_libs = LIBGLOG_LIBRARY
5251

53-
self.with_gflags = PaddleLDFlag.cmake_bool(WITH_GFLAGS)
5452
self.with_coverage = PaddleLDFlag.cmake_bool(WITH_COVERALLS)
5553
self.gflags_libs = GFLAGS_LIBRARIES
5654
self.gflags_location = GFLAGS_LOCATION
@@ -88,6 +86,8 @@ def libs_str(self):
8886
"-lpaddle_cuda",
8987
"-lpaddle_api",
9088
self.normalize_flag(self.protolib),
89+
self.normalize_flag(self.glog_libs),
90+
self.normalize_flag(self.gflags_libs),
9191
self.normalize_flag(self.zlib),
9292
self.normalize_flag(self.thread),
9393
self.normalize_flag(self.dl_libs),
@@ -96,10 +96,6 @@ def libs_str(self):
9696

9797
if self.with_python:
9898
libs.append(self.normalize_flag(self.python_libs))
99-
if self.with_glog:
100-
libs.append(self.normalize_flag(self.glog_libs))
101-
if self.with_gflags:
102-
libs.append(self.normalize_flag(self.gflags_libs))
10399
if self.with_gpu:
104100
libs.append(self.normalize_flag(self.curt))
105101
if self.with_coverage:

0 commit comments

Comments
 (0)