Commit Graph

1314 Commits

Author SHA1 Message Date
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
Sameer Agarwal 2f2e7222fa Fix c++98 mode compilation for parallel_utils_test.cc
Change-Id: I009032978bca910704c52f4de693d04fa13c6e07
2018-03-02 16:41:18 -08:00
William Rucklidge 21f519d009 Improve threading in covariance.
Covariance computation wants to do a triangular iteration but as a
single loop. Right now it iterates over a square and does nothing half
the time, which is inefficient and has bad worst-case threading
performance. This adds a utility that allows waste-free linear iteration
over a triangle.

Change-Id: I881d5683c65882f87dc2b5f8449a855d22ace755
2018-03-02 13:33:19 -08:00
Keir Mierle 0a30117489 Add parallel bundle tests to CMake build
This converts the bundle_adjustment_test to the parallel
version with multiple binaries, as is already in place for
the Bazel build. Additionally, since there is no longer a
need for it, this deletes bundle_adjustment_test.cc.

The test suite now runs on my 6 year old desktop in ~60 seconds!

Change-Id: Ib4a59f8749e823f697e6da5d303977d284303ae3
2018-03-02 19:38:32 +00:00
Sameer Agarwal 660960294c Remove an errant binary character
Change-Id: I22b6ef8975c3c8a34e7f96ca89e4ec90461f453c
2018-03-01 13:12:57 -08:00
Mike Vitus f0c3b23684 Increases the performance of the C++11 threading.
Previously, the thread ID was acquired and released on every iteration
of the for loop.  The C++11 concurrent queue implementation is much
slower than TBB's version and consequently this was a huge bottleneck.

This introduces another ParallelFor API which takes the thread ID as a
parameter in the evaluation function.  This allows us to acquire and
release the thread ID for each block of work which drastically improves
the performance.

This change brings us on par with OpenMP and TBB.  See below for a
timing comparison.  Note: in this example this CLs C++11 version is
faster to compute the residuals because TBB still must acquire the
thread ID on every iteration, which has some overhead.

Tested by building and running tests for no threading, OpenMP, TBB, and
C++11 threads.  Also ran bazel tests.

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

C++11 @Head
Time (in seconds):
  Residual only evaluation           7.819692 (5)
  Jacobian & residual evaluation    11.606063 (6)
  Linear solver                     47.860195 (5)
Minimizer                           70.877072

Total                               90.806338
---------------------------------------------------

C++11 (This CL)
Time (in seconds):
  Residual only evaluation           1.217500 (5)
  Jacobian & residual evaluation     5.796112 (6)
  Linear solver                     44.080873 (5)
Minimizer                           54.635524

Total                               77.640072

---------------------------------------------------
OpenMP
Time (in seconds):
  Residual only evaluation           0.797023 (5)
  Jacobian & residual evaluation     5.633916 (6)
  Linear solver                     43.280020 (5)
Minimizer                           53.199058

Total                               76.250861

---------------------------------------------------
TBB
Time (in seconds):

  Residual only evaluation           1.911095 (5)
  Jacobian & residual evaluation     5.557807 (6)
  Linear solver                     44.074680 (5)
Minimizer                           55.002688

Total                               78.052687

---------------------------------------------------
No Threads

Time (in seconds):

  Residual only evaluation           2.939212 (5)
  Jacobian & residual evaluation    18.519874 (6)
  Linear solver                     74.017837 (5)
Minimizer                           98.980080

Total                              122.216391

Change-Id: I3af959b0771bbdfe8cad8c13896191d6ac903181
2018-03-01 09:00:44 -08:00
Mike Vitus 4e391c36c1 Corrects the documentation of Problem::AddResidualBlock.
This change is provided on behalf of Steve Hsu.

Tested by compiling and inspecting the documentation.

Change-Id: Ib892bcc3ad76cba1bad133a1fd1d26468d0e6437
2018-03-01 04:09:09 +00:00
Sameer Agarwal 8c81149e4d Revert changes to MatrixTransposeMatrixMultiply.
This change while algebraically equivalent was causing non-trivial
changes in the numbers being reported by ceres and in some cases
they got worse.

Also fix a small header include in parallel_for_test.cc which
was discovered as part of testing this patch.

Change-Id: I8c8d61538819f0b25af6059fa75ad068fc22f5e4
2018-02-28 19:47:52 -08: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
Sameer Agarwal d9d8de556a Convert a nested loop into a linear loop in covariance_impl.h
This improves the readability and simplifies the logic
for interfacing with ParallelFor. More importantly, it paves the
way for ParallelFor refactoring to improve its performance.

Change-Id: I13b05596228900ee00d71f2ccce1db338844b9ab
2018-02-27 15:43:41 -08:00
Mike Vitus 5fcd3155f4 Fixes the configuration check in port.h.
Fixes a bug introduced in 12280 that incorrectly used xor for multiple
values.

Tested it manually by verifying it would fail for 2, 3, or 4 of them
defined.

Change-Id: I90c2662f4744aceaf0119dbbe072beced3f67c9a
2018-02-27 10:51:02 -08:00
Sameer Agarwal c48937e8cf Renable accidentally disabled tests in inner_product_computer_test
Change-Id: I25a73a2436c320ac5a3f84f9867258393fb2ffe9
2018-02-27 10:10:08 -08:00
Sameer Agarwal 973d30dffa Revert "Improve the performance of MatrixTransposeVector Multiply."
This reverts commit 6c835f81a7.

This CL introduced a subtle cancellation error which is causing
some application tests to fail, and is therefore being reverted.

Change-Id: Iaaa8f13a18f0a805b0e70a25ccd1e97efb21f330
2018-02-27 14:40:45 +00:00
Sameer Agarwal 0e0d5b44b5 Make SubsetPreconditionerTest compatible with old Eigen.
The enum Eigen::UpLoType did not have a name in older versions
of Eigen, so a templated function using that enum type fails
to compile with earlier versions of Eigen.

This change replaces the enum in the template declaration with
an int.

Change-Id: Id128fd96b76818be347ee6ed5945c231936d9af8
2018-02-27 14:40:17 +00:00
Mike Vitus 7b2717582a Adds C++11 parallel for implementation.
Implements ParallelFor using the C++11 based ThreadPool.  The C++11
parallel for is 50-70% faster than single threaded, and 20-30% slower
than TBB.

Tested by compiling with OpenMP, TBB, and C++11 Threading support and
ran the unit tests.  Ran bazel as well.

Change-Id: I7fd6c9037ff9f200ce6999b5f39918995bb6b8ea
2018-02-26 16:12:03 -08:00
Mike Vitus f408f89e8b Adds a Ceres Context structure.
A Ceres Context holds common global state that can be re-used within
Ceres.  The Context current contains a thread pool if compiling with
C++11 threading support.  Threads are expensive to create and destroy so
it is good to maintain across multiple Ceres solves.

Tested by compiling with and without TBB support and ran unit tests. Ran
bazel as well.

Change-Id: I82f598dfae642aa0e81a6039dc174608a5e8dbfb
2018-02-26 10:37:53 -08:00
Sameer Agarwal f217ccfb69 Use MatrixTransposeMatrix multiply from small_blas.h
Prior to this Cheng Wang had to work the MatrixTransposeMatrixMultiply
function in inner_product_computer because of its lagging performance.

Now that the implementation of MatrixTransposeMatrixMultiply
has been updated to match the implementation in inner_product_computer
this CL removes the redundancy.

This CL also includes a fix to MatrixTransposeMatrixMultiply
which was missed in the earlier refactoring, because the test
coverage for small_blas is broken. The tests for InnerProductComputer
caught the problem.

Change-Id: Ia8890010da058c2d9fe738dc77f0be34af5618ab
2018-02-25 20:53:10 -08:00
Sameer Agarwal 656f9efbd3 Improve the performance of MatrixTransposeMatrix multiply.
Compute A'B as rank-1 sums of outer products of the rows of
A and B. This is more cache coherent.

Benchmark                                                 Time             CPU      Time Old      Time New       CPU Old       CPU New
--------------------------------------------------------------------------------------------------------------------------------------
BM_MatrixMatrixMultiplyDynamic/2/2/2                   +0.0031         +0.0033            27            27            27            27
BM_MatrixMatrixMultiplyDynamic/2/2/4                   +0.0383         +0.0380            41            42            41            42
BM_MatrixMatrixMultiplyDynamic/2/2/6                   +0.0001         +0.0019            58            58            57            58
BM_MatrixMatrixMultiplyDynamic/2/2/8                   +0.0169         +0.0169            70            71            70            71
BM_MatrixMatrixMultiplyDynamic/2/2/10                  +0.0162         +0.0161            83            85            83            85
BM_MatrixMatrixMultiplyDynamic/2/2/12                  -0.0049         -0.0048            93            93            93            93
BM_MatrixMatrixMultiplyDynamic/2/2/15                  +0.0131         +0.0129           114           115           114           115
BM_MatrixMatrixMultiplyDynamic/2/4/2                   +0.0494         +0.0489            32            34            32            34
BM_MatrixMatrixMultiplyDynamic/2/4/4                   +0.0121         +0.0121            51            52            51            52
BM_MatrixMatrixMultiplyDynamic/2/4/6                   +0.0134         +0.0138            70            71            70            71
BM_MatrixMatrixMultiplyDynamic/2/4/8                   +0.0006         +0.0005            90            90            90            90
BM_MatrixMatrixMultiplyDynamic/2/4/10                  +0.0248         +0.0248           107           110           107           110
BM_MatrixMatrixMultiplyDynamic/2/4/12                  -0.0239         -0.0234           125           122           125           122
BM_MatrixMatrixMultiplyDynamic/2/4/15                  +0.0611         +0.0605           155           164           155           164
BM_MatrixMatrixMultiplyDynamic/2/6/2                   -0.0017         -0.0017            39            39            39            39
BM_MatrixMatrixMultiplyDynamic/2/6/4                   +0.0139         +0.0147            59            60            59            60
BM_MatrixMatrixMultiplyDynamic/2/6/6                   -0.1062         -0.1003            89            80            89            80
BM_MatrixMatrixMultiplyDynamic/2/6/8                   -0.0339         -0.0344           116           112           115           111
BM_MatrixMatrixMultiplyDynamic/2/6/10                  +0.0568         +0.0455           142           150           141           148
BM_MatrixMatrixMultiplyDynamic/2/6/12                  -0.0073         -0.0062           155           154           155           154
BM_MatrixMatrixMultiplyDynamic/2/6/15                  +0.0219         +0.0215           187           191           187           191
BM_MatrixMatrixMultiplyDynamic/2/8/2                   -0.0165         -0.0160            43            42            43            42
BM_MatrixMatrixMultiplyDynamic/2/8/4                   -0.0247         -0.0245            71            69            70            69
BM_MatrixMatrixMultiplyDynamic/2/8/6                   -0.0642         -0.0614           104            98           104            98
BM_MatrixMatrixMultiplyDynamic/2/8/8                   -0.0607         -0.0599           133           125           133           125
BM_MatrixMatrixMultiplyDynamic/2/8/10                  -0.0523         -0.0510           166           157           166           157
BM_MatrixMatrixMultiplyDynamic/2/8/12                  -0.0381         -0.0376           189           182           189           182
BM_MatrixMatrixMultiplyDynamic/2/8/15                  -0.0725         -0.0716           243           226           243           225
BM_MatrixMatrixMultiplyDynamic/2/10/2                  -0.0421         -0.0416            50            48            50            48
BM_MatrixMatrixMultiplyDynamic/2/10/4                  -0.0558         -0.0549            83            78            83            78
BM_MatrixMatrixMultiplyDynamic/2/10/6                  -0.0527         -0.0518           115           109           115           109
BM_MatrixMatrixMultiplyDynamic/2/10/8                  -0.0421         -0.0413           150           144           150           144
BM_MatrixMatrixMultiplyDynamic/2/10/10                 -0.0606         -0.0601           202           190           202           190
BM_MatrixMatrixMultiplyDynamic/2/10/12                 -0.0409         -0.0406           224           215           224           215
BM_MatrixMatrixMultiplyDynamic/2/10/15                 -0.0308         -0.0302           277           268           277           268
BM_MatrixMatrixMultiplyDynamic/2/12/2                  -0.0059         -0.0058            53            52            53            52
BM_MatrixMatrixMultiplyDynamic/2/12/4                  +0.0019         +0.0023            87            87            87            87
BM_MatrixMatrixMultiplyDynamic/2/12/6                  -0.0032         -0.0025           126           125           126           125
BM_MatrixMatrixMultiplyDynamic/2/12/8                  -0.0039         -0.0038           159           158           159           158
BM_MatrixMatrixMultiplyDynamic/2/12/10                 -0.0175         -0.0171           205           201           205           201
BM_MatrixMatrixMultiplyDynamic/2/12/12                 -0.0643         -0.0633           295           276           294           276
BM_MatrixMatrixMultiplyDynamic/2/12/15                 -0.0215         -0.0201           328           321           328           321
BM_MatrixMatrixMultiplyDynamic/2/15/2                  +0.0092         +0.0103            58            58            58            58
BM_MatrixMatrixMultiplyDynamic/2/15/4                  +0.0762         +0.0765            98           105            98           105
BM_MatrixMatrixMultiplyDynamic/2/15/6                  -0.0155         -0.0172           138           136           138           136
BM_MatrixMatrixMultiplyDynamic/2/15/8                  +0.0674         +0.0658           180           192           180           191
BM_MatrixMatrixMultiplyDynamic/2/15/10                 +0.0254         +0.0255           236           242           236           242
BM_MatrixMatrixMultiplyDynamic/2/15/12                 -0.0383         -0.0378           289           278           289           278
BM_MatrixMatrixMultiplyDynamic/2/15/15                 -0.0313         -0.0308           407           394           406           394
BM_MatrixMatrixMultiplyDynamic/4/2/2                   +0.0286         +0.0286            42            43            42            43
BM_MatrixMatrixMultiplyDynamic/4/2/4                   -0.0455         -0.0439            71            68            71            68
BM_MatrixMatrixMultiplyDynamic/4/2/6                   +0.0221         +0.0229            93            95            93            95
BM_MatrixMatrixMultiplyDynamic/4/2/8                   -0.0226         -0.0225           120           118           120           118
BM_MatrixMatrixMultiplyDynamic/4/2/10                  -0.1153         -0.1130           158           140           158           140
BM_MatrixMatrixMultiplyDynamic/4/2/12                  -0.0145         -0.0143           164           162           164           162
BM_MatrixMatrixMultiplyDynamic/4/2/15                  -0.0396         -0.0393           205           197           205           197
BM_MatrixMatrixMultiplyDynamic/4/4/2                   -0.0696         -0.0682            57            53            57            53
BM_MatrixMatrixMultiplyDynamic/4/4/4                   -0.0233         -0.0231            91            89            91            89
BM_MatrixMatrixMultiplyDynamic/4/4/6                   -0.0711         -0.0702           130           121           130           121
BM_MatrixMatrixMultiplyDynamic/4/4/8                   -0.1180         -0.1113           178           157           176           157
BM_MatrixMatrixMultiplyDynamic/4/4/10                  -0.0301         -0.0282           194           188           194           188
BM_MatrixMatrixMultiplyDynamic/4/4/12                  -0.1156         -0.1137           251           222           251           222
BM_MatrixMatrixMultiplyDynamic/4/4/15                  -0.0182         -0.0179           307           302           307           301
BM_MatrixMatrixMultiplyDynamic/4/6/2                   -0.0228         -0.0220            64            63            64            63
BM_MatrixMatrixMultiplyDynamic/4/6/4                   +0.0048         +0.0045           106           107           106           107
BM_MatrixMatrixMultiplyDynamic/4/6/6                   -0.0131         -0.0126           155           153           155           153
BM_MatrixMatrixMultiplyDynamic/4/6/8                   -0.0526         -0.0502           211           200           210           200
BM_MatrixMatrixMultiplyDynamic/4/6/10                  -0.0995         -0.0975           274           247           274           247
BM_MatrixMatrixMultiplyDynamic/4/6/12                  -0.0436         -0.0430           297           284           297           284
BM_MatrixMatrixMultiplyDynamic/4/6/15                  +0.0042         +0.0050           344           345           343           345
BM_MatrixMatrixMultiplyDynamic/4/8/2                   -0.0283         -0.0279            74            72            74            72
BM_MatrixMatrixMultiplyDynamic/4/8/4                   -0.0282         -0.0277           125           122           125           122
BM_MatrixMatrixMultiplyDynamic/4/8/6                   -0.0756         -0.0693           185           171           184           171
BM_MatrixMatrixMultiplyDynamic/4/8/8                   -0.0510         -0.0444           267           253           265           253
BM_MatrixMatrixMultiplyDynamic/4/8/10                  -0.0512         -0.0460           301           285           299           285
BM_MatrixMatrixMultiplyDynamic/4/8/12                  -0.0046         -0.0006           351           349           349           349
BM_MatrixMatrixMultiplyDynamic/4/8/15                  -0.0795         -0.0785           452           416           451           416
BM_MatrixMatrixMultiplyDynamic/4/10/2                  -0.0415         -0.0406            85            81            85            81
BM_MatrixMatrixMultiplyDynamic/4/10/4                  -0.0118         -0.0118           143           141           143           141
BM_MatrixMatrixMultiplyDynamic/4/10/6                  -0.0484         -0.0478           217           206           216           206
BM_MatrixMatrixMultiplyDynamic/4/10/8                  -0.0373         -0.0372           280           269           280           269
BM_MatrixMatrixMultiplyDynamic/4/10/10                 +0.0083         +0.0083           350           353           350           353
BM_MatrixMatrixMultiplyDynamic/4/10/12                 -0.0364         -0.0365           436           420           436           420
BM_MatrixMatrixMultiplyDynamic/4/10/15                 -0.0221         -0.0210           513           502           512           502
BM_MatrixMatrixMultiplyDynamic/4/12/2                  -0.0569         -0.0565            94            89            94            89
BM_MatrixMatrixMultiplyDynamic/4/12/4                  -0.0343         -0.0338           162           157           162           157
BM_MatrixMatrixMultiplyDynamic/4/12/6                  +0.0197         +0.0198           227           232           227           231
BM_MatrixMatrixMultiplyDynamic/4/12/8                  -0.0390         -0.0388           310           298           310           298
BM_MatrixMatrixMultiplyDynamic/4/12/10                 -0.0088         -0.0085           389           386           389           386
BM_MatrixMatrixMultiplyDynamic/4/12/12                 +0.0524         +0.0505           545           574           545           572
BM_MatrixMatrixMultiplyDynamic/4/12/15                 +0.0801         +0.0764           597           645           597           642
BM_MatrixMatrixMultiplyDynamic/4/15/2                  -0.0024         -0.0026            99            99            99            99
BM_MatrixMatrixMultiplyDynamic/4/15/4                  -0.0289         -0.0270           187           181           186           181
BM_MatrixMatrixMultiplyDynamic/4/15/6                  -0.0264         -0.0261           263           256           263           256
BM_MatrixMatrixMultiplyDynamic/4/15/8                  -0.0344         -0.0334           349           337           348           337
BM_MatrixMatrixMultiplyDynamic/4/15/10                 -0.0189         -0.0191           454           446           454           445
BM_MatrixMatrixMultiplyDynamic/4/15/12                 -0.0483         -0.0470           524           499           523           498
BM_MatrixMatrixMultiplyDynamic/4/15/15                 -0.1084         -0.1070           840           749           838           748
BM_MatrixMatrixMultiplyDynamic/6/2/2                   -0.0574         -0.0561            59            56            59            56
BM_MatrixMatrixMultiplyDynamic/6/2/4                   -0.0727         -0.0721            98            91            98            91
BM_MatrixMatrixMultiplyDynamic/6/2/6                   -0.0292         -0.0283           133           129           133           129
BM_MatrixMatrixMultiplyDynamic/6/2/8                   -0.0283         -0.0278           167           162           167           162
BM_MatrixMatrixMultiplyDynamic/6/2/10                  -0.0482         -0.0476           216           206           216           206
BM_MatrixMatrixMultiplyDynamic/6/2/12                  -0.0117         -0.0115           243           240           243           240
BM_MatrixMatrixMultiplyDynamic/6/2/15                  -0.0234         -0.0225           299           292           299           292
BM_MatrixMatrixMultiplyDynamic/6/4/2                   -0.0950         -0.0898            79            72            79            72
BM_MatrixMatrixMultiplyDynamic/6/4/4                   -0.0300         -0.0298           130           127           130           127
BM_MatrixMatrixMultiplyDynamic/6/4/6                   -0.0379         -0.0376           175           169           175           169
BM_MatrixMatrixMultiplyDynamic/6/4/8                   -0.0340         -0.0319           236           228           236           228
BM_MatrixMatrixMultiplyDynamic/6/4/10                  -0.0498         -0.0490           289           275           289           275
BM_MatrixMatrixMultiplyDynamic/6/4/12                  +0.0134         +0.0134           325           330           325           330
BM_MatrixMatrixMultiplyDynamic/6/4/15                  -0.0836         -0.0794           469           429           466           429
BM_MatrixMatrixMultiplyDynamic/6/6/2                   -0.0614         -0.0563            91            86            91            86
BM_MatrixMatrixMultiplyDynamic/6/6/4                   -0.0249         -0.0239           153           149           152           149
BM_MatrixMatrixMultiplyDynamic/6/6/6                   -0.0442         -0.0438           235           224           234           224
BM_MatrixMatrixMultiplyDynamic/6/6/8                   -0.0127         -0.0083           296           292           295           292
BM_MatrixMatrixMultiplyDynamic/6/6/10                  +0.0305         +0.0302           360           371           360           371
BM_MatrixMatrixMultiplyDynamic/6/6/12                  -0.0479         -0.0463           434           413           433           413
BM_MatrixMatrixMultiplyDynamic/6/6/15                  -0.0774         -0.0742           542           500           540           500
BM_MatrixMatrixMultiplyDynamic/6/8/2                   -0.0617         -0.0611           106            99           106            99
BM_MatrixMatrixMultiplyDynamic/6/8/4                   -0.1153         -0.1147           202           179           202           179
BM_MatrixMatrixMultiplyDynamic/6/8/6                   -0.0591         -0.0589           270           254           270           254
BM_MatrixMatrixMultiplyDynamic/6/8/8                   -0.0677         -0.0671           381           355           381           355
BM_MatrixMatrixMultiplyDynamic/6/8/10                  -0.0771         -0.0757           451           416           450           416
BM_MatrixMatrixMultiplyDynamic/6/8/12                  -0.0520         -0.0519           522           495           522           495
BM_MatrixMatrixMultiplyDynamic/6/8/15                  -0.0386         -0.0386           639           614           638           614
BM_MatrixMatrixMultiplyDynamic/6/10/2                  -0.0764         -0.0756           121           111           120           111
BM_MatrixMatrixMultiplyDynamic/6/10/4                  -0.0847         -0.0777           224           205           222           205
BM_MatrixMatrixMultiplyDynamic/6/10/6                  -0.0762         -0.0748           320           295           319           295
BM_MatrixMatrixMultiplyDynamic/6/10/8                  -0.0160         -0.0164           413           407           413           406
BM_MatrixMatrixMultiplyDynamic/6/10/10                 +0.0438         +0.0429           526           549           525           548
BM_MatrixMatrixMultiplyDynamic/6/10/12                 +0.0641         +0.0615           606           645           605           643
BM_MatrixMatrixMultiplyDynamic/6/10/15                 +0.0983         +0.0965           741           814           740           812
BM_MatrixMatrixMultiplyDynamic/6/12/2                  +0.0697         +0.0663           135           144           135           144
BM_MatrixMatrixMultiplyDynamic/6/12/4                  -0.0230         -0.0240           251           245           250           244
BM_MatrixMatrixMultiplyDynamic/6/12/6                  -0.0728         -0.0703           365           338           364           338
BM_MatrixMatrixMultiplyDynamic/6/12/8                  -0.1444         -0.1402           514           440           511           440
BM_MatrixMatrixMultiplyDynamic/6/12/10                 -0.1268         -0.1216           628           548           624           548
BM_MatrixMatrixMultiplyDynamic/6/12/12                 -0.1323         -0.1250           883           766           875           766
BM_MatrixMatrixMultiplyDynamic/6/12/15                 -0.1337         -0.1304           995           862           991           862
BM_MatrixMatrixMultiplyDynamic/6/15/2                  -0.1163         -0.1140           158           140           158           140
BM_MatrixMatrixMultiplyDynamic/6/15/4                  -0.0721         -0.0689           285           265           284           265
BM_MatrixMatrixMultiplyDynamic/6/15/6                  -0.0597         -0.0582           414           389           413           389
BM_MatrixMatrixMultiplyDynamic/6/15/8                  -0.1189         -0.1173           563           496           562           496
BM_MatrixMatrixMultiplyDynamic/6/15/10                 -0.0754         -0.0737           749           693           747           692
BM_MatrixMatrixMultiplyDynamic/6/15/12                 +0.0141         +0.0153           871           883           866           879
BM_MatrixMatrixMultiplyDynamic/6/15/15                 -0.1184         -0.1152          1398          1233          1387          1228
BM_MatrixMatrixMultiplyDynamic/8/2/2                   -0.0232         -0.0242            77            75            77            75
BM_MatrixMatrixMultiplyDynamic/8/2/4                   +0.1114         +0.1085           120           133           119           132
BM_MatrixMatrixMultiplyDynamic/8/2/6                   +0.0794         +0.0760           169           183           169           182
BM_MatrixMatrixMultiplyDynamic/8/2/8                   +0.0833         +0.0780           221           239           221           238
BM_MatrixMatrixMultiplyDynamic/8/2/10                  +0.0037         +0.0037           264           265           264           265
BM_MatrixMatrixMultiplyDynamic/8/2/12                  +0.0114         +0.0115           301           304           301           304
BM_MatrixMatrixMultiplyDynamic/8/2/15                  +0.0034         +0.0030           378           380           378           380
BM_MatrixMatrixMultiplyDynamic/8/4/2                   +0.0197         +0.0198            90            91            90            91
BM_MatrixMatrixMultiplyDynamic/8/4/4                   +0.0231         +0.0230           156           160           156           160
BM_MatrixMatrixMultiplyDynamic/8/4/6                   +0.0233         +0.0235           225           230           225           230
BM_MatrixMatrixMultiplyDynamic/8/4/8                   +0.0352         +0.0349           286           296           286           296
BM_MatrixMatrixMultiplyDynamic/8/4/10                  +0.0569         +0.0551           362           382           362           382
BM_MatrixMatrixMultiplyDynamic/8/4/12                  -0.0180         -0.0181           424           416           424           416
BM_MatrixMatrixMultiplyDynamic/8/4/15                  -0.0807         -0.0763           627           576           623           576
BM_MatrixMatrixMultiplyDynamic/8/6/2                   -0.0030         -0.0029           111           111           111           111
BM_MatrixMatrixMultiplyDynamic/8/6/4                   +0.0053         +0.0051           198           199           198           199
BM_MatrixMatrixMultiplyDynamic/8/6/6                   -0.1261         -0.1233           330           288           329           288
BM_MatrixMatrixMultiplyDynamic/8/6/8                   -0.0760         -0.0755           398           368           398           368
BM_MatrixMatrixMultiplyDynamic/8/6/10                  -0.0497         -0.0487           505           480           505           480
BM_MatrixMatrixMultiplyDynamic/8/6/12                  +0.0090         +0.0091           529           534           529           534
BM_MatrixMatrixMultiplyDynamic/8/6/15                  -0.0778         -0.0757           704           649           702           649
BM_MatrixMatrixMultiplyDynamic/8/8/2                   -0.1332         -0.1305           150           130           149           130
BM_MatrixMatrixMultiplyDynamic/8/8/4                   -0.0903         -0.0878           257           234           257           234
BM_MatrixMatrixMultiplyDynamic/8/8/6                   -0.1177         -0.1165           380           335           379           335
BM_MatrixMatrixMultiplyDynamic/8/8/8                   -0.0799         -0.0786           509           468           508           468
BM_MatrixMatrixMultiplyDynamic/8/8/10                  -0.1098         -0.1057           604           538           601           537
BM_MatrixMatrixMultiplyDynamic/8/8/12                  -0.0676         -0.0662           697           650           696           650
BM_MatrixMatrixMultiplyDynamic/8/8/15                  -0.0707         -0.0696           856           796           855           796
BM_MatrixMatrixMultiplyDynamic/8/10/2                  -0.0429         -0.0417           149           142           149           142
BM_MatrixMatrixMultiplyDynamic/8/10/4                  -0.0652         -0.0640           286           267           286           267
BM_MatrixMatrixMultiplyDynamic/8/10/6                  -0.0259         -0.0253           402           392           402           392
BM_MatrixMatrixMultiplyDynamic/8/10/8                  -0.0131         -0.0129           526           520           526           519
BM_MatrixMatrixMultiplyDynamic/8/10/10                 -0.0873         -0.0865           697           636           696           636
BM_MatrixMatrixMultiplyDynamic/8/10/12                 -0.0130         -0.0127           799           788           798           788
BM_MatrixMatrixMultiplyDynamic/8/10/15                 -0.0441         -0.0438          1018           973          1018           973
BM_MatrixMatrixMultiplyDynamic/8/12/2                  -0.0384         -0.0379           172           166           172           165
BM_MatrixMatrixMultiplyDynamic/8/12/4                  -0.0321         -0.0307           307           297           307           297
BM_MatrixMatrixMultiplyDynamic/8/12/6                  -0.0394         -0.0380           458           440           458           440
BM_MatrixMatrixMultiplyDynamic/8/12/8                  -0.0529         -0.0522           608           576           607           576
BM_MatrixMatrixMultiplyDynamic/8/12/10                 -0.0566         -0.0560           747           705           747           705
BM_MatrixMatrixMultiplyDynamic/8/12/12                 -0.0007         -0.0006          1024          1024          1024          1023
BM_MatrixMatrixMultiplyDynamic/8/12/15                 -0.0422         -0.0420          1163          1114          1162          1113
BM_MatrixMatrixMultiplyDynamic/8/15/2                  -0.0241         -0.0241           197           192           197           192
BM_MatrixMatrixMultiplyDynamic/8/15/4                  -0.0515         -0.0514           352           334           352           333
BM_MatrixMatrixMultiplyDynamic/8/15/6                  -0.0192         -0.0194           506           496           506           496
BM_MatrixMatrixMultiplyDynamic/8/15/8                  -0.0338         -0.0334           674           651           674           651
BM_MatrixMatrixMultiplyDynamic/8/15/10                 -0.0556         -0.0545           922           871           921           871
BM_MatrixMatrixMultiplyDynamic/8/15/12                 -0.0473         -0.0462          1052          1002          1050          1001
BM_MatrixMatrixMultiplyDynamic/8/15/15                 -0.0522         -0.0521          1484          1406          1483          1406
BM_MatrixTransposeMatrixMultiplyDynamic/2/2/2          -0.1216         -0.1203            31            27            31            27
BM_MatrixTransposeMatrixMultiplyDynamic/2/2/4          -0.3827         -0.3818            49            30            49            30
BM_MatrixTransposeMatrixMultiplyDynamic/2/2/6          -0.3901         -0.3888            67            41            67            41
BM_MatrixTransposeMatrixMultiplyDynamic/2/2/8          -0.5469         -0.5458            86            39            86            39
BM_MatrixTransposeMatrixMultiplyDynamic/2/4/2          -0.2362         -0.2365            47            36            47            36
BM_MatrixTransposeMatrixMultiplyDynamic/2/4/4          -0.4470         -0.4469            77            43            77            43
BM_MatrixTransposeMatrixMultiplyDynamic/2/4/6          -0.4545         -0.4546           111            61           111            61
BM_MatrixTransposeMatrixMultiplyDynamic/2/4/8          -0.6093         -0.6093           142            56           142            56
BM_MatrixTransposeMatrixMultiplyDynamic/2/5/2          -0.2345         -0.2348            54            41            54            41
BM_MatrixTransposeMatrixMultiplyDynamic/2/5/4          -0.5111         -0.5107            99            48            99            48
BM_MatrixTransposeMatrixMultiplyDynamic/2/5/6          -0.4944         -0.4946           136            69           136            69
BM_MatrixTransposeMatrixMultiplyDynamic/2/5/8          -0.6354         -0.6354           171            62           171            62
BM_MatrixTransposeMatrixMultiplyDynamic/2/8/2          -0.3370         -0.3369            82            55            82            55
BM_MatrixTransposeMatrixMultiplyDynamic/2/8/4          -0.5062         -0.5064           139            69           139            69
BM_MatrixTransposeMatrixMultiplyDynamic/2/8/6          -0.5422         -0.5421           208            95           208            95
BM_MatrixTransposeMatrixMultiplyDynamic/2/8/8          -0.6903         -0.6896           294            91           294            91
BM_MatrixTransposeMatrixMultiplyDynamic/2/10/2         -0.1791         -0.1811            99            82            99            81
BM_MatrixTransposeMatrixMultiplyDynamic/2/10/4         -0.5062         -0.5061           177            88           177            88
BM_MatrixTransposeMatrixMultiplyDynamic/2/10/6         -0.5110         -0.5110           256           125           256           125
BM_MatrixTransposeMatrixMultiplyDynamic/2/10/8         -0.6632         -0.6632           334           112           333           112
BM_MatrixTransposeMatrixMultiplyDynamic/2/12/2         -0.3272         -0.3269           120            81           120            81
BM_MatrixTransposeMatrixMultiplyDynamic/2/12/4         -0.5019         -0.5019           212           105           212           105
BM_MatrixTransposeMatrixMultiplyDynamic/2/12/6         -0.5365         -0.5365           303           140           303           140
BM_MatrixTransposeMatrixMultiplyDynamic/2/12/8         -0.6856         -0.6856           398           125           398           125
BM_MatrixTransposeMatrixMultiplyDynamic/2/15/2         -0.2425         -0.2425           143           109           143           109
BM_MatrixTransposeMatrixMultiplyDynamic/2/15/4         -0.5891         -0.5871           298           122           296           122
BM_MatrixTransposeMatrixMultiplyDynamic/2/15/6         -0.5790         -0.5782           414           174           413           174
BM_MatrixTransposeMatrixMultiplyDynamic/2/15/8         -0.7173         -0.7173           509           144           509           144
BM_MatrixTransposeMatrixMultiplyDynamic/4/2/2          +0.0482         +0.0489            37            39            37            39
BM_MatrixTransposeMatrixMultiplyDynamic/4/2/4          -0.2428         -0.2433            60            45            60            45
BM_MatrixTransposeMatrixMultiplyDynamic/4/2/6          -0.2921         -0.2917            84            59            84            59
BM_MatrixTransposeMatrixMultiplyDynamic/4/2/8          -0.4632         -0.4630           105            56           105            56
BM_MatrixTransposeMatrixMultiplyDynamic/4/4/2          -0.0305         -0.0301            60            58            60            58
BM_MatrixTransposeMatrixMultiplyDynamic/4/4/4          -0.3008         -0.3007           101            70           101            70
BM_MatrixTransposeMatrixMultiplyDynamic/4/4/6          -0.3708         -0.3700           149            94           149            94
BM_MatrixTransposeMatrixMultiplyDynamic/4/4/8          -0.5160         -0.5159           190            92           189            92
BM_MatrixTransposeMatrixMultiplyDynamic/4/5/2          -0.0187         -0.0185            71            70            71            70
BM_MatrixTransposeMatrixMultiplyDynamic/4/5/4          -0.3064         -0.3054           130            90           130            90
BM_MatrixTransposeMatrixMultiplyDynamic/4/5/6          -0.3762         -0.3753           184           115           184           115
BM_MatrixTransposeMatrixMultiplyDynamic/4/5/8          -0.5845         -0.5838           240           100           240           100
BM_MatrixTransposeMatrixMultiplyDynamic/4/8/2          +0.0517         +0.0521           109           115           109           115
BM_MatrixTransposeMatrixMultiplyDynamic/4/8/4          -0.2895         -0.2889           194           138           194           138
BM_MatrixTransposeMatrixMultiplyDynamic/4/8/6          -0.3138         -0.3136           279           191           279           191
BM_MatrixTransposeMatrixMultiplyDynamic/4/8/8          -0.5429         -0.5421           381           174           380           174
BM_MatrixTransposeMatrixMultiplyDynamic/4/10/2         +0.0612         +0.0620           135           143           135           143
BM_MatrixTransposeMatrixMultiplyDynamic/4/10/4         -0.3269         -0.3263           259           174           258           174
BM_MatrixTransposeMatrixMultiplyDynamic/4/10/6         -0.2955         -0.2961           343           242           343           241
BM_MatrixTransposeMatrixMultiplyDynamic/4/10/8         -0.5484         -0.5475           466           210           465           210
BM_MatrixTransposeMatrixMultiplyDynamic/4/12/2         +0.1234         +0.1239           157           177           157           177
BM_MatrixTransposeMatrixMultiplyDynamic/4/12/4         -0.3002         -0.2997           291           204           291           204
BM_MatrixTransposeMatrixMultiplyDynamic/4/12/6         -0.3419         -0.3415           415           273           415           273
BM_MatrixTransposeMatrixMultiplyDynamic/4/12/8         -0.5604         -0.5600           545           239           544           239
BM_MatrixTransposeMatrixMultiplyDynamic/4/15/2         +0.1730         +0.1712           185           217           185           216
BM_MatrixTransposeMatrixMultiplyDynamic/4/15/4         -0.3099         -0.3097           346           239           346           239
BM_MatrixTransposeMatrixMultiplyDynamic/4/15/6         -0.3743         -0.3741           521           326           521           326
BM_MatrixTransposeMatrixMultiplyDynamic/4/15/8         -0.5411         -0.5409           654           300           654           300
BM_MatrixTransposeMatrixMultiplyDynamic/6/2/2          +0.2546         +0.2547            41            51            41            51
BM_MatrixTransposeMatrixMultiplyDynamic/6/2/4          -0.0940         -0.0942            66            60            66            60
BM_MatrixTransposeMatrixMultiplyDynamic/6/2/6          -0.1584         -0.1585            95            80            95            80
BM_MatrixTransposeMatrixMultiplyDynamic/6/2/8          -0.4333         -0.4329           130            74           130            74
BM_MatrixTransposeMatrixMultiplyDynamic/6/4/2          +0.1951         +0.1952            69            82            69            82
BM_MatrixTransposeMatrixMultiplyDynamic/6/4/4          -0.2034         -0.2034           123            98           123            98
BM_MatrixTransposeMatrixMultiplyDynamic/6/4/6          -0.1998         -0.1995           178           142           178           142
BM_MatrixTransposeMatrixMultiplyDynamic/6/4/8          -0.4348         -0.4347           233           131           233           131
BM_MatrixTransposeMatrixMultiplyDynamic/6/5/2          +0.5517         +0.5521            82           128            82           128
BM_MatrixTransposeMatrixMultiplyDynamic/6/5/4          -0.1427         -0.1427           145           124           145           124
BM_MatrixTransposeMatrixMultiplyDynamic/6/5/6          -0.1846         -0.1846           220           179           220           179
BM_MatrixTransposeMatrixMultiplyDynamic/6/5/8          -0.4871         -0.4873           290           149           290           148
BM_MatrixTransposeMatrixMultiplyDynamic/6/8/2          +0.3469         +0.3473           131           176           131           176
BM_MatrixTransposeMatrixMultiplyDynamic/6/8/4          -0.1013         -0.1018           248           223           248           222
BM_MatrixTransposeMatrixMultiplyDynamic/6/8/6          -0.1652         -0.1670           354           295           353           294
BM_MatrixTransposeMatrixMultiplyDynamic/6/8/8          -0.4302         -0.4299           447           255           447           255
BM_MatrixTransposeMatrixMultiplyDynamic/6/10/2         +0.4005         +0.4001           157           219           157           219
BM_MatrixTransposeMatrixMultiplyDynamic/6/10/4         -0.0439         -0.0441           295           282           294           281
BM_MatrixTransposeMatrixMultiplyDynamic/6/10/6         -0.1031         -0.1074           420           377           420           375
BM_MatrixTransposeMatrixMultiplyDynamic/6/10/8         -0.3655         -0.3679           556           353           555           351
BM_MatrixTransposeMatrixMultiplyDynamic/6/12/2         +0.5654         +0.5604           183           287           183           286
BM_MatrixTransposeMatrixMultiplyDynamic/6/12/4         -0.1118         -0.1116           353           314           353           314
BM_MatrixTransposeMatrixMultiplyDynamic/6/12/6         -0.2045         -0.2053           517           411           516           410
BM_MatrixTransposeMatrixMultiplyDynamic/6/12/8         -0.4662         -0.4660           657           350           656           350
BM_MatrixTransposeMatrixMultiplyDynamic/6/15/2         +0.3582         +0.3588           242           328           241           328
BM_MatrixTransposeMatrixMultiplyDynamic/6/15/4         -0.1403         -0.1407           428           368           428           367
BM_MatrixTransposeMatrixMultiplyDynamic/6/15/6         -0.2424         -0.2421           632           479           632           479
BM_MatrixTransposeMatrixMultiplyDynamic/6/15/8         -0.5094         -0.5092           835           410           834           409
BM_MatrixTransposeMatrixMultiplyDynamic/8/2/2          +0.3930         +0.3925            47            66            47            66
BM_MatrixTransposeMatrixMultiplyDynamic/8/2/4          +0.0226         +0.0215            78            80            78            80
BM_MatrixTransposeMatrixMultiplyDynamic/8/2/6          -0.0428         -0.0427           105           100           105           100
BM_MatrixTransposeMatrixMultiplyDynamic/8/2/8          -0.3418         -0.3437           141            93           141            92
BM_MatrixTransposeMatrixMultiplyDynamic/8/4/2          +0.3927         +0.3924            85           118            85           118
BM_MatrixTransposeMatrixMultiplyDynamic/8/4/4          -0.0040         -0.0039           137           136           136           136
BM_MatrixTransposeMatrixMultiplyDynamic/8/4/6          -0.0342         -0.0339           204           197           204           197
BM_MatrixTransposeMatrixMultiplyDynamic/8/4/8          -0.3575         -0.3577           267           171           267           171
BM_MatrixTransposeMatrixMultiplyDynamic/8/5/2          +0.7014         +0.7033            99           168            99           168
BM_MatrixTransposeMatrixMultiplyDynamic/8/5/4          +0.0952         +0.0952           163           179           163           179
BM_MatrixTransposeMatrixMultiplyDynamic/8/5/6          -0.1164         -0.1163           246           218           246           218
BM_MatrixTransposeMatrixMultiplyDynamic/8/5/8          -0.3550         -0.3565           322           208           322           207
BM_MatrixTransposeMatrixMultiplyDynamic/8/8/2          +0.7074         +0.7072           140           239           140           239
BM_MatrixTransposeMatrixMultiplyDynamic/8/8/4          +0.1072         +0.1075           276           306           276           306
BM_MatrixTransposeMatrixMultiplyDynamic/8/8/6          -0.0771         -0.0768           398           368           398           367
BM_MatrixTransposeMatrixMultiplyDynamic/8/8/8          -0.3614         -0.3612           524           335           524           335
BM_MatrixTransposeMatrixMultiplyDynamic/8/10/2         +0.6979         +0.7004           184           313           184           312
BM_MatrixTransposeMatrixMultiplyDynamic/8/10/4         +0.0967         +0.0955           326           357           325           356
BM_MatrixTransposeMatrixMultiplyDynamic/8/10/6         -0.0248         -0.0239           486           474           485           474
BM_MatrixTransposeMatrixMultiplyDynamic/8/10/8         -0.3432         -0.3437           603           396           603           396
BM_MatrixTransposeMatrixMultiplyDynamic/8/12/2         +0.5977         +0.5985           210           335           210           335
BM_MatrixTransposeMatrixMultiplyDynamic/8/12/4         -0.0530         -0.0484           405           384           403           384
BM_MatrixTransposeMatrixMultiplyDynamic/8/12/6         -0.0557         -0.0561           574           542           574           541
BM_MatrixTransposeMatrixMultiplyDynamic/8/12/8         -0.2835         -0.2849           730           523           730           522
BM_MatrixTransposeMatrixMultiplyDynamic/8/15/2         +0.7117         +0.7085           254           434           254           433
BM_MatrixTransposeMatrixMultiplyDynamic/8/15/4         +0.0630         +0.0602           458           487           458           486
BM_MatrixTransposeMatrixMultiplyDynamic/8/15/6         -0.0321         -0.0330           662           641           662           640
BM_MatrixTransposeMatrixMultiplyDynamic/8/15/8         -0.3974         -0.3978           911           549           910           548

Change-Id: I09d87c1885be86177b93c8fe0e6f89a75eb2f7a1
2018-02-26 00:17:51 +00:00
Keir Mierle 22fa21c6f8 Build benchmarks with Bazel
Change-Id: I559cc1aa17d5be01dcff931e05b22e0dd9e248b6
2018-02-25 15:18:26 -08:00
Keir Mierle a3b1e19c2c Add examples to the Bazel build
Also moves the gflags namespace define
into the ceres_library() target.

Change-Id: Ibb8f3fdd9a8c371fe96b475f752f8320ffe63cdc
2018-02-25 14:55:27 -08:00
Sameer Agarwal d634d6168e Add small_blas_gemm_benchmark.
Change-Id: Ide8c86c77c4adf73a3f5b6be4f23ab3d59705f7b
2018-02-25 14:42:06 -08:00
Emil Ernerfeldt 39ccb79ae6 Implement some C++11 math functions for Jet
Change-Id: Ie164aeaac980cd2fe48a86230e1948c9fd75424a
2018-02-25 21:48:48 +00:00
Sameer Agarwal 6c835f81a7 Improve the performance of MatrixTransposeVector Multiply.
This is done by making the matrix access more cache coherent.
For small matrices there isn't much difference, but for
larger matrices like 4x20, this leads to ~50% performance
improvement.

Benchmark                                        Time             CPU      Time Old      Time New       CPU Old       CPU New
-----------------------------------------------------------------------------------------------------------------------------
BM_MatrixVectorMultiply/1/1                   +0.0138         +0.0046            10            10            10            10
BM_MatrixVectorMultiply/1/2                   +0.0215         +0.0146            10            11            10            10
BM_MatrixVectorMultiply/1/3                   +0.0469         +0.0422            10            10            10            10
BM_MatrixVectorMultiply/1/4                   +0.0696         +0.0671            10            11            10            11
BM_MatrixVectorMultiply/1/6                   +0.0827         +0.0795            12            13            12            13
BM_MatrixVectorMultiply/1/7                   +0.1408         +0.1152            13            15            13            14
BM_MatrixVectorMultiply/1/12                  +0.0317         +0.0232            17            18            17            17
BM_MatrixVectorMultiply/1/16                  -0.0362         -0.0168            21            20            20            20
BM_MatrixVectorMultiply/1/20                  +0.0304         +0.0290            22            22            22            22
BM_MatrixVectorMultiply/2/1                   +0.0019         +0.0009            10            10            10            10
BM_MatrixVectorMultiply/2/2                   +0.0285         +0.0291            11            12            11            12
BM_MatrixVectorMultiply/2/3                   -0.1178         -0.0977            16            14            15            14
BM_MatrixVectorMultiply/2/4                   +0.0938         +0.1144            15            17            15            17
BM_MatrixVectorMultiply/2/6                   +0.0617         +0.0629            17            18            17            18
BM_MatrixVectorMultiply/2/7                   +0.0956         +0.0876            20            22            19            21
BM_MatrixVectorMultiply/2/12                  +0.0043         +0.0119            24            24            24            24
BM_MatrixVectorMultiply/2/16                  +0.0361         +0.0337            29            30            29            30
BM_MatrixVectorMultiply/2/20                  +0.0463         +0.0365            33            35            33            34
BM_MatrixVectorMultiply/3/1                   -0.0201         -0.0210            12            12            12            11
BM_MatrixVectorMultiply/3/2                   -0.0741         -0.0766            16            15            16            15
BM_MatrixVectorMultiply/3/3                   -0.0076         -0.0118            18            18            18            18
BM_MatrixVectorMultiply/3/4                   +0.1071         +0.0963            19            21            19            21
BM_MatrixVectorMultiply/3/6                   +0.0449         +0.0390            23            24            23            23
BM_MatrixVectorMultiply/3/7                   +0.1099         +0.1018            25            28            24            27
BM_MatrixVectorMultiply/3/12                  +0.1512         +0.0992            33            38            32            35
BM_MatrixVectorMultiply/3/16                  +0.2281         +0.2005            37            46            37            44
BM_MatrixVectorMultiply/3/20                  +0.2387         +0.1799            49            61            48            57
BM_MatrixVectorMultiply/4/1                   +0.4444         +0.2574            14            21            14            18
BM_MatrixVectorMultiply/4/2                   +0.0313         +0.0230            19            20            19            20
BM_MatrixVectorMultiply/4/3                   +0.0626         +0.0596            23            24            23            24
BM_MatrixVectorMultiply/4/4                   +0.2322         +0.1440            23            28            23            26
BM_MatrixVectorMultiply/4/6                   +0.0936         +0.0768            26            29            26            28
BM_MatrixVectorMultiply/4/7                   +0.0848         +0.0835            28            30            28            30
BM_MatrixVectorMultiply/4/12                  +0.1607         +0.1101            39            46            39            43
BM_MatrixVectorMultiply/4/16                  +0.0752         +0.0687            48            52            48            51
BM_MatrixVectorMultiply/4/20                  +0.1782         +0.1463            61            72            60            69
BM_MatrixTransposeVectorMultiply/1/1          +0.3609         +0.2857             9            13             9            12
BM_MatrixTransposeVectorMultiply/1/2          +0.3106         +0.2970            10            13            10            12
BM_MatrixTransposeVectorMultiply/1/3          +0.3018         +0.2383            11            14            11            13
BM_MatrixTransposeVectorMultiply/1/4          -0.0795         -0.0819            14            13            14            12
BM_MatrixTransposeVectorMultiply/1/6          -0.0108         -0.0629            18            18            18            16
BM_MatrixTransposeVectorMultiply/1/7          -0.1073         -0.0879            20            18            19            17
BM_MatrixTransposeVectorMultiply/1/12         -0.3035         -0.3016            26            18            26            18
BM_MatrixTransposeVectorMultiply/1/16         -0.4909         -0.4951            39            20            38            19
BM_MatrixTransposeVectorMultiply/1/20         -0.4619         -0.4985            43            23            42            21
BM_MatrixTransposeVectorMultiply/2/1          +0.3471         +0.2906            10            13            10            13
BM_MatrixTransposeVectorMultiply/2/2          +0.2323         +0.2266            12            15            12            15
BM_MatrixTransposeVectorMultiply/2/3          +0.0802         +0.0779            16            17            16            17
BM_MatrixTransposeVectorMultiply/2/4          -0.0951         -0.0983            19            17            19            17
BM_MatrixTransposeVectorMultiply/2/6          -0.0974         -0.1064            24            21            24            21
BM_MatrixTransposeVectorMultiply/2/7          +0.0612         -0.0457            27            29            27            26
BM_MatrixTransposeVectorMultiply/2/12         -0.3777         -0.3838            41            25            41            25
BM_MatrixTransposeVectorMultiply/2/16         -0.4783         -0.4843            53            28            53            27
BM_MatrixTransposeVectorMultiply/2/20         -0.5567         -0.5566            71            32            70            31
BM_MatrixTransposeVectorMultiply/3/1          +0.4607         +0.4753            10            15            10            15
BM_MatrixTransposeVectorMultiply/3/2          +0.2870         +0.2754            14            19            14            18
BM_MatrixTransposeVectorMultiply/3/3          +0.1270         +0.1245            19            21            19            21
BM_MatrixTransposeVectorMultiply/3/4          +0.0160         +0.0076            22            22            22            22
BM_MatrixTransposeVectorMultiply/3/6          -0.0612         -0.0635            27            26            27            25
BM_MatrixTransposeVectorMultiply/3/7          -0.0531         -0.0695            31            29            30            28
BM_MatrixTransposeVectorMultiply/3/12         -0.4009         -0.3938            49            29            47            29
BM_MatrixTransposeVectorMultiply/3/16         -0.4584         -0.4537            64            35            62            34
BM_MatrixTransposeVectorMultiply/3/20         -0.5087         -0.5098            78            38            77            38
BM_MatrixTransposeVectorMultiply/4/1          +0.6696         +0.6837            11            18            11            18
BM_MatrixTransposeVectorMultiply/4/2          +0.3085         +0.3085            17            22            17            22
BM_MatrixTransposeVectorMultiply/4/3          +0.2908         +0.2821            21            26            20            26
BM_MatrixTransposeVectorMultiply/4/4          +0.0076         -0.0031            24            25            24            24
BM_MatrixTransposeVectorMultiply/4/6          -0.0884         -0.0841            34            31            34            31
BM_MatrixTransposeVectorMultiply/4/7          -0.0834         -0.0825            37            34            36            33
BM_MatrixTransposeVectorMultiply/4/12         -0.4477         -0.4453            62            34            61            34
BM_MatrixTransposeVectorMultiply/4/16         -0.5324         -0.5203            86            40            83            40
BM_MatrixTransposeVectorMultiply/4/20         -0.4905         -0.4933            99            50            98            50

Change-Id: I7f2a1c986e4a345bb67cb9eb0235234573024889
2018-02-25 13:44:22 -08:00
Sameer Agarwal 72cb66cb8f Refactor small_blas_benchmark.cc
1. Rename it to small_blas_gemv_benchmark.cc to better reflect
   its coverage.
2. Simplify the data generation.
3. Make the two vectors and the matrix in each element live in
   separate arrays to ensure that they are not cache coherent.
4. Use "Apply" instead of ArgPair to simplify and unify the
   matrix sizes.
5. Update the benchmark numbers and move them to a json
   file in the benchmarks directory.

Change-Id: Iaf3764083f902258def739c4be42e0580be103cb
2018-02-25 13:21:20 -08:00
Alex Stewart 1141f4ad1a Fix integer conversion warning in MSVC.
- Raised by cnovel as issue #346:
  https://github.com/ceres-solver/ceres-solver/issues/346.

Change-Id: I90815ab6412834dd793ca7c327002d551da0675b
2018-02-24 18:51:54 +00:00
Mike Vitus 126e0ef0fe Adds missing source and tests to bazel build.
Change 12060 added parallel_for_tbb.cc and parallel_for_test.cc but did not add
it to the bazel build rule.

Tested by running bazel tests.

Change-Id: I286cf0e191e0353f2c0266911a79e01f09e47343
2018-02-22 11:08:50 -08:00
Keir Mierle d2090cd10a Improve NDK build error handling
Change-Id: I1dd51d8c5d3b8eef829f60a72c8c869e18b64830
2018-02-22 15:11:03 +00:00
Mike Vitus 27789c0d96 Adds a ThreadPool and a thread-safe ConcurrentQueue.
This is in preparation for adding support for a C++11 based parallel
for implementation. The code is behind CERES_USE_CXX11_THREADS which
is not exposed to the user yet.

Tested by building with and without CERES_USE_CXX11_THREADS defined
and the tests pass.

Change-Id: I60f5730fa055feeb0ee0fa6c980633aebd8d87b4
2018-02-21 15:40:06 -08:00
Keir Mierle 523de29803 Fix build: -Wreorder, test fail
Change-Id: I7e032a9017470612fe233c3eecd51c37020dee64
2018-02-21 15:09:37 -08:00
Sameer Agarwal 9d02b76dce An implementation of SubsetPreconditioner.
The key idea being, use some subset of the rows of the Jacobian
as the preconditioner.

This CL only implements the preconditioner assuming that the row
selection has already been done. How the rows are selected will be
left to the user based on their knowledge of the problem.

A follow up CL will hook this preconditioner into the rest of the
solver.

Change-Id: I3e18dc57811116534e9ddf35d7b154bcce496d3b
2018-02-21 13:58:45 -08:00
Sameer Agarwal ff8a13d4a5 Add a benchmark for small_blas.h
This CL adds a benchmark for MatrixVectorMultiply and
MatrixTransposeVectorMultiply.

Change-Id: I50e1cec72c91dedf081b6f00681874abf545123b
2018-02-21 13:30:27 -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
Alex Stewart 2f99a2a37d Require Eigen >= 3.3.4 on aarch64.
- Raised as issue #289:
  https://github.com/ceres-solver/ceres-solver/issues/289.

Change-Id: I35888bf7eb3498cefbf02dadc893b231e0a9229f
2018-02-19 02:12:52 +00:00
Mike Vitus dc5ea0ea4d Adds a ParallelFor wrapper for tbb::parallel_for.
This is in preparation for adding support for a c++11 based parallel
for implementation. The parallel for abstraction does not have the
ability to constrain the total number of threads in nested for loops.
This is solved by distributing the number of threads evenly between
the nested for loops. Adds a TODO to consolidate the next for loops
into a single loop that can be properly split between threads.

Tested by building with TBB and running tests.

Change-Id: I546973b9a4d19b9cdd53caff55d1c80bac8ea953
2018-02-16 14:24:17 -08:00
Alex Stewart c426f464ab Fix TBB detection on Windows.
- Reported as issue #334 by anuppari:
  https://github.com/ceres-solver/ceres-solver/issues/334.

Change-Id: Ie8af4b3ce7ef97e471deb780e2b7d683dcb0d658
2018-02-15 19:14:08 +00:00
Keir Mierle 1af2747421 Support disabling Schur specializations in Bazel build
Change-Id: If72bcd9f19ba4b44482b267e45fb2355b1a93ff0
2018-02-08 13:38:00 -08:00
Sameer Agarwal 2145c10539 Improve ExecutionSummary
1. Replace two maps by 1.
2. Update number of calls and the time for the call at the cost
   of a single map lookup.
3. Add Solver::Summary::num_linear_solves.

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

Change-Id: I71eb9be7fb363a8cb066591c4c1761f256c81677
2018-02-05 16:37:27 -08:00
Sameer Agarwal 0251359830 A bunch of minor changes.
1. Fix a typo in auto_diff_cost_function.h
2. Fix and update Solver::Summary::FullReport() text labels.
3. Add logging of the number of residual and jacobian evaluations
   to the full report. The GradientProblemSolver already does this.

Change-Id: I41059af5f0ebe0417accbbc30b0808a4b04b9edb
2018-02-05 15:51:08 -08:00
Sameer Agarwal 0ca99358cc Remove as typo from callbacks.h
Change-Id: I69fdae40adaed812454d7ff4d7e8909a5539e304
2018-02-02 15:01:03 -08:00
Mike Vitus c82dd50962 Removes two unimplemented class functions.
General clean up to the Ceres codebase to remove the functions
Evaluator::Evaluate and ProblemImpl::InternalEvaluate as they are unimplemented.

Change-Id: I77fcb2c5f43aeca69555e953d6472b6c4cd1b778
2018-01-31 20:21:05 +00:00
Sameer Agarwal 78d49f4682 Update EigenTypes to deal with 1 column matrices
Most matrices in Ceres are row-major. Eigen does now
allow statically sized row-major matrices with a single
column.

This CL changes the EigenTypes struct to change the definition
of typedefs to change to ColMajor if this is the case.

This will allow Schur specializations (2,1,6) for example.

Change-Id: I24e7b62d4e1cb5660541062336225bbc9c41c6bf
2018-01-31 04:57:54 -08:00
Sameer Agarwal 202dd9f3a1 Add GradientProblemSolver::Options::update_state_every_iteration
The non-linear least squares solver had the ability to update the
user's parameters every iteration. Now GradientProblemSolver can
do the same.

Also a few minor Sphinx markup related cleanup to the documentation
which were found in the process of updating Sphinx on my machine
and adding the docs for this feature.

This fixes https://github.com/ceres-solver/ceres-solver/issues/246

Change-Id: Ib6b90ac22be8bfb60b14f25ad52082ba371af164
2018-01-25 21:30:09 -08:00
Mike Vitus 30b862d126 Fixes the pose graph example documentation.
Change-Id: Ia20f1463c042785bdae32568de77750d41963c3c
2018-01-19 16:06:00 -08:00
Rodrigo Queiro c12aae5860 Fix macOS build by updating glog
This includes https://github.com/google/glog/pull/285.

Change-Id: I4844d24ae7fc3187d4f4983e34d3a8066422a9c9
2018-01-16 17:09:06 +01:00
Rodrigo Queiro c1075cd313 Create ceres_library() and use to provide :ceres
This doesn't add any configurability to ceres_library() yet, but it
does correctly determine the include path for use with -I, allowing
this to be used as a dependency from other workspaces.

Change-Id: I223b6e63c2ea82ab7f552337f78fffd54f20b0e0
2018-01-15 15:28:13 +01:00
Rodrigo Queiro ac22a97492 Run buildifier on BUILD/WORKSPACE
Change-Id: I80bf7025811128c0795bff3e3f5b61a355d848ba
2018-01-15 15:26:19 +01:00
Rodrigo Queiro 093223454c Add bazel output to .gitignore
Change-Id: Ic7a300381badaf9c5c795da7f82ed10e5a433c3b
2018-01-15 12:23:15 +01:00