diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 0a0a863a9..782c4b885 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -166,10 +166,8 @@ template<> struct make_unsigned { typedef unsigned int type; } template<> struct make_unsigned { typedef unsigned int type; }; template<> struct make_unsigned { typedef unsigned long type; }; template<> struct make_unsigned { typedef unsigned long type; }; -#if EIGEN_COMP_MSVC -template<> struct make_unsigned { typedef unsigned __int64 type; }; -template<> struct make_unsigned { typedef unsigned __int64 type; }; -#endif +template<> struct make_unsigned { typedef unsigned long type; }; +template<> struct make_unsigned { typedef unsigned long type; }; #endif template struct add_const { typedef const T type; }; @@ -527,7 +525,7 @@ template struct scalar_product_traits } // end namespace internal namespace numext { - + #if defined(__CUDA_ARCH__) template EIGEN_DEVICE_FUNC void swap(T &a, T &b) { T tmp = b; b = a; a = tmp; } #else diff --git a/blas/CMakeLists.txt b/blas/CMakeLists.txt index 9887d5804..351b43a9d 100644 --- a/blas/CMakeLists.txt +++ b/blas/CMakeLists.txt @@ -7,7 +7,7 @@ workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS) if(EIGEN_Fortran_COMPILER_WORKS) enable_language(Fortran OPTIONAL) - if(NOT CMAKE_Fortran_COMPILER) + if(CMAKE_CROSSCOMPILING OR NOT CMAKE_Fortran_COMPILER) set(EIGEN_Fortran_COMPILER_WORKS OFF) endif() endif() diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake index 3d0074c71..d7056a6ac 100644 --- a/cmake/EigenTesting.cmake +++ b/cmake/EigenTesting.cmake @@ -71,7 +71,7 @@ macro(ei_add_test_internal testname testname_with_suffix) endif(${ARGC} GREATER 2) if(EIGEN_TEST_CUSTOM_CXX_FLAGS) - ei_add_target_property(${targetname} COMPILE_FLAGS "${EIGEN_TEST_CUSTOM_CXX_FLAGS}") + target_compile_options(${targetname} PRIVATE ${EIGEN_TEST_CUSTOM_CXX_FLAGS}) endif() if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) @@ -145,10 +145,10 @@ macro(ei_add_test_internal_sycl testname testname_with_suffix) endif() if(EIGEN_NO_ASSERTION_CHECKING) - ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1") + target_compile_options(${targetname} PRIVATE "-DEIGEN_NO_ASSERTION_CHECKING=1") else(EIGEN_NO_ASSERTION_CHECKING) if(EIGEN_DEBUG_ASSERTS) - ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1") + target_compile_options(${targetname} PRIVATE "-DEIGEN_DEBUG_ASSERTS=1") endif(EIGEN_DEBUG_ASSERTS) endif(EIGEN_NO_ASSERTION_CHECKING) @@ -166,7 +166,7 @@ macro(ei_add_test_internal_sycl testname testname_with_suffix) endif(${ARGC} GREATER 2) if(EIGEN_TEST_CUSTOM_CXX_FLAGS) - ei_add_target_property(${targetname} COMPILE_FLAGS "${EIGEN_TEST_CUSTOM_CXX_FLAGS}") + target_compile_options(${targetname} PRIVATE ${EIGEN_TEST_CUSTOM_CXX_FLAGS}) endif() if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 47e6fee4b..50a2db708 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ # generate split test header file only if it does not yet exist # in order to prevent a rebuild everytime cmake is configured -if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h) +if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h "") foreach(i RANGE 1 999) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h @@ -340,7 +340,7 @@ endif() # boost MP unit test find_package(Boost) -if(Boost_FOUND) +if(Boost_FOUND AND EIGEN_TEST_CXX11) include_directories(${Boost_INCLUDE_DIRS}) ei_add_test(boostmultiprec "" "${Boost_LIBRARIES}") ei_add_property(EIGEN_TESTED_BACKENDS "Boost.Multiprecision, ") @@ -361,9 +361,9 @@ if(EIGEN_TEST_CUDA) find_package(CUDA 5.0) if(CUDA_FOUND) - + set(CUDA_PROPAGATE_HOST_FLAGS OFF) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_C_COMPILER}" CACHE STRING "nvcc flags" FORCE) endif() if(EIGEN_TEST_CUDA_CLANG) @@ -371,9 +371,9 @@ if(CUDA_FOUND) endif() cuda_include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu") - + ei_add_test(cuda_basic) - + unset(EIGEN_ADD_TEST_FILENAME_EXTENSION) endif(CUDA_FOUND) @@ -381,7 +381,7 @@ endif(CUDA_FOUND) endif(EIGEN_TEST_CUDA) -file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests) add_test(NAME failtests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests COMMAND ${CMAKE_COMMAND} ${Eigen_SOURCE_DIR} -G "${CMAKE_GENERATOR}" -DEIGEN_FAILTEST=ON) option(EIGEN_TEST_BUILD_DOCUMENTATION "Test building the doxygen documentation" OFF) diff --git a/unsupported/test/CMakeLists.txt b/unsupported/test/CMakeLists.txt index 3a8775a1c..aa86aa0b1 100644 --- a/unsupported/test/CMakeLists.txt +++ b/unsupported/test/CMakeLists.txt @@ -215,18 +215,6 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA) message(STATUS "Flags used to compile cuda code: " ${CMAKE_CXX_FLAGS}) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_C_COMPILER}" 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(EIGEN_CUDA_RELAXED_CONSTEXPR "--expt-relaxed-constexpr") - if (${CUDA_VERSION} STREQUAL "7.0") - set(EIGEN_CUDA_RELAXED_CONSTEXPR "--relaxed-constexpr") - endif() - if( (NOT EIGEN_TEST_CXX11) OR (CMAKE_VERSION VERSION_LESS 3.3)) set(EIGEN_CUDA_CXX11_FLAG "-std=c++11") else() @@ -234,8 +222,39 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA) set(EIGEN_CUDA_CXX11_FLAG "") endif() - set(CUDA_NVCC_FLAGS "${EIGEN_CUDA_CXX11_FLAG} ${EIGEN_CUDA_RELAXED_CONSTEXPR} -arch compute_${EIGEN_CUDA_COMPUTE_ARCH} -Xcudafe \"--display_error_number\" ${CUDA_NVCC_FLAGS}") - cuda_include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/include") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_C_COMPILER}" CACHE STRING "nvcc flags" FORCE) + endif() + if(EIGEN_TEST_CUDA_CLANG) + string(APPEND CMAKE_CXX_FLAGS " --cuda-path=${CUDA_TOOLKIT_ROOT_DIR} ${EIGEN_CUDA_CXX11_FLAG}") + foreach(ARCH IN LISTS EIGEN_CUDA_COMPUTE_ARCH) + string(APPEND CMAKE_CXX_FLAGS " --cuda-gpu-arch=sm_${ARCH}") + endforeach() + else() + set(CUDA_PROPAGATE_HOST_FLAGS OFF) + set(NVCC_ARCH_FLAGS) + # Define an -arch=sm_, otherwise if GPU does not exactly match one of + # those in the arch list for -gencode, the kernels will fail to run with + # cudaErrorNoKernelImageForDevice + # This can happen with newer cards (e.g. sm_75) and compiling with older + # versions of nvcc (e.g. 9.2) that do not support their specific arch. + list(LENGTH EIGEN_CUDA_COMPUTE_ARCH EIGEN_CUDA_COMPUTE_ARCH_SIZE) + if(EIGEN_CUDA_COMPUTE_ARCH_SIZE) + list(GET EIGEN_CUDA_COMPUTE_ARCH 0 EIGEN_CUDA_COMPUTE_DEFAULT) + set(NVCC_ARCH_FLAGS " -arch=sm_${EIGEN_CUDA_COMPUTE_DEFAULT}") + endif() + foreach(ARCH IN LISTS EIGEN_CUDA_COMPUTE_ARCH) + string(APPEND NVCC_ARCH_FLAGS " -gencode arch=compute_${ARCH},code=sm_${ARCH}") + endforeach() + set(CUDA_NVCC_FLAGS "--expt-relaxed-constexpr -Xcudafe \"--display_error_number\" ${NVCC_ARCH_FLAGS} ${CUDA_NVCC_FLAGS} ${EIGEN_CUDA_CXX11_FLAG}") + cuda_include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/include") + endif() + + set(EIGEN_CUDA_RELAXED_CONSTEXPR "--expt-relaxed-constexpr") + if (${CUDA_VERSION} STREQUAL "7.0") + set(EIGEN_CUDA_RELAXED_CONSTEXPR "--relaxed-constexpr") + endif() + set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu") ei_add_test(cxx11_tensor_complex_cuda) @@ -246,18 +265,13 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA) ei_add_test(cxx11_tensor_scan_cuda) # Contractions require arch 3.0 or higher - if (${EIGEN_CUDA_COMPUTE_ARCH} GREATER 29) - ei_add_test(cxx11_tensor_device) - ei_add_test(cxx11_tensor_cuda) - ei_add_test(cxx11_tensor_contract_cuda) - ei_add_test(cxx11_tensor_of_float16_cuda) - endif() + ei_add_test(cxx11_tensor_device) + ei_add_test(cxx11_tensor_cuda) + ei_add_test(cxx11_tensor_contract_cuda) + ei_add_test(cxx11_tensor_of_float16_cuda) # The random number generation code requires arch 3.5 or greater. - if (${EIGEN_CUDA_COMPUTE_ARCH} GREATER 34) - ei_add_test(cxx11_tensor_random_cuda) - endif() - + ei_add_test(cxx11_tensor_random_cuda) unset(EIGEN_ADD_TEST_FILENAME_EXTENSION) endif()