From: "Rémi Denis-Courmont" <remi@remlab.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 1/6] lavu/riscv: implement floating point clips Date: Thu, 25 Jul 2024 23:25:15 +0300 Message-ID: <20240725202522.276182-1-remi@remlab.net> (raw) Unlike x86, fmin/fmax are single instructions, not function calls. They are much much faster than doing a comparison, then branching based on its results. With this, audiodsp.vector_clipf gets almost twice as fast, and a properly unrollled version of it gets 4-5x faster, on SiFive-U74. This is only the low-hanging fruit: FFMIN and FFMAX are presumably affected as well. This likely applies to other instruction sets with native IEEE floats, especially those lacking a conditional select instruction. --- libavutil/riscv/intmath.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libavutil/riscv/intmath.h b/libavutil/riscv/intmath.h index 3e7ab864c5..24f165eef1 100644 --- a/libavutil/riscv/intmath.h +++ b/libavutil/riscv/intmath.h @@ -22,6 +22,7 @@ #define AVUTIL_RISCV_INTMATH_H #include <stdint.h> +#include <math.h> #include "config.h" #include "libavutil/attributes.h" @@ -72,6 +73,24 @@ static av_always_inline av_const int av_clip_intp2_rvi(int a, int p) return b; } +#if defined (__riscv_f) || defined (__riscv_zfinx) +#define av_clipf av_clipf_rvf +static av_always_inline av_const float av_clipf_rvf(float a, float min, + float max) +{ + return fminf(fmaxf(a, min), max); +} +#endif + +#if defined (__riscv_d) || defined (__riscv_zdinx) +#define av_clipd av_clipd_rvd +static av_always_inline av_const float av_clipd_rvd(double a, double min, + double max) +{ + return fmin(fmax(a, min), max); +} +#endif + #if defined (__GNUC__) || defined (__clang__) static inline av_const int ff_ctz_rv(int x) { -- 2.45.2 _______________________________________________ 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 reply other threads:[~2024-07-25 20:25 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-07-25 20:25 Rémi Denis-Courmont [this message] 2024-07-25 20:25 ` [FFmpeg-devel] [PATCH 2/6] lavc/audiodsp: properly unroll vector_clipf Rémi Denis-Courmont 2024-07-25 20:25 ` [FFmpeg-devel] [PATCH 3/6] lavc/audiodsp: drop opposite sign optimisation Rémi Denis-Courmont 2024-07-25 20:25 ` [FFmpeg-devel] [PATCH 4/6] lavc/audiodsp: drop R-V F vector_clipf Rémi Denis-Courmont 2024-07-25 20:25 ` [FFmpeg-devel] [PATCH 5/6] lavc/riscv: drop probing for F & D extensions Rémi Denis-Courmont 2024-07-25 20:25 ` [FFmpeg-devel] [PATCH 6/6] lavu/cpu: deprecate AV_CPU_FLAG_RV{F, D} Rémi Denis-Courmont 2024-07-26 9:16 ` Andreas Rheinhardt 2024-07-27 12:22 ` Rémi Denis-Courmont 2024-07-27 12:27 ` Rémi Denis-Courmont 2024-07-26 6:23 ` [FFmpeg-devel] [PATCH 1/6] lavu/riscv: implement floating point clips Rémi Denis-Courmont
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=20240725202522.276182-1-remi@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