From dcbba523f216e6685adefbcbf2ab8f7c0a0729a1 Mon Sep 17 00:00:00 2001 From: Kartik Mohta Date: Tue, 9 Feb 2016 21:39:20 +0000 Subject: [PATCH 1/5] Use system Eigen if version >= 3.2.5 since that includes our patches --- CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3123dbea2..07d8d49de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,6 +215,15 @@ endif() ### http://eigen.tuxfamily.org/bz/show_bug.cgi?id=705 (Fix MKL LLT return code) option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" OFF) +# Use system Eigen if version >= 3.2.5 since that includes our patches +find_package(Eigen3 QUIET) +if(EIGEN3_FOUND AND (${EIGEN3_VERSION} VERSION_GREATER "3.2.4")) + set(GTSAM_USE_SYSTEM_EIGEN ON) + set(GTSAM_SYSTEM_EIGEN_MKL_ERROR OFF) +else() + set(GTSAM_SYSTEM_EIGEN_MKL_ERROR ON) +endif() + # Switch for using system Eigen or GTSAM-bundled Eigen if(GTSAM_USE_SYSTEM_EIGEN) find_package(Eigen3 REQUIRED) @@ -224,7 +233,7 @@ if(GTSAM_USE_SYSTEM_EIGEN) set(GTSAM_EIGEN_INCLUDE_PREFIX "${EIGEN3_INCLUDE_DIR}") # check if MKL is also enabled - can have one or the other, but not both! - if(EIGEN_USE_MKL_ALL) + if(EIGEN_USE_MKL_ALL AND GTSAM_SYSTEM_EIGEN_MKL_ERROR) 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() From 9a7dba75c49cd79c1432b6d3380c1e0f6cb0eb0f Mon Sep 17 00:00:00 2001 From: Kartik Mohta Date: Tue, 9 Feb 2016 22:11:28 -0500 Subject: [PATCH 2/5] CMakeLists.txt: Fix eigen version check logic --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07d8d49de..d63bf5c43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,7 @@ option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', us # Use system Eigen if version >= 3.2.5 since that includes our patches find_package(Eigen3 QUIET) -if(EIGEN3_FOUND AND (${EIGEN3_VERSION} VERSION_GREATER "3.2.4")) +if(EIGEN3_FOUND AND (EIGEN3_VERSION VERSION_GREATER 3.2.4)) set(GTSAM_USE_SYSTEM_EIGEN ON) set(GTSAM_SYSTEM_EIGEN_MKL_ERROR OFF) else() From 659ffeda02b9c40431b8c9fedf3569c3a4c67c8b Mon Sep 17 00:00:00 2001 From: Kartik Mohta Date: Tue, 9 Feb 2016 22:12:01 -0500 Subject: [PATCH 3/5] Replace GTSAM_USE_SYSTEM_EIGEN check for householder_qr_inplace_blocked The check was based on whether we are using the included version of Eigen or the system version, but since Eigen v3.2.5, our patches are included in the upstream Eigen, so check for Eigen version instead. --- gtsam/base/Matrix.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gtsam/base/Matrix.cpp b/gtsam/base/Matrix.cpp index c6af89486..eae3dc48b 100644 --- a/gtsam/base/Matrix.cpp +++ b/gtsam/base/Matrix.cpp @@ -704,11 +704,9 @@ void inplace_QR(Matrix& A){ HCoeffsType hCoeffs(size); RowVectorType temp(cols); -#ifdef GTSAM_USE_SYSTEM_EIGEN - // System-Eigen is used, and MKL is off +#if !EIGEN_VERSION_AT_LEAST(3,2,5) 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 From 3df163837abb23dd2ad75336f486e4df5c378d2f Mon Sep 17 00:00:00 2001 From: Kartik Mohta Date: Sat, 13 Feb 2016 15:08:54 -0500 Subject: [PATCH 4/5] Respect user's choice for using system Eigen, default to included copy --- CMakeLists.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d63bf5c43..5105b7423 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,15 +215,6 @@ endif() ### http://eigen.tuxfamily.org/bz/show_bug.cgi?id=705 (Fix MKL LLT return code) option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" OFF) -# Use system Eigen if version >= 3.2.5 since that includes our patches -find_package(Eigen3 QUIET) -if(EIGEN3_FOUND AND (EIGEN3_VERSION VERSION_GREATER 3.2.4)) - set(GTSAM_USE_SYSTEM_EIGEN ON) - set(GTSAM_SYSTEM_EIGEN_MKL_ERROR OFF) -else() - set(GTSAM_SYSTEM_EIGEN_MKL_ERROR ON) -endif() - # Switch for using system Eigen or GTSAM-bundled Eigen if(GTSAM_USE_SYSTEM_EIGEN) find_package(Eigen3 REQUIRED) @@ -233,7 +224,8 @@ if(GTSAM_USE_SYSTEM_EIGEN) set(GTSAM_EIGEN_INCLUDE_PREFIX "${EIGEN3_INCLUDE_DIR}") # check if MKL is also enabled - can have one or the other, but not both! - if(EIGEN_USE_MKL_ALL AND GTSAM_SYSTEM_EIGEN_MKL_ERROR) + # Note: Eigen >= v3.2.5 includes our patches + if(EIGEN_USE_MKL_ALL AND (EIGEN3_VERSION VERSION_LESS 3.2.5)) 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() From 96714269a32c60d8e57a563740161eabbdb3d270 Mon Sep 17 00:00:00 2001 From: Kartik Mohta Date: Sat, 13 Feb 2016 16:34:27 -0500 Subject: [PATCH 5/5] Change Eigen MKL warning message --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5105b7423..602ed01fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,7 +226,7 @@ if(GTSAM_USE_SYSTEM_EIGEN) # check if MKL is also enabled - can have one or the other, but not both! # Note: Eigen >= v3.2.5 includes our patches if(EIGEN_USE_MKL_ALL AND (EIGEN3_VERSION VERSION_LESS 3.2.5)) - 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") + message(FATAL_ERROR "MKL requires at least Eigen 3.2.5, and your system appears to have an older version. Disable GTSAM_USE_SYSTEM_EIGEN to use GTSAM's copy of Eigen, or disable GTSAM_WITH_EIGEN_MKL") endif() else() # Use bundled Eigen include path.