From ffa324765e8b480faaee681412c83657b816cf7d Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Sun, 15 Mar 2015 18:11:17 +0000 Subject: [PATCH] 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 --- internal/ceres/problem_impl.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/ceres/problem_impl.cc b/internal/ceres/problem_impl.cc index 1c76ea691..1a048e5ed 100644 --- a/internal/ceres/problem_impl.cc +++ b/internal/ceres/problem_impl.cc @@ -731,7 +731,15 @@ bool ProblemImpl::Evaluate(const Problem::EvaluateOptions& evaluate_options, // 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(