[Bf-blender-cvs] [4dee97ec5a5] temp-cxx-upgrade: Ceres: Switch from OpenMP to C++ threads

Sergey Sharybin noreply at git.blender.org
Thu Jun 18 11:35:36 CEST 2020


Commit: 4dee97ec5a55d95326dba61e20288927daf94f74
Author: Sergey Sharybin
Date:   Thu Jun 18 11:34:58 2020 +0200
Branches: temp-cxx-upgrade
https://developer.blender.org/rB4dee97ec5a55d95326dba61e20288927daf94f74

Ceres: Switch from OpenMP to C++ threads

Should fix unit test linking, and is something we want to use anyway.

===================================================================

M	CMakeLists.txt
M	extern/ceres/CMakeLists.txt
M	extern/ceres/bundle.sh
M	intern/libmv/libmv/simple_pipeline/bundle.cc

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90133cb7338..c04f2600894 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1245,7 +1245,7 @@ endif()
 
 if(WITH_LIBMV)
   # We always have C++11 which includes unordered_map.
-  set(CERES_DEFINES "-DCERES_STD_UNORDERED_MAP;-DCERES_USE_OPENMP")
+  set(CERES_DEFINES "-DCERES_STD_UNORDERED_MAP;-DCERES_USE_CXX_THREADS")
 endif()
 
 #-----------------------------------------------------------------------------
diff --git a/extern/ceres/CMakeLists.txt b/extern/ceres/CMakeLists.txt
index 14de8cd6906..51cf9657319 100644
--- a/extern/ceres/CMakeLists.txt
+++ b/extern/ceres/CMakeLists.txt
@@ -377,7 +377,7 @@ add_definitions(
   -DCERES_NO_LAPACK
   -DCERES_NO_ACCELERATE_SPARSE
   -DCERES_HAVE_RWLOCK
-  -DCERES_USE_OPENMP
+  -DCERES_USE_CXX_THREADS
 )
 
 blender_add_lib(extern_ceres "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/extern/ceres/bundle.sh b/extern/ceres/bundle.sh
index 62c286005a8..573db5a0a2f 100755
--- a/extern/ceres/bundle.sh
+++ b/extern/ceres/bundle.sh
@@ -158,7 +158,7 @@ add_definitions(
   -DCERES_NO_LAPACK
   -DCERES_NO_ACCELERATE_SPARSE
   -DCERES_HAVE_RWLOCK
-  -DCERES_USE_OPENMP
+  -DCERES_USE_CXX_THREADS
 )
 
 blender_add_lib(extern_ceres "\${SRC}" "\${INC}" "\${INC_SYS}" "\${LIB}")
diff --git a/intern/libmv/libmv/simple_pipeline/bundle.cc b/intern/libmv/libmv/simple_pipeline/bundle.cc
index 44a81fe21c6..22ab0cdf864 100644
--- a/intern/libmv/libmv/simple_pipeline/bundle.cc
+++ b/intern/libmv/libmv/simple_pipeline/bundle.cc
@@ -21,6 +21,7 @@
 #include "libmv/simple_pipeline/bundle.h"
 
 #include <map>
+#include <thread>
 
 #include "ceres/ceres.h"
 #include "ceres/rotation.h"
@@ -35,10 +36,6 @@
 #include "libmv/simple_pipeline/tracks.h"
 #include "libmv/simple_pipeline/distortion_models.h"
 
-#ifdef _OPENMP
-#  include <omp.h>
-#endif
-
 namespace libmv {
 
 // The intrinsics need to get combined into a single parameter block; use these
@@ -642,10 +639,7 @@ void EuclideanBundlePointsOnly(const CameraIntrinsics *invariant_intrinsics,
   options.use_explicit_schur_complement = true;
   options.use_inner_iterations = true;
   options.max_num_iterations = 100;
-
-#ifdef _OPENMP
-  options.num_threads = omp_get_max_threads();
-#endif
+  options.num_threads = std::thread::hardware_concurrency();
 
   // Solve!
   ceres::Solver::Summary summary;
@@ -806,10 +800,7 @@ void EuclideanBundleCommonIntrinsics(
   options.use_explicit_schur_complement = true;
   options.use_inner_iterations = true;
   options.max_num_iterations = 100;
-
-#ifdef _OPENMP
-  options.num_threads = omp_get_max_threads();
-#endif
+  options.num_threads = std::thread::hardware_concurrency();
 
   // Solve!
   ceres::Solver::Summary summary;



More information about the Bf-blender-cvs mailing list