Commit Graph

1360 Commits

Author SHA1 Message Date
Sameer Agarwal cfdc2af28b Remove Solver::Options::num_linear_solver_threads
Also removed Solver::Summary::num_linear_solver_threads_given
and Solver::Summary::num_linear_solver_threads_used.

Change-Id: I559145ae2e7af597ea06ec03d386645a3a892e9f
2018-04-26 21:13:35 -07:00
Keir Mierle cd48f83f8d Bump Ceres version to 2.0.0
Due to the large amount of changes made as part of
the C++11 migration, it makes sense to have a
large version bump.

Change-Id: I2d81828e2d8e23f0829070726e7b3ec31d7f1724
2018-04-24 17:56:25 +00:00
Sameer Agarwal dc8ef467e3 Move max_align_t handling into jet.h
This was currently buried in port.h. Since there is exactly one use
of the max_align_t handling, it is better from a readability
and cleanliness perspective to have this in jet.h.

Change-Id: I2f3dde75df7c333bd95393b9e4fc4cd5160d6afb
2018-04-23 10:03:45 -07:00
Alex Stewart f52e041c49 Fix 'xxx.cc has no symbols' warnings.
- As OPENMP, TBB & CXX11_THREADS are mutually exclusive, and their
  implementations are wholly contained within enclosing #ifdefs if the
  requisite option is not enabled then the source file is 'empty'.
- This triggers 'xxx.cc has no symbol' warnings when compiling
  Ceres statically, as such we now only include these files if they are
  not going to be empty.

Change-Id: I5390251b44c5770bbdd4ccb1bc916dbe3b1814a9
2018-04-22 14:38:54 +01:00
Sameer Agarwal 056140e3a0 Add a typedef to expose the scalar type used in a Jet.
Change-Id: I4232d76619f4f9c48a0c716150b8c5ffc8b74462
2018-04-20 14:05: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 d15503219f Simplify OrderedGroups using C++11 syntax
Change-Id: I3e50bb66c43245df979a471622957fd01e73d014
2018-04-18 16:32:16 -07:00
Sameer Agarwal 31f24521cc Deprecate macros.h and fpclassify.h
1. Replace CERES_DISALLOW_* with explicitly deleted constructors.
2. Replace use of CERES_ARRAY_SIZE and stack allocated arrays
   with std::vector.
3. Move CERES_ALIGN_* macros into manual_constructor.h, which is
   the one place they are used and will be deprecated along with that
   file.
4. Introduce isnan,isnormal,isinf and isfinite for Jets.
5. Replace IsNormal,IsFinite,IsNaN and IsInfinite with corresponding
   c++11 function calls.

Change-Id: I04f33a221aae77d247602150988b6d4aa4efeeab
2018-04-18 09:54:42 -07:00
Sameer Agarwal 58c5edae2f Relax an overly strict tolerance in iterative_refiner_test
Change-Id: I01afef985c0d248a50df2cadb97e4be9cd8d7889
2018-04-16 12:54:18 -07:00
Sameer Agarwal 3b2f1f7d28 Add fake FloatCXSparseCholesky and FloatSuiteSparseCholesky
Change-Id: I8d61144d0678b8da92322a18517fa6924d950653
2018-04-12 11:22:49 -07:00
Sameer Agarwal 93ba16fefc Simplify IterativeRefiner
Change the loop structure of IterativeRefiner to
unconditionally refine for max_num_iterations.

This is done for two reasons.

1. We expect to use this refinement for a small number of iterations
   where the convergence test is useless.
2. Eliminating the convergence test means we can restructure the loop
   and save on a sparse matrix-vector multiply, saving precious
   compute.

Change-Id: I6347f453a5d19d234af2a2eb1bce811048963e06
2018-04-11 21:15:02 -07:00
Mike Vitus 05fc04490f Converts std::unique_lock to std::lock_guard.
Tested by compiling for CXX threads, OpenMP, no threads, and TBB.

Change-Id: If1ba5cfce83e2ad4e1015354ce67f5b23e89101f
2018-04-10 17:22:15 -07:00
Sameer Agarwal f973e107d2 Enable mixed precision solves.
1. Add Solver::Options::use_mixed_precision_solves,
   and Solver::Options::max_num_refinement_iterations.
2. Make SparseCholesky::Create return a unique_ptr.
3. SparseCholesky::Create now takes LinearSolver::Options
   as an argument.
4. IterativeRefiner's constructor does not require num_cols
   as an argument.
5. SparseNormalCholeskySolver now uses a separate rhs vector.

This basic implementation results in a 10% reduction in solver time
and 30% reduction in linear solver memory usage.

Change-Id: I6830f32cae2febf082d2733262eb2c9f0482b0ea
2018-04-10 11:01:38 -07:00
yangfan 81f413b720 Optimization for custom small blas multiplication with dynamic
template parameters in C level.

- unroll for loops
- matrix access more cache coherent
- platform independant

Briefly, this commit brings 1~50% performance improvments for
most cases in small_blas_gem(m/v)_benchmark, but a small drop
for corner cases with small dimensions especially 1,2,3. Here
we list the results partially, which show decrease percentage
of executing time, compared to unoptimized version.

Platform: desktop PC (i7-7700 CPU MP8@3.60GHz + ubuntu 17.10)
(Lenovo Research Device+ Lab, <yangfan34@lenovo.com>)

Benchmark                                   Time        CPU
-----------------------------------------------------------
BM_MatrixMatrixMultiplyDynamic/1/1/1     -0.0850    -0.0851
BM_MatrixMatrixMultiplyDynamic/1/1/2     -0.1444    -0.1446
BM_MatrixMatrixMultiplyDynamic/1/1/3     -0.1934    -0.1935
BM_MatrixMatrixMultiplyDynamic/1/1/4     -0.2933    -0.2934
BM_MatrixMatrixMultiplyDynamic/1/1/8     -0.1579    -0.1580
BM_MatrixMatrixMultiplyDynamic/1/1/12    -0.1556    -0.1558
BM_MatrixMatrixMultiplyDynamic/1/1/15    -0.1598    -0.1599
BM_MatrixMatrixMultiplyDynamic/1/2/1     -0.0797    -0.0799
BM_MatrixMatrixMultiplyDynamic/1/2/2     -0.2950    -0.2951
BM_MatrixMatrixMultiplyDynamic/1/2/3     -0.1363    -0.1364
BM_MatrixMatrixMultiplyDynamic/1/2/4     -0.2435    -0.2437
BM_MatrixMatrixMultiplyDynamic/1/2/8     -0.2299    -0.2300
BM_MatrixMatrixMultiplyDynamic/1/2/12    -0.2441    -0.2442
BM_MatrixMatrixMultiplyDynamic/1/2/15    -0.1671    -0.1673
BM_MatrixMatrixMultiplyDynamic/1/3/1     -0.0774    -0.0775
BM_MatrixMatrixMultiplyDynamic/1/3/2     -0.2761    -0.2762
BM_MatrixMatrixMultiplyDynamic/1/3/3     -0.0840    -0.0841
BM_MatrixMatrixMultiplyDynamic/1/3/4     -0.2027    -0.2028
BM_MatrixMatrixMultiplyDynamic/1/3/8     -0.2481    -0.2482
BM_MatrixMatrixMultiplyDynamic/1/3/12    -0.2629    -0.2630
BM_MatrixMatrixMultiplyDynamic/1/3/15    -0.1958    -0.1959
BM_MatrixMatrixMultiplyDynamic/1/4/1     -0.1260    -0.1261
BM_MatrixMatrixMultiplyDynamic/1/4/2     -0.1834    -0.1835
BM_MatrixMatrixMultiplyDynamic/1/4/3     -0.1379    -0.1380
BM_MatrixMatrixMultiplyDynamic/1/4/4     -0.2636    -0.2637
BM_MatrixMatrixMultiplyDynamic/1/4/8     -0.2838    -0.2839
BM_MatrixMatrixMultiplyDynamic/1/4/12    -0.3320    -0.3321
BM_MatrixMatrixMultiplyDynamic/1/4/15    -0.2464    -0.2465
BM_MatrixMatrixMultiplyDynamic/1/8/1     -0.0766    -0.0767
BM_MatrixMatrixMultiplyDynamic/1/8/2     -0.1713    -0.1714
BM_MatrixMatrixMultiplyDynamic/1/8/3     -0.1158    -0.1159
BM_MatrixMatrixMultiplyDynamic/1/8/4     -0.3205    -0.3206
BM_MatrixMatrixMultiplyDynamic/1/8/8     -0.3514    -0.3515
BM_MatrixMatrixMultiplyDynamic/1/8/12    -0.3658    -0.3658
BM_MatrixMatrixMultiplyDynamic/1/8/15    -0.3187    -0.3188
BM_MatrixMatrixMultiplyDynamic/1/12/1    -0.0424    -0.0425
BM_MatrixMatrixMultiplyDynamic/1/12/2    -0.1800    -0.1800
BM_MatrixMatrixMultiplyDynamic/1/12/3    -0.1457    -0.1457
BM_MatrixMatrixMultiplyDynamic/1/12/4    -0.3768    -0.3769
BM_MatrixMatrixMultiplyDynamic/1/12/8    -0.4072    -0.4073
BM_MatrixMatrixMultiplyDynamic/1/12/12   -0.4391    -0.4392
BM_MatrixMatrixMultiplyDynamic/1/12/15   -0.3383    -0.3383
BM_MatrixMatrixMultiplyDynamic/1/15/1    -0.0442    -0.0443
BM_MatrixMatrixMultiplyDynamic/1/15/2    -0.2378    -0.2379
BM_MatrixMatrixMultiplyDynamic/1/15/3    -0.1553    -0.1554
BM_MatrixMatrixMultiplyDynamic/1/15/4    -0.3954    -0.3955
BM_MatrixMatrixMultiplyDynamic/1/15/8    -0.4334    -0.4335
BM_MatrixMatrixMultiplyDynamic/1/15/12   -0.4175    -0.4175
BM_MatrixMatrixMultiplyDynamic/1/15/15   -0.3242    -0.3243

BM_MatrixVectorMultiply/1/1              +0.1613    +0.1613
BM_MatrixVectorMultiply/1/2              +0.1715    +0.1715
BM_MatrixVectorMultiply/1/3              +0.1051    +0.1051
BM_MatrixVectorMultiply/1/4              +0.1369    +0.1369
BM_MatrixVectorMultiply/1/8              +0.1180    +0.1180
BM_MatrixVectorMultiply/1/12             +0.0869    +0.0869
BM_MatrixVectorMultiply/1/15             +0.1887    +0.1886
BM_MatrixVectorMultiply/2/1              +0.1152    +0.1152
BM_MatrixVectorMultiply/2/2              +0.1520    +0.1520
BM_MatrixVectorMultiply/2/3              +0.1867    +0.1867
BM_MatrixVectorMultiply/2/4              +0.0173    +0.0173
BM_MatrixVectorMultiply/2/8              -0.0528    -0.0528
BM_MatrixVectorMultiply/2/12             -0.0176    -0.0176
BM_MatrixVectorMultiply/2/15             -0.0753    -0.0753
BM_MatrixVectorMultiply/3/1              +0.0844    +0.0844
BM_MatrixVectorMultiply/3/2              +0.0750    +0.0750
BM_MatrixVectorMultiply/3/3              -0.0153    -0.0153
BM_MatrixVectorMultiply/3/4              +0.0060    +0.0060
BM_MatrixVectorMultiply/3/8              +0.0152    +0.0152
BM_MatrixVectorMultiply/3/12             +0.0101    +0.0101
BM_MatrixVectorMultiply/3/15             -0.0795    -0.0795
BM_MatrixVectorMultiply/4/1              -0.1425    -0.1425
BM_MatrixVectorMultiply/4/2              -0.0869    -0.0869
BM_MatrixVectorMultiply/4/3              -0.1371    -0.1371
BM_MatrixVectorMultiply/4/4              -0.0088    -0.0088
BM_MatrixVectorMultiply/4/8              -0.1049    -0.1049
BM_MatrixVectorMultiply/4/12             -0.2566    -0.2566
BM_MatrixVectorMultiply/4/15             -0.2940    -0.2940
BM_MatrixVectorMultiply/6/1              -0.1798    -0.1798
BM_MatrixVectorMultiply/6/2              -0.0627    -0.0627
BM_MatrixVectorMultiply/6/3              -0.0389    -0.0389
BM_MatrixVectorMultiply/6/4              -0.1088    -0.1088
BM_MatrixVectorMultiply/6/8              -0.1815    -0.1815
BM_MatrixVectorMultiply/6/12             -0.1650    -0.1650
BM_MatrixVectorMultiply/6/15             -0.1855    -0.1855
BM_MatrixVectorMultiply/8/1              -0.1630    -0.1630
BM_MatrixVectorMultiply/8/2              -0.1248    -0.1248
BM_MatrixVectorMultiply/8/3              -0.1911    -0.1911
BM_MatrixVectorMultiply/8/4              -0.1996    -0.1996
BM_MatrixVectorMultiply/8/8              -0.2590    -0.2590
BM_MatrixVectorMultiply/8/12             -0.3266    -0.3266
BM_MatrixVectorMultiply/8/15             -0.3999    -0.3999
BM_MatrixTransposeVectorMultiply/1/1     -0.0234    -0.0234
BM_MatrixTransposeVectorMultiply/1/2     -0.0243    -0.0243
BM_MatrixTransposeVectorMultiply/1/3     -0.1324    -0.1324
BM_MatrixTransposeVectorMultiply/1/4     -0.2635    -0.2635
BM_MatrixTransposeVectorMultiply/1/8     -0.2461    -0.2461
BM_MatrixTransposeVectorMultiply/1/12    -0.2702    -0.2702
BM_MatrixTransposeVectorMultiply/1/15    -0.2538    -0.2538
BM_MatrixTransposeVectorMultiply/2/1     -0.0170    -0.0170
BM_MatrixTransposeVectorMultiply/2/2     -0.1475    -0.1475
BM_MatrixTransposeVectorMultiply/2/3     -0.1082    -0.1082
BM_MatrixTransposeVectorMultiply/2/4     -0.2594    -0.2595
BM_MatrixTransposeVectorMultiply/2/8     -0.2710    -0.2710
BM_MatrixTransposeVectorMultiply/2/12    -0.3053    -0.3053
BM_MatrixTransposeVectorMultiply/2/15    -0.2706    -0.2706
BM_MatrixTransposeVectorMultiply/3/1     -0.0096    -0.0096
BM_MatrixTransposeVectorMultiply/3/2     -0.2885    -0.2886
BM_MatrixTransposeVectorMultiply/3/3     -0.0790    -0.0790
BM_MatrixTransposeVectorMultiply/3/4     -0.2329    -0.2330
BM_MatrixTransposeVectorMultiply/3/8     -0.2742    -0.2742
BM_MatrixTransposeVectorMultiply/3/12    -0.3177    -0.3177
BM_MatrixTransposeVectorMultiply/3/15    -0.2610    -0.2610
BM_MatrixTransposeVectorMultiply/4/1     -0.0024    -0.0024
BM_MatrixTransposeVectorMultiply/4/2     -0.1578    -0.1578
BM_MatrixTransposeVectorMultiply/4/3     -0.0918    -0.0918
BM_MatrixTransposeVectorMultiply/4/4     -0.2570    -0.2570
BM_MatrixTransposeVectorMultiply/4/8     -0.3064    -0.3064
BM_MatrixTransposeVectorMultiply/4/12    -0.3316    -0.3316
BM_MatrixTransposeVectorMultiply/4/15    -0.2794    -0.2794
BM_MatrixTransposeVectorMultiply/6/1     -0.0484    -0.0484
BM_MatrixTransposeVectorMultiply/6/2     -0.1102    -0.1102
BM_MatrixTransposeVectorMultiply/6/3     -0.1188    -0.1188
BM_MatrixTransposeVectorMultiply/6/4     -0.2967    -0.2967
BM_MatrixTransposeVectorMultiply/6/8     -0.3190    -0.3190
BM_MatrixTransposeVectorMultiply/6/12    -0.3441    -0.3441
BM_MatrixTransposeVectorMultiply/6/15    -0.2723    -0.2723
BM_MatrixTransposeVectorMultiply/8/1     -0.0397    -0.0397
BM_MatrixTransposeVectorMultiply/8/2     -0.1453    -0.1453
BM_MatrixTransposeVectorMultiply/8/3     -0.1337    -0.1337
BM_MatrixTransposeVectorMultiply/8/4     -0.3084    -0.3084
BM_MatrixTransposeVectorMultiply/8/8     -0.3444    -0.3444
BM_MatrixTransposeVectorMultiply/8/12    -0.3717    -0.3717
BM_MatrixTransposeVectorMultiply/8/15    -0.3440    -0.3440

Change-Id: I17de05bf94699a07eea880b92a6d08daf1f038bb
2018-04-10 14:42:23 +08:00
Sameer Agarwal bdda32bb16 Add MixedSparseCholesky.
A simple class that composes SparseCholesky with IterativeRefiner.

Change-Id: I4a67b8ca33a604aaa7b6a4bf511dad9501815f5b
2018-04-09 17:40:34 -07:00
Sameer Agarwal 7750c4c55c Add a single precision variant of EigenSparseCholesky.
Given a double precision linear system, solve it using
a single precision Cholesky factorization.

Change-Id: I8a6e8b7a451e961a8a23a62dd7b5d8159c4db8ce
2018-04-09 15:59:45 -07:00
Sameer Agarwal 83f70e5c02 Remove unnecessary memory allocations when using SuiteSparse.
1. Add SuiteSparse::CreateDenseVectorView
2. Replace calls to SuiteSparse::CreateDenseVector with
   SuiteSparse::CreateDenseVectorView.
2. Replace NULL with nullptr in suitesparse.cc and
   dynamic_sparse_normal_cholesky_solver.cc

Change-Id: I94355c1dc27789e5b987a7b2850e9db6176a0914
2018-04-09 14:39:02 -07:00
Sameer Agarwal 21ec8f462c Change the API description for SparseCholesky::Solve.
The description does not reflect reality and puts constraints
on the underlying implementation.

Change-Id: I5f64e776c952868ae82fb2144acf51c2dcdfab56
2018-04-09 14:20:58 -07:00
Sameer Agarwal d0e06760ec Bring the Bazel build in sync with the CMake build.
1. Remove defines which are not used anymore.
2. Enable CXX11 threading.
3. Enable EIGEN_SPARSE by default.

Change-Id: I841ba517367e6b204475e5255c91313f01a5bcdb
2018-04-09 11:42:43 -07:00
Mike Vitus 5d8b494557 Adds a ParallelFor wrapper for no threads and OpenMP.
With the addition of C++11 support we can simplify the parallel for code by
removing the ifdef branching.  Converts coordinate_descent_minimizer.cc to use
the thread_id ParallelFor API.

Tested by building with OpenMP, C++11 threads, TBB, and no threads.  All tests
pass.

Also compared timing via the bundle adjuster.

./bin/bundle_adjuster --input=../problem-744-543562-pre.txt

With OpenMP num_threads=8

Head:
Time (in seconds):
  Residual only evaluation           0.807753 (5)
  Jacobian & residual evaluation     4.489404 (6)
  Linear solver                     41.826481 (5)
Minimizer                           50.745857
Total                               73.294424

CL:
Time (in seconds):
  Residual only evaluation           0.970483 (5)
  Jacobian & residual evaluation     4.647438 (6)
  Linear solver                     41.781892 (5)
Minimizer                           50.848904
Total                               73.089983

With OpenMP num_threads=1

HEAD:
Time (in seconds):
  Residual only evaluation           2.990246 (5)
  Jacobian & residual evaluation    14.132090 (6)
  Linear solver                     79.631951 (5)
Minimizer                          100.281847
Total                              122.946267

CL:
Time (in seconds):
  Residual only evaluation           3.075178 (5)
  Jacobian & residual evaluation    13.966451 (6)
  Linear solver                     77.005441 (5)
Minimizer                           97.568712
Total                              120.410454

Change-Id: I1857d7943073be7465b6c6476bf46ab11c5475a3
2018-04-09 10:10:03 -07:00
Sameer Agarwal 8d7b2528bc Improve the test coverage in small_blas_test
1. Add explicit tests for MatrixMatrixMultiplyNaive and
   MatrixTransposeMatrixMultiplyNaive
2. Add tests that exercise a variety of matrix sizes for
   MatrixVectorMultiply and MatrixTransposeVectorMultiply.

Change-Id: I0b25ec346b719f19b2067848f9d4bb64c9848750
2018-04-08 15:26:52 -07:00
Sameer Agarwal df4de10ace Revert "Optimization for custom small blas multiplication with dynamic"
This reverts commit 68cc71ce5d.

Reason for revert: Breaks a number of tests.

Change-Id: I543eaf2103e9903e9026a1fcc2c0bf517d971190
2018-04-08 17:56:16 +00:00
Sameer Agarwal 865ac62d38 Change a rather strict tolerance in the iterative_refiner_test
Change-Id: I924ab56e24b18502797202167703e4e9bf555550
2018-04-08 10:42:10 -07:00
yangfan 68cc71ce5d Optimization for custom small blas multiplication with dynamic
template parameters in C level.

- unroll for loops
- matrix access more cache coherent
- platform independant

Briefly, this commit brings 1~50% performance improvments for
most cases in small_blas_gem(m/v)_benchmark, but a small drop
for corner cases with small dimensions especially 1,2,3. Here
we list the results partially, which show decrease percentage
of executing time, compared to unoptimized version.

Platform: desktop PC (i7-7700 CPU MP8@3.60GHz + ubuntu 17.10)
(Lenovo Research Device+ Lab, <yangfan34@lenovo.com>)

Benchmark                                   Time        CPU
-----------------------------------------------------------
BM_MatrixMatrixMultiplyDynamic/2/2/2     -0.1082    -0.1083
BM_MatrixMatrixMultiplyDynamic/2/2/15    -0.1270    -0.1270
BM_MatrixMatrixMultiplyDynamic/2/4/2     -0.1433    -0.1433
BM_MatrixMatrixMultiplyDynamic/2/4/15    -0.2069    -0.2068
BM_MatrixMatrixMultiplyDynamic/2/6/2     -0.1446    -0.1446
BM_MatrixMatrixMultiplyDynamic/2/6/15    -0.2156    -0.2156
BM_MatrixMatrixMultiplyDynamic/2/8/2     -0.1788    -0.1788
BM_MatrixMatrixMultiplyDynamic/2/8/15    -0.3316    -0.3316
BM_MatrixMatrixMultiplyDynamic/2/10/2    -0.2025    -0.2025
BM_MatrixMatrixMultiplyDynamic/2/10/15   -0.3444    -0.3444
BM_MatrixMatrixMultiplyDynamic/2/12/2    -0.0515    -0.0515
BM_MatrixMatrixMultiplyDynamic/2/12/15   -0.3733    -0.3733
BM_MatrixMatrixMultiplyDynamic/2/15/2    -0.2784    -0.2784
BM_MatrixMatrixMultiplyDynamic/2/15/15   -0.3704    -0.3704
BM_MatrixMatrixMultiplyDynamic/4/2/2     -0.1839    -0.1839
BM_MatrixMatrixMultiplyDynamic/4/2/15    -0.1922    -0.1922
BM_MatrixMatrixMultiplyDynamic/4/4/2     -0.2248    -0.2248
BM_MatrixMatrixMultiplyDynamic/4/4/15    -0.3132    -0.3132
BM_MatrixMatrixMultiplyDynamic/4/6/2     -0.2311    -0.2311
BM_MatrixMatrixMultiplyDynamic/4/6/15    -0.3239    -0.3239
BM_MatrixMatrixMultiplyDynamic/4/8/2     -0.0574    -0.0574
BM_MatrixMatrixMultiplyDynamic/4/8/15    -0.4173    -0.4173
BM_MatrixMatrixMultiplyDynamic/4/10/2    -0.2861    -0.2861
BM_MatrixMatrixMultiplyDynamic/4/10/15   -0.4065    -0.4064
BM_MatrixMatrixMultiplyDynamic/4/12/2    -0.2976    -0.2975
BM_MatrixMatrixMultiplyDynamic/4/12/15   -0.4218    -0.4218
BM_MatrixMatrixMultiplyDynamic/4/15/2    -0.3116    -0.3116
BM_MatrixMatrixMultiplyDynamic/4/15/15   -0.4242    -0.4241
BM_MatrixMatrixMultiplyDynamic/8/12/2    -0.3675    -0.3674
BM_MatrixMatrixMultiplyDynamic/8/12/4    -0.5055    -0.5055
BM_MatrixMatrixMultiplyDynamic/8/12/6    -0.4302    -0.4302
BM_MatrixMatrixMultiplyDynamic/8/12/8    -0.4854    -0.4854
BM_MatrixMatrixMultiplyDynamic/8/12/10   -0.4882    -0.4882
BM_MatrixMatrixMultiplyDynamic/8/12/12   -0.5209    -0.5209
BM_MatrixMatrixMultiplyDynamic/8/12/15   -0.4558    -0.4558
BM_MatrixMatrixMultiplyDynamic/8/15/2    -0.2319    -0.2319
BM_MatrixMatrixMultiplyDynamic/8/15/4    -0.5105    -0.5105
BM_MatrixMatrixMultiplyDynamic/8/15/6    -0.4477    -0.4477
BM_MatrixMatrixMultiplyDynamic/8/15/8    -0.5479    -0.5479
BM_MatrixMatrixMultiplyDynamic/8/15/10   -0.4843    -0.4843
BM_MatrixMatrixMultiplyDynamic/8/15/12   -0.5212    -0.5212
BM_MatrixMatrixMultiplyDynamic/8/15/15   -0.4459    -0.4459

BM_MatrixVectorMultiply/1/1              +0.0978    +0.0978
BM_MatrixVectorMultiply/1/2              +0.0551    +0.0551
BM_MatrixVectorMultiply/1/3              -0.0019    -0.0020
BM_MatrixVectorMultiply/1/4              +0.0563    +0.0562
BM_MatrixVectorMultiply/1/6              +0.1379    +0.1379
BM_MatrixVectorMultiply/1/7              +0.1090    +0.1090
BM_MatrixVectorMultiply/1/12             +0.0901    +0.0901
BM_MatrixVectorMultiply/1/16             +0.0493    +0.0493
BM_MatrixVectorMultiply/1/20             +0.2255    +0.2255
BM_MatrixVectorMultiply/2/1              +0.1261    +0.1261
BM_MatrixVectorMultiply/2/2              +0.2328    +0.2328
BM_MatrixVectorMultiply/2/3              +0.1404    +0.1403
BM_MatrixVectorMultiply/2/4              +0.0257    +0.0256
BM_MatrixVectorMultiply/2/6              -0.1691    -0.1691
BM_MatrixVectorMultiply/2/7              -0.2619    -0.2619
BM_MatrixVectorMultiply/2/12             -0.4261    -0.4261
BM_MatrixVectorMultiply/2/16             -0.5387    -0.5387
BM_MatrixVectorMultiply/2/20             -0.6171    -0.6171
BM_MatrixVectorMultiply/3/1              +0.1664    +0.1664
BM_MatrixVectorMultiply/3/2              +0.0848    +0.0848
BM_MatrixVectorMultiply/3/3              -0.0044    -0.0044
BM_MatrixVectorMultiply/3/4              -0.0683    -0.0684
BM_MatrixVectorMultiply/3/6              -0.1652    -0.1652
BM_MatrixVectorMultiply/3/7              -0.1633    -0.1633
BM_MatrixVectorMultiply/3/12             -0.1921    -0.1921
BM_MatrixVectorMultiply/3/16             -0.3659    -0.3659
BM_MatrixVectorMultiply/3/20             -0.4137    -0.4137
BM_MatrixVectorMultiply/4/1              -0.0577    -0.0577
BM_MatrixVectorMultiply/4/2              -0.1337    -0.1338
BM_MatrixVectorMultiply/4/3              -0.1443    -0.1443
BM_MatrixVectorMultiply/4/4              +0.0013    +0.0013
BM_MatrixVectorMultiply/4/6              -0.1071    -0.1071
BM_MatrixVectorMultiply/4/7              -0.1396    -0.1397
BM_MatrixVectorMultiply/4/12             -0.2792    -0.2792
BM_MatrixVectorMultiply/4/16             -0.4485    -0.4486
BM_MatrixVectorMultiply/4/20             -0.3588    -0.3588

Change-Id: I64a8cf11391e3d06341a2b8764cd1b4f1b8a23f1
2018-04-08 14:23:10 +00:00
Sameer Agarwal f27082a174 Handle possible overflow in TrustRegionStepEvaluator.
Thanks to Volker Grabe for reporting the problem and suggesting
a fix.

Change-Id: I8072ffb275907baac62ee2ad84a02f17eb447c63
2018-04-06 20:13:16 -07:00
Sameer Agarwal 86814ab193 Add Iterative Refinement
Add a class IterativeRefiner which implements iterative refinement
for SPD linear systems.

Change-Id: I705d4e96cb7de9226ee35e2a9c11d98ffc0ee239
2018-04-06 16:51:14 -07:00
Sameer Agarwal 9814a91fcf Use C++11's inline member initialization syntax
Migrate all Option and Summary structs to use
inline member initialization syntax.

This reduces the amount of code, and collocates the
default values with the documentation for the corresponding
member variable.

Change-Id: I8e6b9ee3b31464699d678667f6166ace5fc137c9
2018-04-06 16:50:42 -07:00
Alex Stewart 6851a63861 Fix lower-bound on result of minimising step-size polynomial.
- Previously we were requesting a step-size which minimised the
  polynomial in: [previous.x, current.x * factor].
- This is incorrect c/f Nocedal & Wright p60, the bounds for the
  minimising step-size should be: [current.x, current.x * factor].
- However, Nocedal & Wright's bounds are insufficient when the function
  can return invalid values, which we support.
- In the case that f(current) is invalid, we need to contract the
  step-size to lie within: [previous.x, current.x) given that we know
  that previous.x is valid so a valid step must exist within that range.

Change-Id: I67b5aaa09cc6d54cf5f264e2cf894ddc2af3f3ad
2018-04-06 19:57:38 +01:00
Sameer Agarwal 8202edcbb4 Add missing <algorithm> headers.
Thanks to kea@google.com for reporting this.

Change-Id: I9bde5823e9ea89451f476694c9b860080dffdf17
2018-04-05 11:53:48 -07:00
Sameer Agarwal 47863a1e56 Remove unnecessary unique_ptr initializations
Change-Id: Ibcd3676907f8cb0662b80f600101bcd7bec8e785
2018-04-03 11:29:04 -07:00
Mike Vitus e809cf0c28 Adds missing functional include in thread_pool.h
Fixes a build error when building with CXX11_THREADS=ON.

Change-Id: I5828dc408261c88a93745c2ade0b8da740a68e54
2018-04-03 11:14:41 -07:00
Sameer Agarwal e49507cbea More C++ification.
"> >" -> ">>"
"> > >" -> ">>>"

Change-Id: Id1ddd9dbf030fe21d57207741b4ca8403068e55b
2018-04-03 10:58:15 -07:00
Alex Stewart af77d3e676 Fix exported gflags include path.
- In practice, this was not causing any errors, as
  GFLAGS_INCLUDE_DIR_HINTS is set from GFLAGS_INCLUDE_DIRS so the two
  would have been equivalent, but we should nonetheless be using the
  one set after the find_package() call.
- Note that this would only have been active for older gflags versions
  that were not built with CMake.

Change-Id: Ie54145f522c974b7685052aafb1d2f6055d22337
2018-04-03 18:07:43 +01:00
Keir Mierle 7c4e8a454e Replace scoped_ptr with C++11's unique_ptr
Change-Id: Ib5a504c491e3a79af52a95accf009df473470c6b
2018-04-02 14:47:47 -07:00
Sameer Agarwal fc9336e12a Deprecate mutex.h
Use C++11's std::mutex and std::lock_guard instead.

Change-Id: If8d513d5d8f2ee2a49c1ebb249ffa93e4a80086b
2018-04-02 06:03:06 -07:00
Sameer Agarwal a1458f3348 More C++11ification.
1. Replace HashMap and HashSet with std::unordered_map and
   std::unordered_set respectively.
2. Extract the pair hasher into a struct pair_hash.
3. Delete collections_port.h
4. Convert explicit iterator based loops to auto based
   loops where sensible.

Change-Id: Ib88bcd13a7463d18435639d3b771abaa52080efb
2018-03-30 12:03:28 -07:00
Sameer Agarwal ffae101c75 Removed CERES_USE_CXX11
Remove the special handling for tr1::shared_ptr.

Change-Id: Ic405dcfe881dd6560d236956f84bfb8911d0bcbb
2018-03-29 15:16:49 -07:00
Alex Stewart 282b8b5f35 Require >= C++11 & CMake >= 3.5 when building Ceres.
- Removes CXX11 option, and all associate paraphernalia.  Ceres now
  requires a compiler with full >= C++11 support.  In MSVC terms this
  means >= 2013 Release 4.
- This deprecates the use of CERES_STD_UNORDERED_MAP and CERES_USE_CXX11
  as they will now always be defined.  They will be removed from the
  source in a future CL.
- For clients with CMake >= 3.8 we propagate via the exported/installed
  Ceres target the CXX version that was specified when Ceres was built.
  For versions < 3.8 (but >= 3.5) we specify the CXX features currently
  used in the Ceres public API.

Change-Id: I535b545b10156e4426659c270a4a0649e071df0e
2018-03-29 09:32:59 +01:00
Sameer Agarwal 9d4d0bfe29 Make CompressedRowSparseMatrix sensitive to StorageType
Even though we added support for storing the upper and
lower triangular parts of symmetric matrices in
CompressedRowSparseMatrix. RightMultiply, LeftMultiply
and SquaredColumnNorm were not modified to account for this.

This CL changes their implementation and adds thorough
tests.

Also methods that cannot work correctly with symmetric
storage now CHECK and fail, because that indicates
programmer error.

Change-Id: I76288472c8bac98db7376a79bdb6259e346ef2b7
2018-03-26 20:46:57 +00:00
Sameer Agarwal edffd386d2 Remove an unneeded virtual method from EigenSparseCholesky.
Change-Id: I4f9d1730feb98b21db8dea9cc1357a365fb8fcb8
2018-03-26 13:32:52 -07:00
Sameer Agarwal 0258b2a0b0 Update the sizes in small_blas_gem?_benchmark.cc
The sizes are reflective of the matrix sizes
that occur in production.

Change-Id: I8cd85d0640702df09afafced0d28ef416bab946f
2018-03-23 13:40:14 -07:00
Sameer Agarwal facb199f3e Add the missing (2,4,6) specialization to Android.mk
Change-Id: I02c7a9bd1ac1d4b4b4a19e9846c1347c4c1981a4
1.14.0
2018-03-21 21:00:14 -07:00
Alex Stewart b5d6ee4a88 Move C++11 checks to after external find_package() calls.
- Testing for C++11, and subsequent testing for components using C++11
  requires adding -std=c++11 to CMAKE_REQUIRED_FLAGS used by the
  check_cxx_source_compiles() (and similar) macros if required by the
  compiler.
- This variable is also used for the C equivalent macros, which are used
  by find_package(BLAS), and would cause the detection to fail if
  present.
- Thus if CXX11 was forced ON via -D (not via the GUI) then detection
  would fail (with the GUI an initial configure without CXX11 would
  initialise the variables and no errors would occur in later
  reconfigures).

Change-Id: I08d300baf3730e926fb8e853a384badcceefeaf5
1.14.0rc2
2018-03-19 14:39:07 +00:00
Alex Stewart a80b8cfeac Fix C++11 detection for VS2010.
- Use cmake_dependent_option() for all threading models and encode their
  respective mutual exclusivity in the dependent-option s/t the job of
  ensuring mutual exclusivity is performed by CMake.
- Use of cmake_dependent_option() has the downside that options are
  removed from the GUI if their requirements for availability are not
  met.  So if CXX11 is OFF, then neither TBB nor CXX11_THREADS will
  even appear as options (they will be undefined, assumed OFF).
- Perform checks for availability of C++11 if CXX11 is enabled prior to
  testing other options to handle dependence of TBB & CXX11_THREADS on
  CXX11 actually being present.
- Add check for availability of C++11-specific math functions used in
  jet.h before reporting C++11 as found.
- Add check for <atomic> before allowing TBB or CXX11_THREADS, as both
  options require it and it may not always be available even if the
  other required C++11 components are.

Change-Id: Ife8cd182aeb1978539ce2c9966910ae59ebd9177
2018-03-19 09:40:48 +00:00
Sameer Agarwal 76fc404579 Do not add CERES_NO_THREADS is OPENMP is not detected.
This logic was too strict and conflicted with CXX11 threads.

Change-Id: If9ac543be9765555c1eaa4e1f69d4398c72dc26f
1.14.0rc1
2018-03-13 10:27:07 -07:00
Sameer Agarwal c2f5cd10e7 Update docs and code in preparation for 1.14.0
Change-Id: I81b430fbff62fb5e3f4c75945f6d40361d546918
2018-03-13 10:10:13 -07:00
Keir Mierle 7bdceb46cf Evaluation callback API
This adds a callback mechanism to for users to get notified just
before jacobian and residual evaluations. This will enable
aggressive caching and sharing of compute between cost functions.

Change-Id: I67993726920218edf71ab9ae70c34c204756c71a
2018-03-07 12:41:22 -08:00
Sameer Agarwal 83098e12e8 Two changes to how we manage user's state.
1. When Solver::Options::update_state_every_iteration = true,
   the StateUpdatingCallback only updates the state on a
   successful iteration. This works fine but will not work
   if the user provides an EvaluationCallback, because
   every call to Evaluator::Evaluate will change the state
   visible to the user. This means that on unsuccessful
   iterations when the user's IterationCallback is called
   the state visible to the user would be the last evaluation
   which did not lead to an improved cost. This CL forces
   the StateUpdatingCallback to unconditionally update
   the user visible state.

2. When the minimizer terminates, we update the user visible
   state only if the solution is usable, otherwise the user's
   state will remain the same. To maintain this invariant
   we will now cache the user's state and make sure we
   use it to reset it upon return if the solver is not
   successful.

Change-Id: Ic1f8fa6cb10d2753130ea752c70ff3d6b2f1462f
2018-03-06 19:12:14 +00:00
Alex Stewart df2d882540 Remove armv7 from target architectures when building for iOS >= 11.
- iOS 11+ requires a 64-bit architecture, so only arm64 is supported.

Change-Id: Ieb2ead13ba8722c6c0777b78f59f667331ad670c
2018-03-04 12:16:27 +00:00