Streamline branching in Jet copysign and fdim - Pass the second argument g of copysign(f, g) by const reference instead of by value, and return (sa * sb) * f.v directly when g != 0 to avoid evaluating 0 * g.v. - Check isgreater(f, g) before isnan in fdim so that normal inputs with f > g short-circuit on the first comparison. Benchmark (Apple M1 Pro): ---------------------------------------------------------------------- Benchmark Before After Change ---------------------------------------------------------------------- BM_JetCopysign<3> 2.27 ns 0.453 ns -80.0% BM_JetCopysign<6> 2.33 ns 0.506 ns -78.3% BM_JetCopysign<12> 4.08 ns 1.23 ns -69.9% BM_JetCopysign<30> 9.76 ns 5.23 ns -46.4% BM_JetFdim<3> 1.98 ns 0.728 ns -63.2% BM_JetFdim<6> 2.07 ns 1.25 ns -39.6% BM_JetFdim<12> 2.78 ns 1.83 ns -34.2% BM_JetFdim<30> 5.28 ns 4.86 ns -8.0% ---------------------------------------------------------------------- Change-Id: I3b4ceebad76cbb0eddc42be6368872a9e5543b71
Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It is a feature rich, mature and performant library which has been used in production at Google since 2010. Ceres Solver can solve two kinds of problems.
Please see ceres-solver.org for more information.