OpenMP for Ceres and Eigen

50 views
Skip to first unread message

George Chan

unread,
Feb 13, 2023, 3:12:13 PM2/13/23
to Ceres Solver
Hello, 
I would like to active OpenMP in both eigen-lib(3.4.0) and ceres-lib(2.1.0) for my project. So in the CMakeLists.txt of the project, I have added : target_compile_options(${PROJECT_NAME} PUBLIC "/openmp") 
The source file (.cpp) has two functions to test the performance. Function 1 tests the eigen performance with a simple two matrix product, say mat1 * mat2. With the above compile-option, the speed is significantly improved.  

Function2 tests the ceres-performance using the example of curve_fitting.cc (https://ceres-solver.googlesource.com/ceres-solver/+/master/examples/curve_fitting.cc). A problem happend on this test. Without the compile_options, it works as the demo in the Tutorial. But with the compile_options target_compile_options(${PROJECT_NAME} PUBLIC "/openmp"), it shows only the result of 0th iter (see below), or nothing at all.

iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time 

   0  1.815138e+01    0.00e+00    2.04e+01   0.00e+00   0.00e+00  1.00e+04        0    1.77e-04    7.74e-04 

I have tried to build the ceres2.1.0 with two different setting on  CERES_THREADING_MODELCXX_THREADS  and OPENMP. Unfortunately, neither of them work with "/openmp". 

Does anyone have an idea of what’s happening here? and how to fix it?

Thanks!


Sameer Agarwal

unread,
Feb 16, 2023, 8:35:11 PM2/16/23
to ceres-...@googlegroups.com
This seems to be a problem with your compiler or some sort of linking mess. i would try and run the code in a debugger to see what is going on.
does ceres crash? or does it say why it does not progress past iteration 0?
Sameer


--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/5ca18df2-5fe0-4fb6-8365-8dff27d41ea8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages