ceres multi-threading runs slower on Android

250 views
Skip to first unread message

Frank Young

unread,
Jan 5, 2018, 5:08:27 AM1/5/18
to Ceres Solver
Hi guys,

I pulled ceres solver to the latest version (Dec 11 11:11:07, updated by Alex Stewart), which includes TBB module. I found the case run slower with multi-threading enabling. Some tests are as follow(Number of iterations: 50), and more details can be found in the attached file.

CERES_NO_THREADS defined
---------------------------------------------------
  Residual evaluation                0.013869
  Jacobian evaluation                0.054759
  Linear solver                      0.096086
Minimizer                            0.189615

openmp + num_threads = 1
---------------------------------------------------
  Residual evaluation                0.021007
  Jacobian evaluation                0.063633
  Linear solver                      0.202915
Minimizer                            0.318207


openmp + num_threads = 4
---------------------------------------------------
  Residual evaluation                0.023179
  Jacobian evaluation                0.072973
  Linear solver                      0.192077
Minimizer                            0.319461


tbb + num_threads = 1
---------------------------------------------------
  Residual evaluation                0.052823
  Jacobian evaluation                0.088980
  Linear solver                      0.209207
Minimizer                            0.382557


tbb + num_threads = 4
---------------------------------------------------
  Residual evaluation                0.059175
  Jacobian evaluation                0.094217
  Linear solver                      0.196872
Minimizer                            0.380875


It looks odd. I expect CERES_HAVE_THREAD + num_threads=1 have the same behaviour and performance with the CERES_NO_THREADS case. But the result gave me a surprise. 

Frank

multi-threading.txt

Sameer Agarwal

unread,
Jan 5, 2018, 5:56:55 AM1/5/18
to ceres-...@googlegroups.com, vi...@google.com
Frank, 
We had observed some slow down due to TBB initialization overhead that +Michael Vitus had fixed recently. What version of TBB are you using, it is possible that the TBB initialization overhead is still killing you.
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/f16e3abe-3b24-4437-9a85-4a54ef75a599%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Vitus

unread,
Jan 5, 2018, 12:30:30 PM1/5/18
to Ceres Solver
He is also seeing a slow down when using openmp with 1 thread (but TBB is even slower).  Some openmp implementations have a fast path for 1 thread, but I am not sure how to check for that. If it does have the fast path, then you should be getting the exact same timing results.

Are you consistently seeing ceres no threads take 0.19 seconds or did you just get lucky?  

Mike

Frank Young

unread,
Jan 5, 2018, 8:13:16 PM1/5/18
to Ceres Solver
Sameer,

I found TBB used is 4.4.6 incorrectly.  Sorry for the mistake, I would try 2018_U2 as soon as possible.

在 2018年1月5日星期五 UTC+8下午6:56:55,Sameer Agarwal写道:

Frank Young

unread,
Jan 6, 2018, 9:56:58 AM1/6/18
to Ceres Solver
Mike,

I am sure CERES with no threads takes 0.19~0.2 seconds consistently, and the time goes up to >0.3 seconds once enabling openmp+num_threads(1). (enn, let's talk about OpenMP and skip TBB here because of using incorrect version)

I compiled my project with clang 3.8 and android_ndk_r15c.

Frank

在 2018年1月6日星期六 UTC+8上午1:30:30,Mike Vitus写道:

Sameer Agarwal

unread,
Jan 6, 2018, 10:02:08 AM1/6/18
to ceres-...@googlegroups.com
Frank my guess is that your problem is small enough that the openmp overhead is overwhelming it.
Sameer


Reply all
Reply to author
Forward
0 new messages