1 # generate split test header file only if it does not yet exist 2 # in order to prevent a rebuild everytime cmake is configured 3 if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h) 4 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h "") 5 foreach(i RANGE 1 999) 6 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h 7 "#ifdef EIGEN_TEST_PART_${i}\n" 8 "#define CALL_SUBTEST_${i}(FUNC) CALL_SUBTEST(FUNC)\n" 9 "#else\n" 10 "#define CALL_SUBTEST_${i}(FUNC)\n" 11 "#endif\n\n" 12 ) 13 endforeach() 14 endif() 15 16 set_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT "Unsupported") 17 add_custom_target(BuildUnsupported) 18 19 include_directories(../../test ../../unsupported ../../Eigen 20 ${CMAKE_CURRENT_BINARY_DIR}/../../test) 21 22 find_package (Threads) 23 24 find_package(GoogleHash) 25 if(GOOGLEHASH_FOUND) 26 add_definitions("-DEIGEN_GOOGLEHASH_SUPPORT") 27 include_directories(${GOOGLEHASH_INCLUDES}) 28 ei_add_property(EIGEN_TESTED_BACKENDS "GoogleHash, ") 29 else(GOOGLEHASH_FOUND) 30 ei_add_property(EIGEN_MISSING_BACKENDS "GoogleHash, ") 31 endif(GOOGLEHASH_FOUND) 32 33 find_package(Adolc) 34 if(ADOLC_FOUND) 35 include_directories(${ADOLC_INCLUDES}) 36 ei_add_property(EIGEN_TESTED_BACKENDS "Adolc, ") 37 ei_add_test(forward_adolc "" ${ADOLC_LIBRARIES}) 38 else(ADOLC_FOUND) 39 ei_add_property(EIGEN_MISSING_BACKENDS "Adolc, ") 40 endif(ADOLC_FOUND) 41 42 # this test seems to never have been successful on x87, so is considered to contain a FP-related bug. 43 # see thread: "non-linear optimization test summary" 44 ei_add_test(NonLinearOptimization) 45 46 ei_add_test(NumericalDiff) 47 ei_add_test(autodiff_scalar) 48 ei_add_test(autodiff) 49 50 if (NOT CMAKE_CXX_COMPILER MATCHES "clang\\+\\+$") 51 ei_add_test(BVH) 52 endif() 53 54 ei_add_test(matrix_exponential) 55 ei_add_test(matrix_function) 56 ei_add_test(matrix_power) 57 ei_add_test(matrix_square_root) 58 ei_add_test(alignedvector3) 59 60 ei_add_test(FFT) 61 62 ei_add_test(EulerAngles) 63 64 find_package(MPFR 2.3.0) 65 find_package(GMP) 66 if(MPFR_FOUND AND EIGEN_COMPILER_SUPPORT_CXX11) 67 include_directories(${MPFR_INCLUDES} ./mpreal) 68 ei_add_property(EIGEN_TESTED_BACKENDS "MPFR C++, ") 69 set(EIGEN_MPFR_TEST_LIBRARIES ${MPFR_LIBRARIES} ${GMP_LIBRARIES}) 70 ei_add_test(mpreal_support "-std=c++11" "${EIGEN_MPFR_TEST_LIBRARIES}" ) 71 else() 72 ei_add_property(EIGEN_MISSING_BACKENDS "MPFR C++, ") 73 endif() 74 75 ei_add_test(sparse_extra "" "") 76 77 find_package(FFTW) 78 if(FFTW_FOUND) 79 ei_add_property(EIGEN_TESTED_BACKENDS "fftw, ") 80 include_directories( ${FFTW_INCLUDES} ) 81 if(FFTWL_LIB) 82 ei_add_test(FFTW "-DEIGEN_FFTW_DEFAULT -DEIGEN_HAS_FFTWL" "${FFTW_LIBRARIES}" ) 83 else() 84 ei_add_test(FFTW "-DEIGEN_FFTW_DEFAULT" "${FFTW_LIBRARIES}" ) 85 endif() 86 else() 87 ei_add_property(EIGEN_MISSING_BACKENDS "fftw, ") 88 endif() 89 90 option(EIGEN_TEST_NO_OPENGL "Disable OpenGL support in unit tests" OFF) 91 if(NOT EIGEN_TEST_NO_OPENGL) 92 find_package(OpenGL) 93 find_package(GLUT) 94 find_package(GLEW) 95 if(OPENGL_FOUND AND GLUT_FOUND AND GLEW_FOUND) 96 include_directories(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ${GLEW_INCLUDE_DIRS}) 97 ei_add_property(EIGEN_TESTED_BACKENDS "OpenGL, ") 98 set(EIGEN_GL_LIB ${GLUT_LIBRARIES} ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES}) 99 ei_add_test(openglsupport "" "${EIGEN_GL_LIB}" ) 100 else() 101 ei_add_property(EIGEN_MISSING_BACKENDS "OpenGL, ") 102 endif() 103 else() 104 ei_add_property(EIGEN_MISSING_BACKENDS "OpenGL, ") 105 endif() 106 107 ei_add_test(polynomialsolver) 108 ei_add_test(polynomialutils) 109 ei_add_test(splines) 110 ei_add_test(gmres) 111 ei_add_test(minres) 112 ei_add_test(levenberg_marquardt) 113 ei_add_test(kronecker_product) 114 ei_add_test(special_functions) 115 116 # TODO: The following test names are prefixed with the cxx11 string, since historically 117 # the tests depended on c++11. This isn't the case anymore so we ought to rename them. 118 # FIXME: Old versions of MSVC fail to compile this code, so we just disable these tests 119 # when using visual studio. We should make the check more strict to enable the tests for 120 # newer versions of MSVC. 121 if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 122 ei_add_test(cxx11_tensor_dimension) 123 ei_add_test(cxx11_tensor_map) 124 ei_add_test(cxx11_tensor_assign) 125 ei_add_test(cxx11_tensor_comparisons) 126 ei_add_test(cxx11_tensor_forced_eval) 127 ei_add_test(cxx11_tensor_math) 128 ei_add_test(cxx11_tensor_const) 129 ei_add_test(cxx11_tensor_intdiv) 130 ei_add_test(cxx11_tensor_casts) 131 ei_add_test(cxx11_tensor_empty) 132 ei_add_test(cxx11_tensor_sugar) 133 ei_add_test(cxx11_tensor_roundings) 134 ei_add_test(cxx11_tensor_layout_swap) 135 ei_add_test(cxx11_tensor_io) 136 if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") 137 # This test requires __uint128_t which is only available on 64bit systems 138 ei_add_test(cxx11_tensor_uint128) 139 endif() 140 endif() 141 142 if(EIGEN_TEST_CXX11) 143 if(EIGEN_TEST_SYCL) 144 ei_add_test_sycl(cxx11_tensor_sycl "-std=c++11") 145 ei_add_test_sycl(cxx11_tensor_forced_eval_sycl "-std=c++11") 146 ei_add_test_sycl(cxx11_tensor_broadcast_sycl "-std=c++11") 147 ei_add_test_sycl(cxx11_tensor_device_sycl "-std=c++11") 148 ei_add_test_sycl(cxx11_tensor_reduction_sycl "-std=c++11") 149 endif(EIGEN_TEST_SYCL) 150 # It should be safe to always run these tests as there is some fallback code for 151 # older compiler that don't support cxx11. 152 set(CMAKE_CXX_STANDARD 11) 153 154 ei_add_test(cxx11_eventcount "-pthread" "${CMAKE_THREAD_LIBS_INIT}") 155 ei_add_test(cxx11_runqueue "-pthread" "${CMAKE_THREAD_LIBS_INIT}") 156 ei_add_test(cxx11_non_blocking_thread_pool "-pthread" "${CMAKE_THREAD_LIBS_INIT}") 157 158 ei_add_test(cxx11_meta) 159 ei_add_test(cxx11_tensor_simple) 160 # ei_add_test(cxx11_tensor_symmetry) 161 ei_add_test(cxx11_tensor_index_list) 162 ei_add_test(cxx11_tensor_mixed_indices) 163 ei_add_test(cxx11_tensor_contraction) 164 ei_add_test(cxx11_tensor_convolution) 165 ei_add_test(cxx11_tensor_expr) 166 ei_add_test(cxx11_tensor_fixed_size) 167 ei_add_test(cxx11_tensor_of_const_values) 168 ei_add_test(cxx11_tensor_of_complex) 169 ei_add_test(cxx11_tensor_of_strings) 170 ei_add_test(cxx11_tensor_lvalue) 171 ei_add_test(cxx11_tensor_broadcasting) 172 ei_add_test(cxx11_tensor_chipping) 173 ei_add_test(cxx11_tensor_concatenation) 174 ei_add_test(cxx11_tensor_inflation) 175 ei_add_test(cxx11_tensor_morphing) 176 ei_add_test(cxx11_tensor_padding) 177 ei_add_test(cxx11_tensor_patch) 178 ei_add_test(cxx11_tensor_image_patch) 179 ei_add_test(cxx11_tensor_volume_patch) 180 ei_add_test(cxx11_tensor_reduction) 181 ei_add_test(cxx11_tensor_argmax) 182 ei_add_test(cxx11_tensor_shuffling) 183 ei_add_test(cxx11_tensor_striding) 184 ei_add_test(cxx11_tensor_notification "-pthread" "${CMAKE_THREAD_LIBS_INIT}") 185 ei_add_test(cxx11_tensor_thread_pool "-pthread" "${CMAKE_THREAD_LIBS_INIT}") 186 ei_add_test(cxx11_tensor_ref) 187 ei_add_test(cxx11_tensor_random) 188 ei_add_test(cxx11_tensor_generator) 189 ei_add_test(cxx11_tensor_custom_op) 190 ei_add_test(cxx11_tensor_custom_index) 191 ei_add_test(cxx11_tensor_fft) 192 ei_add_test(cxx11_tensor_ifft) 193 ei_add_test(cxx11_tensor_scan) 194 195 endif() 196 197 # These tests needs nvcc 198 find_package(CUDA 7.0) 199 if(CUDA_FOUND AND EIGEN_TEST_CUDA) 200 # Make sure to compile without the -pedantic, -Wundef, -Wnon-virtual-dtor 201 # and -fno-check-new flags since they trigger thousands of compilation warnings 202 # in the CUDA runtime 203 # Also remove -ansi that is incompatible with std=c++11. 204 string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 205 string(REPLACE "-Wundef" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 206 string(REPLACE "-Wnon-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 207 string(REPLACE "-fno-check-new" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 208 string(REPLACE "-ansi" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 209 210 message(STATUS "Flags used to compile cuda code: " ${CMAKE_CXX_FLAGS}) 211 212 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 213 set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_C_COMPILER}" CACHE STRING "nvcc flags" FORCE) 214 endif() 215 if(EIGEN_TEST_CUDA_CLANG) 216 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 --cuda-gpu-arch=sm_${EIGEN_CUDA_COMPUTE_ARCH}") 217 endif() 218 219 set(EIGEN_CUDA_RELAXED_CONSTEXPR "--expt-relaxed-constexpr") 220 if (${CUDA_VERSION} STREQUAL "7.0") 221 set(EIGEN_CUDA_RELAXED_CONSTEXPR "--relaxed-constexpr") 222 endif() 223 224 if( (NOT EIGEN_TEST_CXX11) OR (CMAKE_VERSION VERSION_LESS 3.3)) 225 set(EIGEN_CUDA_CXX11_FLAG "-std=c++11") 226 else() 227 # otherwise the flag has already been added because of the above set(CMAKE_CXX_STANDARD 11) 228 set(EIGEN_CUDA_CXX11_FLAG "") 229 endif() 230 231 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}") 232 cuda_include_directories("${CMAKE_CURRENT_BINARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/include") 233 set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu") 234 235 ei_add_test(cxx11_tensor_complex_cuda) 236 ei_add_test(cxx11_tensor_complex_cwise_ops_cuda) 237 ei_add_test(cxx11_tensor_reduction_cuda) 238 ei_add_test(cxx11_tensor_argmax_cuda) 239 ei_add_test(cxx11_tensor_cast_float16_cuda) 240 ei_add_test(cxx11_tensor_scan_cuda) 241 242 # Contractions require arch 3.0 or higher 243 if (${EIGEN_CUDA_COMPUTE_ARCH} GREATER 29) 244 ei_add_test(cxx11_tensor_device) 245 ei_add_test(cxx11_tensor_cuda) 246 ei_add_test(cxx11_tensor_contract_cuda) 247 ei_add_test(cxx11_tensor_of_float16_cuda) 248 endif() 249 250 # The random number generation code requires arch 3.5 or greater. 251 if (${EIGEN_CUDA_COMPUTE_ARCH} GREATER 34) 252 ei_add_test(cxx11_tensor_random_cuda) 253 endif() 254 255 256 unset(EIGEN_ADD_TEST_FILENAME_EXTENSION) 257 endif() 258