Make the min. required version of SuiteSparse to be 4.5.6

With this change we can drop the complicated/conditional handling
around CAMD and assume that it is always available.

Change-Id: I93e1da676fb75817f79824b8b2b6549d03f278b0
This commit is contained in:
Sameer Agarwal
2022-05-16 09:27:49 -07:00
parent c8493fc366
commit 12263e2830
6 changed files with 8 additions and 78 deletions
+1 -1
View File
@@ -266,7 +266,7 @@ if (SUITESPARSE)
# built with SuiteSparse support.
# Check for SuiteSparse and dependencies.
find_package(SuiteSparse 4.0 COMPONENTS CHOLMOD SPQR)
find_package(SuiteSparse 4.5.6 COMPONENTS CHOLMOD SPQR)
if (SuiteSparse_FOUND)
set(SuiteSparse_DEPENDENCY "find_dependency(SuiteSparse ${SuiteSparse_VERSION})")
# By default, if all of SuiteSparse's dependencies are found, Ceres is
+1 -1
View File
@@ -68,7 +68,7 @@ optional. For details on customizing the build process, see
examples and tests and usually a dependency for glog.
- `SuiteSparse <http://faculty.cse.tamu.edu/davis/suitesparse.html>`_
4.0 or later. Needed for solving large sparse linear
4.5.6 or later. Needed for solving large sparse linear
systems. **Optional; strongly recommended for large scale bundle
adjustment**
+3 -8
View File
@@ -120,10 +120,9 @@ void OrderingForSparseNormalCholeskyUsingSuiteSparse(
cholmod_sparse* block_jacobian_transpose = ss.CreateSparseMatrix(
const_cast<TripletSparseMatrix*>(&tsm_block_jacobian_transpose));
// No CAMD or the user did not supply a useful ordering, then just
// use regular AMD.
if (parameter_block_ordering.NumGroups() <= 1 ||
!SuiteSparse::IsConstrainedApproximateMinimumDegreeOrderingAvailable()) {
// If the user did not supply a useful ordering, then just use
// regular AMD.
if (parameter_block_ordering.NumGroups() <= 1) {
ss.ApproximateMinimumDegreeOrdering(block_jacobian_transpose, &ordering[0]);
} else {
vector<int> constraints;
@@ -331,10 +330,6 @@ static void MaybeReorderSchurComplementColumnsUsingSuiteSparse(
const ParameterBlockOrdering& parameter_block_ordering, Program* program) {
#ifndef CERES_NO_SUITESPARSE
SuiteSparse ss;
if (!SuiteSparse::IsConstrainedApproximateMinimumDegreeOrderingAvailable()) {
return;
}
vector<int> constraints;
vector<ParameterBlock*>& parameter_blocks =
*(program->mutable_parameter_blocks());
-9
View File
@@ -352,16 +352,7 @@ bool SuiteSparse::NestedDissectionOrdering(cholmod_sparse* matrix,
bool SuiteSparse::ConstrainedApproximateMinimumDegreeOrdering(
cholmod_sparse* matrix, int* constraints, int* ordering) {
#ifndef CERES_NO_CAMD
return cholmod_camd(matrix, nullptr, 0, constraints, ordering, &cc_);
#else
LOG(FATAL) << "Congratulations you have found a bug in Ceres."
<< "Ceres Solver was compiled with SuiteSparse "
<< "version 4.1.0 or less. Calling this function "
<< "in that case is a bug. Please contact the"
<< "the Ceres Solver developers.";
return false;
#endif
}
std::unique_ptr<SparseCholesky> SuiteSparseCholesky::Create(
-50
View File
@@ -49,28 +49,6 @@
#include "cholmod.h"
#include "glog/logging.h"
// Before SuiteSparse version 4.2.0, cholmod_camd was only enabled
// if SuiteSparse was compiled with Metis support. This makes
// calling and linking into cholmod_camd problematic even though it
// has nothing to do with Metis. This has been fixed reliably in
// 4.2.0.
//
// The fix was actually committed in 4.1.0, but there is
// some confusion about a silent update to the tar ball, so we are
// being conservative and choosing the next minor version where
// things are stable.
#if (SUITESPARSE_VERSION < 4002)
#define CERES_NO_CAMD
#endif
// UF_long is deprecated but SuiteSparse_long is only available in
// newer versions of SuiteSparse. So for older versions of
// SuiteSparse, we define SuiteSparse_long to be the same as UF_long,
// which is what recent versions of SuiteSparse do anyways.
#ifndef SuiteSparse_long
#define SuiteSparse_long UF_long
#endif
#include "ceres/internal/disable_warnings.h"
namespace ceres::internal {
@@ -240,20 +218,6 @@ class CERES_NO_EXPORT SuiteSparse {
// Find a fill reducing ordering using nested dissection.
bool NestedDissectionOrdering(cholmod_sparse* matrix, int* ordering);
// Before SuiteSparse version 4.2.0, cholmod_camd was only enabled
// if SuiteSparse was compiled with Metis support. This makes
// calling and linking into cholmod_camd problematic even though it
// has nothing to do with Metis. This has been fixed reliably in
// 4.2.0.
//
// The fix was actually committed in 4.1.0, but there is
// some confusion about a silent update to the tar ball, so we are
// being conservative and choosing the next minor version where
// things are stable.
static bool IsConstrainedApproximateMinimumDegreeOrderingAvailable() {
return (SUITESPARSE_VERSION > 4001);
}
// Nested dissection is only available if SuiteSparse is compiled
// with Metis support.
static bool IsNestedDissectionAvailable() {
@@ -274,9 +238,6 @@ class CERES_NO_EXPORT SuiteSparse {
// Calling ApproximateMinimumDegreeOrdering is equivalent to calling
// ConstrainedApproximateMinimumDegreeOrdering with a constraint
// array that puts all columns in the same elimination group.
//
// If CERES_NO_CAMD is defined then calling this function will
// result in a crash.
bool ConstrainedApproximateMinimumDegreeOrdering(cholmod_sparse* matrix,
int* constraints,
int* ordering);
@@ -339,17 +300,6 @@ namespace internal {
class CERES_NO_EXPORT SuiteSparse {
public:
// Defining this static function even when SuiteSparse is not
// available, allows client code to check for the presence of CAMD
// without checking for the absence of the CERES_NO_CAMD symbol.
//
// This is safer because the symbol maybe missing due to a user
// accidentally not including suitesparse.h in their code when
// checking for the symbol.
static bool IsConstrainedApproximateMinimumDegreeOrderingAvailable() {
return false;
}
void Free(void* /*arg*/) {}
};
+3 -9
View File
@@ -227,21 +227,15 @@ bool SetupLinearSolver(PreprocessedProblem* pp) {
if (options.linear_solver_type == SPARSE_SCHUR) {
// When using SPARSE_SCHUR, we ignore the user's postordering
// preferences in certain cases.
//
// 1. SUITE_SPARSE is the sparse linear algebra library requested
// but cholmod_camd is not available.
// 2. CX_SPARSE is the sparse linear algebra library requested.
// preferences if CX_SPARSE is the sparse linear algebra
// backend.
//
// This ensures that the linear solver does not assume that a
// fill-reducing pre-ordering has been done.
//
// TODO(sameeragarwal): Implement the reordering of parameter
// blocks for CX_SPARSE.
if ((options.sparse_linear_algebra_library_type == SUITE_SPARSE &&
!SuiteSparse::
IsConstrainedApproximateMinimumDegreeOrderingAvailable()) ||
(options.sparse_linear_algebra_library_type == CX_SPARSE)) {
if (options.sparse_linear_algebra_library_type == CX_SPARSE) {
pp->linear_solver_options.use_postordering = true;
}
}