On Thu, May 29, 2025 at 07:26:09PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Hi
> > 
> > On Thu, May 29, 2025 at 04:37:16PM +0800, Zhao Zhili wrote:
> >>
> >>
> >>> On May 29, 2025, at 15:03, Jiawei <jia...@iscas.ac.cn> wrote:
> >>>
> >>> This patch modifies the FFmpeg build system to remove the explicit 
> >>> disabling
> >>> of GCC's auto-vectorization feature.
> >>>
> >>> Modern GCC versions have demonstrated stable auto-vectorization 
> >>> capabilities
> >>> through extensive optimizations in loop analysis and SIMD code generation.
> >>> The explicit -fno-tree-vectorize flag originally added in commit 973859f
> >>> (2009) to workaround early GCC vectorization instability is no longer
> >>> necessary for recent gcc versions.
> >>>
> >>> Key improvements justifying this change:
> >>> 1. Enhanced heuristics for loop vectorization cost models
> >>> 2. Mature handling of alignment and memory access patterns
> >>> 3. Robust fallback mechanisms for unsupported architectures
> >>>
> >>> This change allows FFmpeg to benefit from automated SIMD optimizations
> >>> when built with -O3 optimization level, particularly improving
> >>> performance on x86_64 (AVX), ARM64 (SVE) and RISC-V(RVV) architectures.
> >>>
> >>> [1] 
> >>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/973859f5230e77beea7bb59dc081870689d6d191
> >>>
> >>> Version log:
> >>>  Only allow GCC versions >= 13 to use auto-vectorization.
> >>> Disscussion see:
> >>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250521061750.54882-1-jia...@iscas.ac.cn/
> >>>
> >>> ---
> >>> configure | 1 -
> >>> 1 file changed, 1 deletion(-)
> >>>
> >>> Signed-off-by: Jiawei <jia...@iscas.ac.cn>
> >>> ---
> >>> configure | 6 +++++-
> >>> 1 file changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/configure b/configure
> >>> index 3730b0524c..91e3e107c2 100755
> >>> --- a/configure
> >>> +++ b/configure
> >>> @@ -7656,7 +7656,11 @@ if enabled icc; then
> >>>             disable aligned_stack
> >>>     fi
> >>> elif enabled gcc; then
> >>> -    check_optflags -fno-tree-vectorize
> >>> +    gcc_version=$($cc -dumpversion)
> >>> +    major_version=${gcc_version%%.*}
> >>> +    if [ $major_version -lt 13 ]; then
> >>> +        check_optflags -fno-tree-vectorize
> >>> +    fi
> >>>     check_cflags -Werror=format-security
> >>>     check_cflags -Werror=implicit-function-declaration
> >>>     check_cflags -Werror=missing-prototypes
> >>> -- 
> >>> 2.43.0
> >>>
> >>> This patch modifies the FFmpeg build system to remove the explicit 
> >>> disabling
> >>> of GCC's auto-vectorization feature.
> >>>
> >>> Modern GCC versions have demonstrated stable auto-vectorization 
> >>> capabilities
> >>> through extensive optimizations in loop analysis and SIMD code generation.
> >>> The explicit -fno-tree-vectorize flag originally added in commit 973859f
> >>> (2009) to workaround early GCC vectorization instability is no longer
> >>> necessary for recent gcc versions.
> >>>
> >>> Key improvements justifying this change:
> >>> 1. Enhanced heuristics for loop vectorization cost models
> >>> 2. Mature handling of alignment and memory access patterns
> >>> 3. Robust fallback mechanisms for unsupported architectures
> >>>
> >>> This change allows FFmpeg to benefit from automated SIMD optimizations
> >>> when built with -O3 optimization level, particularly improving
> >>> performance on x86_64 (AVX), ARM64 (SVE) and RISC-V(RVV) architectures.
> >>>
> >>> [1] 
> >>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/973859f5230e77beea7bb59dc081870689d6d191
> >>>
> >>> Version log:
> >>>  Only allow GCC versions >= 13 to use auto-vectorization.
> >>> Disscussion see:
> >>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250521061750.54882-1-jia...@iscas.ac.cn/
> >>>
> >>> ---
> >>> configure | 1 -
> >>> 1 file changed, 1 deletion(-)
> >>>
> >>> Signed-off-by: Jiawei <jia...@iscas.ac.cn>
> >>> ---
> >>> configure | 6 +++++-
> >>> 1 file changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/configure b/configure
> >>> index 3730b0524c..91e3e107c2 100755
> >>> --- a/configure
> >>> +++ b/configure
> >>> @@ -7656,7 +7656,11 @@ if enabled icc; then
> >>>             disable aligned_stack
> >>>     fi
> >>> elif enabled gcc; then
> >>> -    check_optflags -fno-tree-vectorize
> >>> +    gcc_version=$($cc -dumpversion)
> >>> +    major_version=${gcc_version%%.*}
> >>> +    if [ $major_version -lt 13 ]; then
> >>> +        check_optflags -fno-tree-vectorize
> >>> +    fi
> >>>     check_cflags -Werror=format-security
> >>>     check_cflags -Werror=implicit-function-declaration
> >>>     check_cflags -Werror=missing-prototypes
> >>> -- 
> >>> 2.43.0
> >>>
> >>> This patch modifies the FFmpeg build system to remove the explicit 
> >>> disabling
> >>> of GCC's auto-vectorization feature.
> >>>
> >>> Modern GCC versions have demonstrated stable auto-vectorization 
> >>> capabilities
> >>> through extensive optimizations in loop analysis and SIMD code generation.
> >>> The explicit -fno-tree-vectorize flag originally added in commit 973859f
> >>> (2009) to workaround early GCC vectorization instability is no longer
> >>> necessary for recent gcc versions.
> >>>
> >>> Key improvements justifying this change:
> >>> 1. Enhanced heuristics for loop vectorization cost models
> >>> 2. Mature handling of alignment and memory access patterns
> >>> 3. Robust fallback mechanisms for unsupported architectures
> >>>
> >>> This change allows FFmpeg to benefit from automated SIMD optimizations
> >>> when built with -O3 optimization level, particularly improving
> >>> performance on x86_64 (AVX), ARM64 (SVE) and RISC-V(RVV) architectures.
> >>>
> >>> [1] 
> >>> https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/973859f5230e77beea7bb59dc081870689d6d191
> >>>
> >>> Version log:
> >>>  Only allow GCC versions >= 13 to use auto-vectorization.
> >>> Disscussion see:
> >>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250521061750.54882-1-jia...@iscas.ac.cn/
> >>>
> >>> ---
> >>> configure | 1 -
> >>> 1 file changed, 1 deletion(-)
> >>>
> >>> Signed-off-by: Jiawei <jia...@iscas.ac.cn>
> >>> ---
> >>> configure | 6 +++++-
> >>> 1 file changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/configure b/configure
> >>> index 3730b0524c..91e3e107c2 100755
> >>> --- a/configure
> >>> +++ b/configure
> >>> @@ -7656,7 +7656,11 @@ if enabled icc; then
> >>>             disable aligned_stack
> >>>     fi
> >>> elif enabled gcc; then
> >>> -    check_optflags -fno-tree-vectorize
> >>> +    gcc_version=$($cc -dumpversion)
> >>> +    major_version=${gcc_version%%.*}
> >>> +    if [ $major_version -lt 13 ]; then
> >>> +        check_optflags -fno-tree-vectorize
> >>> +    fi
> >>>     check_cflags -Werror=format-security
> >>>     check_cflags -Werror=implicit-function-declaration
> >>>     check_cflags -Werror=missing-prototypes
> >>> -- 
> >>> 2.43.0
> >>>
> >>
> >> It looks like the patch format is corrupted.
> >>
> >> I’m OK with the code change. However, the commit message is misleading. As 
> >> already pointed out
> >> by multiple developers, this option doesn’t help with AVX, SVE and RVV 
> >> because we can’t assume
> >> they are available at runtime, unless build and run on a particular 
> >> hardware.
> > 
> > can gcc or clang not build code like our runtime cpudetect ?
> > i mean build functions for each major type and detect cpu once
> > and switch accordingly ?
> 
> How would this "once" work in practice? If the cpu is supposed to be
> detected only once, the result needs to be stored somewhere (in static
> storage). Even if this is initialized in the libraries .init function
> (so that we can be sure that it is initialized when the actual code is
> run), this would still need a check every time one of these code
> snippets is run.

Iam not a compiler developer, nor an expert in ELF
but the cpu detect could edit the PLT or use an approuch
similar to how our code works, that is function pointers

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus

Attachment: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to