blob: 9883d4c72d8fdcaa1599c468553281daf5008b65 [file] [log] [blame]
Narayan Kamathc981c482012-11-02 10:59:05 +00001
2project(EigenLapack CXX)
3
4include("../cmake/language_support.cmake")
5
6workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
7
8if(EIGEN_Fortran_COMPILER_WORKS)
9 enable_language(Fortran OPTIONAL)
Carlos Hernandez7faaa9f2014-08-05 17:53:32 -070010 if(NOT CMAKE_Fortran_COMPILER)
11 set(EIGEN_Fortran_COMPILER_WORKS OFF)
12 endif()
Narayan Kamathc981c482012-11-02 10:59:05 +000013endif()
14
15add_custom_target(lapack)
16include_directories(../blas)
17
18set(EigenLapack_SRCS
19single.cpp double.cpp complex_single.cpp complex_double.cpp ../blas/xerbla.cpp
20)
21
22if(EIGEN_Fortran_COMPILER_WORKS)
23
Carlos Hernandez7faaa9f2014-08-05 17:53:32 -070024set(EigenLapack_SRCS ${EigenLapack_SRCS}
25 slarft.f dlarft.f clarft.f zlarft.f
26 slarfb.f dlarfb.f clarfb.f zlarfb.f
27 slarfg.f dlarfg.f clarfg.f zlarfg.f
28 slarf.f dlarf.f clarf.f zlarf.f
29 sladiv.f dladiv.f cladiv.f zladiv.f
30 ilaslr.f iladlr.f ilaclr.f ilazlr.f
31 ilaslc.f iladlc.f ilaclc.f ilazlc.f
32 dlapy2.f dlapy3.f slapy2.f slapy3.f
33 clacgv.f zlacgv.f
34 slamch.f dlamch.f
35 second_NONE.f dsecnd_NONE.f
Narayan Kamathc981c482012-11-02 10:59:05 +000036)
Carlos Hernandez7faaa9f2014-08-05 17:53:32 -070037
38option(EIGEN_ENABLE_LAPACK_TESTS OFF "Enbale the Lapack unit tests")
39
40if(EIGEN_ENABLE_LAPACK_TESTS)
41
42 get_filename_component(eigen_full_path_to_reference_lapack "./reference/" ABSOLUTE)
43 if(NOT EXISTS ${eigen_full_path_to_reference_lapack})
44 # Download lapack and install sources and testing at the right place
45 message(STATUS "Download lapack_addons_3.4.1.tgz...")
46
47 file(DOWNLOAD "http://downloads.tuxfamily.org/eigen/lapack_addons_3.4.1.tgz"
48 "${CMAKE_CURRENT_SOURCE_DIR}/lapack_addons_3.4.1.tgz"
49 INACTIVITY_TIMEOUT 15
50 TIMEOUT 240
51 STATUS download_status
52 EXPECTED_MD5 5758ce55afcf79da98de8b9de1615ad5
53 SHOW_PROGRESS)
54
55 message(STATUS ${download_status})
56 list(GET download_status 0 download_status_num)
57 set(download_status_num 0)
58 if(download_status_num EQUAL 0)
59 message(STATUS "Setup lapack reference and lapack unit tests")
60 execute_process(COMMAND tar xzf "lapack_addons_3.4.1.tgz" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
61 else()
62 message(STATUS "Download of lapack_addons_3.4.1.tgz failed, LAPACK unit tests wont be enabled")
63 set(EIGEN_ENABLE_LAPACK_TESTS false)
64 endif()
65
66 endif()
67
68 get_filename_component(eigen_full_path_to_reference_lapack "./reference/" ABSOLUTE)
69 if(EXISTS ${eigen_full_path_to_reference_lapack})
70 set(EigenLapack_funcfilenames
71 ssyev.f dsyev.f csyev.f zsyev.f
72 spotrf.f dpotrf.f cpotrf.f zpotrf.f
73 spotrs.f dpotrs.f cpotrs.f zpotrs.f
74 sgetrf.f dgetrf.f cgetrf.f zgetrf.f
75 sgetrs.f dgetrs.f cgetrs.f zgetrs.f)
76
77 FILE(GLOB ReferenceLapack_SRCS0 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "reference/*.f")
78 foreach(filename1 IN LISTS ReferenceLapack_SRCS0)
79 string(REPLACE "reference/" "" filename ${filename1})
80 list(FIND EigenLapack_SRCS ${filename} id1)
81 list(FIND EigenLapack_funcfilenames ${filename} id2)
82 if((id1 EQUAL -1) AND (id2 EQUAL -1))
83 set(ReferenceLapack_SRCS ${ReferenceLapack_SRCS} reference/${filename})
84 endif()
85 endforeach()
86 endif()
87
88
89endif(EIGEN_ENABLE_LAPACK_TESTS)
Narayan Kamathc981c482012-11-02 10:59:05 +000090
91endif(EIGEN_Fortran_COMPILER_WORKS)
92
Carlos Hernandez7faaa9f2014-08-05 17:53:32 -070093add_library(eigen_lapack_static ${EigenLapack_SRCS} ${ReferenceLapack_SRCS})
Narayan Kamathc981c482012-11-02 10:59:05 +000094add_library(eigen_lapack SHARED ${EigenLapack_SRCS})
95
Carlos Hernandez7faaa9f2014-08-05 17:53:32 -070096target_link_libraries(eigen_lapack eigen_blas)
97
Narayan Kamathc981c482012-11-02 10:59:05 +000098if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
99 target_link_libraries(eigen_lapack_static ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
100 target_link_libraries(eigen_lapack ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
101endif()
102
103add_dependencies(lapack eigen_lapack eigen_lapack_static)
104
105install(TARGETS eigen_lapack eigen_lapack_static
106 RUNTIME DESTINATION bin
107 LIBRARY DESTINATION lib
108 ARCHIVE DESTINATION lib)
109
Carlos Hernandez7faaa9f2014-08-05 17:53:32 -0700110
111
112get_filename_component(eigen_full_path_to_testing_lapack "./testing/" ABSOLUTE)
113if(EXISTS ${eigen_full_path_to_testing_lapack})
114
115 # The following comes from lapack/TESTING/CMakeLists.txt
116 # Get Python
117 find_package(PythonInterp)
118 message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}")
119 if (PYTHONINTERP_FOUND)
120 message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
121 endif()
122
123 set(LAPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
124 set(LAPACK_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
125 set(BUILD_SINGLE true)
126 set(BUILD_DOUBLE true)
127 set(BUILD_COMPLEX true)
128 set(BUILD_COMPLEX16E true)
129
130 if(MSVC_VERSION)
131# string(REPLACE "/STACK:10000000" "/STACK:900000000000000000"
132# CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
133 string(REGEX REPLACE "(.*)/STACK:(.*) (.*)" "\\1/STACK:900000000000000000 \\3"
134 CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
135 endif()
136 add_subdirectory(testing/MATGEN)
137 add_subdirectory(testing/LIN)
138 add_subdirectory(testing/EIG)
139 macro(add_lapack_test output input target)
140 set(TEST_INPUT "${LAPACK_SOURCE_DIR}/testing/${input}")
141 set(TEST_OUTPUT "${LAPACK_BINARY_DIR}/testing/${output}")
142 get_target_property(TEST_LOC ${target} LOCATION)
143 string(REPLACE "." "_" input_name ${input})
144 set(testName "${target}_${input_name}")
145 if(EXISTS "${TEST_INPUT}")
146 add_test(LAPACK-${testName} "${CMAKE_COMMAND}"
147 -DTEST=${TEST_LOC}
148 -DINPUT=${TEST_INPUT}
149 -DOUTPUT=${TEST_OUTPUT}
150 -DINTDIR=${CMAKE_CFG_INTDIR}
151 -P "${LAPACK_SOURCE_DIR}/testing/runtest.cmake")
152 endif()
153 endmacro(add_lapack_test)
154
155 if (BUILD_SINGLE)
156 add_lapack_test(stest.out stest.in xlintsts)
157 #
158 # ======== SINGLE RFP LIN TESTS ========================
159 add_lapack_test(stest_rfp.out stest_rfp.in xlintstrfs)
160 #
161 #
162 # ======== SINGLE EIG TESTS ===========================
163 #
164
165 add_lapack_test(snep.out nep.in xeigtsts)
166
167
168 add_lapack_test(ssep.out sep.in xeigtsts)
169
170
171 add_lapack_test(ssvd.out svd.in xeigtsts)
172
173
174 add_lapack_test(sec.out sec.in xeigtsts)
175
176
177 add_lapack_test(sed.out sed.in xeigtsts)
178
179
180 add_lapack_test(sgg.out sgg.in xeigtsts)
181
182
183 add_lapack_test(sgd.out sgd.in xeigtsts)
184
185
186 add_lapack_test(ssb.out ssb.in xeigtsts)
187
188
189 add_lapack_test(ssg.out ssg.in xeigtsts)
190
191
192 add_lapack_test(sbal.out sbal.in xeigtsts)
193
194
195 add_lapack_test(sbak.out sbak.in xeigtsts)
196
197
198 add_lapack_test(sgbal.out sgbal.in xeigtsts)
199
200
201 add_lapack_test(sgbak.out sgbak.in xeigtsts)
202
203
204 add_lapack_test(sbb.out sbb.in xeigtsts)
205
206
207 add_lapack_test(sglm.out glm.in xeigtsts)
208
209
210 add_lapack_test(sgqr.out gqr.in xeigtsts)
211
212
213 add_lapack_test(sgsv.out gsv.in xeigtsts)
214
215
216 add_lapack_test(scsd.out csd.in xeigtsts)
217
218
219 add_lapack_test(slse.out lse.in xeigtsts)
220 endif()
221
222 if (BUILD_DOUBLE)
223 #
224 # ======== DOUBLE LIN TESTS ===========================
225 add_lapack_test(dtest.out dtest.in xlintstd)
226 #
227 # ======== DOUBLE RFP LIN TESTS ========================
228 add_lapack_test(dtest_rfp.out dtest_rfp.in xlintstrfd)
229 #
230 # ======== DOUBLE EIG TESTS ===========================
231
232 add_lapack_test(dnep.out nep.in xeigtstd)
233
234
235 add_lapack_test(dsep.out sep.in xeigtstd)
236
237
238 add_lapack_test(dsvd.out svd.in xeigtstd)
239
240
241 add_lapack_test(dec.out dec.in xeigtstd)
242
243
244 add_lapack_test(ded.out ded.in xeigtstd)
245
246
247 add_lapack_test(dgg.out dgg.in xeigtstd)
248
249
250 add_lapack_test(dgd.out dgd.in xeigtstd)
251
252
253 add_lapack_test(dsb.out dsb.in xeigtstd)
254
255
256 add_lapack_test(dsg.out dsg.in xeigtstd)
257
258
259 add_lapack_test(dbal.out dbal.in xeigtstd)
260
261
262 add_lapack_test(dbak.out dbak.in xeigtstd)
263
264
265 add_lapack_test(dgbal.out dgbal.in xeigtstd)
266
267
268 add_lapack_test(dgbak.out dgbak.in xeigtstd)
269
270
271 add_lapack_test(dbb.out dbb.in xeigtstd)
272
273
274 add_lapack_test(dglm.out glm.in xeigtstd)
275
276
277 add_lapack_test(dgqr.out gqr.in xeigtstd)
278
279
280 add_lapack_test(dgsv.out gsv.in xeigtstd)
281
282
283 add_lapack_test(dcsd.out csd.in xeigtstd)
284
285
286 add_lapack_test(dlse.out lse.in xeigtstd)
287 endif()
288
289 if (BUILD_COMPLEX)
290 add_lapack_test(ctest.out ctest.in xlintstc)
291 #
292 # ======== COMPLEX RFP LIN TESTS ========================
293 add_lapack_test(ctest_rfp.out ctest_rfp.in xlintstrfc)
294 #
295 # ======== COMPLEX EIG TESTS ===========================
296
297 add_lapack_test(cnep.out nep.in xeigtstc)
298
299
300 add_lapack_test(csep.out sep.in xeigtstc)
301
302
303 add_lapack_test(csvd.out svd.in xeigtstc)
304
305
306 add_lapack_test(cec.out cec.in xeigtstc)
307
308
309 add_lapack_test(ced.out ced.in xeigtstc)
310
311
312 add_lapack_test(cgg.out cgg.in xeigtstc)
313
314
315 add_lapack_test(cgd.out cgd.in xeigtstc)
316
317
318 add_lapack_test(csb.out csb.in xeigtstc)
319
320
321 add_lapack_test(csg.out csg.in xeigtstc)
322
323
324 add_lapack_test(cbal.out cbal.in xeigtstc)
325
326
327 add_lapack_test(cbak.out cbak.in xeigtstc)
328
329
330 add_lapack_test(cgbal.out cgbal.in xeigtstc)
331
332
333 add_lapack_test(cgbak.out cgbak.in xeigtstc)
334
335
336 add_lapack_test(cbb.out cbb.in xeigtstc)
337
338
339 add_lapack_test(cglm.out glm.in xeigtstc)
340
341
342 add_lapack_test(cgqr.out gqr.in xeigtstc)
343
344
345 add_lapack_test(cgsv.out gsv.in xeigtstc)
346
347
348 add_lapack_test(ccsd.out csd.in xeigtstc)
349
350
351 add_lapack_test(clse.out lse.in xeigtstc)
352 endif()
353
354 if (BUILD_COMPLEX16)
355 #
356 # ======== COMPLEX16 LIN TESTS ========================
357 add_lapack_test(ztest.out ztest.in xlintstz)
358 #
359 # ======== COMPLEX16 RFP LIN TESTS ========================
360 add_lapack_test(ztest_rfp.out ztest_rfp.in xlintstrfz)
361 #
362 # ======== COMPLEX16 EIG TESTS ===========================
363
364 add_lapack_test(znep.out nep.in xeigtstz)
365
366
367 add_lapack_test(zsep.out sep.in xeigtstz)
368
369
370 add_lapack_test(zsvd.out svd.in xeigtstz)
371
372
373 add_lapack_test(zec.out zec.in xeigtstz)
374
375
376 add_lapack_test(zed.out zed.in xeigtstz)
377
378
379 add_lapack_test(zgg.out zgg.in xeigtstz)
380
381
382 add_lapack_test(zgd.out zgd.in xeigtstz)
383
384
385 add_lapack_test(zsb.out zsb.in xeigtstz)
386
387
388 add_lapack_test(zsg.out zsg.in xeigtstz)
389
390
391 add_lapack_test(zbal.out zbal.in xeigtstz)
392
393
394 add_lapack_test(zbak.out zbak.in xeigtstz)
395
396
397 add_lapack_test(zgbal.out zgbal.in xeigtstz)
398
399
400 add_lapack_test(zgbak.out zgbak.in xeigtstz)
401
402
403 add_lapack_test(zbb.out zbb.in xeigtstz)
404
405
406 add_lapack_test(zglm.out glm.in xeigtstz)
407
408
409 add_lapack_test(zgqr.out gqr.in xeigtstz)
410
411
412 add_lapack_test(zgsv.out gsv.in xeigtstz)
413
414
415 add_lapack_test(zcsd.out csd.in xeigtstz)
416
417
418 add_lapack_test(zlse.out lse.in xeigtstz)
419 endif()
420
421
422 if (BUILD_SIMPLE)
423 if (BUILD_DOUBLE)
424 #
425 # ======== SINGLE-DOUBLE PROTO LIN TESTS ==============
426 add_lapack_test(dstest.out dstest.in xlintstds)
427 endif()
428 endif()
429
430
431 if (BUILD_COMPLEX)
432 if (BUILD_COMPLEX16)
433 #
434 # ======== COMPLEX-COMPLEX16 LIN TESTS ========================
435 add_lapack_test(zctest.out zctest.in xlintstzc)
436 endif()
437 endif()
438
439 # ==============================================================================
440
441 execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${LAPACK_SOURCE_DIR}/testing/lapack_testing.py ${LAPACK_BINARY_DIR})
442 add_test(
443 NAME LAPACK_Test_Summary
444 WORKING_DIRECTORY ${LAPACK_BINARY_DIR}
445 COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py"
446 )
447
448endif()
Narayan Kamathc981c482012-11-02 10:59:05 +0000449