Why won't Ceres run in parallel or with multithreading?24 Jan 2023
I discovered by accident some time ago, wandering through some .h files (solver.h), that the reason I couldn’t get Ceres to run in parallel despite having OpenMP support enabled, was that the default number of threads is …. 1.
// Maximum number of iterations for the minimizer to run for. int max_num_iterations = 50; // Maximum time for which the minimizer should run for. double max_solver_time_in_seconds = 1e9; // Number of threads used by Ceres for evaluating the cost and // jacobians. int num_threads = 1;
num_threads, modify a member of
Solver::options. For example, since I am using OpenMP, I do
Solver::Options options; options.num_threads = omp_get_max_threads();