From 6efc29457d860e70164b830c73d5c229fc252e71 Mon Sep 17 00:00:00 2001 From: Radovan Bast Date: Thu, 17 Sep 2015 10:44:30 +0200 Subject: [PATCH] adding lapacke.cmake stub --- modules/lapacke.cmake | 41 ++++++++++++++++++++++++++++ test/cxx_lapacke/cmake/autocmake.cfg | 4 +-- test/cxx_lapacke/src/CMakeLists.txt | 14 +++------- test/cxx_lapacke/src/example.cpp | 19 +------------ test/test.py | 3 +- 5 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 modules/lapacke.cmake diff --git a/modules/lapacke.cmake b/modules/lapacke.cmake new file mode 100644 index 0000000..38580e8 --- /dev/null +++ b/modules/lapacke.cmake @@ -0,0 +1,41 @@ +#.rst: +# +# Find and link to LAPACKE. +# +# Variables defined:: +# +# LAPACKE_FOUND - describe me, uncached +# LAPACKE_LIBRARIES - describe me, uncached +# LAPACKE_INCLUDE_DIR - describe me, uncached +# +# autocmake.cfg configuration:: +# +# docopt: --lapacke Find and link to LAPACKE [default: False]. +# define: '-DENABLE_LAPACKE=%s' % arguments['--lapacke'] +# fetch: https://github.com/scisoft/autocmake/raw/master/modules/find/find_libraries.cmake +# https://github.com/scisoft/autocmake/raw/master/modules/find/find_include_files.cmake + +option(ENABLE_LAPACKE "Find and link to LAPACKE" OFF) + +if(ENABLE_LAPACKE) + include(find_libraries) + include(find_include_files) + + set(LAPACKE_FOUND FALSE) + set(LAPACKE_LIBRARIES "undefined") + set(LAPACKE_INCLUDE_DIR "undefined") + +# if(APPLE) +# _find_library(Accelerate cblas_dgemm LAPACKE_LIBRARIES) +# _find_include_dir(Accelerate.h /usr LAPACKE_INCLUDE_DIR) +# else() + _find_library(lapacke LAPACKE_dgesv LAPACKE_LIBRARIES) + _find_include_dir(lapacke.h /usr LAPACKE_INCLUDE_DIR) +# endif() + + if(NOT "${LAPACKE_LIBRARIES}" STREQUAL "undefined") + if(NOT "${LAPACKE_INCLUDE_DIR}" STREQUAL "undefined") + set(LAPACKE_FOUND TRUE) + endif() + endif() +endif() diff --git a/test/cxx_lapacke/cmake/autocmake.cfg b/test/cxx_lapacke/cmake/autocmake.cfg index 293159b..fc8cc21 100644 --- a/test/cxx_lapacke/cmake/autocmake.cfg +++ b/test/cxx_lapacke/cmake/autocmake.cfg @@ -5,8 +5,8 @@ min_cmake_version: 2.8 [cxx] source: ../../../modules/cxx.cmake -[math_libs] -source: ../../../modules/math_libs.cmake +[lapacke] +source: ../../../modules/lapacke.cmake [default_build_paths] source: ../../../modules/default_build_paths.cmake diff --git a/test/cxx_lapacke/src/CMakeLists.txt b/test/cxx_lapacke/src/CMakeLists.txt index bc44c1e..a53030c 100644 --- a/test/cxx_lapacke/src/CMakeLists.txt +++ b/test/cxx_lapacke/src/CMakeLists.txt @@ -1,13 +1,7 @@ -if(LAPACK_FOUND) - if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - #windows needs to find of openblas - include_directories($ENV{PATH}) - else() - #ftravis-ci needs find of ATLAS - include_directories(/usr/include/atlas) - endif() +if(LAPACKE_FOUND) + include_directories(${LAPACKE_INCLUDE_DIR}) add_executable(example example.cpp) - target_link_libraries(example ${MATH_LIBS}) + target_link_libraries(example ${LAPACKE_LIBRARIES}) else() - message(FATAL_ERROR "LAPACK library not found for the test cc_lapacke!") + message(FATAL_ERROR "LAPACKE library not found") endif() diff --git a/test/cxx_lapacke/src/example.cpp b/test/cxx_lapacke/src/example.cpp index df9e384..7f05dd6 100644 --- a/test/cxx_lapacke/src/example.cpp +++ b/test/cxx_lapacke/src/example.cpp @@ -1,19 +1,7 @@ #include #include -#if defined HAVE_MKL_LAPACK -#include -#include -#pragma message "Using Intel MKL c-lapack interface, ." -#elif defined HAVE_OPENBLAS_LAPACK -#include -#include -#pragma message "Using OpenBLAS C-lapack interface, ." -#else -#include -#include -#pragma message "Using ATLAS/SYSTEM_NATIVE C lapack interface, ." -#endif +#include "lapacke.h" int main() { @@ -39,12 +27,7 @@ int main() int ierr; int ipiv[n]; -/* MKL, OpenBLAS */ -#if defined HAVE_MKL_LAPACK || defined HAVE_OPENBLAS_LAPACK ierr = LAPACKE_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n); -#else /* ATLAS, SYSTEM_NATIVE */ - ierr = clapack_dgesv(CblasColMajor, n, 1, a, n, ipiv, b, n); -#endif if (ierr != 0) { fprintf(stderr, "\ndgesv failure with error %i\n", ierr); diff --git a/test/test.py b/test/test.py index cc6d921..d549b8b 100644 --- a/test/test.py +++ b/test/test.py @@ -164,9 +164,8 @@ def test_fc_lapack(): configure_build_and_exe('fc_lapack', 'python setup.py --fc=gfortran --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') -@skip_on_osx def test_cxx_lapacke(): - configure_build_and_exe('cxx_lapacke', 'python setup.py --cxx=g++ --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') + configure_build_and_exe('cxx_lapacke', 'python setup.py --cxx=g++ --lapacke') # ------------------------------------------------------------------------------