Commit Graph

14 Commits

Author SHA1 Message Date
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
Taylor Braun-Jones 3f6d273676 Unify symbol visibility configuration for all compilers
This makes it possible to build unit tests with shared libraries on MSVC.

Change-Id: I1db66a80b2c78c4f3d354e35235244d17bac9809
2020-10-15 16:56:07 -04:00
Darius Rueckert 8e962f37d7 Add Autodiff Codegen Tests
This patch adds end-to-end tests for the autodiff codegen system.
First, code is generated for various functors. This code is then
executed with different arguments and the result is compared
to traditional autodiff.

Change-Id: Icba9996ece26384a795d5b50480ec8194cab572f
2020-02-25 08:57:22 +01:00
Sameer Agarwal 2ffddaccfe Use override & final instead of just using virtual.
This is safer than using virtual and this lead to a minor
bug fixes.

Change-Id: Id69cb1cc569bf6bf245f22f029c7871b6c712568
2019-07-25 16:29:14 -07:00
Sameer Agarwal 865952821f Fix a use after free bug in the tests.
The way the SystemTest fixture works is that it takes
a "FooProblem" object as a type, which contains a ceres::Problem
and a ceres::Solver::Options object.

The Options object also contains a linear_solver_ordering which
contains double* which refer to memory that is allocated when
a problem object is created.

So it is important that the lifetime of the ceres::Problem object
and the ceres::Solver::Options object be tied together. But we were
violating this by creating a FooProblem object on the stack, grabbing
its Options struct and passing it to the SystemTest fixture, which
would then create another instance of FooProblem, grab its Problem
object and copy the modified options struct into it.

In the case where a user provided ordering was being used,
this ordering would now be referring to memory allocated by the first
FooProblem object, which would cause Ceres's internal ApplyOrdering
function to fail.

The fix is ofcourse to Problem and Options object that are born
together.

Change-Id: I07c377a9d5fcabbb6c7ca8aa3460206ce045ffa9
2018-04-20 11:02:48 -07:00
Sameer Agarwal 4556eb9810 Simplify integration tests.
1. Remove SolverConfig, this was a wrapper
   around Solver::Options. As we experiment
   with more Solver::Options, it became a hurdle.

2. Updated generate_bundle_adjustment_tests.py to use
   Solver::Options directly.
3. Update system_test to use Solver::Options.

NOTE: generate_bundle_adjustment_tests.py changes are a bit
gunky, but I tried to minimize the changes in this CL
as I am going to introduce new test cases and that
is going to significantly change this file.

Change-Id: I34a2f51824b04ef368a5bbe54fbd7b281381909e
2018-04-18 17:37:20 -07:00
Sameer Agarwal 3d933750a7 Deprecate Solver::Options::num_linear_solver_threads
1. Solver::Options::num_threads now controls parallelism in Ceres
   Solver. The user specified value of
   Solver::Options::num_linear_solver_threads is ignored.
2. If the user specifies Solver::Options::num_linear_solver_threads
   and it is different from Solver::Options::num_threads,
   a warning is printed.
3. Solver::Summary:num_linear_solver_threads_given and
   Solver::Summary::num_linear_solver_threads_used are also
   deprecated and are always set to Solver::Summary::num_threads_given
   and Solver::Summary::num_threads_used.

Change-Id: I20b9336d9336e400e6f0a15b63857c0c43eb271c
2018-02-27 20:38:05 -08:00
Keir Mierle 8549c88d7c Split bundle adjustment tests into individual binaries
The bundle adjustment test is extremely slow to
run (especially in debug or fastbuild), and since
it is in one binary, there is no way to get CMake
or Bazel to parallelize the test execution.

This change divides the test into a single binary
for each configuration, making parallelized
execution possible.

In this patch, only the Bazel build is updated to
use the new test. The old test still exists to
retain parity with the CMake build. A followup
change will complete the process of adding
equivalent test execution to the CMake build.

Example build output:

% bazel test -c opt :all
INFO: Analysed 123 targets (15 packages loaded).
INFO: Found 2 targets and 121 test targets...
INFO: From Compiling external/com_github_google_glog/src/logging.cc:
external/com_github_google_glog/src/logging.cc: In static member function 'static void google::LogMessage::Fail()':
external/com_github_google_glog/src/logging.cc:1518:1: warning: 'noreturn' function does return
 }
 ^
INFO: Elapsed time: 98.056s, Critical Path: 23.80s
INFO: Build completed successfully, 976 total actions
//:array_utils_test                                                      PASSED in 0.1s
//:autodiff_cost_function_test                                           PASSED in 0.2s
//:autodiff_local_parameterization_test                                  PASSED in 0.2s
//:autodiff_test                                                         PASSED in 0.1s
//:ba_denseschur_auto_test                                               PASSED in 5.3s
//:ba_denseschur_auto_threads_test                                       PASSED in 0.1s
//:ba_denseschur_user_test                                               PASSED in 5.3s
//:ba_denseschur_user_threads_test                                       PASSED in 0.1s
//:ba_iterschur_jacobi_auto_test                                         PASSED in 6.2s
//:ba_iterschur_jacobi_auto_threads_test                                 PASSED in 0.1s
//:ba_iterschur_jacobi_user_test                                         PASSED in 6.0s
//:ba_iterschur_jacobi_user_threads_test                                 PASSED in 0.2s
//:ba_iterschur_schurjacobi_auto_test                                    PASSED in 6.1s
//:ba_iterschur_schurjacobi_auto_threads_test                            PASSED in 0.2s
//:ba_iterschur_schurjacobi_user_test                                    PASSED in 5.7s
//:ba_iterschur_schurjacobi_user_threads_test                            PASSED in 0.1s
//:ba_iterschur_suitesparse_clustjacobi_auto_test                        PASSED in 0.1s
//:ba_iterschur_suitesparse_clustjacobi_auto_threads_test                PASSED in 0.1s
//:ba_iterschur_suitesparse_clustjacobi_user_test                        PASSED in 0.1s
//:ba_iterschur_suitesparse_clustjacobi_user_threads_test                PASSED in 0.1s
//:ba_iterschur_suitesparse_clusttri_auto_test                           PASSED in 0.1s
//:ba_iterschur_suitesparse_clusttri_auto_threads_test                   PASSED in 0.1s
//:ba_iterschur_suitesparse_clusttri_user_test                           PASSED in 0.1s
//:ba_iterschur_suitesparse_clusttri_user_threads_test                   PASSED in 0.1s
//:ba_sparsecholesky_cxsparse_auto_test                                  PASSED in 0.2s
//:ba_sparsecholesky_cxsparse_auto_threads_test                          PASSED in 0.2s
//:ba_sparsecholesky_cxsparse_user_test                                  PASSED in 0.1s
//:ba_sparsecholesky_cxsparse_user_threads_test                          PASSED in 0.1s
//:ba_sparsecholesky_eigensparse_auto_test                               PASSED in 0.1s
//:ba_sparsecholesky_eigensparse_auto_threads_test                       PASSED in 0.1s
//:ba_sparsecholesky_eigensparse_user_test                               PASSED in 0.2s
//:ba_sparsecholesky_eigensparse_user_threads_test                       PASSED in 0.1s
//:ba_sparsecholesky_suitesparse_auto_test                               PASSED in 0.1s
//:ba_sparsecholesky_suitesparse_auto_threads_test                       PASSED in 0.3s
//:ba_sparsecholesky_suitesparse_user_test                               PASSED in 0.1s
//:ba_sparsecholesky_suitesparse_user_threads_test                       PASSED in 0.2s
//:ba_sparseschur_cxsparse_auto_test                                     PASSED in 0.1s
//:ba_sparseschur_cxsparse_auto_threads_test                             PASSED in 0.2s
//:ba_sparseschur_cxsparse_user_test                                     PASSED in 0.1s
//:ba_sparseschur_cxsparse_user_threads_test                             PASSED in 0.2s
//:ba_sparseschur_eigensparse_auto_test                                  PASSED in 0.2s
//:ba_sparseschur_eigensparse_auto_threads_test                          PASSED in 0.2s
//:ba_sparseschur_eigensparse_user_test                                  PASSED in 0.1s
//:ba_sparseschur_eigensparse_user_threads_test                          PASSED in 0.2s
//:ba_sparseschur_suitesparse_auto_test                                  PASSED in 0.3s
//:ba_sparseschur_suitesparse_auto_threads_test                          PASSED in 0.2s
//:ba_sparseschur_suitesparse_user_test                                  PASSED in 0.2s
//:ba_sparseschur_suitesparse_user_threads_test                          PASSED in 0.2s
//:block_jacobi_preconditioner_test                                      PASSED in 0.1s
//:block_random_access_dense_matrix_test                                 PASSED in 0.2s
//:block_random_access_diagonal_matrix_test                              PASSED in 0.4s
//:block_random_access_sparse_matrix_test                                PASSED in 0.2s
//:block_sparse_matrix_test                                              PASSED in 0.2s
//:c_api_test                                                            PASSED in 0.2s
//:canonical_views_clustering_test                                       PASSED in 0.4s
//:compressed_col_sparse_matrix_utils_test                               PASSED in 0.3s
//:compressed_row_sparse_matrix_test                                     PASSED in 0.3s
//:conditioned_cost_function_test                                        PASSED in 0.2s
//:conjugate_gradients_solver_test                                       PASSED in 0.2s
//:corrector_test                                                        PASSED in 0.2s
//:cost_function_to_functor_test                                         PASSED in 0.1s
//:covariance_test                                                       PASSED in 0.1s
//:cubic_interpolation_test                                              PASSED in 0.2s
//:dense_linear_solver_test                                              PASSED in 0.1s
//:dense_sparse_matrix_test                                              PASSED in 0.4s
//:detect_structure_test                                                 PASSED in 0.3s
//:dogleg_strategy_test                                                  PASSED in 0.4s
//:dynamic_autodiff_cost_function_test                                   PASSED in 0.2s
//:dynamic_compressed_row_sparse_matrix_test                             PASSED in 0.2s
//:dynamic_numeric_diff_cost_function_test                               PASSED in 0.1s
//:dynamic_sparse_normal_cholesky_solver_test                            PASSED in 0.4s
//:dynamic_sparsity_test                                                 PASSED in 0.3s
//:evaluator_test                                                        PASSED in 0.2s
//:gradient_checker_test                                                 PASSED in 0.2s
//:gradient_checking_cost_function_test                                  PASSED in 0.2s
//:gradient_problem_solver_test                                          PASSED in 0.2s
//:gradient_problem_test                                                 PASSED in 0.4s
//:graph_algorithms_test                                                 PASSED in 0.4s
//:graph_test                                                            PASSED in 0.2s
//:householder_vector_test                                               PASSED in 0.2s
//:implicit_schur_complement_test                                        PASSED in 0.2s
//:inner_product_computer_test                                           PASSED in 0.3s
//:invert_psd_matrix_test                                                PASSED in 0.1s
//:is_close_test                                                         PASSED in 0.4s
//:iterative_schur_complement_solver_test                                PASSED in 0.3s
//:jet_test                                                              PASSED in 0.3s
//:levenberg_marquardt_strategy_test                                     PASSED in 0.2s
//:line_search_minimizer_test                                            PASSED in 0.2s
//:line_search_preprocessor_test                                         PASSED in 0.1s
//:local_parameterization_test                                           PASSED in 0.1s
//:loss_function_test                                                    PASSED in 0.1s
//:minimizer_test                                                        PASSED in 0.2s
//:normal_prior_test                                                     PASSED in 0.3s
//:numeric_diff_cost_function_test                                       PASSED in 0.2s
//:ordered_groups_test                                                   PASSED in 0.2s
//:parameter_block_ordering_test                                         PASSED in 0.2s
//:parameter_block_test                                                  PASSED in 0.1s
//:partitioned_matrix_view_test                                          PASSED in 0.1s
//:polynomial_test                                                       PASSED in 0.1s
//:problem_test                                                          PASSED in 0.1s
//:program_test                                                          PASSED in 0.2s
//:reorder_program_test                                                  PASSED in 0.2s
//:residual_block_test                                                   PASSED in 0.2s
//:residual_block_utils_test                                             PASSED in 0.2s
//:rotation_test                                                         PASSED in 7.1s
//:schur_complement_solver_test                                          PASSED in 0.2s
//:schur_eliminator_test                                                 PASSED in 0.2s
//:single_linkage_clustering_test                                        PASSED in 0.2s
//:small_blas_test                                                       PASSED in 0.2s
//:solver_test                                                           PASSED in 0.2s
//:sparse_cholesky_test                                                  PASSED in 0.2s
//:sparse_normal_cholesky_solver_test                                    PASSED in 0.2s
//:system_test                                                           PASSED in 0.1s
//:tiny_solver_autodiff_function_test                                    PASSED in 0.2s
//:tiny_solver_cost_function_adapter_test                                PASSED in 0.1s
//:tiny_solver_test                                                      PASSED in 0.1s
//:triplet_sparse_matrix_test                                            PASSED in 0.2s
//:trust_region_minimizer_test                                           PASSED in 0.2s
//:trust_region_preprocessor_test                                        PASSED in 0.2s
//:visibility_based_preconditioner_test                                  PASSED in 0.1s
//:visibility_test                                                       PASSED in 0.2s

Executed 121 out of 121 tests: 121 tests pass.
There were tests whose specified size is too big. Use the --test_verbose_timeout_warnings command line option to see which ones these are.

Change-Id: I32825f1e6278ba69dc296bb2dc05fb8ebda26592
2018-02-20 14:46:10 -08:00
Sameer Agarwal f4b768b69a Lint changes from William Rucklidge
Change-Id: I0dac2549a8fa2bfd12f745a8d8a0db623b7ec1ac
2015-09-14 13:53:24 -07:00
Sameer Agarwal 5f2f05c726 Refactor system_test
1. Move common test infrastructure into test_util.
2. system_test now only contains powells function.
3. Add bundle_adjustment_test.

Instead of a single function which computes everything,
there is now a test for each solver configuration which
uses the reference solution computed by the fixture.

Change-Id: I16a9a9a83a845a7aaf28762bcecf1a8ff5aee805
2015-09-12 15:41:05 -07:00
Keir Mierle 7492b0d8de Update copyright headers with new year and URL
Since Ceres is moving to using GitHub for issues, and the Google
Code URL in the current copyright header will soon become invalid,
update all the headers.

Change-Id: I1fce70375d1bcf098591f07b4d8f01a5c1e0789c
2015-03-18 05:43:23 +00:00
Sameer Agarwal 05a07ecc77 Remove using std::string from port.h
Change-Id: I7376f5e7eace22ec1fc05a61eaa858594f08682d
2015-01-07 15:10:46 -08:00
Sameer Agarwal c6bbecf26d Consolidate path handling for test data files.
Added CERES_TEST_SRCDIR_POSTFIX macro.
Added TestFileAbsolutePath function.

Change-Id: I223b74af027bfb775447e062edab897395b21514
2012-08-14 11:35:13 -07:00
Keir Mierle 8ebb073038 Initial commit of Ceres Solver. 2012-04-30 23:09:08 -07:00