From f14aa417f0188db905b1af26aeccccd29b71705b Mon Sep 17 00:00:00 2001 From: Hanno Schwalm Date: Sun, 29 Jun 2025 17:28:24 +0200 Subject: [PATCH] OPENMP and __GNUC__ compiler safety and performance As references see #18729 #18975 and https://bugzilla.redhat.com/show_bug.cgi?id=2362561 see late comments there from Jakub Jelinek https://bugzilla.redhat.com/show_bug.cgi?id=2368336 https://bugzilla.redhat.com/show_bug.cgi?id=2373291 --- src/develop/openmp_maths.h | 53 ++++++++++++++++++-------------------- src/iop/rawdenoise.c | 4 +-- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/develop/openmp_maths.h b/src/develop/openmp_maths.h index a3d466b841f4..fa88077e1ba9 100644 --- a/src/develop/openmp_maths.h +++ b/src/develop/openmp_maths.h @@ -23,44 +23,41 @@ #pragma once -#if defined(_OPENMP) && !defined(_WIN32) && (!defined(__GNUC__) || __GNUC__ >= 12) +#if defined(_OPENMP) && !defined(_WIN32) && !defined(__GNUC__) + // GCC and CLANG have declarations in standard headers if and only if the architecture and compile options support vectorization, so + // don't try to override that here - causes dynamic-link errors at startup. + DT_OMP_DECLARE_SIMD() + extern float fmaxf(const float x, const float y); -#ifndef __GNUC__ // GCC 12 compiles but fails at runtime due to missing library function -DT_OMP_DECLARE_SIMD() -extern float fmaxf(const float x, const float y); -#endif + DT_OMP_DECLARE_SIMD() + extern float fminf(const float x, const float y); -#ifndef __GNUC__ // GCC 12 compiles but fails at runtime due to missing library function -DT_OMP_DECLARE_SIMD() -extern float fminf(const float x, const float y); -#endif + DT_OMP_DECLARE_SIMD() + extern float fabsf(const float x); -DT_OMP_DECLARE_SIMD() -extern float fabsf(const float x); - -DT_OMP_DECLARE_SIMD() -extern float powf(const float x, const float y); + DT_OMP_DECLARE_SIMD() + extern float powf(const float x, const float y); -DT_OMP_DECLARE_SIMD() -extern float sqrtf(const float x); + DT_OMP_DECLARE_SIMD() + extern float sqrtf(const float x); -DT_OMP_DECLARE_SIMD() -extern float cbrtf(const float x); + DT_OMP_DECLARE_SIMD() + extern float cbrtf(const float x); -DT_OMP_DECLARE_SIMD() -extern float log2f(const float x); + DT_OMP_DECLARE_SIMD() + extern float log2f(const float x); -DT_OMP_DECLARE_SIMD() -extern float exp2f(const float x); + DT_OMP_DECLARE_SIMD() + extern float exp2f(const float x); -DT_OMP_DECLARE_SIMD() -extern float log10f(const float x); + DT_OMP_DECLARE_SIMD() + extern float log10f(const float x); -DT_OMP_DECLARE_SIMD() -extern float expf(const float x); + DT_OMP_DECLARE_SIMD() + extern float expf(const float x); -DT_OMP_DECLARE_SIMD() -extern float logf(const float x); + DT_OMP_DECLARE_SIMD() + extern float logf(const float x); #endif diff --git a/src/iop/rawdenoise.c b/src/iop/rawdenoise.c index 841f068dbde6..deb0db55bbd1 100644 --- a/src/iop/rawdenoise.c +++ b/src/iop/rawdenoise.c @@ -1,6 +1,6 @@ /* This file is part of darktable, - Copyright (C) 2011-2024 darktable developers. + Copyright (C) 2011-2025 darktable developers. darktable is free software: you can redistribute it and/or modify @@ -226,7 +226,7 @@ static void wavelet_denoise(const float *const restrict in, float *const restric const float *const restrict inp = in + (size_t)row * roi->width + offset; const int senselwidth = (roi->width-offset+1)/2; for(int col = 0; col < senselwidth; col++) - fimgp[col] = sqrtf(fmaxf(0.0f, inp[2*col])); + fimgp[col] = sqrtf(MAX(0.0f, inp[2*col])); } // perform the wavelet decomposition and denoising