Commit Graph

1364 Commits

Author SHA1 Message Date
Sameer Agarwal 88f2cb32cd ClangTidy fixes
Change-Id: I1f4d6975fd1b9629d1db0d529d9ee92d79c11e84
2024-09-15 20:12:27 -07:00
Sameer Agarwal c59882eca0 ClangTidy fixes
Change-Id: I421b29e218c045c5d8bef42c840fa366d7c011fc
2024-09-15 22:29:56 +00:00
Sameer Agarwal 8f1b6123ad GradientProblem & related classes use std::unique_ptr
Previously these classes in analogy with ceres::Problem's interface
had interfaces to allow bare pointers as well as unique_ptrs. This
CL changes the API to always use unique_ptr, this is less error prone
and makes the default ownership semantics clearer.

Change-Id: I7577a90761f341c7e009c248c820f0fec2e6f32d
2024-09-15 21:57:23 +00:00
Sameer Agarwal ecae3de151 Fix a declaration order problem in sparse_cholesky_test.cc
Change-Id: Ie74069e8716145c244955bf907e2bae79f48972f
2024-08-26 16:57:17 +00:00
Sameer Agarwal 8964e52b01 ClangTidy fixes
Change-Id: Id7358fcdccae69b46b479d55ed6aee80efd3431e
2024-08-26 09:18:17 -07:00
Sameer Agarwal 80fce72bfd Add mixed precision solves for SUITE_SPARSE
Starting with SuiteSparse version 7.4.0 CHOLMOD has support for single
precision matrices. This allows us to have single precision and mixed
precision solves when using the SUITE_SPARSE backend.

This CL also fixes sparse_cholesky_test which was completely broken for
single precision testing.

Sample performance on my Mac.
/usr/bin/time -l ./bin/bundle_adjuster --input=../../Downloads/problem-3068-310854-pre.txt
<SNIP>

Cost:
Initial                          9.099334e+07
Final                            4.161838e+06
Change                           8.683150e+07

Minimizer iterations                        6
Successful steps                            4
Unsuccessful steps                          2

Time (in seconds):
Preprocessor                         2.528222

  Residual only evaluation           0.142804 (5)
  Jacobian & residual evaluation     0.424014 (4)
  Linear solver                     54.083396 (5)
Minimizer                           54.895752

Postprocessor                        0.024564
Total                               57.448539

Termination:                   NO_CONVERGENCE (Maximum number of iterations reached. Number of iterations: 5.)

       59.04 real       341.24 user         5.49 sys
          5776375808  maximum resident set size
<SNIP>
        616329634071  instructions retired
        929475980510  cycles elapsed
          5375034560  peak memory footprint

/usr/bin/time -l ./bin/bundle_adjuster --input=../../Downloads/problem-3068-310854-pre.txt  -mixed_precision_solves
<SNIP>

Cost:
Initial                          9.099334e+07
Final                            4.148930e+06
Change                           8.684441e+07

Minimizer iterations                        6
Successful steps                            4
Unsuccessful steps                          2

Time (in seconds):
Preprocessor                         2.580217

  Residual only evaluation           0.144098 (5)
  Jacobian & residual evaluation     0.396723 (4)
  Linear solver                     23.636074 (5)
Minimizer                           24.427163

Postprocessor                        0.023790
Total                               27.031170

Termination:                   NO_CONVERGENCE (Maximum number of iterations reached. Number of iterations: 5.)

       28.58 real       128.53 user         2.37 sys
          4818386944  maximum resident set size
<SNIP>
        395186936091  instructions retired
        368802808856  cycles elapsed
          4327029824  peak memory footprint

Change-Id: I1f137b0dd12da8da7f9ced338dd8f20f4bbdf99d
2024-08-24 21:12:54 -07:00
Sameer Agarwal 9186dcc49c Add the ability to use system installed versions of abseil and googletest
If the user has checked out the submodules in third_party, they will be
used, otherwise we will try and find the system installed versions of
these dependencies and use them if they are modern enough.

Change-Id: I52164bc48a6ea804b85cdda05fee9cb94632f6c0
2024-08-14 21:16:57 -07:00
Sameer Agarwal 6726cd5073 Fix absl::log_flags linking on Linux
Generator expressions were introduced in CMake version 3.24. Without
them including absl::log_flags as an internal dependency causes
linking problems on some platforms. So for platforms with an older
CMake version we make absl::log_flags a public dependency.

Change-Id: I686f41e76b0ac17a03f1cd1d614372a7f130dfd9
2024-08-12 07:06:34 -07:00
Sameer Agarwal 4aa57d8096 Replace string_view with string.
The use of string_view causes problems with absl::StrCat
in certain compilation configurations.

Change-Id: I1beda82692378bf9cf378a7d42df46de8491d1c9
2024-08-09 17:02:53 -07:00
Sameer Agarwal f45b98709d More ClangTidy Fixes
Change-Id: I286a9b6402812707e64f71952eeb79b755ec43d9
2024-08-09 16:35:09 -07:00
Sameer Agarwal a3afe3d724 ClangTidy fixes
Change-Id: I2ed57cd6f84bae81686a833834bf00ddef91f61b
2024-08-09 16:24:07 -07:00
Sameer Agarwal 0bd9e63dcc Add absl/log/vlog_is_on.h when using VLOG_IS_ON
Previously this header was included in absl/log/log.h
but going forward this header will not be included.

Change-Id: Ie663b221d90e32a852fb00dfe20f731dcd1dcf6b
2024-08-09 16:15:22 -07:00
Sameer Agarwal b97ffeadbb Use absl::time
Replace WallTimeInSeconds with absl::Now and use
absl::Time and absl::Duration objects instead of doubles.

wall_time.h/cc -> event_logger.h/cc

Change-Id: I41279961368840fbdf6bb3456ffdbdf2f9bfb85b
2024-08-08 07:18:44 -07:00
Sameer Agarwal 03caeed1c6 ceres/stringprintf -> absl::strings
Replace ceres::String* with their more modern and performant
absl strings library equivalent and delete our string
manipulation library.

Change-Id: Iecbdba9864e0abf329778f81fdc0708f78f7594f
2024-08-08 07:05:23 -07:00
Sameer Agarwal 0ecdb82616 Link to absl::log_flags
This enables control of logging using commandline flags.

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

Change-Id: Ia0fd6abf4a8e6dfa8bc4e71d2263d622a28b0268
2024-08-08 06:59:39 -07:00
Sameer Agarwal ebb66e655f ceres::internal::FixedArray -> absl::FixedArray
Ceres Solver was using an old forked version of FixedArray,
now that we are using absl, we can use the official version
that ships with it.

Change-Id: Ic88d7f6e8a49b928d611f7cbb04172452b322b01
2024-07-23 13:45:45 -07:00
Sameer Agarwal c181b6dbc4 ClangTidy fixes part 3
Change-Id: I69587f663b8d91a465ed068a82f9e09e3b7a72e2
2024-07-22 07:25:14 -07:00
Sameer Agarwal 3c4f012606 ClangTidy fixes #2
Change-Id: Ib3baa62248342276d63b900b45561323fd81402d
2024-07-21 20:31:32 -07:00
Sameer Agarwal 0ca2db57c7 Fix a number of typos
Change-Id: I0038f9c91dc70c422c01305dc10fca5a22a2f0d0
2024-07-21 15:15:36 -07:00
Sameer Agarwal 6b9a690009 ClangTidy cleanup part 1
Change-Id: Id592fc68b8f184cd002df9d94a68d05fbbf9c24d
2024-07-21 14:55:46 -07:00
Sameer Agarwal 68eeba2c2c Add a missing include
Change-Id: I3060e80a69374f7a2db31121715d0d892a54d311
2024-07-21 13:25:45 -07:00
Sameer Agarwal 1e19a11f5f Add a missing include
Change-Id: I0a3fa842183bc7cb9ba00b17d6181cebc3eac50d
2024-07-21 08:24:31 -07:00
Sameer Agarwal de4ea5b4c7 Add a missing override
Change-Id: I6f610d187551fb3dca57912681e0e37eea26723f
2024-07-21 08:20:19 -07:00
Sameer Agarwal 7566ebae08 Various cleanups
Change-Id: Ie453e199a128a102bf3d5524a466f549aac0c7ce
2024-07-21 08:14:08 -07:00
Sameer Agarwal 968079f9fa Remove ASSERT macros from non-void functions
Change-Id: I891e00671e7a3ddaecf006cacb93b48379b8d9c8
2024-07-18 14:04:24 -07:00
Sameer Agarwal 6016a69bd5 Remove a header added by mistake
Change-Id: I5138804540978d6dfd2206d10a32b9d20a756d3d
2024-07-18 11:45:16 -07:00
Sameer Agarwal 57e26182f3 Add more missing headers
Change-Id: I35875ca856b7b80c622562a1c14b4c8ced10f740
2024-07-18 11:37:07 -07:00
Sameer Agarwal ea4d8c63ef Fix an incorrect include
Change-Id: I5b19dc5d4203a0603f21f1db06f4edb7fe2b76c2
2024-07-18 11:08:39 -07:00
Sameer Agarwal 14e8118a36 Add a missing header to context_impl.cc
Change-Id: I7b6c564ac67926e91543a96bfd6362471de775c8
2024-07-18 10:22:18 -07:00
Sameer Agarwal 0a53aa9054 Take abseil as a dependency
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
2024-07-18 00:24:49 -07:00
Mark Shachkov 6fb3dae4ee Add cuDSS as sparse Cholesky solver
cuDSS could be used as an alternative for SuiteSparse and EigenSparse
in case if CUDA capable GPU is available.

Change-Id: I7a567093ce91363478118153e181134ed5804573
2024-07-09 20:23:18 +02:00
Sergiu Deitsch e47a42c295 Fix MSVC builds and test runs
Change-Id: I79f839b22985a6510965559af54209d89c8703a0
2024-07-08 23:48:13 +02:00
Sameer Agarwal 6f2c319e0f Unbreak levenberg_marquardt_strategy_test
Add a missing quotation mark.

Change-Id: I9d7d3c3d6bd5ac616e0dc23f75845178294c45a6
2024-07-07 10:12:52 -07:00
Sameer Agarwal 894fd6903c Update the googletest version
We now use googletest as a git submodule instead
of the old way of converting it into a single header
and including it in the source.

This removes the dependence on googleflags for tests
to be enabled.

Change-Id: If25ea3ba7a39c2b8ba9c6effbed3e7173361b6b1
2024-07-07 09:15:27 -07:00
Sameer Agarwal 6a74af202d Remove a level of indirection when using CellInfo
The CellInfo struct contains a mutex, which interacts poorly
with some standard library containers which may move things around.
As a result we were using std::unique_ptr<CellInfo> in these
containers, but this change gets rid of that level of indirection
as std::unordered_map can construct CellInfo in place and we can
replace the use of std::vector with an array we know will not be
resized.

This improves the performance of the schur eliminator a bit but
also the performance of the block diagonal preconditioners.

Change-Id: If3ccd1273a754d9c5112e6e611ce31066b6b27b5
2024-05-30 15:53:02 -07:00
Sergiu Deitsch 20954e693f Eliminate CUDA set but unused variable warning
This avoids warnings such as

    D:\a\ceres-solver\ceres-solver\internal\ceres\cuda_kernels_bsm_to_crs.cu.cc(143): warning #550-D: variable "row_nnz_e" was set but never used [D:\a\ceres-solver\ceres-solver\build_Release\internal\ceres\ceres_cuda_kernels.vcxproj]
          int row_nnz_e = 0;
              ^
                detected during instantiation of "void ceres::internal::RowBlockIdAndNNZ(int, int, int, const int *, const ceres::internal::Cell *, const ceres::internal::Block *, const ceres::internal::Block *, int *, int *, int *) [with partitioned=false]" at line 240

      Remark: The warnings can be suppressed with "-diag-suppress <warning-number>"

that is caused by compile-time conditional use of the variable.

Change-Id: I041b076a5208eeb662b8c7500d7b238965be833c
2024-05-21 23:15:31 +02:00
Sergiu Deitsch 308a5bb434 Add missing include
std::copy_n is defined in <algorithm>, which is not explicitly included
and therefore causes compilation errors with the recent GCC 14.1 and/or
CUDA 12.4.1.

Change-Id: I9fcab48770ccfc5ec195dca5a190ceaad9debe81
2024-05-21 23:01:01 +02:00
Sameer Agarwal f71181a92d Remove remaining references to CXSparse
Also remove examples/Makefile.example as it is hopelessly
out of date.

Change-Id: I2ed2f0c4768eacbf65cf76299c7a8b3474eb750b
2024-05-21 12:20:49 -07:00
Mark Shachkov 522210a08d Reuse macro to format version string
Change-Id: Ib21f2d8f06b6594dae410681d16a738b8b75c89a
2024-05-07 01:47:41 +02:00
Johannes Schönberger cd2dd06e9a Fix clang16 compiler warnings
Fixes the following two warnings:

preconditioner.h:64:11: warning: field 'f_block_size' will be initialized after field 'elimination_groups' [-Wreorder-ctor]
block_sparse_matrix.cc:70:19: warning: unused parameter 'values' [-Wunused-parameter]

Change-Id: I5cc55ca387b3f12259096c1531c263279650bd49
2024-04-22 17:22:03 +00:00
Yuriy Chernyshov 1f2e6313a5 Add missing std qualifiers
Change-Id: Ib7bc432c56f7a8ba062a6d74a206733872c3d089
2024-04-22 17:20:54 +00:00
Markus Heß 125c068829 Link static cuda libs when ceres is build static
Change-Id: I8821a2df5302cf164b6f80d6787ae795691d6b32
2024-04-03 11:09:40 +02:00
Sameer Agarwal 62c03d6ff3 Revert "Update Eigen::BDCSVD usage to comply with Eigen 3.4"
This reverts commit 4027f69975.

Reason for revert: This breaks the build because this constructor syntax is only present in the unstable/development version of eigen. So the macro check is incorrect.

Change-Id: I1e664208c7c50041e295aeb7c4b65259f9f2fc8f
2024-02-01 05:00:25 +00:00
Xiaodong Huang 4027f69975 Update Eigen::BDCSVD usage to comply with Eigen 3.4
Change-Id: Ida9360071056cbbc8cf3dff4dd34e6a3119200d4
2024-02-01 08:32:49 +08:00
Sameer Agarwal da34da3da2 Remove CreateFakeBundleAdjustmentPartitionedJacobian
This function is not used and is not written correctly to
deal with the case wherre Schur specialization is disabled.

Change-Id: I48509317e6df5f9cdc37c81e879fad425bb2d037
2024-01-26 11:58:00 -08:00
Sameer Agarwal 85b2c418a6 ClangTidy fixes
Change-Id: I127f50920ee1f1754b94763b5d3cb01a24aa28cb
2024-01-23 09:16:36 -08:00
Sergiu Deitsch 91773746be Simplify instantiation of cost functions and their functors
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
2024-01-23 01:34:27 +01:00
Sergiu Deitsch 8b88a9ab49 Use C++17 Bessel functions
Move Bessel functions availability checks from configuration time to
inclusion time to be more robust and allow the use of ABI compatible
compilers (e.g., Ceres is compiled using Clang but is used in a project
compiled using GCC.)

Since libc++ does not yet implement special math functions, we fallback
to their POSIX implementation if available. However, then only the
deprecated BesselJ{0,1,n} are provided.

Fixes #814

Change-Id: Ic3e62452b36e90cb22644cc8e553e3dd1881193f
2024-01-22 20:42:59 +01:00
Dmitriy Korchemkin 095d483927 Skip structure detection on preprocessor failure
Change-Id: I679ff2045ab0ac5da64e72d87e0c78054369da5c
2023-10-28 18:45:44 +00:00
MaximSmolskiy a0876309a6 Fix typos in comments
Change-Id: I17faeb9b9a4cd40de7651eea3ff011e48910f059
2023-10-22 00:23:58 +03:00