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

+7-13
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

+2-6
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

+3-11
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

+1-3
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

-2
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

-2
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

+10-14
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

+3-3
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

-2
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

+2-6
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:

paddle/cuda/src/hl_cuda_cudnn.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ limitations under the License. */
2121
#include "paddle/utils/CommandLineParser.h"
2222
#include "paddle/utils/Logging.h"
2323

24-
P_DEFINE_int32(cudnn_conv_workspace_limit_in_mb,
25-
4096,
26-
"Specify cuDNN max workspace limit, in units MB, "
27-
"4096MB=4GB by default.");
24+
DEFINE_int32(cudnn_conv_workspace_limit_in_mb,
25+
4096,
26+
"Specify cuDNN max workspace limit, in units MB, "
27+
"4096MB=4GB by default.");
2828

2929
namespace dynload {
3030

paddle/cuda/src/hl_dso_loader.cc

+15-15
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ limitations under the License. */
1616
#include "paddle/utils/CommandLineParser.h"
1717
#include "paddle/utils/Logging.h"
1818

19-
P_DEFINE_string(cudnn_dir,
20-
"",
21-
"Specify path for loading libcudnn.so. For instance, "
22-
"/usr/local/cudnn/lib. If empty [default], dlopen "
23-
"will search cudnn from LD_LIBRARY_PATH");
24-
25-
P_DEFINE_string(cuda_dir,
26-
"",
27-
"Specify path for loading cuda library, such as libcublas, "
28-
"libcurand. For instance, /usr/local/cuda/lib64. (Note: "
29-
"libcudart can not be specified by cuda_dir, since some "
30-
"build-in function in cudart already ran before main entry). "
31-
"If default, dlopen will search cuda from LD_LIBRARY_PATH");
32-
33-
P_DEFINE_string(warpctc_dir, "", "Specify path for loading libwarpctc.so.");
19+
DEFINE_string(cudnn_dir,
20+
"",
21+
"Specify path for loading libcudnn.so. For instance, "
22+
"/usr/local/cudnn/lib. If empty [default], dlopen "
23+
"will search cudnn from LD_LIBRARY_PATH");
24+
25+
DEFINE_string(cuda_dir,
26+
"",
27+
"Specify path for loading cuda library, such as libcublas, "
28+
"libcurand. For instance, /usr/local/cuda/lib64. (Note: "
29+
"libcudart can not be specified by cuda_dir, since some "
30+
"build-in function in cudart already ran before main entry). "
31+
"If default, dlopen will search cuda from LD_LIBRARY_PATH");
32+
33+
DEFINE_string(warpctc_dir, "", "Specify path for loading libwarpctc.so.");
3434

3535
static inline std::string join(const std::string& part1,
3636
const std::string& part2) {

paddle/gserver/dataproviders/ProtoDataProvider.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ limitations under the License. */
2222
#include "DataProviderGroup.h"
2323
#include "paddle/utils/Logging.h"
2424

25-
P_DEFINE_double(memory_threshold_on_load_data,
26-
1.0,
27-
"stop loading data when memory is not sufficient");
25+
DEFINE_double(memory_threshold_on_load_data,
26+
1.0,
27+
"stop loading data when memory is not sufficient");
2828

2929
namespace paddle {
3030

paddle/gserver/evaluators/Evaluator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License. */
1717

1818
#include "paddle/gserver/gradientmachines/NeuralNetwork.h"
1919

20-
P_DECLARE_int32(trainer_id);
20+
DECLARE_int32(trainer_id);
2121

2222
namespace paddle {
2323

paddle/gserver/gradientmachines/MultiGradientMachine.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ limitations under the License. */
2121
#include "NeuralNetwork.h"
2222
#include "ParallelNeuralNetwork.h"
2323

24-
P_DEFINE_bool(allow_only_one_model_on_one_gpu,
25-
true,
26-
"If true, do not allow multiple models on one GPU device");
24+
DEFINE_bool(allow_only_one_model_on_one_gpu,
25+
true,
26+
"If true, do not allow multiple models on one GPU device");
2727
#ifdef PADDLE_METRIC_LEARNING
28-
P_DECLARE_bool(external);
28+
DECLARE_bool(external);
2929
#endif
3030

3131
namespace paddle {

paddle/gserver/gradientmachines/RecurrentGradientMachine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ limitations under the License. */
2424
#include "paddle/utils/Stat.h"
2525
#include "paddle/utils/Util.h"
2626

27-
P_DEFINE_string(diy_beam_search_prob_so, "", "the diy beam search cost so");
27+
DEFINE_string(diy_beam_search_prob_so, "", "the diy beam search cost so");
2828

2929
static const char* DIY_CALC_PROB_SYMBOL_NAME = "calc_prob";
3030
static const char* DIY_START_CALC_PROB_SYMBOL_NAME = "start_calc_prob";

paddle/gserver/layers/Layer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ limitations under the License. */
3333
#include "TransLayer.h"
3434
#include "ValidationLayer.h"
3535

36-
P_DEFINE_bool(log_error_clipping, false, "enable log error clipping or not");
36+
DEFINE_bool(log_error_clipping, false, "enable log error clipping or not");
3737

3838
namespace paddle {
3939

paddle/gserver/layers/LstmLayer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License. */
1717
#include "paddle/math/Matrix.h"
1818
#include "paddle/utils/Stat.h"
1919

20-
P_DECLARE_bool(prev_batch_state);
20+
DECLARE_bool(prev_batch_state);
2121

2222
namespace paddle {
2323

paddle/gserver/layers/RecurrentLayer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License. */
1717
#include "paddle/utils/CommandLineParser.h"
1818
#include "paddle/utils/Stat.h"
1919

20-
P_DEFINE_bool(rnn_use_batch, false, "Using the batch method for calculation.");
20+
DEFINE_bool(rnn_use_batch, false, "Using the batch method for calculation.");
2121

2222
namespace paddle {
2323

paddle/gserver/layers/ValidationLayer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License. */
1818
#include "Layer.h"
1919
#include "paddle/gserver/evaluators/Evaluator.h"
2020

21-
P_DECLARE_int32(trainer_id);
21+
DECLARE_int32(trainer_id);
2222

2323
namespace paddle {
2424

paddle/gserver/tests/LayerGradUtil.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License. */
1414

1515
#include "LayerGradUtil.h"
1616

17-
P_DECLARE_bool(thread_local_rand_use_global_seed);
17+
DECLARE_bool(thread_local_rand_use_global_seed);
1818

1919
namespace paddle {
2020
real getCostSum(LayerPtr& testLayer, MatrixPtr weights) {

paddle/gserver/tests/TestUtil.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License. */
1717
#include "paddle/math/SparseMatrix.h"
1818
#include "paddle/utils/CommandLineParser.h"
1919

20-
P_DEFINE_int32(fixed_seq_length, 0, "Produce some sequence of fixed length");
20+
DEFINE_int32(fixed_seq_length, 0, "Produce some sequence of fixed length");
2121

2222
namespace paddle {
2323

paddle/gserver/tests/test_ActivationGrad.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ limitations under the License. */
2525
using namespace paddle; // NOLINT
2626
using namespace std; // NOLINT
2727

28-
P_DECLARE_bool(use_gpu);
29-
P_DECLARE_bool(thread_local_rand_use_global_seed);
28+
DECLARE_bool(use_gpu);
29+
DECLARE_bool(thread_local_rand_use_global_seed);
3030

3131
void testActivation(const string& act) {
3232
LOG(INFO) << "test activation: " << act;

paddle/gserver/tests/test_BatchNorm.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ limitations under the License. */
2727
using namespace paddle; // NOLINT
2828
using namespace std; // NOLINT
2929

30-
P_DECLARE_bool(use_gpu);
31-
P_DECLARE_int32(gpu_id);
32-
P_DECLARE_double(checkgrad_eps);
33-
P_DECLARE_bool(thread_local_rand_use_global_seed);
34-
P_DECLARE_bool(prev_batch_state);
30+
DECLARE_bool(use_gpu);
31+
DECLARE_int32(gpu_id);
32+
DECLARE_double(checkgrad_eps);
33+
DECLARE_bool(thread_local_rand_use_global_seed);
34+
DECLARE_bool(prev_batch_state);
3535

3636
// Test that the batchNormLayer can be followed by a ConvLayer
3737
TEST(Layer, batchNorm) {

0 commit comments

Comments
 (0)