Commit Graph

1814 Commits

Author SHA1 Message Date
Sergiu Deitsch 817f5a0688 Switch to imported SuiteSparse, CXSparse, and METIS targets
These changes allow the use of a SuiteSparse CMake package from
https://github.com/sergiud/SuiteSparse that allows native compilation of
SuiteSparse using CMake on a variety of platforms Packages generated
using official SuiteSparse makefiles can still be used without
modifications. The find module remains agnostic to specific CMake
package implementation.

CMake packages have the advantage that they are self-contained and
relocatable. The latter is particularly useful in cross-compilation
scenarios.

Fixes #728

Change-Id: I089d5c6f87c05b1530a5ab9a36dff2fcbe82d13d
2022-03-03 21:26:45 +01:00
Sergiu Deitsch b0f32a20d7 Hide remaining internal symbols
Change-Id: Ibd2f8c5e7a730503479cb4f17db2de8727f94d2c
2022-03-03 18:45:01 +01:00
Sameer Agarwal 5723950987 Add a missing include
Change-Id: Ide00da72d493c6ce38f4ba6542f7c673d7091bfd
2022-03-03 09:37:52 -08:00
Sergiu Deitsch b0aef211db Allow to store pointers in ProductManifold
Change-Id: I32df7afab3a195efb0407b0d8f35dcd2d7cb95d2
2022-03-03 17:08:24 +00:00
Joydeep Biswas 9afe8cc45e Small compile fix to context_impl
* Add missing header include for <string>, affects CUDA builds.
* Fix typo

Change-Id: I82ca6eb180b85a7b85966c36d6ec59ce78726a96
2022-03-03 10:32:18 -06:00
Sergiu Deitsch 284be88ca1 Allow ProductManifold default construction
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
2022-03-03 14:50:03 +01:00
Joydeep Biswas f59059fffb Bugfix to CUDA workspace handling
* Fix workspace type in CUDADenseQR and CUDADenseCholesky --
  Workspace sizes are in terms of number of elements, not bytes.
* Add cuda-memcheck tests to catch such CUDA memory errors in
  the future.

Change-Id: I3dd0f0947daba9e4c6cd0216bef81d694547d505
2022-03-03 12:50:56 +00:00
Sergiu Deitsch 779634164d Fix MSVC linker error
Apparently, MSVC does not like whenever a fully templated class is
exported.

Change-Id: Ie920720d645941925b4ee04d9ae2b92e6c061f2b
2022-03-03 13:39:38 +01:00
Sergiu Deitsch 7743d2e73c Store ProductManifold instances in a tuple
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
2022-03-02 23:57:10 +00:00
Alex Stewart 9f32c42ba6 Update Travis-CI status badge to .com from .org
Change-Id: I77091d541d81463b33731fc9b1a2971ce2e8a1f8
2022-03-02 19:25:46 +00:00
Sameer Agarwal eadfead69d Move LineManifold and SphereManifold into their own headers.
Previously they were defined in manifold.h but their implementations
were in the internal directory and to prevent circular dependencies
the implementation headers were pushed to the bottom of manifold.h

This started out as one header and has become progressively worse
as more manifolds are templated.

This change moves the two manifolds into their own headers which
also contain their implementations.

Change-Id: I671da0279a47cd2ff1f52c69a1d159426f55bd80
2022-03-02 06:51:37 -08:00
Sergiu Deitsch f0f8f93bbc Fix docs inconsistencies
Change-Id: Ie3f767d537206ed4c326c7a504825cc751817c61
2022-03-02 14:05:39 +01:00
Sameer Agarwal e40391efa3 Update version history in preparation for 2.1.0
Change-Id: I3771d5d289bbb9982eeec2ae3701246dd25eaac1
2022-03-01 09:35:20 -08:00
Sameer Agarwal 6a37fbf9b4 Add static/compile time sizing to EuclideanManifold
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
2022-03-01 09:34:23 -08:00
Sameer Agarwal 4ad787ce19 Fix the bazel build
Change-Id: I38c684b816b5e377aa873cf35d13b1181aa152db
2022-02-27 07:50:56 -08:00
Sameer Agarwal ae4d95df6e Two small clang-tidy fixes
Change-Id: I1eb3b5aabc9586958d618c680ca1a2c6ed501fd4
2022-02-27 05:41:07 -08:00
Sergiu Deitsch f0851667be Fix MSVC compilation errors
Disable the definition of `min`/`max` macros by defining `NOMINMAX`
and prevent macro substitution in the public interface.

Also, quiet floating-point comparisons are defined as template functions
by the MSVC STL which causes compilation errors due to ambiguities in
resolving the template parameter types.

Fixes #668
Fixes #716
Fixes #718

Change-Id: I5fe7832a6a3a7ad0421a2557527528c34b88e9c7
2022-02-27 13:24:42 +01:00
Sergiu Deitsch c8658c8992 Modernize more
Apply clang-tidy Google and modernize fixes without trailing return type
using:

$ clang-tidy -p <build-dir> \
  -checks='-*,google-*,modernize-*,-modernize-use-trailing-return-type' {} -fix

Change-Id: I7450cc58ea9abf928f73a467e87876083217fa26
2022-02-26 22:16:56 +00:00
Sergiu Deitsch 46b3495a4f Standardize path handling using GNUInstallDirs
Fixes #649

Change-Id: Iefb3e7be69a04474db0fc768b47f4f3636c8a587
2022-02-25 23:59:34 +00:00
Alex Stewart 98bc3ca17a Fix shared library build due to missing compile features specification
Change-Id: Ib4c7f0b18b8770ab8cb09b15b9cc17f90042ceb0
2022-02-25 19:07:21 +00:00
Sameer Agarwal 8fe8ebc3a6 Add final specifier to public classes
Change-Id: Ib7291dc68d5d4141ee821689743481fc84768606
2022-02-18 15:51:17 -08:00
Sameer Agarwal 84e1696f4e Add final specifier to internal classes.
This should help the compiler devirtualize a bunch of function
calls.

https://github.com/ceres-solver/ceres-solver/issues/747

Change-Id: I9913e68d85e0e9c9f955a249cc710a657875c869
2022-02-18 18:07:06 +00:00
Sameer Agarwal 518970f81e Context should be exported
Change-Id: I451a7f471a6b93d1d32dc003adaa3c5c315fef9f
2022-02-18 09:54:40 -08:00
Sergiu Deitsch 09ec4997fa Cleanup examples
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
2022-02-18 00:53:44 +01:00
William Rucklidge 90e58e10fd Add missing #include.
Change-Id: If32d858c9d9eec9f53753007e0831e56f25d32d4
2022-02-17 11:40:45 -05:00
Sameer Agarwal 15348abe90 Add CUDA based bundle adjustment tests.
Also refactor the logic for generating ba tests a bit
breaking it into dense, sparse and iterative tests.

Change-Id: I6b33e3b047ef900b12907bd150febe4744779b7a
2022-02-15 12:36:18 -08:00
Sergiu Deitsch 57ec9dc92e Do not enforce a specific C++ standard
Current language standard selection mechanism is quite convoluted and
the logic for propagating a specific C++ language standard (which cannot
be fully enforced anyway) is unnecessarily complicated. Instead
communicate the minimum required C++ standard and let CMake handle the
requirement. This allows the compiler and consumers to use newer
language revisions if available. The language standard used to compile
Ceres solver can still be set via `CMAKE_CXX_STANDARD`.

Move to CMake 3.10 which is supported by Ubuntu 18.04 LTS and simplify
the corresponding language features request.

Change-Id: Ib1f95e2bc5f06bf1275a62565d303eb0f114d127
2022-02-15 21:14:29 +01:00
Sergiu Deitsch 99698f0535 Fix Apple Clang weak symbols warnings
Change-Id: I71eba56ca37060c83d05ff14d6f9bfaef61e9493
2022-02-15 21:00:22 +01:00
Joydeep Biswas 8e08421628 Add support for dense CUDA solvers #3
1. Add CUDA initialization and cleanup management to the
   ContextImpl object. The ContextImpl is now solely responsible
   for managing CUDA-related resources.
2. All CUDA dense solvers now use lazy CUDA initialization
   via the ContextImpl object.

Change-Id: Ief456860c72e462367ee997d389c19e2bff50baf
2022-02-15 13:26:12 -06:00
Sameer Agarwal aff51c907d Revert "Do not enforce a specific C++ standard"
This reverts commit d839b77928.

Reason for revert: Breaks the BUILD on macOS

Change-Id: I49f448ed4942cc88df9e4ad3b78d56f6be04351d
2022-02-15 19:17:02 +00:00
Sergiu Deitsch 527c3f7da0 Fixed gflags dependency
Both test_util and gtest depend directly on gflags.

Change-Id: Ia3699f4710cb86710ffd547149ffa08e678f6df9
2022-02-15 19:44:05 +01:00
Sergiu Deitsch d839b77928 Do not enforce a specific C++ standard
Current language standard selection mechanism is quite convoluted and
the logic for propagating a specific C++ language standard (which cannot
be fully enforced anyway) is unnecessarily complicated. Instead
communicate the minimum required C++ standard and let CMake handle the
requirement. This allows the compiler and consumers to use newer
language revisions if available. The language standard used to compile
Ceres solver can still be set via `CMAKE_CXX_STANDARD`.

Move to CMake 3.10 which is supported by Ubuntu 18.04 LTS and simplify
the corresponding language features request.

Change-Id: Id3526c69990315289e7ea0fbcdeaa6af79d24d03
2022-02-15 19:10:51 +01:00
Sergiu Deitsch f71167c628 Fixed missing include in minilog build
Change-Id: Ib4ff0595a6a496848922d9cb8462b2cd4cb83e99
2022-02-15 17:17:05 +00:00
Sameer Agarwal 47502b8339 Miscellaneous CUDA related changes.
1. Fix a stupid error in types.cc
2. Update documentation for Solver::Options::dense_linear_algebra_library_type
3. Add a note to installation.rst to update the installation docs.
4. Mention GPU acceleration in features.rst

Change-Id: Id63202ff090e23bbb211d2ee458559fb8046281d
2022-02-14 21:45:34 -08:00
Sameer Agarwal bb29966810 Check CUDA is available in solver.cc
Add logic for checking for availability of CUDA as the
dense linear algebra library before allowing the user
to use it.

Change-Id: I0ceafa1052632504b33685bc731366ef6933e518
2022-02-14 13:47:47 -08:00
Joydeep Biswas 7d2e4152ec Add support for dense CUDA solvers #2
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
2022-02-14 15:22:39 -06:00
Sergiu Deitsch f90833f5fa Simplify symbol export
Currently, the logic for exporting symbols is rather complicated: when
tests are enabled internal symbols are exported in addition to the
public symbols. Such logic causes several problems. (1) Test binaries
link against a Ceres build that is different from the final release
since fewer optimizations are applied if more symbols are exported. (2)
Also, some toolchains hide symbols by default breaking the existing
logic eventually causing linker errors.

Since internal symbols are not intended to be used outside of the
project, we can compile them into object files and use exactly the same
binary code both for the final build and the tests without relying on
conditionals.

By default, all symbols are now hidden unless annotated as public.
Internal symbols are explicitly marked as not being exported in case
users chose not to hide symbols by default.

Change-Id: I589dd10be2f6f438508783cf99d141af0120057b
2022-02-14 20:19:08 +01:00
Sergiu Deitsch c6158e0ab5 Replace NULL by nullptr
Change-Id: I200a40678091b984a01635d8637a487b7ad5cc13
2022-02-14 19:22:21 +01:00
Sameer Agarwal 7e4f5a51ba Remove blas.h/cc as they are not used anymore.
Change-Id: I120631c8fc66ddee5829b89bb5b98dc2ac80ff1f
2022-02-14 09:36:16 -08:00
John Harrison e0fef6ef05 Add cmake option ENABLE_BITCODE for iOS builds
Change-Id: Ib56c711c626044754c1c3a397d7c4648c4ec089d
2022-02-13 15:54:24 +00:00
Sameer Agarwal 446487c54c Add <memory> header to all files using std::unique_ptr.
Fixes https://github.com/ceres-solver/ceres-solver/issues/758

Change-Id: I884819ec62cf7dcb95368eb46f3c03a46bb5243f
2022-02-12 08:12:05 -08:00
Sameer Agarwal 9c5f29d46d Use compiler attributes instead of [[deprecated]]
This change is needed because compiler attributes and c++
annotations like [[deprecated]] do not mix well and we need that
for our public API.

https://github.com/ceres-solver/ceres-solver/issues/749

Change-Id: I79eda795f2912f9af9ab36ee24b8428b47104743
2022-02-11 09:29:21 -08:00
Sameer Agarwal 44039af2cb Convert factory functions to return std::unique_ptrs.
https://github.com/ceres-solver/ceres-solver/issues/755

Change-Id: I8ff028ca6082a5f448f3891214af03971d565937
2022-02-10 16:16:37 -08:00
Sergiu Deitsch 708a2a7233 Silence LocalParameterization deprecation warnings
Suppress warnings in all Ceres targets without leaking suppressions into
user code (fixes #750).

Change-Id: I3aa1063cb0aae547865a15311ac286ef6d81a955
2022-02-10 20:55:25 +00:00
Sergiu Deitsch de69e657a6 Fix another missing declaration warning
Change-Id: I895e16f3e43792bd7f92560709f9ebf6374c4777
2022-02-10 20:53:19 +01:00
Sergiu Deitsch 677711138a Fix segmentation fault in AVX2 builds
Enabling the AVX2 instruction set causes a segmentation fault in mocked
manifold tests. This is due to Eigen vectors stored in a std::shared_ptr
for which the memory allocated by gmock is not aligned even though it is
expected to be by Eigen for correct use of packet math.

The problem does not occur if Ceres is compiled with C++17 (or later)
enabled due to the support for aligned new allocations.

Change-Id: I711abe9439cc411bd7a8b4936f3b93af07b7fbd6
2022-02-10 16:21:55 +01:00
Sameer Agarwal 0141ca090c Deprecate LocalParameterizations
Add [[deprecate]] notices to everything LocalParameterization
related.

Make sure that Ceres can be compiled without triggering
deprecation warnings.

Update the documentation:

a. Add deprecation notices.
b. Document interaction between LocalParameterization and Manifold
   coexisting in the Problem.
c. Add documentation for Manifold(s)

Change-Id: Ie4ad48963c83fded86e533c8c60561af402fbaff
2022-02-10 06:36:47 -08:00
Sergiu Deitsch fdfa5184a5 Fix missing declaration warning
Change-Id: I690b81af11bb98930d0a0d1c8d5d4d6d75f61bd3
2022-02-10 15:29:40 +01:00
Johannes Beck 4742bf3862 Add LineManifold.
This MR ports the LineParameterization of manifolds. The unit test are
rewritten to use the manifold test facilities.

The LineManifold is extended so that it can also handle dynamic size
ambient space dimensions.

Change-Id: I1fe3cd34b56f74b72ca028c34f5368e9df9fe4d7
2022-02-10 08:52:01 +01:00
Sergiu Deitsch c14f360e63 Drop trivial special members
Do not define trivial constructors or destructors unless necessary
(e.g., for implementing pimpl) following the rule of zero. Define
virtual base class destructors out-of-line to avoid emitting vtables in
every translation unit.

Change-Id: Iea2d8978e62a8ee5a97b86cbb4e858d56e0fb274
2022-02-09 21:30:14 +01:00