Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Jiawei <jiawei@iscas.ac.cn>
To: Zhao Zhili <quinkblack@foxmail.com>,
	FFmpeg development discussions and patches
	<ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] gcc: Remove auto-vectorization limitation.
Date: Wed, 21 May 2025 18:26:07 +0800
Message-ID: <ea955f81-c774-4f28-9ac3-f663ea3f8907@iscas.ac.cn> (raw)
In-Reply-To: <tencent_CE7202B56BE67C7AAD3A3BD9C345B7E0680A@qq.com>


在 2025/5/21 17:04, Zhao Zhili 写道:
>
>> On May 21, 2025, at 14:17, Jiawei <jiawei@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 (>= 10.0) 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.
> This isn’t the whole story.
>
> The flag was added by 973859f in 2009.
> Then it was reverted by cb8646af in 2016.
> Shortly after that, the revert was reverted again by fd6dbc5 in 2016.
>
>> 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.
> Those flags can only be enabled in tightly controlled environments (e.g., built and run on the same
> machine), while FFmpeg has hand written assembly, runtime cpu probe and dynamic binding/dispatch.
>
> Those auto-vectorization and ARCH flags can be enabled manually, but be careful.

Thank you point this out, since I am using x64 AVX2 and RISC-V RVV, when 
I enable the vector feature

by -O3 -mavx(-march=rv64gcv for RV). This configure will adds the 
`-fno-tree-vectorize` option automatically.

It will still add the vector load/store instructions in the result, but 
no vector operation here.


GCC import the explicit option to controll if there need generate the 
vectorized instructions. It's okay to use -O3
but not do auto-vectorization.

>
>> [1] https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/973859f5230e77beea7bb59dc081870689d6d191
>>
>> ---
>> configure | 1 -
>> 1 file changed, 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index 3730b0524c..b9e95ce4ec 100755
>> --- a/configure
>> +++ b/configure
>> @@ -7656,7 +7656,6 @@ if enabled icc; then
>>              disable aligned_stack
>>      fi
>> elif enabled gcc; then
>> -    check_optflags -fno-tree-vectorize
>>      check_cflags -Werror=format-security
>>      check_cflags -Werror=implicit-function-declaration
>>      check_cflags -Werror=missing-prototypes
>> -- 
>> 2.43.0
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

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

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

  reply	other threads:[~2025-05-21 10:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21  6:17 Jiawei
2025-05-21  6:52 ` Nicolas George
2025-05-21 10:17   ` Jiawei
2025-05-21 18:21     ` Frank Plowman
2025-05-22  6:32       ` Jiawei
2025-05-24  1:46         ` Kieran Kunhya via ffmpeg-devel
2025-05-24  4:10           ` Jiawei
2025-05-24 16:10         ` Rémi Denis-Courmont
2025-05-25 21:37           ` Michael Niedermayer
2025-05-26  8:43             ` Rémi Denis-Courmont
2025-05-30  0:46               ` Michael Niedermayer
2025-05-30  6:58                 ` Rémi Denis-Courmont
2025-05-31 13:39                   ` Michael Niedermayer
2025-06-03 16:14                   ` Niklas Haas
2025-06-04 11:13                     ` Rémi Denis-Courmont
2025-05-21  7:46 ` Michael Niedermayer
2025-05-21 10:32   ` Jiawei
2025-05-21 11:09     ` Michael Niedermayer
2025-05-21  9:04 ` Zhao Zhili
2025-05-21 10:26   ` Jiawei [this message]
2025-05-21 10:33 ` Andreas Rheinhardt
2025-05-21 12:09   ` Martin Storsjö
2025-05-21 12:14     ` Andreas Rheinhardt
2025-05-21 12:22       ` Martin Storsjö
2025-05-21 18:12         ` softworkz .
2025-05-24 12:00 ` Rémi Denis-Courmont
2025-05-21 10:08 Jiawei
2025-05-21 10:14 Jiawei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea955f81-c774-4f28-9ac3-f663ea3f8907@iscas.ac.cn \
    --to=jiawei@iscas.ac.cn \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=quinkblack@foxmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git