Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v2] add a configure flag to enabled tree-vecorization with gcc
@ 2022-08-08 15:25 Swinney, Jonathan
  2022-08-08 19:31 ` Lynne
  0 siblings, 1 reply; 2+ messages in thread
From: Swinney, Jonathan @ 2022-08-08 15:25 UTC (permalink / raw)
  To: ffmpeg-devel

Recent version of gcc improve the automatic vectorization. This flag
allows adventurous users to enable vectorization. Known problems with
this are primarily related to inline assembly for x86 and so to address
those, add a pragma to explicitly disable automatic vectorization for
those files.

Signed-off-by: Jonathan Swinney <jswinney@amazon.com>

--

Thank you considering this patch. I believe this addresses the primary
concerns that were raised by my previous submission. There may be more
files which require the pragma add `-fno-tree-vectorize`, and I welcome
suggestions. This should strike a compromise, allowing some users to
enable vectorization while not breaking mainstream builds. This should
give time to work out additional problems if they arise before enabling
vectorization more broadly.

---
 configure              | 7 ++++++-
 libavcodec/x86/cabac.h | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index cbbb4dd9c8..8e842da1b8 100755
--- a/configure
+++ b/configure
@@ -110,6 +110,7 @@ Configuration options:
   --disable-swscale-alpha  disable alpha channel support in swscale
   --disable-all            disable building components, libraries and programs
   --disable-autodetect     disable automatically detected external libraries [no]
+  --enable-auto-vectorization enable compiler auto vectorization
 
 Program options:
   --disable-programs       do not build command line programs
@@ -1945,6 +1946,7 @@ FEATURE_LIST="
     small
     static
     swscale_alpha
+    auto_vectorization
 "
 
 # this list should be kept in linking order
@@ -7176,7 +7178,9 @@ if enabled icc; then
             disable aligned_stack
     fi
 elif enabled gcc; then
-    check_optflags -fno-tree-vectorize
+    if disabled auto_vectorization; then
+        check_optflags -fno-tree-vectorize
+    fi
     check_cflags -Werror=format-security
     check_cflags -Werror=implicit-function-declaration
     check_cflags -Werror=missing-prototypes
@@ -7569,6 +7573,7 @@ echo "pod2man enabled           ${pod2man-no}"
 echo "makeinfo enabled          ${makeinfo-no}"
 echo "makeinfo supports HTML    ${makeinfo_html-no}"
 echo "xmllint enabled           ${xmllint-no}"
+echo "auto-vectorization        ${auto_vectorization-no}"
 test -n "$random_seed" &&
     echo "random seed               ${random_seed}"
 echo
diff --git a/libavcodec/x86/cabac.h b/libavcodec/x86/cabac.h
index b046a56a6b..782e4cbda4 100644
--- a/libavcodec/x86/cabac.h
+++ b/libavcodec/x86/cabac.h
@@ -39,6 +39,10 @@
 
 #if HAVE_INLINE_ASM
 
+#ifdef __GNUC__
+    __attribute__((optimize("-fno-tree-vectorize")))
+#endif
+
 #ifndef UNCHECKED_BITSTREAM_READER
 #define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
 #endif
-- 
2.37.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2] add a configure flag to enabled tree-vecorization with gcc
  2022-08-08 15:25 [FFmpeg-devel] [PATCH v2] add a configure flag to enabled tree-vecorization with gcc Swinney, Jonathan
@ 2022-08-08 19:31 ` Lynne
  0 siblings, 0 replies; 2+ messages in thread
From: Lynne @ 2022-08-08 19:31 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Aug 8, 2022, 17:25 by jswinney@amazon.com:

> Recent version of gcc improve the automatic vectorization. This flag
> allows adventurous users to enable vectorization. Known problems with
> this are primarily related to inline assembly for x86 and so to address
> those, add a pragma to explicitly disable automatic vectorization for
> those files.
>
> Signed-off-by: Jonathan Swinney <jswinney@amazon.com>
>
> --
>
> Thank you considering this patch. I believe this addresses the primary
> concerns that were raised by my previous submission. There may be more
> files which require the pragma add `-fno-tree-vectorize`, and I welcome
> suggestions. This should strike a compromise, allowing some users to
> enable vectorization while not breaking mainstream builds. This should
> give time to work out additional problems if they arise before enabling
> vectorization more broadly.
>

I dislike this, pretty soon we'll end up with compiler version checks
whenever vectorization breaks.
Either gcc should fix miscompilation, or patches should be sent
to write assembly (which they should be anyway).
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-08 19:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 15:25 [FFmpeg-devel] [PATCH v2] add a configure flag to enabled tree-vecorization with gcc Swinney, Jonathan
2022-08-08 19:31 ` Lynne

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