Libmv: update ceres to latest upstream version
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 30 Sep 2014 08:49:34 +0000 (14:49 +0600)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 30 Sep 2014 08:50:05 +0000 (14:50 +0600)
This brings faster BlockRandomAccessSparseMatrix::SymmetricRightMultiply.

extern/libmv/third_party/ceres/ChangeLog
extern/libmv/third_party/ceres/internal/ceres/block_jacobi_preconditioner.cc
extern/libmv/third_party/ceres/internal/ceres/block_jacobi_preconditioner.h
extern/libmv/third_party/ceres/internal/ceres/block_random_access_sparse_matrix.cc
extern/libmv/third_party/ceres/internal/ceres/block_random_access_sparse_matrix.h
extern/libmv/third_party/ceres/internal/ceres/solver.cc

index ee67da5afb95191771076e56980c23616568e679..6f92154201992e549d055b6fde269fb5b4431288 100644 (file)
@@ -1,3 +1,25 @@
+commit 9e11cd16d09403b9270e621e839d5948b6a74b8d
+Author: Sameer Agarwal <sameeragarwal@google.com>
+Date:   Mon Sep 29 14:27:58 2014 -0700
+
+    Faster  BlockRandomAccessSparseMatrix::SymmetricRightMultiply.
+    
+    Trade a small amount of memory to improve the cache coherency of
+    the SymmetricRightMultiply operation.
+    
+    The resulting code leads to a 10-20% speedup in the linear solver
+    end to end.
+    
+    Change-Id: I8ab2fe152099e849b211b5b19e4ef9f03d8e7f1c
+
+commit 46b8461fd010c1e7ffce6bb2bdf8a84b659d5e09
+Author: Sameer Agarwal <sameeragarwal@google.com>
+Date:   Mon Sep 29 15:10:58 2014 -0700
+
+    Various minor fixes from William Rucklidge.
+    
+    Change-Id: Ibe731d5db374ad8ee148d62a9fdd8d726b607a3f
+
 commit b44cfdef25f6bf0917a23b3fd65cce38aa6a3362
 Author: Sameer Agarwal <sameeragarwal@google.com>
 Date:   Mon Sep 29 07:53:54 2014 -0700
@@ -647,19 +669,3 @@ Date:   Thu Aug 7 12:19:10 2014 -0700
     construction is the right thing to do.
     
     Change-Id: I3bfdc89bb0027c8d67cde937e8f2fa385d89c30c
-
-commit cfb36463f9c1f806121779d651c7105ad899bb20
-Author: Sameer Agarwal <sameeragarwal@google.com>
-Date:   Tue Aug 5 14:42:33 2014 -0700
-
-    Small fixes from William Rucklidge.
-    
-    Change-Id: I0be52f0f1e53cedccffe4807dc664a2f3fb4a8e4
-
-commit 9a41132a0523af407b53644c07900f86aa6fceac
-Author: Sameer Agarwal <sameeragarwal@google.com>
-Date:   Mon Aug 4 22:45:53 2014 -0700
-
-    Small changes from Jim Roseborough.
-    
-    Change-Id: Ic8b19ea5c5f4f8fd782eb4420b30514153087d18
index ea49f077e37b706367520446dd287ed0b2fe54d5..7f79a4f993d16cbea5a15c7ac57bc5ff1cf973da 100644 (file)
@@ -102,9 +102,5 @@ void BlockJacobiPreconditioner::RightMultiply(const double* x,
   m_->RightMultiply(x, y);
 }
 
-void BlockJacobiPreconditioner::LeftMultiply(const double* x, double* y) const {
-  m_->RightMultiply(x, y);
-}
-
 }  // namespace internal
 }  // namespace ceres
index 857929709250c447503fd78b57115a2a74d43717..e23e0e2d24c159cb373442021cc983091761b7ef 100644 (file)
@@ -60,7 +60,6 @@ class BlockJacobiPreconditioner : public BlockSparseMatrixPreconditioner {
 
   // Preconditioner interface
   virtual void RightMultiply(const double* x, double* y) const;
-  virtual void LeftMultiply(const double* x, double* y) const;
   virtual int num_rows() const { return m_->num_rows(); }
   virtual int num_cols() const { return m_->num_rows(); }
 
index 9da16a469d5608967e4f0098e52536abdb1ae75e..c43a9b78feb700cc78c41d29764b286caca9186c 100644 (file)
@@ -88,6 +88,8 @@ BlockRandomAccessSparseMatrix::BlockRandomAccessSparseMatrix(
        ++it) {
     const int row_block_size = blocks_[it->first];
     const int col_block_size = blocks_[it->second];
+    cell_values_.push_back(make_pair(make_pair(it->first, it->second),
+                                     values + pos));
     layout_[IntPairToLong(it->first, it->second)] =
         new CellInfo(values + pos);
     pos += row_block_size * col_block_size;
@@ -156,20 +158,19 @@ void BlockRandomAccessSparseMatrix::SetZero() {
 
 void BlockRandomAccessSparseMatrix::SymmetricRightMultiply(const double* x,
                                                            double* y) const {
-  for (LayoutType::const_iterator it = layout_.begin();
-       it != layout_.end();
-       ++it) {
-    int row;
-    int col;
-    LongToIntPair(it->first, &row, &col);
-
+  vector< pair<pair<int, int>, double*> >::const_iterator it =
+      cell_values_.begin();
+  for (; it != cell_values_.end(); ++it) {
+    const int row = it->first.first;
     const int row_block_size = blocks_[row];
     const int row_block_pos = block_positions_[row];
+
+    const int col = it->first.second;
     const int col_block_size = blocks_[col];
     const int col_block_pos = block_positions_[col];
 
     MatrixVectorMultiply<Eigen::Dynamic, Eigen::Dynamic, 1>(
-        it->second->values, row_block_size, col_block_size,
+        it->second, row_block_size, col_block_size,
         x + col_block_pos,
         y + row_block_pos);
 
@@ -179,7 +180,7 @@ void BlockRandomAccessSparseMatrix::SymmetricRightMultiply(const double* x,
     // triangular multiply also.
     if (row != col) {
       MatrixTransposeVectorMultiply<Eigen::Dynamic, Eigen::Dynamic, 1>(
-          it->second->values, row_block_size, col_block_size,
+          it->second, row_block_size, col_block_size,
           x + row_block_pos,
           y + col_block_pos);
     }
index a4f89d8130f54ceec585fdf8b52999ac248a9a0d..51b5d20cfe01c55eabcd779a506b736df3426ca5 100644 (file)
@@ -111,6 +111,10 @@ class BlockRandomAccessSparseMatrix : public BlockRandomAccessMatrix {
   typedef HashMap<long int, CellInfo* > LayoutType;
   LayoutType layout_;
 
+  // In order traversal of contents of the matrix. This allows us to
+  // implement a matrix-vector which is 20% faster than using the
+  // iterator in the Layout object instead.
+  vector<pair<pair<int, int>, double*> > cell_values_;
   // The underlying matrix object which actually stores the cells.
   scoped_ptr<TripletSparseMatrix> tsm_;
 
index e1c5ee30ba5d42e7711a330be4cc7947ed1b1c71..3512e156f9e71438f6ee23f6505560baedc4345d 100644 (file)
@@ -123,7 +123,7 @@ bool TrustRegionOptionsAreValid(const Solver::Options& options, string* error) {
   if (options.linear_solver_type == ITERATIVE_SCHUR &&
       options.use_explicit_schur_complement &&
       options.preconditioner_type != SCHUR_JACOBI) {
-    *error =  "use_explicit_schur_complement only supports"
+    *error =  "use_explicit_schur_complement only supports "
         "SCHUR_JACOBI as the preconditioner.";
     return false;
   }