Skip to content

Commit 1f4a434

Browse files
authored
Merge pull request #14046 from dzhwinter/windows/debug
cherry picked windows patches.
2 parents d8425e0 + 234a1d9 commit 1f4a434

Some content is hidden

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

70 files changed

+519
-199
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ message(STATUS "C compiler: ${CMAKE_C_COMPILER}, version: "
2626
"${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
2727
if(WIN32)
2828
set(CMAKE_STATIC_LIBRARY_PREFIX lib)
29+
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "/MT") #create multithread dynamic library
2930
endif(WIN32)
3031

3132
if(NOT CMAKE_CROSSCOMPILING)
3233
find_package(CUDA QUIET)
3334
endif(NOT CMAKE_CROSSCOMPILING)
3435
find_package(Git REQUIRED)
3536
find_package(Threads REQUIRED)
36-
3737
include(simd)
3838

3939
################################ Configurations #######################################
@@ -178,10 +178,10 @@ include(external/eigen) # download eigen3
178178
include(external/pybind11) # download pybind11
179179
include(external/cares)
180180
include(external/cub)
181-
include(external/xxhash) # download xxhash
182181

183182
if (NOT WIN32)
184183
# there is no official support of snappystream, warpctc, nccl, cupti in windows
184+
include(external/xxhash) # download xxhash
185185
include(external/snappy) # download snappy
186186
include(external/snappystream) # download snappystream
187187
include(external/warpctc) # download, build, install warpctc

cmake/cuda.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,21 @@ set(CUDA_PROPAGATE_HOST_FLAGS OFF)
169169

170170
# Release/Debug flags set by cmake. Such as -O3 -g -DNDEBUG etc.
171171
# So, don't set these flags here.
172+
172173
if (NOT WIN32) # windows msvc2015 support c++11 natively.
173-
# -std=c++11 -fPIC not recoginize by msvc, -Xcompiler will be added by cmake.
174+
# -std=c++11 -fPIC not recoginize by msvc
174175
list(APPEND CUDA_NVCC_FLAGS "-std=c++11")
175-
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler -fPIC")
176+
# in cuda9, suppress cuda warning on eigen with "-w"
177+
list(APPEND CUDA_NVCC_FLAGS "-w" "-Xcompiler -fPIC")
178+
else(NOT WIN32)
179+
list(APPEND CUDA_NVCC_FLAGS "-w" "-Xcompiler -fPIC" "-Xcompiler /w")
176180
endif(NOT WIN32)
177181

178182
if(WITH_FAST_MATH)
179183
# Make use of fast math library. https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html
180184
list(APPEND CUDA_NVCC_FLAGS "--use_fast_math")
181-
endif()
182-
# in cuda9, suppress cuda warning on eigen
183-
list(APPEND CUDA_NVCC_FLAGS "-w")
185+
endif(WITH_FAST_MATH)
186+
184187
# Set :expt-relaxed-constexpr to suppress Eigen warnings
185188
list(APPEND CUDA_NVCC_FLAGS "--expt-relaxed-constexpr")
186189

cmake/cudnn.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ find_library(CUDNN_LIBRARY NAMES ${CUDNN_LIB_NAME} # libcudnn_static.a
4848
NO_DEFAULT_PATH
4949
DOC "Path to cuDNN library.")
5050

51-
5251
if(CUDNN_INCLUDE_DIR AND CUDNN_LIBRARY)
5352
set(CUDNN_FOUND ON)
5453
else()
@@ -83,7 +82,7 @@ if(CUDNN_FOUND)
8382

8483
if(NOT CUDNN_MAJOR_VERSION)
8584
set(CUDNN_VERSION "???")
86-
else()
85+
else()
8786
math(EXPR CUDNN_VERSION
8887
"${CUDNN_MAJOR_VERSION} * 1000 +
8988
${CUDNN_MINOR_VERSION} * 100 + ${CUDNN_PATCHLEVEL_VERSION}")

cmake/external/boost.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ExternalProject_Add(
4848
DOWNLOAD_DIR ${BOOST_DOWNLOAD_DIR}
4949
DOWNLOAD_COMMAND wget --no-check-certificate ${BOOST_URL} -c -q -O ${BOOST_TAR}.tar.gz
5050
&& tar zxf ${BOOST_TAR}.tar.gz
51-
DOWNLOAD_NO_PROGRESS 1
51+
DOWNLOAD_NO_PROGRESS 1
5252
PREFIX ${BOOST_SOURCES_DIR}
5353
CONFIGURE_COMMAND ""
5454
BUILD_COMMAND ""

cmake/external/gflags.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ ExternalProject_Add(
3535
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
3636
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
3737
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
38+
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
3839
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
40+
-DBUILD_STATIC_LIBS=ON
3941
-DCMAKE_INSTALL_PREFIX=${GFLAGS_INSTALL_DIR}
4042
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
4143
-DBUILD_TESTING=OFF
@@ -45,16 +47,17 @@ ExternalProject_Add(
4547
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
4648
-DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE}
4749
)
50+
51+
ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL)
52+
SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES})
53+
ADD_DEPENDENCIES(gflags extern_gflags)
4854
IF(WIN32)
4955
IF(NOT EXISTS "${GFLAGS_INSTALL_DIR}/lib/libgflags.lib")
5056
add_custom_command(TARGET extern_gflags POST_BUILD
5157
COMMAND cmake -E rename ${GFLAGS_INSTALL_DIR}/lib/gflags_static.lib ${GFLAGS_INSTALL_DIR}/lib/libgflags.lib
5258
)
5359
ENDIF()
5460
ENDIF(WIN32)
55-
ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL)
56-
SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES})
57-
ADD_DEPENDENCIES(gflags extern_gflags)
5861

5962
LIST(APPEND external_project_dependencies gflags)
6063

cmake/external/glog.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ ELSE()
3434
SET(GLOG_REPOSITORY "https://github.com/google/glog.git")
3535
SET(GLOG_TAG "v0.3.5")
3636
ENDIF()
37-
3837
ExternalProject_Add(
3938
extern_glog
4039
${EXTERNAL_PROJECT_LOG_ARGS}
@@ -46,6 +45,7 @@ ExternalProject_Add(
4645
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
4746
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
4847
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
48+
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
4949
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
5050
-DCMAKE_INSTALL_PREFIX=${GLOG_INSTALL_DIR}
5151
-DCMAKE_INSTALL_LIBDIR=${GLOG_INSTALL_DIR}/lib

cmake/external/gtest.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ IF(WITH_TESTING)
5151
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
5252
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
5353
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
54+
-DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}
5455
-DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_DIR}
5556
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
5657
-DBUILD_GMOCK=ON
@@ -70,6 +71,5 @@ IF(WITH_TESTING)
7071
ADD_LIBRARY(gtest_main STATIC IMPORTED GLOBAL)
7172
SET_PROPERTY(TARGET gtest_main PROPERTY IMPORTED_LOCATION ${GTEST_MAIN_LIBRARIES})
7273
ADD_DEPENDENCIES(gtest_main extern_gtest)
73-
7474
LIST(APPEND external_project_dependencies gtest gtest_main)
7575
ENDIF(WITH_TESTING)

cmake/external/openblas.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ INCLUDE_DIRECTORIES(${CBLAS_INC_DIR})
124124
# linear algebra libraries for cc_library(xxx SRCS xxx.c DEPS cblas)
125125
SET(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/cblas_dummy.c)
126126
FILE(WRITE ${dummyfile} "const char *dummy_cblas = \"${dummyfile}\";")
127+
127128
ADD_LIBRARY(cblas STATIC ${dummyfile})
128129

129130
IF("${CBLAS_PROVIDER}" STREQUAL "MKLML")

cmake/flags.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,14 @@ set(GPU_COMMON_FLAGS
144144
-Wno-error=unused-function # Warnings in Numpy Header.
145145
-Wno-error=array-bounds # Warnings in Eigen::array
146146
)
147-
148147
else(NOT WIN32)
149148
set(COMMON_FLAGS
149+
-fPIC
150+
-fno-omit-frame-pointer
150151
"/w") #disable all warnings.
151152
set(GPU_COMMON_FLAGS
153+
-fPIC
154+
-fno-omit-frame-pointer
152155
"/w") #disable all warnings
153156
endif(NOT WIN32)
154157

@@ -164,8 +167,8 @@ endif(APPLE)
164167
if(LINUX)
165168
set(GPU_COMMON_FLAGS
166169
-Wall
167-
-Wextra
168170
-Werror
171+
-Wextra
169172
${GPU_COMMON_FLAGS})
170173
endif(LINUX)
171174

cmake/generic.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ function(cc_library TARGET_NAME)
238238
# add libxxx.lib prefix in windows
239239
set(${TARGET_NAME}_LIB_NAME "${CMAKE_STATIC_LIBRARY_PREFIX}${TARGET_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE STRING "output library name for target ${TARGET_NAME}")
240240
endif(WIN32)
241+
241242
if(cc_library_SRCS)
242243
if(cc_library_SHARED OR cc_library_shared) # build *.so
243244
add_library(${TARGET_NAME} SHARED ${cc_library_SRCS})
@@ -307,7 +308,11 @@ function(cc_test TARGET_NAME)
307308
set(multiValueArgs SRCS DEPS ARGS)
308309
cmake_parse_arguments(cc_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
309310
add_executable(${TARGET_NAME} ${cc_test_SRCS})
311+
if(WIN32) # in windows deps. shlwapi library.
312+
target_link_libraries(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main lod_tensor memory gtest gflags glog shlwapi)
313+
else(WIN32)
310314
target_link_libraries(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main lod_tensor memory gtest gflags glog)
315+
endif(WIN32)
311316
add_dependencies(${TARGET_NAME} ${cc_test_DEPS} paddle_gtest_main lod_tensor memory gtest gflags glog)
312317
add_test(NAME ${TARGET_NAME}
313318
COMMAND ${TARGET_NAME} ${cc_test_ARGS}
@@ -378,7 +383,11 @@ function(nv_test TARGET_NAME)
378383
set(multiValueArgs SRCS DEPS)
379384
cmake_parse_arguments(nv_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
380385
cuda_add_executable(${TARGET_NAME} ${nv_test_SRCS})
386+
if(WIN32)
387+
target_link_libraries(${TARGET_NAME} ${nv_test_DEPS} paddle_gtest_main lod_tensor memory gtest gflags glog shlwapi)
388+
else(WIN32)
381389
target_link_libraries(${TARGET_NAME} ${nv_test_DEPS} paddle_gtest_main lod_tensor memory gtest gflags glog)
390+
endif(WIN32)
382391
add_dependencies(${TARGET_NAME} ${nv_test_DEPS} paddle_gtest_main lod_tensor memory gtest gflags glog)
383392
add_test(${TARGET_NAME} ${TARGET_NAME})
384393
if (nv_test_SERIAL)

0 commit comments

Comments
 (0)