diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e575bd794..05d88544c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,7 +224,7 @@ OCV_OPTION(WITH_VA "Include VA support" OFF OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) ) OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) ) OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID) ) -OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (UNIX AND NOT ANDROID) ) +OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID) ) # OpenCV build components # =================================================== diff --git a/cmake/OpenCVFindLibsPerf.cmake b/cmake/OpenCVFindLibsPerf.cmake index c679102d37..0364847329 100644 --- a/cmake/OpenCVFindLibsPerf.cmake +++ b/cmake/OpenCVFindLibsPerf.cmake @@ -7,11 +7,21 @@ if(WITH_LAPACK) find_package(LAPACK) if(LAPACK_FOUND) find_path(LAPACKE_INCLUDE_DIR "lapacke.h") - if(LAPACKE_INCLUDE_DIR) + find_path(MKL_LAPACKE_INCLUDE_DIR "mkl_lapack.h") + if(LAPACKE_INCLUDE_DIR OR MKL_LAPACKE_INCLUDE_DIR) find_path(CBLAS_INCLUDE_DIR "cblas.h") - if(CBLAS_INCLUDE_DIR) + find_path(MKL_CBLAS_INCLUDE_DIR "mkl_cblas.h") + + if(CBLAS_INCLUDE_DIR OR MKL_CBLAS_INCLUDE_DIR) set(HAVE_LAPACK 1) + + if(CBLAS_INCLUDE_DIR) ocv_include_directories(${LAPACKE_INCLUDE_DIR} ${CBLAS_INCLUDE_DIR}) + set(HAVE_LAPACK_GENERIC 1) + elseif(MKL_CBLAS_INCLUDE_DIR) + ocv_include_directories(${MKL_LAPACKE_INCLUDE_DIR} ${MKL_CBLAS_INCLUDE_DIR}) + set(HAVE_LAPACK_MKL 1) + endif() list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES}) endif() endif() diff --git a/cmake/templates/cvconfig.h.in b/cmake/templates/cvconfig.h.in index 8dac1ed618..4012f69426 100644 --- a/cmake/templates/cvconfig.h.in +++ b/cmake/templates/cvconfig.h.in @@ -204,5 +204,11 @@ /* Lapack */ #cmakedefine HAVE_LAPACK +/* Lapack Generic */ +#cmakedefine HAVE_LAPACK_GENERIC + +/* Lapack MKL */ +#cmakedefine HAVE_LAPACK_MKL + /* FP16 */ #cmakedefine HAVE_FP16 diff --git a/modules/core/src/hal_internal.cpp b/modules/core/src/hal_internal.cpp index 07054f1d6c..5b83522eed 100644 --- a/modules/core/src/hal_internal.cpp +++ b/modules/core/src/hal_internal.cpp @@ -46,9 +46,17 @@ #ifdef HAVE_LAPACK +#ifdef HAVE_LAPACK_MKL + #include + #include +#endif + +#ifdef HAVE_LAPACK_GENERIC + #include + #include +#endif + #include -#include -#include #include #include #include @@ -150,7 +158,7 @@ lapack_LU(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, int* template static inline int lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, bool* info) { - int lapackStatus; + int lapackStatus = 0; int lda = a_step / sizeof(fptype); char L[] = {'L', '\0'}; @@ -227,7 +235,7 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype else if(typeid(fptype) == typeid(double)) dgesdd_(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)&work1, &lwork, iworkBuf, info); - lwork = round(work1); //optimal buffer size + lwork = (int)round(work1); //optimal buffer size fptype* buffer = new fptype[lwork + 1]; if(typeid(fptype) == typeid(float))