diff --git a/.travis.yml b/.travis.yml index 1158330..88eeb15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,8 @@ addons: - binutils-gold - libc6-dev - libpthread-stubs0-dev - # Math libraries + # Math libraries : SYSTEM_NATIVE-static/dynamic and ATLAS-dynamic only + # do not install libatlas-dev due to conflicts of repeating xerbla in *.a lib files - libblas-dev - liblapack-dev - libatlas-base-dev diff --git a/test/cc_clapack/cmake/autocmake.cfg b/test/cc_clapack/cmake/autocmake.cfg new file mode 100644 index 0000000..442df8d --- /dev/null +++ b/test/cc_clapack/cmake/autocmake.cfg @@ -0,0 +1,17 @@ +[project] +name: example + +[cc] +source: ../../../modules/cc.cmake + +[static] +source: ../../../modules/static_linking.cmake + +[math_libs] +source: ../../../modules/math_libs.cmake + +[default_build_paths] +source: ../../../modules/default_build_paths.cmake + +[src] +source: ../../../modules/src.cmake diff --git a/test/cc_clapack/src/CMakeLists.txt b/test/cc_clapack/src/CMakeLists.txt new file mode 100644 index 0000000..08b25a5 --- /dev/null +++ b/test/cc_clapack/src/CMakeLists.txt @@ -0,0 +1,13 @@ +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() + add_executable(example example.c) + target_link_libraries(example ${MATH_LIBS}) +else() + message(FATAL_ERROR "LAPACK library not found for the test cc_clapack!") +endif() diff --git a/test/cc_clapack/src/example.c b/test/cc_clapack/src/example.c new file mode 100644 index 0000000..78a20b0 --- /dev/null +++ b/test/cc_clapack/src/example.c @@ -0,0 +1,52 @@ +#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 + +void main(void) +{ + int i,j,n=3; + double a[n*n],b[n],small = 1.0e-12; + int ierr,ipiv[n]; + int roots_ok=0; + + a[0] = 2.00; + a[1] = 1.00; + a[2] = 3.00; + a[3] = 2.00; + a[4] = 6.00; + a[5] = 8.00; + a[6] = 6.00; + a[7] = 8.00; + a[8] = 18.00; + + b[0] = 1.00; + b[1] = 3.00; + b[2] = 5.00; + +/* 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, "\nC dgesv failure with error %d\n", ierr);} + + if (abs(b[0] + 0.500) <= small && + abs(b[1] - 0.250) <= small && + abs(b[2] - 0.250) <= small) roots_ok=1; + + if ( roots_ok == 1 ) {fprintf(stdout,"PASSED"); } + else {fprintf(stderr,"\nC LAPACK dgesv failure!");} +} diff --git a/test/test.py b/test/test.py index d8dacba..3d0548d 100644 --- a/test/test.py +++ b/test/test.py @@ -205,6 +205,14 @@ def test_fc_lapack(): def test_fc_lapack_static(): configure_build_and_exe('fc_lapack', 'python setup.py --fc=gfortran --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') + +def test_cc_clapack(): + configure_build_and_exe('cc_clapack', 'python setup.py --cc=gcc --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') + + +def test_cc_clapack_static(): + configure_build_and_exe('cc_clapack', 'python setup.py --cc=gcc --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') + # ------------------------------------------------------------------------------