From f61e398e2d970cc2d523bb58bff7c52dbf682732 Mon Sep 17 00:00:00 2001 From: cbeall3 Date: Tue, 10 Mar 2015 13:00:28 -0400 Subject: [PATCH] Deal with patched/un-patched version of householder_qr_inplace_blocked --- CMakeLists.txt | 5 +++++ gtsam/base/Matrix.cpp | 7 +++++++ gtsam/config.h.in | 3 +++ 3 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0041c4710..dd626bde8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,6 +205,11 @@ if(GTSAM_USE_SYSTEM_EIGEN) find_package(Eigen3 REQUIRED) include_directories(AFTER "${EIGEN3_INCLUDE_DIR}") + + # check if MKL is also enabled - can have one or the other, but not both! + if(EIGEN_USE_MKL_ALL) + message(FATAL_ERROR "MKL cannot be used together with system-installed Eigen, as MKL support relies on patches which are not yet in the system-installed Eigen. Disable either GTSAM_USE_SYSTEM_EIGEN or GTSAM_WITH_EIGEN_MKL") + endif() else() # Use bundled Eigen include path. set(GTSAM_EIGEN_INCLUDE_PREFIX "gtsam/3rdparty/Eigen/") diff --git a/gtsam/base/Matrix.cpp b/gtsam/base/Matrix.cpp index a5836a3ac..9e56dfb6c 100644 --- a/gtsam/base/Matrix.cpp +++ b/gtsam/base/Matrix.cpp @@ -706,6 +706,7 @@ std::string formatMatrixIndented(const std::string& label, const Matrix& matrix, return ss.str(); } +/* ************************************************************************* */ void inplace_QR(Matrix& A){ size_t rows = A.rows(); size_t cols = A.cols(); @@ -716,7 +717,13 @@ void inplace_QR(Matrix& A){ HCoeffsType hCoeffs(size); RowVectorType temp(cols); +#ifdef GTSAM_USE_SYSTEM_EIGEN + // System-Eigen is used, and MKL is off + Eigen::internal::householder_qr_inplace_blocked(A, hCoeffs, 48, temp.data()); +#else + // Patched Eigen is used, and MKL is either on or off Eigen::internal::householder_qr_inplace_blocked::run(A, hCoeffs, 48, temp.data()); +#endif zeroBelowDiagonal(A); } diff --git a/gtsam/config.h.in b/gtsam/config.h.in index 64136511d..8d406e21f 100644 --- a/gtsam/config.h.in +++ b/gtsam/config.h.in @@ -42,6 +42,9 @@ // Whether we are using TBB (if TBB was found and GTSAM_WITH_TBB is enabled in CMake) #cmakedefine GTSAM_USE_TBB +// Whether we are using system-Eigen or our own patched version +#cmakedefine GTSAM_USE_SYSTEM_EIGEN + // Whether Eigen will use MKL (if MKL was found and GTSAM_WITH_EIGEN_MKL is enabled in CMake) #cmakedefine GTSAM_USE_EIGEN_MKL #cmakedefine EIGEN_USE_MKL_ALL // This is also defined in gtsam_eigen_includes.h