From: "Rémi Denis-Courmont" <remi@remlab.net> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] gcc: Remove auto-vectorization limitation. Date: Mon, 26 May 2025 11:43:15 +0300 Message-ID: <EDD1A9D3-A391-4670-B4B4-BC6D59A5BDD6@remlab.net> (raw) In-Reply-To: <20250525213708.GO29660@pb2> Le 26 mai 2025 00:37:08 GMT+03:00, Michael Niedermayer <michael@niedermayer.cc> a écrit : >Hi Rémi > >On Sat, May 24, 2025 at 07:10:57PM +0300, Rémi Denis-Courmont wrote: >> Le torstaina 22. toukokuuta 2025, 9.32.18 Itä-Euroopan kesäaika Jiawei a écrit >> : >> > > The RISC-V autovectorised output looks like it has a warning "Odd >> > > rotation angle" which is not present in the non-autovectorised output. >> > >> > I found this occured when using '-ffast-math' in RISC-V, also occur in >> > -O3 -ffast-math -fno-tree-vectorize case(much slower due to the >> > -ffast-math),supplementary more comparison results here: >> > >> Unfortunately, the FFmpeg code is written with x87 semantics in mind. > >I dont remember ever writing code intentionally with x87 semantics. And i >have doubts other people did. It doesn't have to be intentional. FFmpeg was started and mostly developed with x86-32 then x86-64 in mind. It's entirely possible that this happened innocently. Specifically, FFmpeg uses open-code for minimum, maximum, absolute value and so on (see FFMIN, FFMAX, FFABS). They work nicely for integer maths. They also work nicely on x87 with the current set of FPU optimisations, but they differ from IEEE semantics because of NaNs, negative zeros and such. Because of that the compiler will *not* use the native FPU instructions on platforms with native IEEE floats. >> For >> instance, the FFmpeg math macros work nicely on x86, but they would work much >> better with fabs/fmax/fmin/fabsf/fmaxf/fminf on other platforms. I tried to fix >> that with copious amount of _Generic(), but that lead to ICE... > >ICE as the name says, is a internal compiler error and not the fault of >the code passed to the compiler Obviously yes. But if it crashes every major recent versions of both major compilers, then it is a given that the code will be rejected. And even if the compilers got fixed, the code wouldn't be accepted until ten or twenty years in the future judging by how conservative this project is with compiler versions. Lastly, I suspect it's caused ny excessively complex evaluation that simply drive compilers into OOM. It is debatable if OOM is even a compiler bug. >> So we are stuck between a rock and a hard place where we need fast math for >> good perfs, but we need to turn it off for correct results. > >--ffast-math is not one option, its many Indeed only a few of these flags are troublesome. I mentioned it on IRC many moons ago. > >on the gcc here, it does this: >+ -fassociative-math [enabled] >+ -fcx-limited-range [enabled] >+ -ffinite-math-only [enabled] >+ -fmath-errno [disabled] >+ -freciprocal-math [enabled] >+ -fsigned-zeros [disabled] >+ -ftrapping-math [disabled] >+ -funsafe-math-optimizations [enabled] > >So maybe some of this can be globally enabled. > >But some things like fassociative-math are simply not "safe" >on general nummeric code. It also violates ISO C according to >the official gcc documentation > >thx > >[...] _______________________________________________ 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".
next prev parent reply other threads:[~2025-05-26 8:43 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 [this message] 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 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=EDD1A9D3-A391-4670-B4B4-BC6D59A5BDD6@remlab.net \ --to=remi@remlab.net \ --cc=ffmpeg-devel@ffmpeg.org \ /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