Commit Graph

1880 Commits

Author SHA1 Message Date
Sergiu Deitsch 4e5ea292ba Fixed MSVC 2022 warning
MSVC rightfully issues warning C4305: 'if': truncation from 'size_t' to
'bool' in a static_assert condition that implicitly converts sizeof
result to a boolean.

Change-Id: Ie3b913288bfeaa7a4b362ef7f83d2505ed368641
2022-06-24 00:12:09 +02:00
Alex Stewart 83f6e08530 Fix use of conditional preprocessor checks within a macro in tests
- These are non-standard C++, and whilst they are accepted by GCC and
  Clang on *NIX and macOS, they are rejected by MSVC.

Change-Id: Ie627d74bb02ebdce3dc5e13c2010616c26cb5dea
2022-06-23 16:30:59 +01:00
Alex Stewart 70f1aac31f Fix fmin/fmax() when using Jets with float as their scalar type
Change-Id: Ie7f400763f91b0e264a50401716321587ab1d477
2022-06-23 16:05:58 +01:00
Alex Stewart 5de77f399e Fix reporting of METIS version
- Also fixes behaviour of EIGENMETIS option to match that of the other
  CMake dependency options, and ensure that its value aligns exactly
  with whether Eigen support for METIS will be compiled into Ceres.

Change-Id: Ifbf6f5d82b9ba89a156673eb6042519a985e6b04
2022-06-22 19:20:40 +01:00
Alex Stewart 11e6376675 Fix #ifdef guards around METIS usage in EigenSparse backend and tests
Change-Id: Idd1e0b7b1b2df2d402431b107dee0fa8e0fd58f5
2022-06-22 19:05:30 +01:00
Sergiu Deitsch 0c88301e66 Provide optional METIS support
* Split `CERES_NO_METIS` into two defines: `CERES_NO_PARTITION` and
  `CERES_NO_METIS`. The former refers to METIS support in SuiteSparse,
  the latter to the Eigen's MetisSupport module. This enables the use of
  sparse matrix reordering independent from SuiteSparse.
* Run Linux, macOS, and macOS Github workflows with METIS enabled
  SuiteSparse.

Fixes #808

Change-Id: I5076b7e1268d32cc3e7e56650edcbaf7fb3b59ce
2022-06-22 16:46:02 +00:00
Alex Stewart f11c256265 Fix fmin/fmax() to use Jet averaging on equality
- Prior to 48cb54d1, Ceres' fmin/fmax() for Jets followed the convention
  of std::min/max(), and always returned the first argument on equality,
  irrespective of whether this argument was natively a scalar or a Jet.
- After 48cb54d1, Ceres' fmin/fmax() instead returned the second
  argument on equality, again irrespective of whether this argument was
  natively a scalar or a Jet.
- Now on equality we average the arguments as Jets, which ensures that
  a consistent answer is produced irrespective of the ordering or type
  (Jet or scalar) of the input arguments. This also ensures that we
  preserve a non-zero derivative where it exists, excluding the edge
  case of two Jet inputs with equal but oppositely signed infinitesimal
  components.
- We retain the behaviour introduced in 48cb54d1 whereby NaNs are
  treated as missing values, following the convention of
  std::fmin/fmax().
- Raised as issue #816.

Change-Id: I01217c0e32c1be83be440e4515b57c79dd290923
2022-06-22 14:19:55 +01:00
Joydeep Biswas b90053f1ad Revert C++17 usage of std::exclusive_scan
* Unfortunately on some systems such as the Nvidia Jetson, while the
  compiler supports C++17, the STL implementations are incomplete.
  One such missing implementation is std::exclusive_scan, so this
  patch reverts to the old way of manually computing prefix sums.

Change-Id: I4192257519b0083560a4b44e2659ee44d7421105
2022-06-12 11:24:08 -05:00
Sergiu Deitsch dfce1e128d Link against threading library only if necessary
1. The platform specific threads library is only needed if we actually
   use threads. In this case, the library is not optional opposed to
   previous logic.
2. Do not hide the find module output to allow the user to understand
   what happens in case of a CMake failure to locate Threads.
3. Finally, Threads is private dependency that does need to be
   propagated to consumers unless Ceres was compiled as a static
   library.

Change-Id: I8d9d9cd42930e1ed234f69a2dba70d0ee2755b4e
2022-06-08 00:03:41 +02:00
Sergiu Deitsch 69eddfb6da Use find module to link against OpenMP
Depending on the compiler in use, linking against OpenMP may require
passing specific compiler flags instead of linking against a library.
Use the CMake OpenMP find module to abstract OpenMP activation.

Change-Id: Ib43f576ac12e2c5e9598e9586df3dfa018e9c08b
2022-06-07 23:39:39 +02:00
Sameer Agarwal b4803778c3 Update documentation for linear_solver_ordering_type
Also update obsolete documentation related to building and
using sparse linear algebra libraries.

Change-Id: I83682b43472e6a6ec4e4dad32fa21c089d518c06
2022-06-07 14:08:26 -07:00
Joydeep Biswas 2e764df06f Update Cuda memcheck test
* Fix silly typo in CMakeLists.txt

Change-Id: I98b5a2fc0b8452f2f078117e31fb0ef350e6c11f
2022-06-02 17:41:40 -05:00
Joydeep Biswas 443ae9ce26 Update Cuda memcheck test
* Previously the Cuda memcheck tests relied on the Cuda binaries being
  on the environment PATH. This has been changed instead to use the
  path discovered by CMake when searching for Cuda. This has the added
  benefit that the memcheck tool will be sure to be from the same Cuda
  version install as the version being compiled against.

Change-Id: I650d1bb7e14064ca98a01e3c13eb1bcb772b51cc
2022-06-02 22:25:58 +00:00
Sergiu Deitsch 55b4c3f447 Retain terminal formatting when building docs
This prevents Sphinx output to be stripped of colors, emphasis etc.

Change-Id: I127e02cbdda69a5d49a73678a7a7e2b4512b189e
2022-05-28 21:02:12 +00:00
Sergiu Deitsch 786866d9f7 Generate version string at compile time
Strings can be concatenated during compilation bypassing any dynamic
memory allocation.

Change-Id: Iecd94ca44dddde4694bfeb823a0a06f174b6085b
2022-05-28 15:04:09 +02:00
Sameer Agarwal 5bd83c4ac0 Unbreak the build with EIGENSPARSE is disabled
Change-Id: Ia3a6121f031e647b51adba427c814e818eed2d2d
2022-05-27 10:12:50 -07:00
Sameer Agarwal 2335b5b4b7 Remove support for CXSparse
Eigen provides all the functionality that we need from CXSparse
with a more liberal license.

I will update the documentation in a follow up CL.

Change-Id: I0b9fd8be3c27754cc2986cc0e06595c8b3fdec0b
2022-05-27 09:20:21 -07:00
Sameer Agarwal fbc2eea166 Nested dissection for ACCELERATE_SPARSE & EIGEN_SPARSE
Change-Id: Iec8ea6b0a537559b48b59bcfc91b94b58cb2070e
2022-05-27 06:50:12 -07:00
Sergiu Deitsch d87fd551bc Fix Ubuntu 20.04 workflow tests
Previously, the tests did not run because the CMake version shipped with
Ubuntu 20.04 does not understand the `--test-dir` option and silently
fails.

Change-Id: I335e1d9e3890aa56e66a9dfd0fccd4594a84a08c
2022-05-27 10:47:07 +00:00
Sergiu Deitsch 71717f37c6 Use glog 0.6 release to run Windows Github workflow
Change-Id: I2853ea13c798c6ef05b3a19a2d3986b514caf1ed
2022-05-27 11:43:41 +02:00
Sameer Agarwal 66e0adfa70 Fix detection of sphinx-rtd-theme
Upstreaming fix from Debian.

https: //github.com/ceres-solver/ceres-solver/issues/809
Change-Id: I0e2f90a405a56ceffdda37f70d6e1ac853e176f1
2022-05-23 23:02:40 -07:00
Sameer Agarwal d09f7e9d5e Enable postordering when computing the sparse factorization.
Previously when using a natural ordering, we had postordering
turned off. This is not a good idea. Enabling postordering will
also has the possibility of improving the size of the supernodes.

Change-Id: I8c270e54751b8bed53b38a0b461f647f5c8f5640
2022-05-21 14:23:36 -07:00
Sameer Agarwal 9b34ecef1c Unbreak the build on MacOS
Change-Id: I9144a84842baf1921b8d5808983d8d4e7cde747a
2022-05-19 14:21:15 -07:00
Sameer Agarwal 8ba8fbb173 Remove Solver::Options::use_postordering
This was an ill-advised and complicated to interpret option
which offers nothing particularly useful.

Change-Id: Ia7741ed62ef977c96fa52299a884e404bee659ac
2022-05-19 21:10:33 +00:00
Sameer Agarwal 30b4d5df35 Fix the ceres.bzl to add missing cc files.
Thanks to nate-thirdwave@ for pointing this out and offering
a fix.

Also add a TODO about an odd loop in covariance_impl.cc which was
revealed as I was testing the bazel build

https: //github.com/ceres-solver/ceres-solver/issues/800
Change-Id: I87d17155ee43ea2a52b8031177d6b3ac5ae1460a
2022-05-19 14:07:15 -07:00
Sameer Agarwal 39ec5e8f99 Add Nested Dissection based fill reducing ordering
With this change, the user can now choose between Approximate Minimum
Degree and Nested Dissection as a fill reducing algorithm when using
a sparse direct factorization based linear solver like SPARSE_NORMAL_CHOLESKY
or SPARSE_SCHUR.

Currenly only SUITE_SPARSE is supported. It requires that
SuiteSparse be compiled with Metis support enabled.

On most problems AMD is still the better choice, but in some cases
like the grid3D dataset from https://lucacarlone.mit.edu/datasets/
the solution time with AMD is 57s and with NESDIS 38 on my M1 Mac.

On some other problems at Google we have observed speedups of 10x,
there is also a corresponding decrease in the total amount of memory
used.

This patch is based on the original work done by NeroBurner in
https://ceres-solver-review.googlesource.com/c/ceres-solver/+/20580

1. Add a new enum to the public api LinearSolverOrderingType and
   a setting Solver::Options::linear_solver_ordering_type.
2. TrustRegionPreprocessor had some complicated logic which determined
   when linear solvers should reorder their matrices on their own and not
   this has been refactored into a more readable function that lives
   inside reorder_program.h/cc.
3. Plumbing in reorder_program.cc and trust_region_processor.cc to use
   nested dissection.
4. Update bundle_adjuster.cc to use nested dissection.

Change-Id: I388b027934f86c58b4da2b65a4fa5204ea73bf40
2022-05-19 12:36:20 -07:00
Sameer Agarwal aa62dd86a8 Fix a build breakage
Change-Id: I57591bc42d53f9856b49f7a16732a2a1e259dc67
2022-05-19 11:20:38 -07:00
Sameer Agarwal 41c5fb1e80 Refactor suitesparse.h/cc
1. Generalize SuiteSparse::AnalyzeCholesky and
   SuiteSparse::BlockAnalyzeCholesky from just doing AMD to taking
   OrderingType as an argument and using that to determine whether
   AMD & Nested Dissection algorithms are used for computing the
   fill-reducing ordering or a natural ordering when computing
   the symbolic factorization.

2. Remove AnalyzeCholeskyWithNaturalOrdering.

3. Replace and generalize SuiteSparse::BlockAMDOrdering with
   SuiteSparse::BlockOrdering which also takes OrderingType as an
   argument. Same for SuiteSparse::ApproximateMinimumDegreeOrdering
   and SuiteSparse::NestedDissectionOrdering by
   SuiteSparse::Ordering.

4. Remove LinearSolver::Options::use_postordering and replace it
   with LinearSolver::Options::ordering_type.

5. Replace Preconditioner::Options::use_postordering and replace it
   with Preconditioner::Options::ordering_type.

6. Add NESDIS to OrderingType. With the above changes, the linear
   solvers can now use Nested Dissection once this information
   is piped through the nonlinear solver.

Change-Id: Ib8e93fbf34ae2981bf2ac54dcda9e25c7c213790
2022-05-19 11:05:46 -07:00
Sameer Agarwal 12263e2830 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
2022-05-16 12:48:43 -07:00
Sameer Agarwal c8493fc366 Convert internal enums to be class enums.
Change-Id: Ide89c7115c3b12c0f2452a2969dc5523b3a7970f
2022-05-16 12:47:15 -07:00
Sameer Agarwal bb3a40c091 Add Nested Dissection ordering method to SuiteSparse
Change-Id: I5e00977839d9d5ce914bda0978d81e97e28fc673
2022-05-14 15:08:10 -07:00
Evan Levine f1414cb5bd Correct spelling in comments and docs.
Change-Id: Iad9a0599d644d3b3cd54244edaf64d408cb1308e
2022-04-24 21:40:13 -07:00
Evan Levine fd2b0ceed2 Correct spelling (contiguous, BANS)
Change-Id: I9d3363c3d6e251fbdcf41d6d9635543c7295c3a2
2022-04-24 14:27:22 -07:00
Sergiu Deitsch 464abc1983 Run Linux Github workflow on Ubuntu 22.04
Change-Id: I8a404c23d9f38bf9bd538edef933258814a91a67
2022-04-23 13:28:39 +02:00
Sameer Agarwal caf614a6c1 Modernize code using c++17 constructs
Mostly done using

find . \( -name '*.cc' -o -name '*.h' \) -a -type f -exec clang-tidy -p \
cmake-build -checks='-*,google-*,modernize-*,-modernize-use-nodiscard,-modernize-use-trailing-return-type' {} -fix \;

Change-Id: Ifccbcabe7a1d9a32a09d28ac4f3f8466696c1a50
2022-04-22 06:11:18 -07:00
Sameer Agarwal be618133e7 Simplify some template metaprograms using fold expressions.
Change-Id: I865b670b99df30db39d33cbfe45170b70472e532
2022-04-15 06:03:09 -07:00
Sameer Agarwal 3b0096c1bb Add the ability to specify the pivot threshold in Covariance::Options
https: //github.com/ceres-solver/ceres-solver/issues/777
Change-Id: I481612b7bc727d5cd0dc21a0e0dbaf356722ba22
2022-04-12 18:55:35 -07:00
Sergiu Deitsch 40c1a7e18e Fix Github workflows
* Ubuntu 18.04 GCC does not fully support C++17, hence remove the
  runner.
* Using CMake SuiteSparse in a C++17 project requires a workaround
  implemented in a recent release.

Change-Id: I9985fe12d582dfc9b74e97d670828334e507e9f5
2022-04-01 21:19:54 +02:00
Sameer Agarwal 1274743609 Ceres Solver now requires C++17
Fixes https://github.com/ceres-solver/ceres-solver/issues/779

Change-Id: I6671b8da9d2004f9c76be8b03f6753c9fc5a0061
2022-03-31 11:14:17 -07:00
Sameer Agarwal b5f1b78777 clang-format cleanup
Change-Id: Icebce956d35135e46df657c6038a47fa9ed165df
2022-03-31 08:57:31 -07:00
Sameer Agarwal 32cd1115c0 Make the code in small_blas_generic.h more compiler friendly.
Instead of having four separate scalars, allocate them as
an array as they are all touched as a group of four.

Change-Id: I773cfc08cf53b66032985c11a4b0ebc06db06083
2022-03-31 08:36:04 -07:00
Sameer Agarwal f68321e7de Update version history
Change-Id: I8a1ad5051f7654dfdead0a225fa9263c02643914
2.1.0
2022-03-28 07:02:35 -07:00
Sergiu Deitsch b34280207b Fix MSVC small_blas_test failures
The tests fail only in C++17 mode (and above) with optimizations enabled.

Fixes #782

Change-Id: Ia3b7221efdd9091d252a7323613b7e54794470ee
2022-03-27 17:31:02 +00:00
Sameer Agarwal b246991b6f Update the citation instructions in the docs
1. Update the cff file to be more inclusive.
2. Update the BibTeX entry in index.rst to match the one generated
   by GitHub.

Change-Id: I26d031b2128d1d4330623bcdace284ca9ffce9e1
2022-03-27 10:19:41 -07:00
Sergiu Deitsch c0c14abca2 Fix version history item numbering
The last item in the 'New Features' section restarts the enumeration
because the indention of the previous subitem is one space short.

Change-Id: Ifa2873d3e2ddd6bac5034b48207775019ef1c462
2022-03-26 23:33:26 +01:00
Sergiu Deitsch d23dbac25b Update Windows install guide
Change-Id: I445354bee0f54b33921ea9411b7bb320af275d43
2022-03-25 19:19:45 +01:00
Sergiu Deitsch e669c9fc7a Provide citation file
This makes citations accessible directly on Github and allows users to
automatically generate citations in APA and BibTeX format.

Change-Id: Ic5eb3857c92d93a6afafba06a5009da5db2b3c60
2022-03-25 00:01:01 +01:00
Sameer Agarwal ff57c2e91e Update version history for 2.1.0rc2
Change-Id: If107c2cc356ff402d743d8393c2a1f49a0720c28
2.1.0rc2
2022-03-21 09:34:42 -07:00
Sergiu Deitsch ab9436cb9e Workaround MSVC STL deficiency in C++17 mode
Compiling jet_test using the /std:c++17 switch triggers a C3198 compile
error in <numeric>. Moving #pragma below all the includes, allows to
workaround the issue.

Additionally, locally ensure the floating-point model is always
/fp:precise to be able to access the floating-point environment in
jet_test.

Change-Id: Ia5b3a3dac13baf46546ac1d0d304fc05512f8816
2022-03-20 14:35:02 +00:00
Sameer Agarwal 97c232857d Update the included gtest to version 1.11.0
Change-Id: Icd79eaebce95d2836587aaa5273674bcf2899bc5
2022-03-20 14:34:12 +00:00