aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-04-08 13:16:08 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-04-08 13:16:08 -0700
commit0d2a532fc3b25199af03106b6d4ade0f92a30dfc (patch)
treeed32b7f06a90d2ba5d0c0a66cabbf45fa9ce5ec4
parent2d072b38c134c60fb796e36466fd4e7a1888ce35 (diff)
Created the new EIGEN_TEST_CUDA_CLANG option to compile the CUDA tests using clang instead of nvcc
-rw-r--r--cmake/EigenTesting.cmake27
-rw-r--r--test/CMakeLists.txt11
-rw-r--r--unsupported/test/CMakeLists.txt4
3 files changed, 37 insertions, 5 deletions
diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake
index d5e3972b5..6f3661921 100644
--- a/cmake/EigenTesting.cmake
+++ b/cmake/EigenTesting.cmake
@@ -19,10 +19,25 @@ macro(ei_add_test_internal testname testname_with_suffix)
endif()
if(EIGEN_ADD_TEST_FILENAME_EXTENSION STREQUAL cu)
- if (${ARGC} GREATER 2)
- cuda_add_executable(${targetname} ${filename} OPTIONS ${ARGV2})
+ if(EIGEN_TEST_CUDA_CLANG)
+ set_source_files_properties(${filename} PROPERTIES LANGUAGE CXX)
+ if(CUDA_64_BIT_DEVICE_CODE)
+ link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
+ else()
+ link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib")
+ endif()
+ if (${ARGC} GREATER 2)
+ add_executable(${targetname} ${filename})
+ else()
+ add_executable(${targetname} ${filename} OPTIONS ${ARGV2})
+ endif()
+ target_link_libraries(${targetname} "cudart_static" "cuda" "dl" "rt" "pthread")
else()
- cuda_add_executable(${targetname} ${filename})
+ if (${ARGC} GREATER 2)
+ cuda_add_executable(${targetname} ${filename} OPTIONS ${ARGV2})
+ else()
+ cuda_add_executable(${targetname} ${filename})
+ endif()
endif()
else()
add_executable(${targetname} ${filename})
@@ -316,7 +331,11 @@ macro(ei_testing_print_summary)
endif()
if(EIGEN_TEST_CUDA)
- message(STATUS "CUDA: ON")
+ if(EIGEN_TEST_CUDA_CLANG)
+ message(STATUS "CUDA: ON (using clang)")
+ else()
+ message(STATUS "CUDA: ON (using nvcc)")
+ endif()
else()
message(STATUS "CUDA: OFF")
endif()
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 841c4572b..7bed6a45c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -327,8 +327,14 @@ endif()
# CUDA unit tests
option(EIGEN_TEST_CUDA "Enable CUDA support in unit tests" OFF)
+option(EIGEN_TEST_CUDA_CLANG "Use clang instead of nvcc to compile the CUDA tests" OFF)
+
+if(EIGEN_TEST_CUDA_CLANG AND NOT CMAKE_CXX_COMPILER MATCHES "clang")
+ message(WARNING "EIGEN_TEST_CUDA_CLANG is set, but CMAKE_CXX_COMPILER does not appear to be clang.")
+endif()
+
if(EIGEN_TEST_CUDA)
-
+
find_package(CUDA 5.0)
if(CUDA_FOUND)
@@ -336,6 +342,9 @@ if(CUDA_FOUND)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CUDA_NVCC_FLAGS "-ccbin /usr/bin/clang" CACHE STRING "nvcc flags" FORCE)
endif()
+ if(EIGEN_TEST_CUDA_CLANG)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 --cuda-gpu-arch=sm_30")
+ endif()
cuda_include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu")
diff --git a/unsupported/test/CMakeLists.txt b/unsupported/test/CMakeLists.txt
index c6a92fe73..b1931d80a 100644
--- a/unsupported/test/CMakeLists.txt
+++ b/unsupported/test/CMakeLists.txt
@@ -190,6 +190,10 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CUDA_NVCC_FLAGS "-ccbin /usr/bin/clang" CACHE STRING "nvcc flags" FORCE)
endif()
+ if(EIGEN_TEST_CUDA_CLANG)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 --cuda-gpu-arch=sm_${EIGEN_CUDA_COMPUTE_ARCH}")
+ endif()
+
set(CUDA_NVCC_FLAGS "-std=c++11 --relaxed-constexpr -arch compute_${EIGEN_CUDA_COMPUTE_ARCH} -Xcudafe \"--display_error_number\"")
cuda_include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/include")
set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu")