mirror of
https://github.com/opencv/opencv.git
synced 2025-06-11 20:09:23 +08:00
Add MKL support
This commit is contained in:
parent
c1d73e4fca
commit
a113d9bcc1
@ -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_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_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_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
|
# OpenCV build components
|
||||||
# ===================================================
|
# ===================================================
|
||||||
|
@ -7,11 +7,21 @@ if(WITH_LAPACK)
|
|||||||
find_package(LAPACK)
|
find_package(LAPACK)
|
||||||
if(LAPACK_FOUND)
|
if(LAPACK_FOUND)
|
||||||
find_path(LAPACKE_INCLUDE_DIR "lapacke.h")
|
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")
|
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)
|
set(HAVE_LAPACK 1)
|
||||||
|
|
||||||
|
if(CBLAS_INCLUDE_DIR)
|
||||||
ocv_include_directories(${LAPACKE_INCLUDE_DIR} ${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})
|
list(APPEND OPENCV_LINKER_LIBS ${LAPACK_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -204,5 +204,11 @@
|
|||||||
/* Lapack */
|
/* Lapack */
|
||||||
#cmakedefine HAVE_LAPACK
|
#cmakedefine HAVE_LAPACK
|
||||||
|
|
||||||
|
/* Lapack Generic */
|
||||||
|
#cmakedefine HAVE_LAPACK_GENERIC
|
||||||
|
|
||||||
|
/* Lapack MKL */
|
||||||
|
#cmakedefine HAVE_LAPACK_MKL
|
||||||
|
|
||||||
/* FP16 */
|
/* FP16 */
|
||||||
#cmakedefine HAVE_FP16
|
#cmakedefine HAVE_FP16
|
||||||
|
@ -46,9 +46,17 @@
|
|||||||
|
|
||||||
#ifdef HAVE_LAPACK
|
#ifdef HAVE_LAPACK
|
||||||
|
|
||||||
|
#ifdef HAVE_LAPACK_MKL
|
||||||
|
#include <mkl_cblas.h>
|
||||||
|
#include <mkl_lapack.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LAPACK_GENERIC
|
||||||
|
#include <lapacke.h>
|
||||||
|
#include <cblas.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <lapacke.h>
|
|
||||||
#include <cblas.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -150,7 +158,7 @@ lapack_LU(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, int*
|
|||||||
template <typename fptype> static inline int
|
template <typename fptype> static inline int
|
||||||
lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n, bool* info)
|
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);
|
int lda = a_step / sizeof(fptype);
|
||||||
char L[] = {'L', '\0'};
|
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))
|
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);
|
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];
|
fptype* buffer = new fptype[lwork + 1];
|
||||||
|
|
||||||
if(typeid(fptype) == typeid(float))
|
if(typeid(fptype) == typeid(float))
|
||||||
|
Loading…
Reference in New Issue
Block a user