1. Add abseil-cpp as a submodule. We are tracking the latest LTS
release, which is lts_2024_01_16.
2. Replace glog/gflags with absl::log and absl::flags.
3. Remove miniglog
4. Also take a whack at making the bazel build work with
abseil-cpp and gtest.
There are a number of TODOs in this CL that still need to be resolved.
Change-Id: I39355ed7d61375be4ebcbc8596d9cc70acc1c678
cuDSS could be used as an alternative for SuiteSparse and EigenSparse
in case if CUDA capable GPU is available.
Change-Id: I7a567093ce91363478118153e181134ed5804573
If arguments are passed to a cost function that can be used to construct
the functor, the latter will be instantiated by the cost function using
std::make_unique to ensure exception safety. This not only avoids static
analysis warnings caused by calling new but also spelling the cost
functor type name multiple times.
Also expand deduction guides for instantiating
Dynamic(Auto|Numeric)DiffCostFunction from std::unique_ptr enabled
constructor overloads.
Finally, make CostFunction default move constructible and assignable but
only through derived classes. This in turn allows derived classes to be
movable without relying on custom implementations of corresponding
operators.
Change-Id: Idee8b9871d862bc9f9f8b5a8d0bedc52863e93c0
Previously, MSVC warning C4996 was suppressed unconditionally in the
entire code base which made it difficult identifying and fixing specific
problems, particularly those in the public interface.
Prefer now to disable warnings at the specific location they occur. This
approach, however, reveals an inconsistency in how Ceres handles POSIX
functions which are declared deprecated by MSVC. Specifically, Bessel
functions use the underscore form whereas the read function does not. To
simplify the logic, we revert to POSIX compatible functions.
C++23 also deprecates std::numeric_limits<T>::has_denorm which MSVC
warns about. Here, we disable the deprecation warning locally to avoid
the warning leaking into the user code.
Fixes#1013
Change-Id: Ida8457cc8dd8770b4384a7c49d16f213b02cdec4
iteration_callback_example.cc uses the curve_fitting.cc example
and uses a custom IterationCallback to log the values of the
parameter blocks are they change over the course of the optimization.
Change-Id: I6a478a8418e237aff576ca627d9b5c0b751b8088
Remove "using ceres:foo" directives from example code. The using
directives actually make the code harder to read unless you already
know the ceres API. By making the namespace explicit it is clear
to the reader that these are functions and objects from the Ceres
API.
Change-Id: I89b1281c754bf71c0f82e39e1607c5e40a148388
1. Add a version history
2. Update copyright years across the code base
3. Run format_all.sh
4. Update version strings from 2.1.0 to 2.2.0 in the docs and
elsewhere.
Change-Id: I46d8d479d54bd6002d532785e67342106e73c9ac
1. Use hardware_concurrency to configure number of threads.
2. Use user ordering instead of automatic ordering.
Fixes https://github.com/ceres-solver/ceres-solver/issues/874
Change-Id: I4d7d69612e1ee40358943019a0c3a909e419c4e4
* Added CudaCgnrSolver, a new CUDA-accelerated CGNR.
* To use CudaCgnrSolver, the user must select CGNR as the linear_solver
and CUDA_SPARSE as the sparse_linear_algebra_library.
* Updated ConjugateGradientSolver to work with an array of pointers to
scratch to support CudaVectors as scratch.
* Moved CUDA initialization to run in Solver::Solve as needed.
Some performance comparisons on an Ubuntu 20.04 desktop with an
Intel i9-9940X CPU @ 3.30GHz, and an nVidia Quadro RTX 6000,
all configurations run with 24 threads, and 10 iterations.
=================================================
CGNR + CUDA_SPARSE + IDENTITY Preconditioner
problem-1778-993923-pre.txt
=================================================
Cost:
Initial 2.563973e+08
Final 1.724755e+06
Change 2.546725e+08
Minimizer iterations 11
Successful steps 7
Unsuccessful steps 4
Time (in seconds):
Preprocessor 4.020158
Residual only evaluation 1.567092 (10)
Jacobian & residual evaluation 7.847130 (7)
Linear solver 31.688898 (10)
Minimizer 46.834987
Postprocessor 0.353974
Total 51.209120
=================================================
SPARSE_SCHUR (CPU) + SUITE_SPARSE + AMD
problem-1778-993923-pre.txt
=================================================
Cost:
Initial 2.563973e+08
Final 1.651617e+06
Change 2.547457e+08
Minimizer iterations 11
Successful steps 11
Unsuccessful steps 0
Time (in seconds):
Preprocessor 35.812003
Residual only evaluation 1.658980 (10)
Jacobian & residual evaluation 12.218799 (11)
Linear solver 76.409992 (10)
Minimizer 98.809773
Postprocessor 0.372712
Total 134.994489
=================================================
ITERATIVE_SCHUR (CPU) + JACOBI Preconditioner
problem-1778-993923-pre.txt
=================================================
Cost:
Initial 2.563973e+08
Final 1.684447e+06
Change 2.547128e+08
Minimizer iterations 11
Successful steps 8
Unsuccessful steps 3
Time (in seconds):
Preprocessor 15.331614
Residual only evaluation 1.606114 (10)
Jacobian & residual evaluation 8.502166 (8)
Linear solver 351.910080 (10)
Minimizer 368.797327
Postprocessor 0.363536
Total 384.492478
=================================================
CGNR + CUDA_SPARSE + IDENTITY Preconditioner
problem-13682-4456117-pre.txt
=================================================
Cost:
Initial 1.126372e+09
Final 2.269329e+07
Change 1.103678e+09
Minimizer iterations 11
Successful steps 7
Unsuccessful steps 4
Time (in seconds):
Preprocessor 19.140087
Residual only evaluation 8.721920 (10)
Jacobian & residual evaluation 41.955923 (7)
Linear solver 214.121861 (10)
Minimizer 296.636890
Postprocessor 1.971827
Total 317.748804
Change-Id: I3a09f31aa6903f661e91f595afd39d427583e856
1. Remove an unused variable from block_sparse_matrix.cc
2. Add explicit types to the distributions to get around
-Wctad-maybe-unsupported
Change-Id: Ib7d606fbfe2b93ba4fce408f38ee4f7626b74ff0
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
In many cases, manifolds stored in ProductManifold have a default
constructor which can simplify ProductManifold initialization even
further. Allow default construction of ProductManifold in this case.
Change-Id: I29b2612870c02232556688019a77049709684a55
Since the number of manifolds used to initialize ProductManifold and
their types are known at compile-time, it is possible to avoid storing
pointers to the base class as required by a homogeneous, currently
dynamically sized container. Instead, we can use std::tuple<> as a
heterogenous container with the number of elements fixed at compile-time
that allows us to store the concrete manifold realizations.
The advantage of this approach is that we can bypass the vtable when
iterating over each manifold within ProductManifold. The indirection is
invoked only once while accessing the ProductManifoldImpl members.
Additionally, potential dynamic memory allocations by a std::vector can
be completely avoided. This makes the ProductManifold implementation
more efficient both in memory and runtime.
Change-Id: Ic71b0c175ab726f8992e9703f7666bca477baf19
This brings it in line with other manifolds like SphereManifold
and LineManifold, where the user has the choice to specify the size
of the manifold at compile time or runtime.
Most of the time the size is known at compile time so this will
speed up the common case.
Change-Id: I0c7ff8b7a9a64a81203eb11afc074874e208815a
Remove logic invoked based on obsolete variable definitions. Use new
(explicit) target_link_libraries syntax to link binaries against
dependencies. Do not rely on prior knowledge about the compiler for
specifying flags and system libraries but instead directly test their
presence to be more robust.
Change-Id: I76e0d10fae6eba4b343048e4404f0a9b08c7cb6c
1. Add CUDADenseQR & tests.
CUDADenseQR uses the cuSolverDN LAPACK implementation
of QR factorization. A key limitation, however, is that
this solver does not perform singularity checking --
this is because cuSolverDN does not have a trtrs
implementation; we instead use cuBLAS' trsv for
backsubstitution.
2. All CPU -> GPU memory transfers are now async, and both
CUDADenseQR and CUDADenseCholesky explicitly manage their
own streams for async operations.
3. Simplified CUDADenseCholesky to only use the legacy 32-bit
cuSolverDN API.
Change-Id: I2a9b7b65469658ddfe33b5b2a3892c8744d6e437
1. Add CUDADenseCholesky64Bit, CUDADenseCholesky32Bit, & tests.
CUDADenseCholesky32Bit uses the legacy versions of potrf/potrs
in cuSolverDN, while CUDADenseCholesky64Bit uses the new 64-bit
versions available since Cuda 11.1. The legacy versions are
provided since some platforms such as the Nvidia Jetsons only
support Cuda 10.2.
2. Expose CUDA as a new option under DenseLinearAlgebraLibraryType.
The relevant option to string and string to option helper functions
are modified accordingly.
3. Add cuda as a dense_linear_algebra_library option in bundle_adjuster
to demonstrate the use of the new CUDA option.
Change-Id: I23615e1d301df5185ed646b3e33ee802508dae86
1. Add EigenDenseQR & tests.
This implementation now uses an in place decomposition,
which means that we are not allocating, deallocating
memory every call.
2. Add LAPACKDenseQR and tests.
The LAPACK implementation instead of using dgels which is a
routine which does the factorization and solve in one
call, now uses dgeqrf for factorization and then
dormqr and dtrtrs for solving. This allows us to
have a factorize and solve interface like DenseCholesky.
And opens the door to iterative refinement and mixed
precision solves.
3. The refactor also allows us to simplify the interface to
DenseSparseMatrix considerably. The internals of this
class were complicated because we had the AppendDiagonal
and RemoveDiagonal methods and we did not want to allocate
deallocate memory every call. But since we pay the cost
of the copy anyways, we can just hold that buffer
in DenseQRSolver.
4. Delete lapack.cc/h
5. The net result is that everything seems to be a bit faster.
For LAPACK we are not doing some of the scaling work that
dgels was doing. For Eigen I think it maybe the inplace
decomposition.
Benchmark Time CPU Time Old Time New CPU Old CPU New
----------------------------------------------------------------------------------------------------------------------------------------------------------
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/1/1 -0.1154 -0.1159 692 612 691 611
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/2/1 -0.1601 -0.1553 717 603 712 601
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/3/1 -0.1673 -0.1575 733 610 724 610
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/6/2 -0.1008 -0.1003 886 797 884 796
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/10/3 -0.1489 -0.1514 1283 1092 1281 1087
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/12/4 -0.1040 -0.1104 1556 1394 1553 1381
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/20/5 -0.0007 -0.0097 1911 1910 1908 1890
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/40/5 -0.1033 -0.1022 2981 2673 2957 2655
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/100/10 -0.0147 +0.0015 9275 9138 9026 9040
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/200/10 -0.1408 -0.1284 15093 12968 14778 12880
BM_DenseSolver<ceres::EIGEN, ceres::DENSE_QR>/200/20 -0.0310 -0.0355 38973 37765 38837 37460
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/1/1 -0.1228 -0.1256 736 646 731 640
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/2/1 -0.1401 -0.1396 740 636 735 633
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/3/1 -0.1731 -0.1695 744 615 738 613
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/6/2 -0.1399 -0.1408 1121 965 1113 956
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/10/3 -0.1110 -0.1145 1571 1397 1560 1382
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/12/4 -0.1411 -0.1417 2006 1722 1993 1710
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/20/5 -0.1740 -0.1729 2741 2264 2724 2253
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/40/5 -0.0966 -0.1123 3462 3128 3425 3040
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/100/10 -0.0387 -0.0998 10365 9964 10339 9307
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/200/10 -0.2044 -0.2049 16031 12754 15998 12720
BM_DenseSolver<ceres::LAPACK, ceres::DENSE_QR>/200/20 -0.2391 -0.2386 35777 27223 35716 27193
Change-Id: I782f0d7664efe1435eebda92ddf47a0fe66c9c72
This has been a long requested feature so that users can minimize
functions using numeric differentiation.
As part of this, I have also redone rosenbrock.cc, which now has three
variants.
rosenbrock.cc now uses automatic differentiation.
rosenbrock_numeric_diff.cc uses numeric differentiation.
rosenbrock_analytic_diff.cc uses analytic derivatives.
This is analogus to how the helloworld example code is structured.
The tutorial for GradientProblemSolver has also been updated to reflect
this.
https://github.com/ceres-solver/ceres-solver/issues/691
Change-Id: Ib0fb9e35127fe4c8299d4793bea3558722c70dd7