Commit Graph

1958 Commits

Author SHA1 Message Date
Joydeep Biswas fc826c5780 CUDA Cleanup
* All Cuda* objects now take in a ContextImpl* during
  construction, and save the context instead of individual
  handles.
* Since we no longer use the legacy default stream, we need to
  explicitly synchronize the stream before performing GPU->CPU
  transfers, and CudaBuffer is responsible for such synchronization
  when asked to perform GPU to CPU transfers.
* Remove all manual syncs and relegate syncing to CudaBuffer
  before performing GPU to CPU transfers.

Change-Id: Ic73cb24174a1e09842827323280e90241716cc20
2022-09-19 10:02:53 -05:00
Sameer Agarwal 660af905fb Fix a bug in TrustRegionMinimizer.
The value of x_norm_ was computed and then incorrectly set to -1.
This meant that ParameterToleranceReached was using the incorrect
value till such time as the minimizer made its first successful
step.

This change removes the member variable and just computes
the norm of x inside ParameterToleranceReached.

Fixes https://github.com/ceres-solver/ceres-solver/issues/885

Thanks to Anton Adanasyev for reporting this.

Change-Id: Ib4d52a45c2d925557ce2c5b57de8a9fa37da6c70
2022-09-19 07:53:27 -07:00
Sameer Agarwal 4cd257cf4a Let NumericDiffFirstOrderFunction take a dynamically sized parameter vector
Also fix a template naming lint along the way.

Change-Id: Iabb98aeec2ff9609a19c3778b9ea2da37771c985
2022-09-16 10:16:35 -07:00
Joydeep Biswas 6c27ac6d50 Fix repeated SpMV Benchmark
Change-Id: I9180cb548a865665f74e1b082c11741a1b87b5ab
2022-09-14 08:37:49 -05:00
Sameer Agarwal 430a292aca Add a missing include
Change-Id: I3c7e43e053366f3d3c38484b65025285d771f330
2022-09-12 17:17:17 -07:00
Sameer Agarwal 858b4b89b5 More ClangTidy fixes
Change-Id: Ib0c450531b362b528aa02b07461fdca97d6055b4
2022-09-12 17:12:22 -07:00
Sameer Agarwal e9e9957401 ClangTidy fixes
Change-Id: Ifc6adb4d6e78668d25d2f06043e0f0d766acdc05
2022-09-12 16:20:30 -07:00
Sameer Agarwal 7f8e930a02 Fix lint errors
Change-Id: I368075a235b4404bb80cd5a7a91f0dad2d202137
2022-09-12 12:17:07 -07:00
Sameer Agarwal f86a3bdbea Unify Block handling across matrix types
Previously some matrices used Block to keep track of
row/column block sizes and some would just use ints, and
then compute the position of each row and column from it.

By uniformly using Block everywhere, we reduce duplicate
computation and data copies.

I also cleaned up a bunch of c++17 related stuff as I edited
these files.

Change-Id: I4c86b1593fd4c91f9057fbb38314f62f303e0477
2022-09-11 07:31:28 -07:00
Sameer Agarwal 5f19468794 clang-formated source
Change-Id: Ia15a55ae053e38d19e1fe7bbc6e452f5d0d1d3ed
2022-09-01 17:01:58 -07:00
Joydeep Biswas 00a05cf70f CUDA SDK Version-based SpMV Selection
* The algorithm enum value for SpMV is now selected based on the
  version of the CUDA runtime that Ceres is compiled against.

Change-Id: I2e0e39f1cbdb8ac26d2a9d45f4ebfc09b96d872b
2022-08-30 10:13:32 -05:00
Sameer Agarwal de0f74e40a Optimize the BlockCRSJacobiPreconditioner
Instead of iterating row-wise, use the row block structure
to update the preconditioner one row block at a time.

While benchmarking, I also found an opportunity to speed up
BlockSparseJacobiPreconditiner.

Before
-----------------------------------------------------------------------------------------
Benchmark                                               Time             CPU   Iterations
-----------------------------------------------------------------------------------------
BM_BlockSparseJacobiPreconditioner              132122392 ns    132103000 ns            5
BM_BlockCRSJacobiPreconditionerBA                73365217 ns     73335800 ns           10
BM_BlockSparseJacobiPreconditionerUnstructured   92407762 ns     92407714 ns            7
BM_BlockCRSJacobiPreconditionerUnstructured      72256367 ns     72256400 ns           10

After

-----------------------------------------------------------------------------------------
Benchmark                                               Time             CPU   Iterations
-----------------------------------------------------------------------------------------
BM_BlockSparseJacobiPreconditionerBA             39723456 ns     39722222 ns           18
BM_BlockCRSJacobiPreconditionerBA                46561625 ns     46561667 ns           15
BM_BlockSparseJacobiPreconditionerUnstructured   52676208 ns     52676167 ns           12
BM_BlockCRSJacobiPreconditionerUnstructured      54430564 ns     54421462 ns           13

Change-Id: I6da8e044b26f0c24481deee5722322a606e9e5ca
2022-08-28 17:24:28 -07:00
Sameer Agarwal ba65ddd311 Improvements to benchmarks
1. Add CreateFakeBundleAdjustmentJacobian to create
   bundle adjustment structured jacobians.
2. sparse_linear_operator_benchmark -> spmv_benchmark
3. Refactor spmv_benchmark to use CreateFakeBundleAdjustmentJacobian.
4. Add BA and unstructured Jacobian variants of spmv benchmarks
5. Add BA and unstructured Jacobian benchmarks for the block Jacobi
   preconditioner.
6. Fix BlockSparseMatrix::ToCompressedRowSparseMatrix to add the
   row and column block structure to the output.

Change-Id: I737a3d7d82dad665b1f2e7886c2c3aedd702ffcd
2022-08-28 07:20:53 +03:00
Joydeep Biswas 42352e2e2a Added CUDA Jacobi Preconditioner
* Added CudaCpuPreconditionerWrapper, a templated wrapper to leverage
  existing CPU preconditioners that provide CompressedRowSparse
  representation, for use with CudaCgnrSolver.
* Added CudaJacobiPreconditioner as a specific instantiation of
  CudaCpuPreconditionerWrapper over BlockCRSJacobiPreconditioner.

The resulting Jacobi-preconditioned CudaCgnrSolver exhibits moderate
increase in speed with a healthy increase in numerical stability.
Examples of running CudaCgnrSolver with Jacobi vs. Identity
preconditioner for bundle adjustment on problem-13682-4456117-pre.txt
on a desktop computer with an Intel(R) Core(TM) i9-9940X CPU @ 3.30GHz
and an Nvidia Quadro RTX 6000 GPU.

A known issue is that the Jacobi preconditioner update is slow - this
can be sped up in the future by multithreading on the CPU, or by
computing the preconditioner on the GPU.

====================================================================
CUDA CGNR + IDENTITY Preconditioner
====================================================================
iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  1.126372e+09    0.00e+00    3.02e+15   0.00e+00   0.00e+00  1.00e+04        0    9.17e+00    2.70e+01
   1  3.796903e+07    1.09e+09    1.08e+15   6.48e+03   9.95e-01  3.00e+04       49    1.55e+01    4.24e+01
   2  3.529024e+21   -3.53e+21    1.08e+15   1.93e+04  -2.25e+14  1.50e+04      500    3.79e+01    8.03e+01
   3  7.952482e+09   -7.91e+09    1.08e+15   1.63e+04  -5.16e+02  3.75e+03      386    2.96e+01    1.10e+02
   4  8.842366e+08   -8.46e+08    1.08e+15   1.18e+04  -5.87e+01  4.69e+02      312    2.47e+01    1.35e+02
   5  2.935800e+07    8.61e+06    1.24e+13   3.93e+03   8.19e-01  6.32e+02      129    1.96e+01    1.54e+02
   6  2.529342e+07    4.06e+06    3.22e+12   3.39e+03   9.93e-01  1.90e+03      148    2.16e+01    1.76e+02
   7  2.343028e+07    1.86e+06    1.27e+13   6.00e+03   9.37e-01  5.68e+03      387    3.79e+01    2.14e+02
   8  2.332405e+07    1.06e+05    7.92e+12   6.47e+01   8.26e-01  7.87e+03       46    1.48e+01    2.28e+02
   9  3.591512e+14   -3.59e+14    7.92e+12   5.19e+03  -4.09e+08  3.94e+03      500    3.83e+01    2.67e+02
  10  2.956078e+07   -6.24e+06    7.92e+12   3.94e+03  -8.34e+00  9.84e+02      447    3.40e+01    3.01e+02

Solver Summary (v 2.2.0-eigen-(3.3.7)-lapack-suitesparse-(5.7.1)-metis-(5.1.0)-eigensparse-no_openmp-cuda-(11070))

                                     Original                  Reduced
Parameter blocks                      4469799                  4469799
Parameters                           13491489                 13491489
Residual blocks                      28987644                 28987644
Residuals                            57975288                 57975288

Minimizer                        TRUST_REGION
Trust region strategy     LEVENBERG_MARQUARDT
Sparse linear algebra library     CUDA_SPARSE

                                        Given                     Used
Linear solver                            CGNR                     CGNR
Preconditioner                       IDENTITY                 IDENTITY
Threads                                    24                       24
Linear solver ordering          4456117,13682            4456117,13682

Cost:
Initial                          1.126372e+09
Final                            2.332405e+07
Change                           1.103048e+09

Minimizer iterations                       11
Successful steps                            6
Unsuccessful steps                          5

Time (in seconds):
Preprocessor                        17.798455

  Residual only evaluation           8.656350 (10)
  Jacobian & residual evaluation    35.794169 (6)
  Linear solver                    208.586109 (10)
Minimizer                          283.593882

Postprocessor                        1.985112
Total                              303.377449

====================================================================
CUDA CGNR + JACOBI Preconditioner
====================================================================
iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  1.126372e+09    0.00e+00    3.02e+15   0.00e+00   0.00e+00  1.00e+04        0    9.18e+00    2.68e+01
   1  1.491225e+14   -1.49e+14    3.02e+15   8.73e+05  -1.36e+05  5.00e+03        6    1.07e+01    3.74e+01
   2  7.461790e+12   -7.46e+12    3.02e+15   4.78e+05  -6.78e+03  1.25e+03        6    8.88e+00    4.63e+01
   3  4.357438e+07    1.08e+09    5.41e+13   1.57e+05   9.87e-01  3.75e+03        6    1.62e+01    6.25e+01
   4  2.928453e+07    1.43e+07    6.85e+13   3.81e+05   6.97e-01  3.99e+03       23    1.82e+01    8.08e+01
   5  5.977433e+14   -5.98e+14    6.85e+13   4.97e+05  -8.70e+07  2.00e+03        9    9.93e+00    9.07e+01
   6  6.423965e+10   -6.42e+10    6.85e+13   2.45e+05  -9.61e+03  4.99e+02        7    8.95e+00    9.97e+01
   7  2.337471e+07    5.91e+06    1.49e+12   8.24e+04   9.31e-01  1.39e+03        4    1.60e+01    1.16e+02
   8  2.257524e+07    7.99e+05    8.71e+12   1.62e+05   8.99e-01  2.81e+03       54    2.03e+01    1.36e+02
   9  2.285090e+07   -2.76e+05    8.71e+12   3.56e+05  -6.13e-01  1.41e+03      104    1.65e+01    1.52e+02
  10  5.909983e+12   -5.91e+12    8.71e+12   1.78e+05  -1.83e+07  3.52e+02       74    1.36e+01    1.66e+02

Solver Summary (v 2.2.0-eigen-(3.3.7)-lapack-suitesparse-(5.7.1)-metis-(5.1.0)-eigensparse-no_openmp-cuda-(11070))

                                     Original                  Reduced
Parameter blocks                      4469799                  4469799
Parameters                           13491489                 13491489
Residual blocks                      28987644                 28987644
Residuals                            57975288                 57975288

Minimizer                        TRUST_REGION
Trust region strategy     LEVENBERG_MARQUARDT
Sparse linear algebra library     CUDA_SPARSE

                                        Given                     Used
Linear solver                            CGNR                     CGNR
Preconditioner                         JACOBI                   JACOBI
Threads                                    24                       24
Linear solver ordering          4456117,13682            4456117,13682

Cost:
Initial                          1.126372e+09
Final                            2.257524e+07
Change                           1.103796e+09

Minimizer iterations                       11
Successful steps                            5
Unsuccessful steps                          6

Time (in seconds):
Preprocessor                        17.575990

  Residual only evaluation           8.461414 (10)
  Jacobian & residual evaluation    30.055383 (5)
  Linear solver                     82.550675 (10)
Minimizer                          149.137856

Postprocessor                        1.994014
Total                              168.707860

Change-Id: I458d2445bf062e54de44fc91517ed11a300c7182
2022-08-26 08:57:07 -05:00
Sameer Agarwal f802a09ff1 &foo[0] -> foo.data()
Use the more modern form of accessing the data array of a vector
rather than grabbing the pointer to the first element. The latter
can lead to errors if the vector is of zero length.

Change-Id: Ifc8fc969b06b3ba1a9385e8a3a8d5c50b25db5a8
2022-08-25 10:00:12 +05:30
Joydeep Biswas 344929647a Add CUDA GPU and Runtime Detection
* Added GPU device and CUDA compute capability identification.
* Added GpuMemoryAvailable() to aid downstream optimizations based
  on GPU memory availability.

Change-Id: I326dc1e4b7a6a7f5571b7e5479eb9aa300ad1075
2022-08-18 17:07:32 -05:00
Sameer Agarwal 6085e45be7 Minor CUDA cleanup.
1. ceres_cuda_kernels.cu -> cuda_kernels.cu.cc
2. Add missing ifdef guards.
3. Fix an errant namespace

Change-Id: I81a5bfbe3c795ff0b3ef41c3bcaa037b99d5b254
2022-08-17 16:27:13 -07:00
Sameer Agarwal e15ec89f3b Speed up bundle_adjuster
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
2022-08-17 12:47:02 -07:00
Sameer Agarwal 058a72782a One more ClangTidy fix.
Change-Id: Ic350c3ec1c8cf6a5e893b37713e93433640af184
2022-08-16 15:53:32 -07:00
Sameer Agarwal f6f2f0d161 ClangTidy cleanups
Also some clang-format cleanups.

Change-Id: Ifb728f12ec130a5af33db789086f8a9baa078678
2022-08-16 15:46:43 -07:00
Sameer Agarwal 9d74c69130 Fix some more errant CATD warnings
Change-Id: I3adc9076dfcfcb5660d0413a897cf565bea27f95
2022-08-16 15:10:54 -07:00
Sameer Agarwal a4f7440951 Remove an unused variable from compressed_row_sparse_matrix.cc
Change-Id: I7786417f99d87382beca7b3d65ef61b7cb5ea3d9
2022-08-16 15:06:17 -07:00
Sergiu Deitsch 388c142866 Fix GCC 12.1.1 LTO -Walloc-size-larger-than= warnings
With -flto=auto, GCC emits multiple warnings in release builds such as

In function ‘make_unique’,
    inlined from ‘Create’ at ceres-solver/internal/ceres/scratch_evaluate_preparer.cc:43:75,
    inlined from ‘CreateEvaluatePreparers’ at ceres-solver/internal/ceres/compressed_row_jacobian_writer.h:95:66,
    inlined from ‘__ct ’ at ceres-solver/internal/ceres/program_evaluator.h:120:9,
    inlined from ‘Evaluate.constprop.isra’ at ceres-solver/internal/ceres/problem_impl.cc:695:65:
/usr/include/c++/12.1.1/bits/unique_ptr.h:1080:30: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
 1080 |     { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); }
      |                              ^

because a signed integer is used to specify the size of allocated arrays
instead of the expected unsigned (specifically, std::size_t) without
checking for negative values at the call site.

Change-Id: I923b1d074241535426bfea041568ef1dc7f3ec86
2022-08-16 21:23:12 +00:00
Sameer Agarwal 9ec4f7e44a Refactor BlockJacobiPreconditioner
1. Rename BlockJacobiPreconditionet to BlockSparseJacobiPreconditioner.
2. Add CompressedRowSparseJacobiPreconditioner which is a
   block Jacobi preconditioner for CompressedRowSparseMatrix objects.
3. Re-write the tests to be more comprehensive.

Change-Id: Icbc91f9ad2cefaad593c11397f8cdcf805d7e118
2022-08-16 13:47:16 -07:00
Joydeep Biswas adda97acd7 Fixed a few more missing CERES_NO_CUDA guards
Change-Id: I65c1851085f816794079ef56de0426fcdd055c87
2022-08-16 05:17:40 +00:00
Sameer Agarwal 22aeb35843 Fix a missing string assignment in solver.cc
Change-Id: I3dfc28603c6af10f361ca4877f518a5f28edfdbd
2022-08-15 22:16:43 -07:00
Joydeep Biswas 3b891f7672 Insert missing CUDA guards.
Change-Id: If97c51557376385e3958863072cfcf76dd810d15
2022-08-15 23:55:33 -05:00
Joydeep Biswas 829089053e CUDA CGNR, Part 4: CudaCgnrSolver
* 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
2022-08-15 23:44:34 -05:00
Sameer Agarwal 6ab435d774 Fix a missing CERES_NO_CUDA guard
Also run format_all.sh.

Change-Id: I13902c1d3eb0d3a97548540fee13ec67c490a5ff
2022-08-14 16:58:09 -07:00
Joydeep Biswas c560bc2be5 CUDA CGNR, Part 3: CudaSparseMatrix
* Added CudaSparseMatrix to manage and operate on sparse matrices with
  cuSparse.
* Added tests for CudaSparseMatrix.
* Added a new sparse linear operator benchmark.

Change-Id: Id09df46de3b40be1f14441528088b54dab5844af
2022-08-14 18:48:55 -05:00
Joydeep Biswas c914c7a2b3 CUDA CGNR, Part 2: CudaVector
* Added CudaVector to manage and operate on vectors with CUDA.
* Added tests for CudaVector

Change-Id: I528258c8e883011e8709bddf59edb1e933af8060
2022-08-14 12:25:45 -05:00
Joydeep Biswas 3af3dee189 Simplify the implementation to convert from BlockSparseMatrix to
CompressedRowSparseMatrix.

Since the conversion from BlockSparseMatrix to CompressedRowSparseMatrix
is not used in any performance-critical context, this CL simplifies it
by re-using existing conversions.

Change-Id: I51263bc95cc056efb31961ccda548cd7be35b2a4
2022-08-14 10:42:19 -05:00
Sergiu Deitsch 242fc07959 Remove unnecessary destructors
Change-Id: I1d1cc9b15606955ee1d99d2f81585f118bc92aef
2022-08-13 20:34:52 +00:00
Sergiu Deitsch 737200ac8d Add macos-12 to Github workflow runners
Change-Id: I7fc01ff5fe8b8a9d4e93e7536ca80a6aa37a870d
2022-08-13 22:28:33 +02:00
Sergiu Deitsch 9c968d4066 Silence Clang warning
Clang emits the following warning:

internal/ceres/schur_complement_solver.cc:71:51: warning: class with destructor marked 'final' cannot be inherited from [-Wfinal-dtor-non-final-class]
  virtual ~BlockRandomAccessSparseMatrixAdapter() final {}

Change-Id: I9da96711fd1e924ce8504988ff171cb476b6222f
2022-08-13 21:32:11 +02:00
Sameer Agarwal 2c78c5f339 Small naming fixups.
use_power_series_expansion_initialization -> use_spse_initialization
max_linear_solve_iterations -> max_linear_solver_iterations

Change-Id: I7775fa9b1ad12e28c8d01d44349b7eaef9b57edd
2022-08-13 11:59:16 -07:00
Mark Shachkov 2a25d86b01 Integrate schur power series expansion options to bundle adjuster
Change-Id: I64c0b135adeece273a7924d0a7200369eb166b0a
2022-08-13 21:34:02 +03:00
Sergiu Deitsch 4642e4b0c1 Use if constexpr and map SparseMatrix as const
Change-Id: Id72d77ef91d2bfc1055ab67b604f26ebc0d65769
2022-08-13 20:20:53 +02:00
Mark Shachkov 92d8379532 Enable usage of schur power series expansion preconditioner.
Add an option to use schur power series expansion for initialization
of pcg solution in ITERATIVE_SCHUR linear solver.

Change-Id: Ifb8bce02bc5f5ceebc74f961eefd3f6dd2ffab4a
2022-08-13 21:05:11 +03:00
Sergiu Deitsch f1dfac8cd6 Reduce the number of individual PRNG instances
Use same instance of a PRNG throughout by passing it to methods and
functions as an argument to generate random numbers without breaking the
sequence.

Change-Id: Ib024bbc1ea2d14e4b9afb71857856a5fb77b1667
2022-08-13 17:14:06 +00:00
Sergiu Deitsch 79e403b15c Expand vcpkg installation instructions
Change-Id: Iad83869b1411b126beb26cfbbf5f6e9f717ff591
2022-08-13 19:04:17 +02:00
Sameer Agarwal 7b0bb0e3f5 ClangTidy cleanups
Change-Id: I514ca5fd91c08866b412021e6c0f5d6f97c4bf8f
2022-08-12 21:49:02 -07:00
Sameer Agarwal c5c2afcc91 Fix solver_test.cc for preconditioners and sparse linear algebra libraries
Change-Id: Ia391680f872ab49101f672f676cdd68fe332d1d4
2022-08-12 21:35:15 -07:00
Sameer Agarwal 07d333fb68 Refactor options checking for linear solvers
The code that verifies that the linear solver is configuration
specified by the user has grown into a rat's nest. This CL
attempts to bring some order to this madness.

Fixes https://github.com/ceres-solver/ceres-solver/issues/852

Change-Id: I3f34c0e27da13a6412117dee43ef2d9ec3835b64
2022-08-12 21:14:08 -07:00
Sameer Agarwal ba7207b0ba A number of small changes.
These changes came about from testing the power bundle adjustment
integration CL.

1. Allow Solver::Options::max_linear_solver_iterations == 0.
2. Simplify the logic for when inverse(F'F) is computed.
3. norm_b -> norm_rhs in ConjugateGradientsSolver.

Change-Id: I50c19e1f24a4cc08ed60e3a3032b96b37bcada9f
2022-08-12 06:52:37 -07:00
Mark Shachkov 20e85bbe34 Add power series expansion preconditioner
Implementation of "Power Bundle Adjustment for Large-Scale 3D
Reconstruction" by Weber et. al. added in the form of preconditioner.

Change-Id: Ie85526a5fc46f74256f6dfe9173c3571f7160f3a
2022-08-11 19:34:41 +03:00
Sameer Agarwal 04899645cc LinearOperator::FooMultiply -> LinearOperator::FooMultiplyAndAccumulate
These methods were historically poorly named and every time I read code
I get confused whether they are just multiplying or multiplying and
adding. Clarifying them also gives us the changce to introduce
RightMultiply and LeftMultiply methods in the base class which will
simplify a number call sites in a subsequent CL.

Fixes https://github.com/ceres-solver/ceres-solver/issues/855

Change-Id: Ice4fb483f1acd02527a6dd753ef0c5a66037f4b0
2022-08-10 10:03:03 -07:00
Sameer Agarwal 288a3fde6b Add missing virtual destructors to matrix adapters
Change-Id: Ieb0e67fbc9042410a6ae63e7cf0f96cc90603829
2022-08-09 22:16:38 -07:00
Sameer Agarwal 6483a2b4c2 Add Sergiu's name to the list of maintainers
Change-Id: I2e8c6af08bf6b718ab81e84a77df6f72592a954b
2022-08-09 15:23:30 -07:00
Sameer Agarwal 1cf49d6884 Update FindGlog.cmake to create glog::glog target
This change to FindGlog.cmake was originally suggested by
@KrisThielemans

Change-Id: I9277e0c7ba730bffd938371859fd574a82248253
2022-08-09 14:00:04 +00:00