diff --git a/appveyor.yml b/appveyor.yml index 2d04151..fc7dabb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,7 +52,7 @@ build_script: - 7z x OpenBLAS-v0.2.14-Win64-int32.zip > NUL # add both OpenBLAS dynamic (libopenblas.dll) and static (libopenblas.a) library files dir to path -- set path=%path%;C:\software\OpenBLAS-v0.2.14-Win64-int32\bin;C:\software\OpenBLAS-v0.2.14-Win64-int32\lib +- set path=%path%;C:\software\OpenBLAS-v0.2.14-Win64-int32\bin;C:\software\OpenBLAS-v0.2.14-Win64-int32\lib;C:\software\OpenBLAS-v0.2.14-Win64-int32\include # download and upgrade pip diff --git a/modules/math_libs.cmake b/modules/math_libs.cmake index d283e9c..8f6012e 100644 --- a/modules/math_libs.cmake +++ b/modules/math_libs.cmake @@ -128,6 +128,7 @@ set(OPENBLAS_BLAS_INCLUDE_PATH_SUFFIXES) set(OPENBLAS_LAPACK_INCLUDE_PATH_SUFFIXES) set(OPENBLAS_BLAS_HEADERS cblas_openblas.h openblas_config.h cblas.h f77blas.h) +set(OPENBLAS_LAPACK_HEADERS lapacke.h lapacke_config.h lapacke_mangling.h lapacke_utils.h) set(OPENBLAS_BLAS_LIBRARY_PATH_SUFFIXES openblas openblas-base) set(OPENBLAS_LAPACK_LIBRARY_PATH_SUFFIXES openblas openblas-base) @@ -309,6 +310,7 @@ macro(cache_math_result _service MATH_TYPE) mark_as_advanced(${_SERVICE}_TYPE) add_definitions(-DHAVE_${MATH_TYPE}_${_SERVICE}) + message(STATUS "Setting -DHAVE_${MATH_TYPE}_${_SERVICE}") set(HAVE_${_SERVICE} ON CACHE INTERNAL "Defined if ${_SERVICE} is available" ) @@ -502,7 +504,8 @@ if (ENABLE_STATIC_LINKING) BLAS_TYPE MATCHES ATLAS OR BLAS_TYPE MATCHES SYSTEM_NATIVE OR BLAS_TYPE MATCHES OPENBLAS) - set(MATH_LIBS ${MATH_LIBS} -Wl,--whole-archive -lpthread -Wl,--no-whole-archive) + #cc_blas_static with ATLAS on travis-ci needs -lm + set(MATH_LIBS ${MATH_LIBS} -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm) endif() if (LAPACK_TYPE MATCHES MKL OR BLAS_TYPE MATCHES MKL) diff --git a/test/cc_cblas/cmake/autocmake.cfg b/test/cc_cblas/cmake/autocmake.cfg new file mode 100644 index 0000000..442df8d --- /dev/null +++ b/test/cc_cblas/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_cblas/src/CMakeLists.txt b/test/cc_cblas/src/CMakeLists.txt new file mode 100644 index 0000000..811ec3c --- /dev/null +++ b/test/cc_cblas/src/CMakeLists.txt @@ -0,0 +1,10 @@ +if(BLAS_FOUND) + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + #windows does not find cblas.h of openblas by default + include_directories($ENV{PATH}) + endif() + add_executable(example example.c) + target_link_libraries(example ${MATH_LIBS}) +else() + message(FATAL_ERROR "BLAS library not found for the test cc_cblas!") +endif() diff --git a/test/cc_cblas/src/example.c b/test/cc_cblas/src/example.c new file mode 100644 index 0000000..6a954c3 --- /dev/null +++ b/test/cc_cblas/src/example.c @@ -0,0 +1,31 @@ +#include +#include +/* cblas */ +#if defined HAVE_MKL_BLAS +#include "mkl_cblas.h" +#pragma message "Using Intel MKL interface" +#else +#include "cblas.h" +#pragma message "Using GNU interface" +#endif + +void main(void) +{ + int i,j,n=10; + double *a,*b,*c; + unsigned char test_ok=1; + + a = (double*)malloc(n * n * sizeof(a[0])); + b = (double*)malloc(n * n * sizeof(b[0])); + c = (double*)malloc(n * n * sizeof(c[0])); + + for (i = 0; i < n*n; i++) { a[i] = 1.0; b[i] = 2.0; c[i] = 0.0; } + + cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, n, n, n, 1.00, a, n, b, n, 0.00, c, n); + + for (i = 0; i < n*n; i++) { + if (abs(c[i]) - 20.00 > 0.0) { printf ("\n ERROR: element %i is %lf",i,c[i]); test_ok = 0;} + } + if ( test_ok == 1 ) {printf("PASSED");} + free(a);free(b);free(c); +} diff --git a/test/test.py b/test/test.py index 1ffb2c2..d8dacba 100644 --- a/test/test.py +++ b/test/test.py @@ -187,6 +187,14 @@ def test_fc_blas(): def test_fc_blas_static(): configure_build_and_exe('fc_blas', 'python setup.py --fc=gfortran --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') + +def test_cc_cblas(): + configure_build_and_exe('cc_cblas', 'python setup.py --cc=gcc --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') + + +def test_cc_cblas_static(): + configure_build_and_exe('cc_cblas', 'python setup.py --cc=gcc --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'OPENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"') + # ------------------------------------------------------------------------------