Use threaded cost function and jacobian computation
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 26 Feb 2013 17:52:10 +0000 (17:52 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 26 Feb 2013 17:52:10 +0000 (17:52 +0000)
Also made it theraded linear solver, seems it makes
sense for iterative schur with inner iterations
enabled.

Use OpenMO's max therads called from bundler code
to detect how many threads to use. Could be changed
in a way that number of threads is passing in options
from blender side in the future.

Also removed redundant V3D definition from compiler's
flags.

extern/libmv/CMakeLists.txt
extern/libmv/bundle.sh
extern/libmv/libmv/simple_pipeline/bundle.cc
extern/libmv/third_party/ceres/CMakeLists.txt
extern/libmv/third_party/ceres/SConscript
extern/libmv/third_party/ceres/bundle.sh

index 200e20de91bbcc085cd6bd562b643364cbda5f2a..1c289cd27786385176c5beccc5c85d2bc76376b4 100644 (file)
@@ -216,7 +216,6 @@ else()
 endif()
 
 add_definitions(
-       -DV3DLIB_ENABLE_SUITESPARSE
        -DGOOGLE_GLOG_DLL_DECL=
 )
 
index 6b26bd95157c909589d391ef516ad76b7934582f..21d0308268af0179b4f80f71f30ec10a52338869 100755 (executable)
@@ -195,7 +195,6 @@ ${third_glog_headers}
 endif()
 
 add_definitions(
-       -DV3DLIB_ENABLE_SUITESPARSE
        -DGOOGLE_GLOG_DLL_DECL=
 )
 
@@ -218,7 +217,6 @@ Import('env')
 
 defs = []
 
-defs.append('V3DLIB_ENABLE_SUITESPARSE')
 defs.append('GOOGLE_GLOG_DLL_DECL=')
 
 src = env.Glob("*.cpp")
index 7502ca389c4f1c31f1077e4b5fc113371ec819b0..c29eb3d5df6664e635c5f313b361d361e4668c86 100644 (file)
 #include "libmv/simple_pipeline/reconstruction.h"
 #include "libmv/simple_pipeline/tracks.h"
 
+#ifdef _OPENMP
+#  include <omp.h>
+#endif
+
 namespace libmv {
 
 // The intrinsics need to get combined into a single parameter block; use these
@@ -332,6 +336,11 @@ void EuclideanBundleCommonIntrinsics(const Tracks &tracks,
   options.use_inner_iterations = true;
   options.max_num_iterations = 100;
 
+#ifdef _OPENMP
+  options.num_threads = omp_get_max_threads();
+  options.num_linear_solver_threads = omp_get_max_threads();
+#endif
+
   ceres::Solver::Summary summary;
   ceres::Solve(options, &problem, &summary);
 
index 5e58c2964cefdc7d4b32119dd228c4ac67ca13cb..b71fe1d5cdb489fdb38fe32a15df8d1ec1313bc6 100644 (file)
@@ -261,8 +261,15 @@ add_definitions(
        -DCERES_NO_CXSPARSE
        -DCERES_NO_PROTOCOL_BUFFERS
        -DCERES_RESTRICT_SCHUR_SPECIALIZATION
+       -DCERES_HAVE_RWLOCK
 )
 
+if(WITH_OPENMP)
+       add_definitions(
+               -DCERES_USE_OPENMP
+       )
+endif()
+
 if(MSVC10)
        add_definitions(
                -D"CERES_HASH_NAMESPACE_START=namespace std {"
index 6d0d2cd5c4056c4b4965b813a0028048d1d3249b..6e490cfd5cfe36d7986de2676eeaa209c7e41558 100644 (file)
@@ -23,6 +23,10 @@ defs.append('CERES_NO_SUITESPARSE')
 defs.append('CERES_NO_CXSPARSE')
 defs.append('CERES_NO_PROTOCOL_BUFFERS')
 defs.append('CERES_RESTRICT_SCHUR_SPECIALIZATION')
+defs.append('CERES_HAVE_RWLOCK')
+
+if env['WITH_BF_OPENMP']:
+    defs.append('CERES_USE_OPENMP')
 
 if 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
     defs.append('CERES_NO_TR1')
index b2c8330ec3e8f19dbdb4caa66ac03c42a41759da..65af263f7c46996740ebcfc084e3560ba86495ae 100755 (executable)
@@ -162,8 +162,15 @@ add_definitions(
        -DCERES_NO_CXSPARSE
        -DCERES_NO_PROTOCOL_BUFFERS
        -DCERES_RESTRICT_SCHUR_SPECIALIZATION
+       -DCERES_HAVE_RWLOCK
 )
 
+if(WITH_OPENMP)
+       add_definitions(
+               -DCERES_USE_OPENMP
+       )
+endif()
+
 if(MSVC10)
        add_definitions(
                -D"CERES_HASH_NAMESPACE_START=namespace std {"
@@ -213,6 +220,10 @@ defs.append('CERES_NO_SUITESPARSE')
 defs.append('CERES_NO_CXSPARSE')
 defs.append('CERES_NO_PROTOCOL_BUFFERS')
 defs.append('CERES_RESTRICT_SCHUR_SPECIALIZATION')
+defs.append('CERES_HAVE_RWLOCK')
+
+if env['WITH_BF_OPENMP']:
+    defs.append('CERES_USE_OPENMP')
 
 if 'Mac OS X 10.5' in env['MACOSX_SDK_CHECK']:
     defs.append('CERES_NO_TR1')