From: "Rémi Denis-Courmont" <remi@remlab.net> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] lavu/lls: R-V V update_lls Date: Wed, 29 May 2024 18:42:52 +0300 Message-ID: <20240529154253.38556-1-remi@remlab.net> (raw) update_lls_8_c: 7.5 update_lls_8_rvv_f64: 4.2 update_lls_12_c: 14.5 update_lls_12_rvv_f64: 5.7 --- libavutil/lls.c | 4 ++- libavutil/lls.h | 1 + libavutil/riscv/Makefile | 4 ++- libavutil/riscv/lls_init.c | 57 ++++++++++++++++++++++++++++++++++++++ libavutil/riscv/lls_rvv.S | 39 ++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 libavutil/riscv/lls_init.c create mode 100644 libavutil/riscv/lls_rvv.S diff --git a/libavutil/lls.c b/libavutil/lls.c index c1e038daf1..d300ae7a60 100644 --- a/libavutil/lls.c +++ b/libavutil/lls.c @@ -117,7 +117,9 @@ av_cold void avpriv_init_lls(LLSModel *m, int indep_count) m->indep_count = indep_count; m->update_lls = update_lls; m->evaluate_lls = evaluate_lls; -#if ARCH_X86 +#if ARCH_RISCV + ff_init_lls_riscv(m); +#elif ARCH_X86 ff_init_lls_x86(m); #endif } diff --git a/libavutil/lls.h b/libavutil/lls.h index 0709275822..7acef4eff8 100644 --- a/libavutil/lls.h +++ b/libavutil/lls.h @@ -57,6 +57,7 @@ typedef struct LLSModel { } LLSModel; void avpriv_init_lls(LLSModel *m, int indep_count); +void ff_init_lls_riscv(LLSModel *m); void ff_init_lls_x86(LLSModel *m); void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order); diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile index 1597154ba5..7e9a51194b 100644 --- a/libavutil/riscv/Makefile +++ b/libavutil/riscv/Makefile @@ -1,5 +1,7 @@ OBJS += riscv/float_dsp_init.o \ riscv/fixed_dsp_init.o \ + riscv/lls_init.o \ riscv/cpu.o RVV-OBJS += riscv/float_dsp_rvv.o \ - riscv/fixed_dsp_rvv.o + riscv/fixed_dsp_rvv.o \ + riscv/lls_rvv.o diff --git a/libavutil/riscv/lls_init.c b/libavutil/riscv/lls_init.c new file mode 100644 index 0000000000..b1317dc925 --- /dev/null +++ b/libavutil/riscv/lls_init.c @@ -0,0 +1,57 @@ +/* + * Copyright © 2024 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <assert.h> +#include <stdint.h> + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavutil/lls.h" + +void ff_lls_update_covariance_rvv(double covar[][36], const double *var, + int count); +double ff_scalarproduct_double_rvv(const double *, const double *, size_t); + +static void ff_lls_update_rvv(struct LLSModel *m, const double *var) +{ + ff_lls_update_covariance_rvv(m->covariance, var, m->indep_count + 1); +} + +static double ff_lls_evaluate_rvv(struct LLSModel *m, const double *var, + int order) +{ + return ff_scalarproduct_double_rvv(m->coeff[order], var, order + 1); +} + +av_cold void ff_init_lls_riscv(LLSModel *m) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVB_ADDR) && (flags & AV_CPU_FLAG_RVV_F64)) { + if ((flags & AV_CPU_FLAG_RVB_BASIC) && + ff_get_rv_vlenb() > m->indep_count) + m->update_lls = ff_lls_update_rvv; + m->evaluate_lls = ff_lls_evaluate_rvv; + } +#endif +} diff --git a/libavutil/riscv/lls_rvv.S b/libavutil/riscv/lls_rvv.S new file mode 100644 index 0000000000..e0e6f1008e --- /dev/null +++ b/libavutil/riscv/lls_rvv.S @@ -0,0 +1,39 @@ +/* + * Copyright © 2024 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "asm.S" + +func ff_lls_update_covariance_rvv, zve64d, zbb + vtype_vli t0, a2, t1, e64, ta, ma + vsetvl zero, a2, t0 + vle64.v v8, (a1) +1: + vfmv.f.s ft0, v8 + vsetvl zero, a2, t0 + vle64.v v16, (a0) + vfmacc.vf v16, ft0, v8 + addi a2, a2, -1 + vslidedown.vi v8, v8, 1 + vse64.v v16, (a0) + addi a0, a0, (36 + 1) * 8 # 1 row + 1 element + bnez a2, 1b + + ret +endfunc -- 2.45.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".
reply other threads:[~2024-05-29 15:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240529154253.38556-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