Force use of single-thread in Problem::Evaluate() without OpenMP. - Ensure that, as in the preprocessor, we force num_threads to be 1 if Ceres was compiled without OpenMP to prevent a CHECK() failure in internal code. Change-Id: I49d7bdeff81e5bb24aaaa3945018d9d012cd9df9
diff --git a/internal/ceres/problem_impl.cc b/internal/ceres/problem_impl.cc index 1c76ea6..1a048e5 100644 --- a/internal/ceres/problem_impl.cc +++ b/internal/ceres/problem_impl.cc
@@ -731,7 +731,15 @@ // the Evaluator decides the storage for the Jacobian based on the // type of linear solver being used. evaluator_options.linear_solver_type = SPARSE_NORMAL_CHOLESKY; +#ifndef CERES_USE_OPENMP + LOG_IF(WARNING, evaluate_options.num_threads > 1) + << "OpenMP support is not compiled into this binary; " + << "only evaluate_options.num_threads = 1 is supported. Switching " + << "to single threaded mode."; + evaluator_options.num_threads = 1; +#else evaluator_options.num_threads = evaluate_options.num_threads; +#endif // CERES_USE_OPENMP string error; scoped_ptr<Evaluator> evaluator(