Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
30efee33
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
30efee33
编写于
5月 13, 2020
作者:
S
Shibo Tao
提交者:
GitHub
5月 13, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "support CUDA using cmake built-in way (#24395). test=develop" (#24468)
This reverts commit
068d3690
.
上级
417b576c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
63 addition
and
102 deletion
+63
-102
CMakeLists.txt
CMakeLists.txt
+2
-13
cmake/configure.cmake
cmake/configure.cmake
+4
-4
cmake/cuda.cmake
cmake/cuda.cmake
+50
-37
cmake/flags.cmake
cmake/flags.cmake
+3
-7
cmake/generic.cmake
cmake/generic.cmake
+4
-12
cmake/init.cmake
cmake/init.cmake
+0
-29
未找到文件。
CMakeLists.txt
浏览文件 @
30efee33
...
@@ -20,19 +20,6 @@ set(PADDLE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
...
@@ -20,19 +20,6 @@ set(PADDLE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
include
(
system
)
include
(
system
)
project
(
paddle CXX C
)
project
(
paddle CXX C
)
include
(
init
)
# enable language CUDA
# TODO(Shibo Tao): remove find_package(CUDA) completely.
find_package
(
CUDA QUIET
)
option
(
WITH_GPU
"Compile PaddlePaddle with NVIDIA GPU"
${
CUDA_FOUND
}
)
if
(
WITH_GPU AND NOT APPLE
)
enable_language
(
CUDA
)
message
(
STATUS
"CUDA compiler:
${
CMAKE_CUDA_COMPILER
}
, version: "
"
${
CMAKE_CUDA_COMPILER_ID
}
${
CMAKE_CUDA_COMPILER_VERSION
}
"
)
endif
()
message
(
STATUS
"CXX compiler:
${
CMAKE_CXX_COMPILER
}
, version: "
message
(
STATUS
"CXX compiler:
${
CMAKE_CXX_COMPILER
}
, version: "
"
${
CMAKE_CXX_COMPILER_ID
}
${
CMAKE_CXX_COMPILER_VERSION
}
"
)
"
${
CMAKE_CXX_COMPILER_ID
}
${
CMAKE_CXX_COMPILER_VERSION
}
"
)
message
(
STATUS
"C compiler:
${
CMAKE_C_COMPILER
}
, version: "
message
(
STATUS
"C compiler:
${
CMAKE_C_COMPILER
}
, version: "
...
@@ -65,12 +52,14 @@ else(WIN32)
...
@@ -65,12 +52,14 @@ else(WIN32)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-error=deprecated-declarations -Wno-deprecated-declarations"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-error=deprecated-declarations -Wno-deprecated-declarations"
)
endif
(
WIN32
)
endif
(
WIN32
)
find_package
(
CUDA QUIET
)
find_package
(
Git REQUIRED
)
find_package
(
Git REQUIRED
)
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
include
(
simd
)
include
(
simd
)
################################ Exposed Configurations #######################################
################################ Exposed Configurations #######################################
option
(
WITH_GPU
"Compile PaddlePaddle with NVIDIA GPU"
${
CUDA_FOUND
}
)
option
(
WITH_DSO
"Compile PaddlePaddle with dynamic linked CUDA"
ON
)
option
(
WITH_DSO
"Compile PaddlePaddle with dynamic linked CUDA"
ON
)
option
(
WITH_AVX
"Compile PaddlePaddle with AVX intrinsics"
${
AVX_FOUND
}
)
option
(
WITH_AVX
"Compile PaddlePaddle with AVX intrinsics"
${
AVX_FOUND
}
)
option
(
WITH_PYTHON
"Compile PaddlePaddle with python interpreter"
ON
)
option
(
WITH_PYTHON
"Compile PaddlePaddle with python interpreter"
ON
)
...
...
cmake/configure.cmake
浏览文件 @
30efee33
...
@@ -76,7 +76,7 @@ if(WITH_GPU)
...
@@ -76,7 +76,7 @@ if(WITH_GPU)
FIND_PACKAGE
(
CUDA REQUIRED
)
FIND_PACKAGE
(
CUDA REQUIRED
)
if
(
${
C
MAKE_CUDA_COMPILER_VERSION
}
VERSION_LESS 7
)
if
(
${
C
UDA_VERSION_MAJOR
}
VERSION_LESS 7
)
message
(
FATAL_ERROR
"Paddle needs CUDA >= 7.0 to compile"
)
message
(
FATAL_ERROR
"Paddle needs CUDA >= 7.0 to compile"
)
endif
()
endif
()
...
@@ -89,7 +89,7 @@ if(WITH_GPU)
...
@@ -89,7 +89,7 @@ if(WITH_GPU)
else
()
else
()
message
(
STATUS
"Cannot find CUPTI, GPU Profiling is incorrect."
)
message
(
STATUS
"Cannot find CUPTI, GPU Profiling is incorrect."
)
endif
()
endif
()
set
(
C
MAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-Xcompiler=
\"
${
SIMD_FLAG
}
\"
"
)
set
(
C
UDA_NVCC_FLAGS
${
CUDA_NVCC_FLAGS
}
"-Xcompiler
${
SIMD_FLAG
}
"
)
# Include cuda and cudnn
# Include cuda and cudnn
include_directories
(
${
CUDNN_INCLUDE_DIR
}
)
include_directories
(
${
CUDNN_INCLUDE_DIR
}
)
...
@@ -97,11 +97,11 @@ if(WITH_GPU)
...
@@ -97,11 +97,11 @@ if(WITH_GPU)
if
(
TENSORRT_FOUND
)
if
(
TENSORRT_FOUND
)
if
(
WIN32
)
if
(
WIN32
)
if
(
${
C
MAKE_CUDA_COMPILER_VERSION
}
VERSION_LESS 9
)
if
(
${
C
UDA_VERSION_MAJOR
}
VERSION_LESS 9
)
message
(
FATAL_ERROR
"TensorRT needs CUDA >= 9.0 to compile on Windows"
)
message
(
FATAL_ERROR
"TensorRT needs CUDA >= 9.0 to compile on Windows"
)
endif
()
endif
()
else
()
else
()
if
(
${
C
MAKE_CUDA_COMPILER_VERSION
}
VERSION_LESS 8
)
if
(
${
C
UDA_VERSION_MAJOR
}
VERSION_LESS 8
)
message
(
FATAL_ERROR
"TensorRT needs CUDA >= 8.0 to compile"
)
message
(
FATAL_ERROR
"TensorRT needs CUDA >= 8.0 to compile"
)
endif
()
endif
()
if
(
${
CUDNN_MAJOR_VERSION
}
VERSION_LESS 7
)
if
(
${
CUDNN_MAJOR_VERSION
}
VERSION_LESS 7
)
...
...
cmake/cuda.cmake
浏览文件 @
30efee33
...
@@ -104,12 +104,12 @@ function(select_nvcc_arch_flags out_variable)
...
@@ -104,12 +104,12 @@ function(select_nvcc_arch_flags out_variable)
elseif
(
${
CUDA_ARCH_NAME
}
STREQUAL
"Pascal"
)
elseif
(
${
CUDA_ARCH_NAME
}
STREQUAL
"Pascal"
)
set
(
cuda_arch_bin
"60 61"
)
set
(
cuda_arch_bin
"60 61"
)
elseif
(
${
CUDA_ARCH_NAME
}
STREQUAL
"Volta"
)
elseif
(
${
CUDA_ARCH_NAME
}
STREQUAL
"Volta"
)
if
(
NOT
${
C
MAKE_CUDA_COMPILER
_VERSION
}
LESS 10.0
)
if
(
NOT
${
C
UDA
_VERSION
}
LESS 10.0
)
add_definitions
(
"-DSUPPORTS_CUDA_FP16"
)
add_definitions
(
"-DSUPPORTS_CUDA_FP16"
)
endif
()
endif
()
set
(
cuda_arch_bin
"70"
)
set
(
cuda_arch_bin
"70"
)
elseif
(
${
CUDA_ARCH_NAME
}
STREQUAL
"Turing"
)
elseif
(
${
CUDA_ARCH_NAME
}
STREQUAL
"Turing"
)
if
(
NOT
${
C
MAKE_CUDA_COMPILER
_VERSION
}
LESS 10.0
)
if
(
NOT
${
C
UDA
_VERSION
}
LESS 10.0
)
add_definitions
(
"-DSUPPORTS_CUDA_FP16"
)
add_definitions
(
"-DSUPPORTS_CUDA_FP16"
)
endif
()
endif
()
set
(
cuda_arch_bin
"75"
)
set
(
cuda_arch_bin
"75"
)
...
@@ -142,19 +142,19 @@ function(select_nvcc_arch_flags out_variable)
...
@@ -142,19 +142,19 @@ function(select_nvcc_arch_flags out_variable)
foreach
(
arch
${
cuda_arch_bin
}
)
foreach
(
arch
${
cuda_arch_bin
}
)
if
(
arch MATCHES
"([0-9]+)
\\
(([0-9]+)
\\
)"
)
if
(
arch MATCHES
"([0-9]+)
\\
(([0-9]+)
\\
)"
)
# User explicitly specified PTX for the concrete BIN
# User explicitly specified PTX for the concrete BIN
string
(
APPEND nvcc_flags
" -gencode arch=compute_
${
CMAKE_MATCH_2
}
,code=sm_
${
CMAKE_MATCH_1
}
"
)
list
(
APPEND nvcc_flags -gencode arch=compute_
${
CMAKE_MATCH_2
}
,code=sm_
${
CMAKE_MATCH_1
}
)
string
(
APPEND nvcc_archs_readable
" sm_
${
CMAKE_MATCH_1
}
"
)
list
(
APPEND nvcc_archs_readable sm_
${
CMAKE_MATCH_1
}
)
else
()
else
()
# User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN
# User didn't explicitly specify PTX for the concrete BIN, we assume PTX=BIN
string
(
APPEND nvcc_flags
" -gencode arch=compute_
${
arch
}
,code=sm_
${
arch
}
"
)
list
(
APPEND nvcc_flags -gencode arch=compute_
${
arch
}
,code=sm_
${
arch
}
)
string
(
APPEND nvcc_archs_readable
" sm_
${
arch
}
"
)
list
(
APPEND nvcc_archs_readable sm_
${
arch
}
)
endif
()
endif
()
endforeach
()
endforeach
()
# Tell NVCC to add PTX intermediate code for the specified architectures
# Tell NVCC to add PTX intermediate code for the specified architectures
foreach
(
arch
${
cuda_arch_ptx
}
)
foreach
(
arch
${
cuda_arch_ptx
}
)
string
(
APPEND nvcc_flags
" -gencode arch=compute_
${
arch
}
,code=compute_
${
arch
}
"
)
list
(
APPEND nvcc_flags -gencode arch=compute_
${
arch
}
,code=compute_
${
arch
}
)
string
(
APPEND nvcc_archs_readable
" compute_
${
arch
}
"
)
list
(
APPEND nvcc_archs_readable compute_
${
arch
}
)
endforeach
()
endforeach
()
string
(
REPLACE
";"
" "
nvcc_archs_readable
"
${
nvcc_archs_readable
}
"
)
string
(
REPLACE
";"
" "
nvcc_archs_readable
"
${
nvcc_archs_readable
}
"
)
...
@@ -162,32 +162,32 @@ function(select_nvcc_arch_flags out_variable)
...
@@ -162,32 +162,32 @@ function(select_nvcc_arch_flags out_variable)
set
(
${
out_variable
}
_readable
${
nvcc_archs_readable
}
PARENT_SCOPE
)
set
(
${
out_variable
}
_readable
${
nvcc_archs_readable
}
PARENT_SCOPE
)
endfunction
()
endfunction
()
message
(
STATUS
"CUDA detected: "
${
C
MAKE_CUDA_COMPILER
_VERSION
}
)
message
(
STATUS
"CUDA detected: "
${
C
UDA
_VERSION
}
)
if
(
${
C
MAKE_CUDA_COMPILER
_VERSION
}
LESS 7.0
)
if
(
${
C
UDA
_VERSION
}
LESS 7.0
)
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs
}
)
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs
}
)
elseif
(
${
C
MAKE_CUDA_COMPILER
_VERSION
}
LESS 8.0
)
# CUDA 7.x
elseif
(
${
C
UDA
_VERSION
}
LESS 8.0
)
# CUDA 7.x
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs7
}
)
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs7
}
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D_MWAITXINTRIN_H_INCLUDED"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D_MWAITXINTRIN_H_INCLUDED"
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D__STRICT_ANSI__"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D__STRICT_ANSI__"
)
elseif
(
${
C
MAKE_CUDA_COMPILER
_VERSION
}
LESS 9.0
)
# CUDA 8.x
elseif
(
${
C
UDA
_VERSION
}
LESS 9.0
)
# CUDA 8.x
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs8
}
)
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs8
}
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D_MWAITXINTRIN_H_INCLUDED"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D_MWAITXINTRIN_H_INCLUDED"
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D__STRICT_ANSI__"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D__STRICT_ANSI__"
)
# CUDA 8 may complain that sm_20 is no longer supported. Suppress the
# CUDA 8 may complain that sm_20 is no longer supported. Suppress the
# warning for now.
# warning for now.
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-Wno-deprecated-gpu-targets"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-Wno-deprecated-gpu-targets"
)
elseif
(
${
C
MAKE_CUDA_COMPILER
_VERSION
}
LESS 10.0
)
# CUDA 9.x
elseif
(
${
C
UDA
_VERSION
}
LESS 10.0
)
# CUDA 9.x
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs9
}
)
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs9
}
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D_MWAITXINTRIN_H_INCLUDED"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D_MWAITXINTRIN_H_INCLUDED"
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D__STRICT_ANSI__"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D__STRICT_ANSI__"
)
elseif
(
${
C
MAKE_CUDA_COMPILER
_VERSION
}
LESS 11.0
)
# CUDA 10.x
elseif
(
${
C
UDA
_VERSION
}
LESS 11.0
)
# CUDA 10.x
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs10
}
)
set
(
paddle_known_gpu_archs
${
paddle_known_gpu_archs10
}
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D_MWAITXINTRIN_H_INCLUDED"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D_MWAITXINTRIN_H_INCLUDED"
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-D__STRICT_ANSI__"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-D__STRICT_ANSI__"
)
endif
()
endif
()
add_definitions
(
"-DPADDLE_CUDA_BINVER=
\"
${
CUDA_VERSION_MAJOR
}${
CUDA_VERSION_MINOR
}
\"
"
)
message
(
STATUS
"PADDLE_CUDA_BINVER=
${
CUDA_VERSION_MAJOR
}${
CUDA_VERSION_MINOR
}
"
)
include_directories
(
${
CUDA_INCLUDE_DIRS
}
)
if
(
NOT WITH_DSO
)
if
(
NOT WITH_DSO
)
if
(
WIN32
)
if
(
WIN32
)
set_property
(
GLOBAL PROPERTY CUDA_MODULES
${
CUDNN_LIBRARY
}
${
CUDA_CUBLAS_LIBRARIES
}
${
CUDA_curand_LIBRARY
}
${
CUDA_cusolver_LIBRARY
}
)
set_property
(
GLOBAL PROPERTY CUDA_MODULES
${
CUDNN_LIBRARY
}
${
CUDA_CUBLAS_LIBRARIES
}
${
CUDA_curand_LIBRARY
}
${
CUDA_cusolver_LIBRARY
}
)
...
@@ -196,24 +196,37 @@ endif(NOT WITH_DSO)
...
@@ -196,24 +196,37 @@ endif(NOT WITH_DSO)
# setting nvcc arch flags
# setting nvcc arch flags
select_nvcc_arch_flags
(
NVCC_FLAGS_EXTRA
)
select_nvcc_arch_flags
(
NVCC_FLAGS_EXTRA
)
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
${
NVCC_FLAGS_EXTRA
}
"
)
list
(
APPEND CUDA_NVCC_FLAGS
${
NVCC_FLAGS_EXTRA
}
)
message
(
STATUS
"
NVCC_FLAGS_EXTRA:
${
NVCC_FLAGS_EXTRA
}
"
)
message
(
STATUS
"
Added CUDA NVCC flags for:
${
NVCC_FLAGS_EXTRA_readable
}
"
)
# Set C++11 support
# Set C++11 support
set
(
CUDA_PROPAGATE_HOST_FLAGS OFF
)
set
(
CUDA_PROPAGATE_HOST_FLAGS OFF
)
# Release/Debug flags set by cmake. Such as -O3 -g -DNDEBUG etc.
# Release/Debug flags set by cmake. Such as -O3 -g -DNDEBUG etc.
# So, don't set these flags here.
# So, don't set these flags here.
if
(
NOT WIN32
)
# windows msvc2015 support c++11 natively.
if
(
NOT WIN32
)
# windows msvc2015 support c++11 natively.
# -std=c++11 -fPIC not recoginize by msvc, -Xcompiler will be added by cmake.
# -std=c++11 -fPIC not recoginize by msvc, -Xcompiler will be added by cmake.
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-std=c++11"
)
list
(
APPEND CUDA_NVCC_FLAGS
"-std=c++11"
)
list
(
APPEND CUDA_NVCC_FLAGS
"-Xcompiler -fPIC"
)
endif
(
NOT WIN32
)
endif
(
NOT WIN32
)
# in cuda9, suppress cuda warning on eigen
# in cuda9, suppress cuda warning on eigen
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
-w"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
-w"
)
# Set :expt-relaxed-constexpr to suppress Eigen warnings
# Set :expt-relaxed-constexpr to suppress Eigen warnings
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
--expt-relaxed-constexpr"
)
list
(
APPEND CUDA_NVCC_FLAGS
"
--expt-relaxed-constexpr"
)
if
(
WIN32
)
if
(
NOT WIN32
)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Debug"
)
list
(
APPEND CUDA_NVCC_FLAGS
${
CMAKE_CXX_FLAGS_DEBUG
}
)
elseif
(
CMAKE_BUILD_TYPE STREQUAL
"Release"
)
list
(
APPEND CUDA_NVCC_FLAGS
${
CMAKE_CXX_FLAGS_RELEASE
}
)
elseif
(
CMAKE_BUILD_TYPE STREQUAL
"RelWithDebInfo"
)
list
(
APPEND CUDA_NVCC_FLAGS
${
CMAKE_CXX_FLAGS_RELWITHDEBINFO
}
)
elseif
(
CMAKE_BUILD_TYPE STREQUAL
"MinSizeRel"
)
# nvcc 9 does not support -Os. Use Release flags instead
list
(
APPEND CUDA_NVCC_FLAGS
${
CMAKE_CXX_FLAGS_RELEASE
}
)
endif
()
else
(
NOT WIN32
)
list
(
APPEND CUDA_NVCC_FLAGS
"-Xcompiler
\"
/wd 4244 /wd 4267 /wd 4819
\"
"
)
list
(
APPEND CUDA_NVCC_FLAGS
"-Xcompiler
\"
/wd 4244 /wd 4267 /wd 4819
\"
"
)
list
(
APPEND CUDA_NVCC_FLAGS
"--compiler-options;/bigobj"
)
list
(
APPEND CUDA_NVCC_FLAGS
"--compiler-options;/bigobj"
)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Debug"
)
if
(
CMAKE_BUILD_TYPE STREQUAL
"Debug"
)
...
@@ -223,9 +236,9 @@ if (WIN32)
...
@@ -223,9 +236,9 @@ if (WIN32)
elseif
(
CMAKE_BUILD_TYPE STREQUAL
"Release"
)
elseif
(
CMAKE_BUILD_TYPE STREQUAL
"Release"
)
list
(
APPEND CUDA_NVCC_FLAGS
"-O3 -DNDEBUG"
)
list
(
APPEND CUDA_NVCC_FLAGS
"-O3 -DNDEBUG"
)
else
()
else
()
message
(
FATAL
"Windows only support Release or Debug build now. Please set visual studio build type to Release/Debug, x64 build."
)
message
(
FATAL
"Windows only support Release or Debug build now. Please set visual studio build type to Release/Debug, x64 build."
)
endif
()
endif
()
endif
(
WIN32
)
endif
(
NOT
WIN32
)
mark_as_advanced
(
CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD
)
mark_as_advanced
(
CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD
)
mark_as_advanced
(
CUDA_SDK_ROOT_DIR CUDA_SEPARABLE_COMPILATION
)
mark_as_advanced
(
CUDA_SDK_ROOT_DIR CUDA_SEPARABLE_COMPILATION
)
cmake/flags.cmake
浏览文件 @
30efee33
...
@@ -76,7 +76,7 @@ macro(safe_set_nvflag flag_name)
...
@@ -76,7 +76,7 @@ macro(safe_set_nvflag flag_name)
CHECK_C_COMPILER_FLAG
(
${
flag_name
}
C_COMPILER_SUPPORT_FLAG_
${
safe_name
}
)
CHECK_C_COMPILER_FLAG
(
${
flag_name
}
C_COMPILER_SUPPORT_FLAG_
${
safe_name
}
)
set
(
safe_name C_COMPILER_SUPPORT_FLAG_
${
safe_name
}
)
set
(
safe_name C_COMPILER_SUPPORT_FLAG_
${
safe_name
}
)
if
(
${
safe_name
}
)
if
(
${
safe_name
}
)
set
(
SAFE_GPU_COMMON_FLAGS
"
${
SAFE_GPU_COMMON_FLAGS
}
-Xcompiler=
\"
${
flag_name
}
\"
"
)
LIST
(
APPEND CUDA_NVCC_FLAGS -Xcompiler
${
flag_name
}
)
endif
()
endif
()
endmacro
()
endmacro
()
...
@@ -169,7 +169,7 @@ if(NOT APPLE)
...
@@ -169,7 +169,7 @@ if(NOT APPLE)
-Wno-error=nonnull-compare
# Warning in boost gcc 8.2
-Wno-error=nonnull-compare
# Warning in boost gcc 8.2
-Wno-error=address
# Warning in boost gcc 8.2
-Wno-error=address
# Warning in boost gcc 8.2
-Wno-ignored-qualifiers
# Warning in boost gcc 8.2
-Wno-ignored-qualifiers
# Warning in boost gcc 8.2
-Wno-ignored-attributes
# Warning in Eigen gcc 8.3
-Wno-ignored-attributes
# Warning in Eigen gcc 8.3
-Wno-parentheses
# Warning in Eigen gcc 8.3
-Wno-parentheses
# Warning in Eigen gcc 8.3
)
)
endif
()
endif
()
...
@@ -187,7 +187,7 @@ set(GPU_COMMON_FLAGS
...
@@ -187,7 +187,7 @@ set(GPU_COMMON_FLAGS
-Wno-error=unused-function
# Warnings in Numpy Header.
-Wno-error=unused-function
# Warnings in Numpy Header.
-Wno-error=array-bounds
# Warnings in Eigen::array
-Wno-error=array-bounds
# Warnings in Eigen::array
)
)
if
(
NOT WITH_NV_JETSON
)
if
(
NOT WITH_NV_JETSON
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-m64"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-m64"
)
endif
()
endif
()
endif
(
NOT WIN32
)
endif
(
NOT WIN32
)
...
@@ -212,14 +212,10 @@ foreach(flag ${COMMON_FLAGS})
...
@@ -212,14 +212,10 @@ foreach(flag ${COMMON_FLAGS})
safe_set_cxxflag
(
CMAKE_CXX_FLAGS
${
flag
}
)
safe_set_cxxflag
(
CMAKE_CXX_FLAGS
${
flag
}
)
endforeach
()
endforeach
()
set
(
SAFE_GPU_COMMON_FLAGS
""
)
foreach
(
flag
${
GPU_COMMON_FLAGS
}
)
foreach
(
flag
${
GPU_COMMON_FLAGS
}
)
safe_set_nvflag
(
${
flag
}
)
safe_set_nvflag
(
${
flag
}
)
endforeach
()
endforeach
()
set
(
CMAKE_CUDA_FLAGS
"
${
CMAKE_CUDA_FLAGS
}
${
SAFE_GPU_COMMON_FLAGS
}
"
)
if
(
WIN32 AND MSVC_STATIC_CRT
)
if
(
WIN32 AND MSVC_STATIC_CRT
)
# windows build turn off warnings.
# windows build turn off warnings.
safe_set_static_flag
()
safe_set_static_flag
()
...
...
cmake/generic.cmake
浏览文件 @
30efee33
...
@@ -412,14 +412,10 @@ function(nv_library TARGET_NAME)
...
@@ -412,14 +412,10 @@ function(nv_library TARGET_NAME)
set
(
multiValueArgs SRCS DEPS
)
set
(
multiValueArgs SRCS DEPS
)
cmake_parse_arguments
(
nv_library
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
nv_library
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
if
(
nv_library_SRCS
)
if
(
nv_library_SRCS
)
# Attention:
# 1. cuda_add_library is deprecated after cmake v3.10, use add_library for CUDA please.
# 2. cuda_add_library does not support ccache.
# Reference: https://cmake.org/cmake/help/v3.10/module/FindCUDA.html
if
(
nv_library_SHARED OR nv_library_shared
)
# build *.so
if
(
nv_library_SHARED OR nv_library_shared
)
# build *.so
add_library
(
${
TARGET_NAME
}
SHARED
${
nv_library_SRCS
}
)
cuda_
add_library
(
${
TARGET_NAME
}
SHARED
${
nv_library_SRCS
}
)
else
()
else
()
add_library
(
${
TARGET_NAME
}
STATIC
${
nv_library_SRCS
}
)
cuda_
add_library
(
${
TARGET_NAME
}
STATIC
${
nv_library_SRCS
}
)
find_fluid_modules
(
${
TARGET_NAME
}
)
find_fluid_modules
(
${
TARGET_NAME
}
)
endif
()
endif
()
if
(
nv_library_DEPS
)
if
(
nv_library_DEPS
)
...
@@ -454,7 +450,7 @@ function(nv_binary TARGET_NAME)
...
@@ -454,7 +450,7 @@ function(nv_binary TARGET_NAME)
set
(
oneValueArgs
""
)
set
(
oneValueArgs
""
)
set
(
multiValueArgs SRCS DEPS
)
set
(
multiValueArgs SRCS DEPS
)
cmake_parse_arguments
(
nv_binary
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
nv_binary
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
add_executable
(
${
TARGET_NAME
}
${
nv_binary_SRCS
}
)
cuda_
add_executable
(
${
TARGET_NAME
}
${
nv_binary_SRCS
}
)
if
(
nv_binary_DEPS
)
if
(
nv_binary_DEPS
)
target_link_libraries
(
${
TARGET_NAME
}
${
nv_binary_DEPS
}
)
target_link_libraries
(
${
TARGET_NAME
}
${
nv_binary_DEPS
}
)
add_dependencies
(
${
TARGET_NAME
}
${
nv_binary_DEPS
}
)
add_dependencies
(
${
TARGET_NAME
}
${
nv_binary_DEPS
}
)
...
@@ -468,11 +464,7 @@ function(nv_test TARGET_NAME)
...
@@ -468,11 +464,7 @@ function(nv_test TARGET_NAME)
set
(
oneValueArgs
""
)
set
(
oneValueArgs
""
)
set
(
multiValueArgs SRCS DEPS
)
set
(
multiValueArgs SRCS DEPS
)
cmake_parse_arguments
(
nv_test
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
cmake_parse_arguments
(
nv_test
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
# Attention:
cuda_add_executable
(
${
TARGET_NAME
}
${
nv_test_SRCS
}
)
# 1. cuda_add_executable is deprecated after cmake v3.10, use cuda_add_executable for CUDA please.
# 2. cuda_add_executable does not support ccache.
# Reference: https://cmake.org/cmake/help/v3.10/module/FindCUDA.html
add_executable
(
${
TARGET_NAME
}
${
nv_test_SRCS
}
)
get_property
(
os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES
)
get_property
(
os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES
)
target_link_libraries
(
${
TARGET_NAME
}
${
nv_test_DEPS
}
paddle_gtest_main lod_tensor memory gtest gflags glog
${
os_dependency_modules
}
)
target_link_libraries
(
${
TARGET_NAME
}
${
nv_test_DEPS
}
paddle_gtest_main lod_tensor memory gtest gflags glog
${
os_dependency_modules
}
)
add_dependencies
(
${
TARGET_NAME
}
${
nv_test_DEPS
}
paddle_gtest_main lod_tensor memory gtest gflags glog
)
add_dependencies
(
${
TARGET_NAME
}
${
nv_test_DEPS
}
paddle_gtest_main lod_tensor memory gtest gflags glog
)
...
...
cmake/init.cmake
已删除
100644 → 0
浏览文件 @
417b576c
# Attention: cmake will append these flags to compile command automatically.
# So if you want to add global option, change this file rather than flags.cmake
# default: "-g"
set
(
CMAKE_C_FLAGS_DEBUG
"-g"
)
# default: "-O3 -DNDEBUG"
set
(
CMAKE_C_FLAGS_RELEASE
"-O3 -DNDEBUG"
)
# default: "-O2 -g -DNDEBUG"
set
(
CMAKE_C_FLAGS_RELWITHDEBINFO
"-O2 -g -DNDEBUG"
)
# default: "-Os -DNDEBUG"
set
(
CMAKE_C_FLAGS_MINSIZEREL
"-Os -DNDEBUG"
)
# default: "-g"
set
(
CMAKE_CXX_FLAGS_DEBUG
"-g"
)
# default: "-O3 -DNDEBUG"
set
(
CMAKE_CXX_FLAGS_RELEASE
"-O3 -DNDEBUG"
)
# default: "-O2 -g -DNDEBUG"
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O2 -g -DNDEBUG"
)
# default: "-Os -DNDEBUG"
set
(
CMAKE_CXX_FLAGS_MINSIZEREL
"-Os -DNDEBUG"
)
# default: "-g"
set
(
CMAKE_CUDA_FLAGS_DEBUG
"-g"
)
# default: "-O3 -DNDEBUG"
set
(
CMAKE_CUDA_FLAGS_RELEASE
"-O3 -DNDEBUG"
)
# default: "-O2 -g -DNDEBUG"
set
(
CMAKE_CUDA_FLAGS_RELWITHDEBINFO
"-O2 -g -DNDEBUG"
)
# default: "-O1 -DNDEBUG"
set
(
CMAKE_CUDA_FLAGS_MINSIZEREL
"-O1 -DNDEBUG"
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录