提交 125c19a3 编写于 作者: H hedaoyuan 提交者: gangliao

fix some nvcc compile options (#392)

上级 57bc6238
...@@ -95,11 +95,26 @@ if(NOT WITH_GPU) ...@@ -95,11 +95,26 @@ if(NOT WITH_GPU)
add_definitions(-DHPPL_STUB_FUNC) add_definitions(-DHPPL_STUB_FUNC)
list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu) list(APPEND CMAKE_CXX_SOURCE_FILE_EXTENSIONS cu)
else() else()
if(${CUDA_VERSION_MAJOR} GREATER 6)
if(COMPILER_SUPPORT_CXX11)
LIST(APPEND CUDA_NVCC_FLAGS -std=c++11)
endif()
endif()
# TODO(yuyang18): Change it to remove std=c++11 in cuda compile. # TODO(yuyang18): Change it to remove std=c++11 in cuda compile.
set(CUDA_PROPAGATE_HOST_FLAGS OFF) set(CUDA_PROPAGATE_HOST_FLAGS OFF)
if(NOT CUDNN_FOUND) if(NOT CUDNN_FOUND)
message(FATAL_ERROR "Paddle need cudnn to compile") message(FATAL_ERROR "Paddle need cudnn to compile")
endif() endif()
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-g -O3 --use_fast_math")
if(WITH_AVX)
if(AVX_FOUND)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler -mavx")
endif(AVX_FOUND)
else(WITH_AVX)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler -msse3")
endif(WITH_AVX)
if(WITH_DSO) if(WITH_DSO)
set(CUDA_LIBRARIES "") set(CUDA_LIBRARIES "")
......
...@@ -188,14 +188,6 @@ macro(add_simple_unittest TARGET_NAME) ...@@ -188,14 +188,6 @@ macro(add_simple_unittest TARGET_NAME)
add_unittest(${TARGET_NAME} ${TARGET_NAME}.cpp) add_unittest(${TARGET_NAME} ${TARGET_NAME}.cpp)
endmacro() endmacro()
macro(add_paddle_culib TARGET_NAME)
set(NVCC_FLAG ${CUDA_NVCC_FLAGS})
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};--use_fast_math)
cuda_add_library(${TARGET_NAME} STATIC ${ARGN})
set(CUDA_NVCC_FLAGS ${NVCC_FLAG})
endmacro()
# Creates C resources file from files in given resource file # Creates C resources file from files in given resource file
function(create_resources res_file output) function(create_resources res_file output)
# Create empty output file # Create empty output file
......
...@@ -50,7 +50,7 @@ if(NOT WITH_PYTHON) ...@@ -50,7 +50,7 @@ if(NOT WITH_PYTHON)
endif() endif()
if(WITH_GPU) if(WITH_GPU)
add_paddle_culib(paddle_gserver ${GSERVER_SOURCES}) cuda_add_library(paddle_gserver ${GSERVER_SOURCES})
else() else()
add_library(paddle_gserver STATIC add_library(paddle_gserver STATIC
${GSERVER_SOURCES}) ${GSERVER_SOURCES})
......
...@@ -23,7 +23,7 @@ if(NOT WITH_GPU) ...@@ -23,7 +23,7 @@ if(NOT WITH_GPU)
add_library(paddle_math STATIC add_library(paddle_math STATIC
${MATH_SOURCES}) ${MATH_SOURCES})
else() else()
add_paddle_culib(paddle_math ${MATH_SOURCES}) cuda_add_library(paddle_math ${MATH_SOURCES})
endif() endif()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册