Skip to content

Commit

Permalink
optimize optimization flags
Browse files Browse the repository at this point in the history
Move the optimization pragma before the #includes so that we don't
prevent functions from inlining because they were compiled with
different optimization flags than the caller.

Eliminate the flags for loop unrolling, tree transformations,
etc. because they either had no effect or were slightly detrimental.

Yields a speedup of 7% to 18% with four threads, depending on which
version of color science (V3-V7) is used.
  • Loading branch information
ralfbrown committed May 3, 2023
1 parent 185b2da commit b69b50a
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/iop/filmicrgb.c
Expand Up @@ -15,6 +15,15 @@
You should have received a copy of the GNU General Public License
along with darktable. If not, see <http://www.gnu.org/licenses/>.
*/

/** Note :
* we use finite-math-only and fast-math because divisions by zero are manually avoided in the code
* fp-contract=fast enables hardware-accelerated Fused Multiply-Add
**/
#if defined(__GNUC__)
#pragma GCC optimize("finite-math-only", "fp-contract=fast", "fast-math", "no-math-errno")
#endif

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
Expand Down Expand Up @@ -93,19 +102,6 @@ DT_MODULE_INTROSPECTION(6, dt_iop_filmicrgb_params_t)
* */


/** Note :
* we use finite-math-only and fast-math because divisions by zero are manually avoided in the code
* fp-contract=fast enables hardware-accelerated Fused Multiply-Add
* the rest is loop reorganization and vectorization optimization
**/
#if defined(__GNUC__)
#pragma GCC optimize("unroll-loops", "tree-loop-if-convert", "tree-loop-distribution", "no-strict-aliasing", \
"loop-interchange", "loop-nest-optimize", "tree-loop-im", "unswitch-loops", \
"tree-loop-ivcanon", "ira-loop-pressure", "split-ivs-in-unroller", \
"variable-expansion-in-unroller", "split-loops", "ivopts", "predictive-commoning", \
"tree-loop-linear", "loop-block", "loop-strip-mine", "finite-math-only", "fp-contract=fast", \
"fast-math", "no-math-errno")
#endif


typedef enum dt_iop_filmicrgb_methods_type_t
Expand Down

0 comments on commit b69b50a

Please sign in to comment.