Dear All,
For those of you using Clang, we would be very interested if you observe any performance improvements from compiling your code which uses Ceres with an increased inline threshold (see below for instructions). Ceres itself is compiled with an increased inline threshold on Clang (currently 600) because we have found that this improved the overall performance (via Eigen).
We have found that for some client code using autodiffed cost functions, using the same increased inlining threshold as Ceres results in a very dramatic (100-1000x) speedup. However, this is not uniform and for other problems it makes only a small difference. We can, through CMake, export an increased inlining threshold (which only triggers for Clang) in the Ceres target which would then get used to compile any target which linked against Ceres using CMake. However, we would like to get a feel for how much difference this change would make for people’s current use of Ceres beforehand.
Thanks!
-Alex
= Instructions for increasing inlining threshold for Clang via CMake:
If using CMake >= 2.8.12: We recommend you use target_compile_options() to add the inlining flags to specific targets for fine grained control:
# Use a larger inlining threshold for Clang, since it can hobble Eigen,
# resulting in reduced performance. The -Qunused-arguments is needed because
# CMake passes the inline threshold to the linker and clang complains about
# it (and dies, if compiling with -Werror).
target_compile_options(<YOUR_TARGET_NAME> PUBLIC
$<$<CXX_COMPILER_ID:Clang>:-Qunused-arguments -mllvm -inline-threshold=600>)
If using CMake < 2.8.12: On CMake < 2.8.12 target_compile_options() is not available, so you cannot add the flags only on a per-target level and must instead set them for all targets declared after the flags are updated:
# Use a larger inlining threshold for Clang, since it can hobble Eigen,
# resulting in reduced performance. The -Qunused-arguments is needed because
# CMake passes the inline threshold to the linker and clang complains about
# it (and dies, if compiling with -Werror).
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Qunused-arguments -mllvm -inline-threshold=600")
endif()