You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

449 lines
11 KiB

  1. project(EigenLapack CXX)
  2. include("../cmake/language_support.cmake")
  3. workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
  4. if(EIGEN_Fortran_COMPILER_WORKS)
  5. enable_language(Fortran OPTIONAL)
  6. if(NOT CMAKE_Fortran_COMPILER)
  7. set(EIGEN_Fortran_COMPILER_WORKS OFF)
  8. endif()
  9. endif()
  10. add_custom_target(lapack)
  11. include_directories(../blas)
  12. set(EigenLapack_SRCS
  13. single.cpp double.cpp complex_single.cpp complex_double.cpp ../blas/xerbla.cpp
  14. )
  15. if(EIGEN_Fortran_COMPILER_WORKS)
  16. set(EigenLapack_SRCS ${EigenLapack_SRCS}
  17. slarft.f dlarft.f clarft.f zlarft.f
  18. slarfb.f dlarfb.f clarfb.f zlarfb.f
  19. slarfg.f dlarfg.f clarfg.f zlarfg.f
  20. slarf.f dlarf.f clarf.f zlarf.f
  21. sladiv.f dladiv.f cladiv.f zladiv.f
  22. ilaslr.f iladlr.f ilaclr.f ilazlr.f
  23. ilaslc.f iladlc.f ilaclc.f ilazlc.f
  24. dlapy2.f dlapy3.f slapy2.f slapy3.f
  25. clacgv.f zlacgv.f
  26. slamch.f dlamch.f
  27. second_NONE.f dsecnd_NONE.f
  28. )
  29. option(EIGEN_ENABLE_LAPACK_TESTS OFF "Enbale the Lapack unit tests")
  30. if(EIGEN_ENABLE_LAPACK_TESTS)
  31. get_filename_component(eigen_full_path_to_reference_lapack "./reference/" ABSOLUTE)
  32. if(NOT EXISTS ${eigen_full_path_to_reference_lapack})
  33. # Download lapack and install sources and testing at the right place
  34. message(STATUS "Download lapack_addons_3.4.1.tgz...")
  35. file(DOWNLOAD "http://downloads.tuxfamily.org/eigen/lapack_addons_3.4.1.tgz"
  36. "${CMAKE_CURRENT_SOURCE_DIR}/lapack_addons_3.4.1.tgz"
  37. INACTIVITY_TIMEOUT 15
  38. TIMEOUT 240
  39. STATUS download_status
  40. EXPECTED_MD5 5758ce55afcf79da98de8b9de1615ad5
  41. SHOW_PROGRESS)
  42. message(STATUS ${download_status})
  43. list(GET download_status 0 download_status_num)
  44. set(download_status_num 0)
  45. if(download_status_num EQUAL 0)
  46. message(STATUS "Setup lapack reference and lapack unit tests")
  47. execute_process(COMMAND tar xzf "lapack_addons_3.4.1.tgz" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  48. else()
  49. message(STATUS "Download of lapack_addons_3.4.1.tgz failed, LAPACK unit tests wont be enabled")
  50. set(EIGEN_ENABLE_LAPACK_TESTS false)
  51. endif()
  52. endif()
  53. get_filename_component(eigen_full_path_to_reference_lapack "./reference/" ABSOLUTE)
  54. if(EXISTS ${eigen_full_path_to_reference_lapack})
  55. set(EigenLapack_funcfilenames
  56. ssyev.f dsyev.f csyev.f zsyev.f
  57. spotrf.f dpotrf.f cpotrf.f zpotrf.f
  58. spotrs.f dpotrs.f cpotrs.f zpotrs.f
  59. sgetrf.f dgetrf.f cgetrf.f zgetrf.f
  60. sgetrs.f dgetrs.f cgetrs.f zgetrs.f)
  61. FILE(GLOB ReferenceLapack_SRCS0 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "reference/*.f")
  62. foreach(filename1 IN LISTS ReferenceLapack_SRCS0)
  63. string(REPLACE "reference/" "" filename ${filename1})
  64. list(FIND EigenLapack_SRCS ${filename} id1)
  65. list(FIND EigenLapack_funcfilenames ${filename} id2)
  66. if((id1 EQUAL -1) AND (id2 EQUAL -1))
  67. set(ReferenceLapack_SRCS ${ReferenceLapack_SRCS} reference/${filename})
  68. endif()
  69. endforeach()
  70. endif()
  71. endif(EIGEN_ENABLE_LAPACK_TESTS)
  72. endif(EIGEN_Fortran_COMPILER_WORKS)
  73. add_library(eigen_lapack_static ${EigenLapack_SRCS} ${ReferenceLapack_SRCS})
  74. add_library(eigen_lapack SHARED ${EigenLapack_SRCS})
  75. target_link_libraries(eigen_lapack eigen_blas)
  76. if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
  77. target_link_libraries(eigen_lapack_static ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
  78. target_link_libraries(eigen_lapack ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
  79. endif()
  80. add_dependencies(lapack eigen_lapack eigen_lapack_static)
  81. install(TARGETS eigen_lapack eigen_lapack_static
  82. RUNTIME DESTINATION bin
  83. LIBRARY DESTINATION lib
  84. ARCHIVE DESTINATION lib)
  85. get_filename_component(eigen_full_path_to_testing_lapack "./testing/" ABSOLUTE)
  86. if(EXISTS ${eigen_full_path_to_testing_lapack})
  87. # The following comes from lapack/TESTING/CMakeLists.txt
  88. # Get Python
  89. find_package(PythonInterp)
  90. message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}")
  91. if (PYTHONINTERP_FOUND)
  92. message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
  93. endif()
  94. set(LAPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  95. set(LAPACK_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
  96. set(BUILD_SINGLE true)
  97. set(BUILD_DOUBLE true)
  98. set(BUILD_COMPLEX true)
  99. set(BUILD_COMPLEX16E true)
  100. if(MSVC_VERSION)
  101. # string(REPLACE "/STACK:10000000" "/STACK:900000000000000000"
  102. # CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  103. string(REGEX REPLACE "(.*)/STACK:(.*) (.*)" "\\1/STACK:900000000000000000 \\3"
  104. CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  105. endif()
  106. add_subdirectory(testing/MATGEN)
  107. add_subdirectory(testing/LIN)
  108. add_subdirectory(testing/EIG)
  109. macro(add_lapack_test output input target)
  110. set(TEST_INPUT "${LAPACK_SOURCE_DIR}/testing/${input}")
  111. set(TEST_OUTPUT "${LAPACK_BINARY_DIR}/testing/${output}")
  112. get_target_property(TEST_LOC ${target} LOCATION)
  113. string(REPLACE "." "_" input_name ${input})
  114. set(testName "${target}_${input_name}")
  115. if(EXISTS "${TEST_INPUT}")
  116. add_test(LAPACK-${testName} "${CMAKE_COMMAND}"
  117. -DTEST=${TEST_LOC}
  118. -DINPUT=${TEST_INPUT}
  119. -DOUTPUT=${TEST_OUTPUT}
  120. -DINTDIR=${CMAKE_CFG_INTDIR}
  121. -P "${LAPACK_SOURCE_DIR}/testing/runtest.cmake")
  122. endif()
  123. endmacro(add_lapack_test)
  124. if (BUILD_SINGLE)
  125. add_lapack_test(stest.out stest.in xlintsts)
  126. #
  127. # ======== SINGLE RFP LIN TESTS ========================
  128. add_lapack_test(stest_rfp.out stest_rfp.in xlintstrfs)
  129. #
  130. #
  131. # ======== SINGLE EIG TESTS ===========================
  132. #
  133. add_lapack_test(snep.out nep.in xeigtsts)
  134. add_lapack_test(ssep.out sep.in xeigtsts)
  135. add_lapack_test(ssvd.out svd.in xeigtsts)
  136. add_lapack_test(sec.out sec.in xeigtsts)
  137. add_lapack_test(sed.out sed.in xeigtsts)
  138. add_lapack_test(sgg.out sgg.in xeigtsts)
  139. add_lapack_test(sgd.out sgd.in xeigtsts)
  140. add_lapack_test(ssb.out ssb.in xeigtsts)
  141. add_lapack_test(ssg.out ssg.in xeigtsts)
  142. add_lapack_test(sbal.out sbal.in xeigtsts)
  143. add_lapack_test(sbak.out sbak.in xeigtsts)
  144. add_lapack_test(sgbal.out sgbal.in xeigtsts)
  145. add_lapack_test(sgbak.out sgbak.in xeigtsts)
  146. add_lapack_test(sbb.out sbb.in xeigtsts)
  147. add_lapack_test(sglm.out glm.in xeigtsts)
  148. add_lapack_test(sgqr.out gqr.in xeigtsts)
  149. add_lapack_test(sgsv.out gsv.in xeigtsts)
  150. add_lapack_test(scsd.out csd.in xeigtsts)
  151. add_lapack_test(slse.out lse.in xeigtsts)
  152. endif()
  153. if (BUILD_DOUBLE)
  154. #
  155. # ======== DOUBLE LIN TESTS ===========================
  156. add_lapack_test(dtest.out dtest.in xlintstd)
  157. #
  158. # ======== DOUBLE RFP LIN TESTS ========================
  159. add_lapack_test(dtest_rfp.out dtest_rfp.in xlintstrfd)
  160. #
  161. # ======== DOUBLE EIG TESTS ===========================
  162. add_lapack_test(dnep.out nep.in xeigtstd)
  163. add_lapack_test(dsep.out sep.in xeigtstd)
  164. add_lapack_test(dsvd.out svd.in xeigtstd)
  165. add_lapack_test(dec.out dec.in xeigtstd)
  166. add_lapack_test(ded.out ded.in xeigtstd)
  167. add_lapack_test(dgg.out dgg.in xeigtstd)
  168. add_lapack_test(dgd.out dgd.in xeigtstd)
  169. add_lapack_test(dsb.out dsb.in xeigtstd)
  170. add_lapack_test(dsg.out dsg.in xeigtstd)
  171. add_lapack_test(dbal.out dbal.in xeigtstd)
  172. add_lapack_test(dbak.out dbak.in xeigtstd)
  173. add_lapack_test(dgbal.out dgbal.in xeigtstd)
  174. add_lapack_test(dgbak.out dgbak.in xeigtstd)
  175. add_lapack_test(dbb.out dbb.in xeigtstd)
  176. add_lapack_test(dglm.out glm.in xeigtstd)
  177. add_lapack_test(dgqr.out gqr.in xeigtstd)
  178. add_lapack_test(dgsv.out gsv.in xeigtstd)
  179. add_lapack_test(dcsd.out csd.in xeigtstd)
  180. add_lapack_test(dlse.out lse.in xeigtstd)
  181. endif()
  182. if (BUILD_COMPLEX)
  183. add_lapack_test(ctest.out ctest.in xlintstc)
  184. #
  185. # ======== COMPLEX RFP LIN TESTS ========================
  186. add_lapack_test(ctest_rfp.out ctest_rfp.in xlintstrfc)
  187. #
  188. # ======== COMPLEX EIG TESTS ===========================
  189. add_lapack_test(cnep.out nep.in xeigtstc)
  190. add_lapack_test(csep.out sep.in xeigtstc)
  191. add_lapack_test(csvd.out svd.in xeigtstc)
  192. add_lapack_test(cec.out cec.in xeigtstc)
  193. add_lapack_test(ced.out ced.in xeigtstc)
  194. add_lapack_test(cgg.out cgg.in xeigtstc)
  195. add_lapack_test(cgd.out cgd.in xeigtstc)
  196. add_lapack_test(csb.out csb.in xeigtstc)
  197. add_lapack_test(csg.out csg.in xeigtstc)
  198. add_lapack_test(cbal.out cbal.in xeigtstc)
  199. add_lapack_test(cbak.out cbak.in xeigtstc)
  200. add_lapack_test(cgbal.out cgbal.in xeigtstc)
  201. add_lapack_test(cgbak.out cgbak.in xeigtstc)
  202. add_lapack_test(cbb.out cbb.in xeigtstc)
  203. add_lapack_test(cglm.out glm.in xeigtstc)
  204. add_lapack_test(cgqr.out gqr.in xeigtstc)
  205. add_lapack_test(cgsv.out gsv.in xeigtstc)
  206. add_lapack_test(ccsd.out csd.in xeigtstc)
  207. add_lapack_test(clse.out lse.in xeigtstc)
  208. endif()
  209. if (BUILD_COMPLEX16)
  210. #
  211. # ======== COMPLEX16 LIN TESTS ========================
  212. add_lapack_test(ztest.out ztest.in xlintstz)
  213. #
  214. # ======== COMPLEX16 RFP LIN TESTS ========================
  215. add_lapack_test(ztest_rfp.out ztest_rfp.in xlintstrfz)
  216. #
  217. # ======== COMPLEX16 EIG TESTS ===========================
  218. add_lapack_test(znep.out nep.in xeigtstz)
  219. add_lapack_test(zsep.out sep.in xeigtstz)
  220. add_lapack_test(zsvd.out svd.in xeigtstz)
  221. add_lapack_test(zec.out zec.in xeigtstz)
  222. add_lapack_test(zed.out zed.in xeigtstz)
  223. add_lapack_test(zgg.out zgg.in xeigtstz)
  224. add_lapack_test(zgd.out zgd.in xeigtstz)
  225. add_lapack_test(zsb.out zsb.in xeigtstz)
  226. add_lapack_test(zsg.out zsg.in xeigtstz)
  227. add_lapack_test(zbal.out zbal.in xeigtstz)
  228. add_lapack_test(zbak.out zbak.in xeigtstz)
  229. add_lapack_test(zgbal.out zgbal.in xeigtstz)
  230. add_lapack_test(zgbak.out zgbak.in xeigtstz)
  231. add_lapack_test(zbb.out zbb.in xeigtstz)
  232. add_lapack_test(zglm.out glm.in xeigtstz)
  233. add_lapack_test(zgqr.out gqr.in xeigtstz)
  234. add_lapack_test(zgsv.out gsv.in xeigtstz)
  235. add_lapack_test(zcsd.out csd.in xeigtstz)
  236. add_lapack_test(zlse.out lse.in xeigtstz)
  237. endif()
  238. if (BUILD_SIMPLE)
  239. if (BUILD_DOUBLE)
  240. #
  241. # ======== SINGLE-DOUBLE PROTO LIN TESTS ==============
  242. add_lapack_test(dstest.out dstest.in xlintstds)
  243. endif()
  244. endif()
  245. if (BUILD_COMPLEX)
  246. if (BUILD_COMPLEX16)
  247. #
  248. # ======== COMPLEX-COMPLEX16 LIN TESTS ========================
  249. add_lapack_test(zctest.out zctest.in xlintstzc)
  250. endif()
  251. endif()
  252. # ==============================================================================
  253. execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${LAPACK_SOURCE_DIR}/testing/lapack_testing.py ${LAPACK_BINARY_DIR})
  254. add_test(
  255. NAME LAPACK_Test_Summary
  256. WORKING_DIRECTORY ${LAPACK_BINARY_DIR}
  257. COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py"
  258. )
  259. endif()