From 43cdd242d0e34aa05e368b3d894c1041aa2cd771 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 9 Dec 2011 10:06:49 +0100 Subject: [PATCH] - split and rename defined tokens to enable the use of BLAS/Lapack/VML/etc - include MKL headers outside the Eigen namespace. --- Eigen/Cholesky | 2 +- Eigen/Core | 28 ++++++++++------- Eigen/Eigenvalues | 2 +- Eigen/LU | 2 +- Eigen/QR | 2 +- Eigen/SVD | 2 +- Eigen/src/Core/Assign_MKL.h | 2 -- .../GeneralMatrixMatrixTriangular_MKL.h | 2 -- .../Core/products/GeneralMatrixMatrix_MKL.h | 2 -- .../Core/products/GeneralMatrixVector_MKL.h | 2 -- Eigen/src/Core/products/Parallelizer.h | 4 ++- .../products/SelfadjointMatrixMatrix_MKL.h | 2 -- .../products/SelfadjointMatrixVector_MKL.h | 2 -- .../products/TriangularMatrixMatrix_MKL.h | 2 -- .../products/TriangularMatrixVector_MKL.h | 2 -- .../products/TriangularSolverMatrix_MKL.h | 2 -- Eigen/src/Core/util/MKL_support.h | 30 +++++++++++++++++-- 17 files changed, 53 insertions(+), 37 deletions(-) diff --git a/Eigen/Cholesky b/Eigen/Cholesky index 7b700c700..d5ac5348f 100644 --- a/Eigen/Cholesky +++ b/Eigen/Cholesky @@ -24,7 +24,7 @@ namespace Eigen { #include "src/misc/Solve.h" #include "src/Cholesky/LLT.h" #include "src/Cholesky/LDLT.h" -#ifdef EIGEN_MKL +#ifdef EIGEN_USE_MKL_CLAPACK #include "src/Cholesky/LLT_MKL.h" #endif diff --git a/Eigen/Core b/Eigen/Core index ea2b6ec51..ed9408a45 100644 --- a/Eigen/Core +++ b/Eigen/Core @@ -34,6 +34,10 @@ // defined e.g. EIGEN_DONT_ALIGN) so it needs to be done before we do anything with vectorization. #include "src/Core/util/Macros.h" +// this include file manages BLAS and MKL related macros +// and inclusion of their respective header files +#include "src/Core/util/MKL_support.h" + // if alignment is disabled, then disable vectorization. Note: EIGEN_ALIGN is the proper check, it takes into // account both the user's will (EIGEN_DONT_ALIGN) and our own platform checks #if !EIGEN_ALIGN @@ -336,16 +340,6 @@ using std::ptrdiff_t; #include "src/Core/products/TriangularMatrixVector.h" #include "src/Core/products/TriangularMatrixMatrix.h" #include "src/Core/products/TriangularSolverMatrix.h" -#ifdef EIGEN_MKL -#include "src/Core/products/GeneralMatrixMatrix_MKL.h" -#include "src/Core/products/GeneralMatrixVector_MKL.h" -#include "src/Core/products/GeneralMatrixMatrixTriangular_MKL.h" -#include "src/Core/products/SelfadjointMatrixMatrix_MKL.h" -#include "src/Core/products/SelfadjointMatrixVector_MKL.h" -#include "src/Core/products/TriangularMatrixMatrix_MKL.h" -#include "src/Core/products/TriangularMatrixVector_MKL.h" -#include "src/Core/products/TriangularSolverMatrix_MKL.h" -#endif #include "src/Core/products/TriangularSolverVector.h" #include "src/Core/BandMatrix.h" @@ -363,7 +357,19 @@ using std::ptrdiff_t; #include "src/Core/CoreEvaluators.h" #include "src/Core/AssignEvaluator.h" #endif -#ifdef EIGEN_MKL + +#ifdef EIGEN_USE_BLAS +#include "src/Core/products/GeneralMatrixMatrix_MKL.h" +#include "src/Core/products/GeneralMatrixVector_MKL.h" +#include "src/Core/products/GeneralMatrixMatrixTriangular_MKL.h" +#include "src/Core/products/SelfadjointMatrixMatrix_MKL.h" +#include "src/Core/products/SelfadjointMatrixVector_MKL.h" +#include "src/Core/products/TriangularMatrixMatrix_MKL.h" +#include "src/Core/products/TriangularMatrixVector_MKL.h" +#include "src/Core/products/TriangularSolverMatrix_MKL.h" +#endif // EIGEN_USE_BLAS + +#ifdef EIGEN_USE_MKL_VML #include "src/Core/Assign_MKL.h" #endif diff --git a/Eigen/Eigenvalues b/Eigen/Eigenvalues index d6de5ab2a..588ee9a82 100644 --- a/Eigen/Eigenvalues +++ b/Eigen/Eigenvalues @@ -36,7 +36,7 @@ namespace Eigen { #include "src/Eigenvalues/ComplexSchur.h" #include "src/Eigenvalues/ComplexEigenSolver.h" #include "src/Eigenvalues/MatrixBaseEigenvalues.h" -#ifdef EIGEN_MKL +#ifdef EIGEN_USE_MKL_CLAPACK #include "src/Eigenvalues/RealSchur_MKL.h" #include "src/Eigenvalues/ComplexSchur_MKL.h" #include "src/Eigenvalues/SelfAdjointEigenSolver_MKL.h" diff --git a/Eigen/LU b/Eigen/LU index da38c2238..9d382e5e9 100644 --- a/Eigen/LU +++ b/Eigen/LU @@ -23,7 +23,7 @@ namespace Eigen { #include "src/misc/Image.h" #include "src/LU/FullPivLU.h" #include "src/LU/PartialPivLU.h" -#ifdef EIGEN_MKL +#ifdef EIGEN_USE_MKL_CLAPACK #include "src/LU/PartialPivLU_MKL.h" #endif #include "src/LU/Determinant.h" diff --git a/Eigen/QR b/Eigen/QR index e5c947b49..3b18c9970 100644 --- a/Eigen/QR +++ b/Eigen/QR @@ -28,7 +28,7 @@ namespace Eigen { #include "src/QR/HouseholderQR.h" #include "src/QR/FullPivHouseholderQR.h" #include "src/QR/ColPivHouseholderQR.h" -#ifdef EIGEN_MKL +#ifdef EIGEN_USE_MKL_CLAPACK #include "src/QR/HouseholderQR_MKL.h" #include "src/QR/ColPivHouseholderQR_MKL.h" #endif diff --git a/Eigen/SVD b/Eigen/SVD index 5b41d4e83..add72aba5 100644 --- a/Eigen/SVD +++ b/Eigen/SVD @@ -24,7 +24,7 @@ namespace Eigen { #include "src/misc/Solve.h" #include "src/SVD/JacobiSVD.h" -#ifdef EIGEN_MKL +#if defined(EIGEN_ALLOW_JACOBISVD_USE_LAPACKSVD) && defined(EIGEN_USE_MKL_CLAPACK) #include "src/SVD/JacobiSVD_MKL.h" #endif #include "src/SVD/UpperBidiagonalization.h" diff --git a/Eigen/src/Core/Assign_MKL.h b/Eigen/src/Core/Assign_MKL.h index 141015f1b..39315c23c 100644 --- a/Eigen/src/Core/Assign_MKL.h +++ b/Eigen/src/Core/Assign_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_ASSIGN_VML_H #define EIGEN_ASSIGN_VML_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { template struct vml_call diff --git a/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h b/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h index d86bc0542..5c52f2a07 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrixTriangular_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H #define EIGEN_GENERAL_MATRIX_MATRIX_TRIANGULAR_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { template diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h b/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h index 9ad589e66..fad7fff53 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_GENERAL_MATRIX_MATRIX_MKL_H #define EIGEN_GENERAL_MATRIX_MATRIX_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { /********************************************************************** diff --git a/Eigen/src/Core/products/GeneralMatrixVector_MKL.h b/Eigen/src/Core/products/GeneralMatrixVector_MKL.h index 20194c9fa..89130142d 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector_MKL.h +++ b/Eigen/src/Core/products/GeneralMatrixVector_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_GENERAL_MATRIX_VECTOR_MKL_H #define EIGEN_GENERAL_MATRIX_VECTOR_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { /********************************************************************** diff --git a/Eigen/src/Core/products/Parallelizer.h b/Eigen/src/Core/products/Parallelizer.h index d002f6d2e..889d76c98 100644 --- a/Eigen/src/Core/products/Parallelizer.h +++ b/Eigen/src/Core/products/Parallelizer.h @@ -85,7 +85,9 @@ template struct GemmParallelInfo template void parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpose) { -#if !(defined (EIGEN_HAS_OPENMP)) || defined (EIGEN_MKL) + // TODO when EIGEN_USE_BLAS is defined, + // we should still enable OMP for other scalar types +#if !(defined (EIGEN_HAS_OPENMP)) || defined (EIGEN_USE_BLAS) // FIXME the transpose variable is only needed to properly split // the matrix product when multithreading is enabled. This is a temporary // fix to support row-major destination matrices. This whole diff --git a/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h b/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h index 338a57a55..2b4e5a4d6 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h +++ b/Eigen/src/Core/products/SelfadjointMatrixMatrix_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_MATRIX_MKL_H #define EIGEN_SELFADJOINT_MATRIX_MATRIX_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h b/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h index 37d20d581..d5a92d9e9 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H #define EIGEN_SELFADJOINT_MATRIX_VECTOR_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { /********************************************************************** diff --git a/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h b/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h index 5c0a07739..6ad62b66c 100644 --- a/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h +++ b/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_TRIANGULAR_MATRIX_MATRIX_MKL_H #define EIGEN_TRIANGULAR_MATRIX_MATRIX_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { diff --git a/Eigen/src/Core/products/TriangularMatrixVector_MKL.h b/Eigen/src/Core/products/TriangularMatrixVector_MKL.h index 6acd43c88..a3750ec96 100644 --- a/Eigen/src/Core/products/TriangularMatrixVector_MKL.h +++ b/Eigen/src/Core/products/TriangularMatrixVector_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_TRIANGULAR_MATRIX_VECTOR_MKL_H #define EIGEN_TRIANGULAR_MATRIX_VECTOR_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { /********************************************************************** diff --git a/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h b/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h index 644ef35c5..3ba20cdda 100644 --- a/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h +++ b/Eigen/src/Core/products/TriangularSolverMatrix_MKL.h @@ -33,8 +33,6 @@ #ifndef EIGEN_TRIANGULAR_SOLVER_MATRIX_MKL_H #define EIGEN_TRIANGULAR_SOLVER_MATRIX_MKL_H -#include "Eigen/src/Core/util/MKL_support.h" - namespace internal { // implements LeftSide op(triangular)^-1 * general diff --git a/Eigen/src/Core/util/MKL_support.h b/Eigen/src/Core/util/MKL_support.h index 6d78e97b1..56a03fa32 100644 --- a/Eigen/src/Core/util/MKL_support.h +++ b/Eigen/src/Core/util/MKL_support.h @@ -33,12 +33,31 @@ #ifndef EIGEN_MKL_SUPPORT_H #define EIGEN_MKL_SUPPORT_H +#ifdef EIGEN_USE_MKL_ALL + #ifndef EIGEN_USE_BLAS + #define EIGEN_USE_BLAS + #endif + #ifndef EIGEN_USE_MKL_CLAPACK + #define EIGEN_USE_MKL_CLAPACK + #endif + #ifndef EIGEN_USE_MKL_VML + #define EIGEN_USE_MKL_VML + #endif +#endif + +#if defined(EIGEN_USE_MKL_CLAPACK) || defined(EIGEN_USE_MKL_VML) + #define EIGEN_USE_MKL +#endif + +#if defined EIGEN_USE_MKL + #include #include -#include #define EIGEN_MKL_VML_THRESHOLD 128 +namespace Eigen { + typedef std::complex dcomplex; typedef std::complex scomplex; @@ -80,5 +99,12 @@ inline void assign_conj_scalar_eig2mkl(MKL_Complex8& mklS } // end namespace internal +} // end namespace Eigen -#endif \ No newline at end of file +#elif defined EIGEN_USE_BLAS + +#include "../../misc/blas.h" + +#endif + +#endif